/* Screen 2 · Love Letter */
.s2 {
  --bg-1: #3A1219; --bg-2: #14060A; --glow: #8A2A3A; --foot: #0E0406;
  --paper-hi: #F8F0E3; --paper-lo: #EEE0C8; --ink: #2B1B17; --cream: #F4EADB;
  --wax: #9E1B22; --wax-hi: #C2343C; --wax-lo: #7A0F16; --wax-btn-hi: #B4262E; --wax-btn-lo: #7E1219; --wax-text: #F0C2A8; --cta-text: #F4EADB;
  --accent: #D4A55A;
  --kraft-hi: #E2CBA5; --kraft-lo: #CDB085; --kraft-flap: #CFB185; --kraft-line: #9C7F55; --kraft-back: #BE9F6E; --stamp: #E7D4B4;
}
.s2[data-theme="midnight-blue"] {
  --bg-1: #16224A; --bg-2: #070B1A; --glow: #3A5A9A; --foot: #05081A;
  --ink: #1B2238; --accent: #E7C27A;
  --kraft-hi: #DCE3EC; --kraft-lo: #BCC8D9; --kraft-flap: #C3CEDD; --kraft-line: #7D8DA6; --kraft-back: #A9B6C9; --stamp: #DCE3EC;
}
.s2[data-theme="forest"] {
  --bg-1: #173326; --bg-2: #06100B; --glow: #2F6B4F; --foot: #040A07;
  --ink: #1E2A22; --accent: #E3C77E;
  --wax: #B8862B; --wax-hi: #E0B24E; --wax-lo: #7A5512; --wax-btn-hi: #D3A042; --wax-btn-lo: #8C6418; --wax-text: #FFF1C9; --cta-text: #1E2A22;
}

.s2 { background: var(--bg-2); color: var(--cream); font-family: Inter, system-ui, sans-serif; }
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: linear-gradient(var(--bg-1), var(--bg-2)); }
.bg__glow { position: absolute; inset: 0; background: radial-gradient(60% 40% at 50% 42%, color-mix(in srgb, var(--glow) 50%, transparent), transparent 70%); animation: candle 5s ease-in-out infinite alternate; }
@keyframes candle { 0% { opacity: 0.85; } 40% { opacity: 1; } 70% { opacity: 0.8; } 100% { opacity: 0.95; } }
.lyrics span { position: absolute; white-space: nowrap; font: italic 400 24px/1 "Cormorant Garamond", serif; color: var(--cream); animation: drift linear infinite alternate; }
@keyframes drift { from { transform: translateY(0) rotate(var(--r)); } to { transform: translateY(-60px) rotate(var(--r)); } }

