html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--rose-deep);
}

a:hover {
  color: var(--rose-deep-hover);
}

.messages-main {
  min-height: 100vh;
  padding: 0 20px;
  box-sizing: border-box;
}

/* ---------- Site nav ---------- */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  padding: 16px 20px;
}

.site-nav-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28em;
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  transition: color .2s;
}

.site-nav-logo:hover {
  color: var(--rose-deep);
}

/* ---------- Ambient background ---------- */

.bg-drift {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  will-change: transform;
}

.blob-1 {
  width: 44vmax;
  height: 44vmax;
  top: -16vmax;
  left: -14vmax;
  background: radial-gradient(circle, var(--blush), transparent 70%);
}

.blob-2 {
  width: 40vmax;
  height: 40vmax;
  bottom: -18vmax;
  right: -14vmax;
  background: radial-gradient(circle, var(--sage-tint), transparent 70%);
}

.amp {
  font-style: italic;
  color: var(--rose);
}

.section-eyebrow {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sage-deep);
}

/* ---------- Shared field / button styles ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.field-label {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.field input {
  font: inherit;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-input);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px var(--blush);
}

.field.has-error input {
  border-color: var(--rose);
}

.field-error {
  font-size: 14px;
  color: var(--rose-deep);
}

.btn-guestbook {
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.08em;
  min-height: 52px;
  border: none;
  border-radius: 999px;
  background: var(--rose-deep);
  color: var(--paper);
  cursor: pointer;
  transition: background .25s;
}

.btn-guestbook:hover {
  background: var(--rose-deep-hover);
  transform: translateY(-2px);
}

.btn-guestbook:active {
  transform: translateY(0) scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  .btn-guestbook:hover,
  .btn-guestbook:active {
    transform: none;
  }
}

.btn-link {
  font: inherit;
  font-size: 13px;
  color: var(--ink-muted);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  min-height: 44px;
  padding: 0 12px;
}

/* ---------- Login screen ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
  box-sizing: border-box;
}

.login-form {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
}

.monogram {
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 0.04em;
}

.login-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(42px, 10vw, 60px);
  line-height: 1;
}

.login-copy {
  margin: 0;
  font-size: var(--size-body);
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink-muted);
  max-width: 320px;
}

.login-field {
  width: 100%;
  margin-top: 8px;
}

.login-submit {
  width: 100%;
}

/* ---------- Book screen ---------- */

.book-screen {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(48px, 9vw, 96px) 0 96px;
  display: flex;
  flex-direction: column;
  gap: clamp(36px, 6vw, 56px);
}

.book-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.book-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(48px, 11vw, 72px);
  line-height: 1;
}

.book-count {
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 300;
}

.btn-outline-msg {
  margin-top: 4px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 18px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.btn-outline-msg:hover {
  border-color: var(--rose);
  color: var(--rose-deep);
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 4vw, 32px);
}

.message-card {
  background: var(--paper);
  border-radius: 4px;
  padding: clamp(12px, 2vw, 16px);
  box-shadow: 0 1px 2px rgba(59, 52, 50, 0.06), 0 24px 44px -24px rgba(59, 52, 50, 0.34);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  rotate: var(--card-rot, 0deg);
  transition: transform .25s, rotate .25s, box-shadow .25s;
}

.message-card:hover {
  transform: translateY(-4px);
  rotate: 0deg;
  box-shadow: 0 4px 8px rgba(59, 52, 50, 0.06), 0 30px 54px -22px rgba(59, 52, 50, 0.38);
}

@media (prefers-reduced-motion: reduce) {
  .message-card:hover {
    transform: none;
  }
}

/* Postcard photo -- deliberately cropped to fill its frame (unlike the
   guestbook form's own uncropped preview), since a postcard photo is
   meant to fill a fixed shape. The frame comes in two shapes so a
   vertical phone photo isn't squeezed into a wide frame and cropped
   down to almost nothing: landscape/square photos get a wide frame,
   portrait photos get a tall one. */
.message-photo-btn {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  align-self: center;
  padding: 0;
  border: none;
  border-radius: 2px;
  overflow: hidden;
  background: var(--blush);
  cursor: zoom-in;
}

.message-photo-btn.is-portrait {
  aspect-ratio: 3 / 4;
}

/* Long messages stack the photo on top instead of sitting side by side
   with it, regardless of viewport width -- a long side-by-side text
   column stretches far taller than the photo and leaves it looking
   small and lost next to it. */
.message-card--stacked {
  grid-template-columns: 1fr;
}

.message-card--stacked .message-photo-btn {
  max-height: 360px;
}

.message-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.message-photo-caption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--paper);
  text-shadow: 0 1px 8px rgba(43, 37, 35, 0.55);
  pointer-events: none;
}

.message-content {
  position: relative;
  padding: clamp(20px, 4vw, 28px) clamp(12px, 3vw, 28px) clamp(12px, 2vw, 16px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.message-meta-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-top: 4px;
  overflow-wrap: break-word;
}

.message-num {
  color: var(--rose-deep);
}

.message-stamp {
  position: relative;
  flex: none;
  width: 58px;
  height: 70px;
  padding: 4px;
  background: var(--paper);
  border: 2px dashed var(--hairline);
  box-sizing: border-box;
  rotate: 3deg;
}

.message-stamp-inner {
  width: 100%;
  height: 100%;
  background: var(--card-tint, var(--blush));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--rose-deep);
}

.message-stamp-inner i {
  font-style: italic;
}

.message-postmark {
  position: absolute;
  left: -54px;
  top: 22px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--rose);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--rose-deep);
  text-transform: uppercase;
  rotate: -14deg;
  text-align: center;
  line-height: 1.3;
  white-space: pre-line;
}

.message-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(21px, 4.4vw, 24px);
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-line;
  overflow-wrap: break-word;
  word-break: break-word;
  text-wrap: pretty;
}

.message-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-footer-line {
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.message-to {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.message-delete {
  align-self: center;
  margin-top: 4px;
  font-size: 12px;
}

.message-delete.is-confirming {
  color: var(--rose-deep);
  text-decoration-color: var(--rose-deep);
}

/* ---------- Photo lightbox ---------- */

.msg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(43, 37, 35, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 16px;
  box-sizing: border-box;
}

.msg-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  object-fit: contain;
}

.msg-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 252, 248, 0.3);
  background: none;
  color: var(--paper);
  font-size: 22px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 300;
  transition: border-color .2s, transform .2s;
}

.msg-lightbox-close:hover {
  border-color: rgba(255, 252, 248, 0.7);
  transform: scale(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .msg-lightbox-close:hover {
    transform: none;
  }
}

.message-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 21px;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.book-end {
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--ink-muted);
  padding-top: 16px;
}

.book-empty {
  background: var(--paper);
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-hero);
  padding: clamp(48px, 10vw, 80px) 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.empty-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blush);
  box-shadow: 0 0 0 8px var(--cream);
}

.book-empty h2 {
  margin: 8px 0 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(30px, 7vw, 38px);
}

.book-empty p {
  margin: 0;
  font-size: var(--size-body);
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink-muted);
  max-width: 340px;
}

.book-footer {
  text-align: center;
}

/* ---------- Print / PDF export ---------- */

@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: var(--cream);
  }

  [data-noprint] {
    display: none !important;
  }

  [data-card] {
    box-shadow: none !important;
    transform: none !important;
    rotate: none !important;
    break-inside: avoid;
    border: 1px solid var(--line);
  }

  .message-card:hover {
    transform: none;
  }
}
