/* ---------- palette ---------- */
:root {
  --paper:      #fbf6ee;
  --paper-2:    #f5ede1;
  --card:       #fffdf9;
  --ink:        #2e2723;
  --ink-soft:   #6b5d52;
  --ink-faint:  #9c8c7e;
  --accent:     #b4614a;
  --accent-soft:#d9a292;
  --line:       #e3d7c7;
  --shadow:     0 1px 2px rgba(70,52,38,.06), 0 8px 24px rgba(70,52,38,.08);
  --shadow-lift:0 2px 6px rgba(70,52,38,.08), 0 18px 40px rgba(70,52,38,.14);
  --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 50% -10%, #fffaf2 0%, rgba(255,250,242,0) 70%);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(48px, 9vw, 104px) clamp(20px, 5vw, 40px) 96px;
}

/* ---------- hero ---------- */
.hero { text-align: center; }

.eyebrow {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.hero-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(44px, 11vw, 88px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-note {
  margin: 20px auto 0;
  max-width: 30rem;
  color: var(--ink-soft);
  font-size: 17px;
}

.rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 44px auto;
  max-width: 260px;
  color: var(--accent-soft);
  font-size: 13px;
}
.rule span {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--line), transparent);
}

/* ---------- letter ---------- */
.letter {
  max-width: 36rem;
  margin: 0 auto;
}

.salutation {
  margin: 0 0 1.4em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(21px, 3.2vw, 25px);
  color: var(--ink);
}

.letter-body p {
  margin: 0 0 1.35em;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(18px, 2.4vw, 20px);
  line-height: 1.78;
  color: var(--ink);
  hanging-punctuation: first;
}

/* the last, shortest paragraph gets to breathe */
.letter-body p:last-child {
  margin-top: 1.9em;
  margin-bottom: 0;
  font-size: clamp(19px, 2.7vw, 22px);
  line-height: 1.65;
  color: var(--accent);
}

.letter-signoff {
  margin: 2.4em 0 0;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink-soft);
}
.letter-name {
  margin: .25em 0 0;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 400;
  letter-spacing: .01em;
  color: var(--ink);
}

/* ---------- section headings ---------- */
.gallery-section { margin-top: clamp(72px, 11vw, 112px); }

.gallery-head { text-align: center; margin-bottom: 34px; }
.gallery-head .rule { margin-top: 0; margin-bottom: 30px; }

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 4vw, 30px);
  letter-spacing: -0.01em;
}
.section-hint {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--ink-faint);
}

/* ---------- grid ---------- */
.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;   /* keeps a short last row centered, not stranded left */
  gap: clamp(14px, 2.4vw, 22px);
  max-width: 740px;
  margin: 0 auto;
}

/* ---------- card ---------- */
.card {
  position: relative;
  flex: 1 1 170px;
  max-width: 222px;
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  -webkit-tap-highlight-color: transparent;
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 12px; }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .68s cubic-bezier(.2,.8,.25,1);
  border-radius: 10px;
}
.card.revealed .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}

/* front (sealed) */
.card-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  background:
    linear-gradient(150deg, var(--card) 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  transition: transform .3s ease, box-shadow .3s ease;
}
.card:hover .card-front { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card.revealed:hover .card-front { transform: none; }

.card-num {
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.card-heart {
  font-size: 26px;
  color: var(--accent-soft);
  transition: transform .3s ease;
}
.card:hover .card-heart { transform: scale(1.12); }
.card-label {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  padding: 0 4px;
  text-wrap: balance;
}
.card-cta {
  position: absolute;
  bottom: 16px;
  left: 0; right: 0;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* back (photo) */
.card-back {
  transform: rotateY(180deg);
  background: var(--paper-2);
}
.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-back .missing {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-faint);
  background: repeating-linear-gradient(45deg, #f2e9dc, #f2e9dc 10px, #eee2d2 10px, #eee2d2 20px);
}
.card-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 26px 14px 12px;
  font-family: var(--serif);
  font-size: 15px;
  color: #fff;
  text-align: left;
  background: linear-gradient(to top, rgba(30,20,14,.78), rgba(30,20,14,0));
}

.reveal-all-wrap { text-align: center; margin-top: 34px; }
.reveal-all {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: .06em;
  cursor: pointer;
  transition: all .25s ease;
}
.reveal-all:hover { border-color: var(--accent-soft); color: var(--accent); box-shadow: var(--shadow); }

/* ---------- closing ---------- */
.closing { text-align: center; margin-top: clamp(56px, 8vw, 80px); }
.closing-text {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(19px, 3vw, 23px);
  color: var(--ink);
}
.signoff {
  margin: 14px 0 0;
  font-size: 14px;
  letter-spacing: .1em;
  color: var(--ink-faint);
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  background: rgba(38, 28, 21, .92);
  backdrop-filter: blur(6px);
  animation: fade .25s ease;
}
.lightbox[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.lb-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.lb-figure img {
  max-width: 100%;
  max-height: 74vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 30px 70px rgba(0,0,0,.45);
}
.lb-caption {
  max-width: 34rem;
  text-align: center;
  color: #f4e9dc;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
}
.lb-caption strong {
  display: block;
  font-weight: 400;
  font-size: 20px;
  margin-bottom: 6px;
  color: #fff;
}

.lb-close, .lb-nav {
  position: absolute;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.18); }
.lb-close { top: 18px; right: 18px; width: 42px; height: 42px; font-size: 26px; line-height: 1; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 30px; line-height: 1; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }

@media (max-width: 560px) {
  .lb-nav { width: 40px; height: 40px; font-size: 26px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

/* ---------- entrance animation ---------- */
.fade-up {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.25,1);
}
.fade-up.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
  .fade-up { opacity: 1; transform: none; }
}