/* Gate: sealed envelope */
.s2 .gate { background: linear-gradient(color-mix(in srgb, var(--bg-1) 70%, transparent), color-mix(in srgb, var(--bg-2) 85%, transparent)); }
.gate__kicker { position: absolute; top: max(64px, env(safe-area-inset-top)); font-size: 11px; opacity: 0.6; }
.gate__word { position: absolute; top: max(90px, calc(env(safe-area-inset-top) + 28px)); font: 600 30px/1 "Cormorant Garamond", serif; letter-spacing: 0.3em; margin-right: -0.3em; }
.env { position: relative; width: min(320px, 82vw); aspect-ratio: 320 / 214; transform: rotate(-3deg); perspective: 800px; margin-top: 40px; }
.env__body { position: absolute; inset: 0; border-radius: 6px; background: linear-gradient(var(--kraft-hi), var(--kraft-lo)); box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5); }
.env__folds { position: absolute; inset: 0; width: 100%; height: 100%; color: color-mix(in srgb, var(--kraft-line) 55%, transparent); }
.env__letter { position: absolute; left: 8%; right: 8%; top: 8%; height: 80%; background: linear-gradient(var(--paper-hi), var(--paper-lo)); border-radius: 2px; z-index: 1; opacity: 0; transition: transform 0.8s 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s 0.5s; }
.env__flap { position: absolute; left: 0; right: 0; top: 0; height: 58%; background: var(--kraft-flap); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform 0.7s cubic-bezier(0.5, 0, 0.3, 1); z-index: 2; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2)); }
.seal { position: absolute; left: 50%; top: 56%; width: 64px; height: 64px; transform: translate(-50%, -50%); z-index: 3; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 40% 35%, var(--wax-hi), var(--wax-lo)); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 5px color-mix(in srgb, var(--wax-lo) 60%, transparent); transition: transform 0.4s, opacity 0.4s; }
/* The seal "breathes" and sends out ripples so people know to tap it. */
.gate:not(.is-opening) .seal { animation: sealbeat 2.4s ease-in-out infinite; }
@keyframes sealbeat {
  0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 5px color-mix(in srgb, var(--wax-lo) 60%, transparent), 0 0 0 0 color-mix(in srgb, var(--wax-hi) 0%, transparent); }
  12% { transform: translate(-50%, -50%) scale(1.1); }
  24% { transform: translate(-50%, -50%) scale(0.98); }
  36% { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 5px color-mix(in srgb, var(--wax-lo) 60%, transparent), 0 0 26px 6px color-mix(in srgb, var(--wax-hi) 55%, transparent); }
  55% { transform: translate(-50%, -50%) scale(1); }
}
.seal::before, .seal::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; pointer-events: none; animation: sealpulse 2.4s ease-out infinite; }
.seal::after { border-color: var(--wax-hi); animation-delay: 0.5s; }
@keyframes sealpulse { 0% { transform: scale(0.95); opacity: 0.85; } 70%, 100% { transform: scale(1.9); opacity: 0; } }
.gate.is-opening .seal::before, .gate.is-opening .seal::after { animation: none; opacity: 0; }
.env:hover .seal, .env:focus-visible .seal { animation-duration: 1.2s; }
/* The envelope gives a little nudge every few seconds. */
.gate:not(.is-opening) .env { animation: envnudge 4.8s ease-in-out 1.2s infinite; }
@keyframes envnudge { 0%, 82%, 100% { transform: rotate(-3deg); } 86% { transform: rotate(-5deg) translateY(-3px); } 90% { transform: rotate(-1deg) translateY(-3px); } 94% { transform: rotate(-4deg); } }
/* Tap hint: a finger that taps the seal. */
.tapper { position: absolute; left: calc(50% + 22px); top: calc(56% + 18px); width: 34px; height: 34px; z-index: 4; pointer-events: none; color: var(--cream); filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45)); animation: tap 2.4s ease-in-out infinite; transform-origin: 30% 10%; }
.tapper svg { width: 100%; height: 100%; }
@keyframes tap { 0%, 100% { transform: translate(8px, 10px) rotate(-12deg); opacity: 0.95; } 10% { transform: translate(0, 0) rotate(-12deg) scale(0.92); } 20% { transform: translate(6px, 8px) rotate(-12deg); } 60% { opacity: 0.95; } }
.gate.is-opening .tapper { opacity: 0; transition: opacity 0.2s; animation: none; }
@media (prefers-reduced-motion: reduce) {
  .gate .seal, .gate .env, .seal::before, .seal::after, .tapper { animation: none !important; }
}
.seal span { font: italic 600 30px/1 "Cormorant Garamond", serif; color: var(--wax-text); }
.env__to { position: absolute; left: 6%; bottom: 14%; font: 13px/1 "Homemade Apple", cursive; color: var(--ink); opacity: 0.7; transform: rotate(-4deg); }
.postmark { position: absolute; right: 6%; bottom: 8%; width: 70px; height: 70px; border-radius: 50%; border: 1.2px solid color-mix(in srgb, var(--ink) 35%, transparent); display: grid; place-items: center; text-align: center; font-size: 9px; line-height: 1.3; letter-spacing: 0.1em; color: var(--ink); opacity: 0.6; transform: rotate(12deg); }
.gate.is-opening .env__flap { transform: rotateX(180deg); z-index: 0; }
.gate.is-opening .seal { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
.gate.is-opening .env__letter { opacity: 1; transform: translateY(-62%); }
.gate__title { font: italic 500 34px/1.15 "Cormorant Garamond", serif; margin-top: 56px; }
.gate__hint { color: var(--accent); font-size: 14px; font-weight: 500; margin-top: 14px; }

/* Header */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 20px 14px; background: linear-gradient(color-mix(in srgb, var(--bg-1) 85%, transparent), transparent); }
.wordmark { font: 600 22px/1 "Cormorant Garamond", serif; letter-spacing: 0.24em; text-decoration: none; }
.top__tag { display: none; font-size: 12px; opacity: 0.6; }

/* Paper pieces */
.desk { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 28px; padding: 84px 16px 40px; }
.paper { color: var(--ink); background: linear-gradient(var(--paper-hi), var(--paper-lo)); border-radius: 3px; box-shadow: 0 20px 44px rgba(10, 0, 0, 0.45); padding: 28px 26px; }
.letter-wrap { position: relative; }
.envelope-back { display: none; }
.letter { display: flex; flex-direction: column; gap: 14px; }
.letter__date { font: 18px/1 Caveat, cursive; opacity: 0.55; text-align: right; }
.letter__dear { font: 20px/1.8 "Homemade Apple", cursive; }
.polaroid { align-self: flex-start; background: #fff; padding: 10px 10px 12px; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3); transform: rotate(-2deg); width: min(260px, 80%); }
.polaroid img { width: 100%; aspect-ratio: 24 / 25; object-fit: cover; object-position: 50% 20%; }
.polaroid figcaption { font: 20px/1 Caveat, cursive; opacity: 0.8; margin-top: 10px; }
.letter__body { font: 23px/1.3 Caveat, cursive; }
.letter__sign { font: 24px/1.8 "Homemade Apple", cursive; color: var(--wax); }
.letter__note { font-size: 9px; opacity: 0.35; letter-spacing: 0.06em; }

.reply { display: flex; flex-direction: column; gap: 14px; }
.reply__head { display: flex; align-items: center; justify-content: space-between; }
.reply__head .mono { font-size: 11px; font-weight: 500; color: var(--wax); }
.stamp { display: grid; place-items: center; padding: 6px 10px; background: var(--stamp); outline: 1px dashed color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: -3px; transform: rotate(4deg); }
.stamp b { font: italic 600 24px/1 "Cormorant Garamond", serif; color: var(--wax); }
.stamp small { font-size: 8px; letter-spacing: 0.1em; opacity: 0.6; }
.tear { display: flex; align-items: center; gap: 8px; opacity: 0.5; font-size: 14px; }
.tear i { flex: 1; border-top: 1px dashed currentColor; }
.tear .mono { font-size: 10px; }
.reply__title { font: italic 600 36px/1.05 "Cormorant Garamond", serif; }
.reply__sub { font-size: 14px; line-height: 1.45; opacity: 0.65; margin-top: 6px; }
.reply form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.line { display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); }
.line span { font-size: 10px; opacity: 0.5; letter-spacing: 0.16em; }
.line input { border: 0; background: transparent; outline: none; font: 24px/1.4 Caveat, cursive; color: var(--ink); padding: 2px 0 4px; width: 100%; }
.line input::placeholder { color: var(--ink); opacity: 0.35; }
.line:focus-within { border-bottom-color: var(--wax); }
.cta { margin-top: 6px; padding: 16px 22px; border-radius: 999px; background: linear-gradient(var(--wax-btn-hi), var(--wax-btn-lo)); color: var(--cta-text); font-weight: 600; font-size: 15px; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.cta:hover { transform: translateY(-1px); }
.cta:disabled { opacity: 0.6; }
.error { font-size: 13px; color: #B42318; }
.success__name:has(span:empty) { display: none; }
.count { text-align: center; font: 20px/1 Caveat, cursive; opacity: 0.85; }
.count b, .heart { color: var(--wax); font-weight: 700; }

.doors { text-align: center; }
.doors__title { font: italic 400 26px/1 "Cormorant Garamond", serif; margin-bottom: 14px; }
.stamps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pstamp { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; background: var(--cream); color: var(--ink); outline: 1px dashed color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: -4px; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
.pstamp:nth-child(odd) { transform: rotate(-2deg); }
.pstamp:nth-child(even) { transform: rotate(1.5deg); }
.pstamp b { font: 600 32px/1.1 "Cormorant Garamond", serif; color: var(--wax); font-variant-numeric: lining-nums tabular-nums; }
.pstamp span { font-size: 9px; opacity: 0.6; letter-spacing: 0.2em; }
.share { text-align: center; }
.share__title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.share__row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pill { padding: 10px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.24); font-size: 13px; font-weight: 500; text-decoration: none; }
.pill:hover { background: rgba(255, 255, 255, 0.08); }
.foot { position: relative; z-index: 1; background: color-mix(in srgb, var(--foot) 92%, transparent); padding: 24px 24px 96px; display: grid; gap: 6px; }
.foot .mono { font-size: 11px; opacity: 0.6; }
.foot__links, .foot__small { font-size: 12px; opacity: 0.4; }

/* Reveal after opening */
.desk > * { opacity: 0; transform: translateY(30px); transition: opacity 0.9s, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.entered .desk > * { opacity: 1; transform: none; }
.entered .desk > :nth-child(2) { transition-delay: 0.15s; }
.entered .desk > :nth-child(3) { transition-delay: 0.3s; }
.entered .desk > :nth-child(4) { transition-delay: 0.4s; }

@media (min-width: 1024px) {
  .top { padding: 34px 64px; }
  .wordmark { font-size: 30px; }
  .top__tag { display: block; position: absolute; left: 50%; transform: translateX(-50%); }
  .desk { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); grid-template-rows: auto auto auto; column-gap: 80px; row-gap: 32px; max-width: 1320px; margin: 0 auto; padding: 130px 64px 80px; align-items: start; }
  .letter-wrap { grid-column: 1; grid-row: 1 / span 3; padding: 20px 30px 120px; }
  .envelope-back { display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 300px; border-radius: 6px; background: linear-gradient(var(--kraft-hi), var(--kraft-lo)); box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5); transform: rotate(-2deg); }
  .envelope-back::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom right, transparent 49.6%, color-mix(in srgb, var(--kraft-line) 40%, transparent) 50%, transparent 50.4%), linear-gradient(to bottom left, transparent 49.6%, color-mix(in srgb, var(--kraft-line) 40%, transparent) 50%, transparent 50.4%); }
  .letter { position: relative; transform: rotate(-2deg); padding: 36px 40px 40px; }
  .letter { display: grid; grid-template-columns: 1fr 210px; column-gap: 28px; align-items: start; }
  .letter__date { grid-column: 1 / -1; }
  .letter__dear, .letter__body, .letter__sign, .letter__note { grid-column: 1; }
  .polaroid { grid-column: 2; grid-row: 2 / span 4; width: 100%; transform: rotate(5deg); margin-top: 10px; align-self: start; height: auto; }
  .letter__body { font-size: 26px; }
  .reply { grid-column: 2; grid-row: 1; transform: rotate(1.2deg); padding: 30px 32px; }
  .reply__title { font-size: 44px; }
  .doors { grid-column: 2; grid-row: 2; text-align: left; }
  .stamps { max-width: 380px; }
  .share { grid-column: 2; grid-row: 2; text-align: left; }
  .share__row { justify-content: flex-start; }
  .foot { padding: 28px 64px 96px; }
  .lyrics span { font-size: 38px; }
}
