/* =========================================================================
   Chaubaraa Post Office — styles.css
   Brand book: Deep Maroon #85242C, Warm Cream #FEF3E0.
   One canonical envelope + letter component (assets/refs/envelope.png) is
   used at three sizes (wall / write preview / reading) via container queries,
   so the composition is identical everywhere. CTAs are brand maroon, inverting
   to cream on wine backgrounds. No em dashes in copy.
   ========================================================================= */

:root {
  --wine:        #85242C;
  --wine-deep:   #611A20;
  --wine-soft:   #9A3A40;
  --cream:       #FEF3E0;
  --cream-dim:   #D8C7A6;
  --ink:         #2A211C;

  /* kraft + card tones sampled from envelope.png (used by the send animation) */
  --kraft:       #CFBCA4;
  --kraft-lo:    #B9A88E;
  --kraft-hi:    #D8C7AE;
  --kraft-flap:  #C6B29A;
  --card:        #F3F1EC;
  --card-lo:     #EAE6DD;
  --card-ink:    #3A2E24;

  --font-display: 'Abraham', 'Oswald', 'Poppins', system-ui, sans-serif;
  --font-ui:      'Gotham', 'Poppins', system-ui, sans-serif;
  --font-serif:   'Crimson Pro', 'Cormorant Garamond', Georgia, serif;
  --font-type:    'Special Elite', 'Courier New', monospace;

  --maxw: 1240px;
  --radius: 4px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --t-slow: 600ms; --t-med: 380ms;

  --bg: var(--wine); --bg-elev: var(--wine-deep);
  --fg: var(--cream); --fg-dim: var(--cream-dim);
  --frame: var(--cream); --card-line: var(--wine-soft);
  --silhouette: rgba(254,243,224,.05);
  --btn-bg: var(--cream); --btn-fg: var(--wine);
}
body[data-theme='light'] {
  --bg: var(--cream); --bg-elev: #F6ECD4;
  --fg: var(--wine); --fg-dim: #9A6B5F;
  --frame: var(--wine); --card-line: rgba(133,36,44,.22);
  --silhouette: rgba(133,36,44,.05);
  --btn-bg: var(--wine); --btn-fg: var(--cream);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
  overflow-x: hidden; width: 100%;
}
img { max-width: 100%; }
h1,h2,h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--wine-soft); outline-offset: 3px; border-radius: 2px; }
body[data-theme='light'] :focus-visible { outline-color: var(--wine); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ambient overlays (plain background: grain + vignette + frame only) */
.grain { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"); }
.vignette { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(120% 90% at 50% 20%, transparent 55%, rgba(0,0,0,.22) 100%); }
body[data-theme='light'] .vignette { background: radial-gradient(120% 90% at 50% 20%, transparent 60%, rgba(133,36,44,.10) 100%); }
.page-frame { position: fixed; inset: 14px; z-index: 3; pointer-events: none; border: 1px solid var(--frame); opacity: .45; border-radius: var(--radius); }
@media (max-width: 640px) { .page-frame { inset: 8px; } }
.silhouettes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.silhouettes svg { position: absolute; color: var(--silhouette); }
.sil-window { top: 4%; left: -40px; width: 220px; }
.sil-bottle { bottom: 6%; right: -20px; width: 150px; }
.sil-rail   { bottom: 0; left: 0; width: 100%; height: 90px; }

/* ---------------------------------------------------------- app shell */
.app { position: relative; z-index: 4; }
.site-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: calc(16px + env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--card-line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: 0 0 auto; }
.brand img { height: 34px; width: auto; display: block; }
.brand .logo-wine { display: none; }
body[data-theme='light'] .brand .logo-cream { display: none; }
body[data-theme='light'] .brand .logo-wine { display: block; }
.site-title { margin: 0 auto; }
.site-title a { text-decoration: none; color: var(--fg); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .16em; font-size: 18px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* small phones: the logo, "POST OFFICE", and the CTA cannot share one row
   at ~375px, so the title drops to its own centered row underneath while
   the logo and the (still full-size, easy-to-tap) CTA stay on row one */
@media (max-width: 600px) {
  .site-header { flex-wrap: wrap; gap: 8px 10px; padding: calc(12px + env(safe-area-inset-top)) 14px 12px; }
  .brand img { height: 26px; }
  .header-actions { order: 2; margin-left: auto; }
  .site-title { order: 3; flex: 1 0 100%; margin: 0; text-align: center; }
  .site-title a { font-size: 12px; letter-spacing: .1em; }
}

.theme-toggle { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--card-line); background: transparent; color: var(--fg); display: grid; place-items: center; transition: border-color var(--t-med) var(--ease), transform var(--t-med) var(--ease); flex-shrink: 0; }
.theme-toggle:hover { transform: rotate(18deg); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
body[data-theme='light'] .theme-toggle .icon-sun { display: none; }
body[data-theme='light'] .theme-toggle .icon-moon { display: block; }

.btn { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .09em; font-size: 13px; border: 1px solid transparent; border-radius: var(--radius); padding: 12px 20px; display: inline-flex; align-items: center; gap: 9px; line-height: 1; text-decoration: none; transition: transform var(--t-med) var(--ease), background var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), color var(--t-med) var(--ease); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.3); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--card-line); }
.btn-ghost:hover { background: color-mix(in srgb, var(--fg) 9%, transparent); transform: translateY(-2px); }
.btn-block { width: 100%; justify-content: center; padding: 15px; }

.screen { display: none; }
.screen.is-active { display: block; animation: fadeUp var(--t-slow) var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.back-link { position: relative; z-index: 6; display: inline-block; margin: 18px 0 0 clamp(16px, 4vw, 40px); font-family: var(--font-display); text-transform: uppercase; letter-spacing: .09em; font-size: 12px; text-decoration: none; color: var(--fg); padding: 8px 12px; border-radius: var(--radius); }
.back-link:hover { background: color-mix(in srgb, var(--fg) 9%, transparent); }
.text-field { width: 100%; background: color-mix(in srgb, var(--fg) 6%, transparent); border: 1px solid var(--card-line); border-radius: var(--radius); color: var(--fg); font-family: var(--font-ui); font-size: 15px; padding: 13px 14px; transition: border-color var(--t-med) var(--ease); }
.text-field::placeholder { color: var(--fg-dim); opacity: .75; }
.text-field:focus { border-color: var(--wine-soft); }

/* ===================================================================== */
/*  THE ENVELOPE COMPONENT — envelope.png with live text layered on top   */
/*  The same image everywhere; text sits inside the blank card region.    */
/* ===================================================================== */
.envelope-card { position: relative; width: 100%; aspect-ratio: 1328 / 1184; container-type: inline-size; }
.ec-envimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 1; pointer-events: none;
  filter: drop-shadow(0 16px 26px rgba(0,0,0,.30)); }

/* the card: a To/From header on top, the message below (left column so the
   flowers on the right never cover it) */
.ec-card { position: absolute; left: 16.5%; right: 15%; top: 10.5%; height: 37%; z-index: 2; overflow: hidden; text-align: left; }
.ec-cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 4%; margin-bottom: 1.4cqw; }
.ec-cardto, .ec-cardfrom { font-family: var(--font-serif); font-style: italic; color: #7a2027; font-size: 3.7cqw; white-space: nowrap; }
.ec-cardto::first-letter { text-transform: uppercase; }
.ec-cardfrom { text-align: right; }
.ec-msg { color: var(--card-ink); margin: 0; padding-right: 13%; font-size: 3.7cqw; line-height: 1.3; word-break: break-word; overflow-wrap: anywhere; text-align: justify; text-align-last: left; }
.ec-msg.is-typewriter { font-size: 3cqw; line-height: 1.34; }   /* Special Elite runs large */

/* the chosen flower sits at the seam where the white card meets the brown
   envelope on the right, in FRONT of the flap (blooms forward) */
.ec-flowers { position: absolute; z-index: 3; pointer-events: none; right: 8%; top: 12%; width: 18%; }
/* the stem is shown in front; only the small bottom tip that overlaps the
   brown flap is clipped so it tucks into the envelope */
.ec-flowers .flower-img { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(0,0,0,.30));
  clip-path: polygon(0 0, 100% 0, 100% 60%, 0 100%); }
.ec-wall .ec-flowers .flower-img { clip-path: none; }   /* wall flower peeks whole from behind */
/* the stamp sits lower-right on the flap (reading view) */
.ec-stamp { position: absolute; z-index: 4; right: 15%; top: 52%; width: 12%; transform: rotate(3deg); filter: drop-shadow(0 3px 6px rgba(0,0,0,.28)); }

/* the address on the envelope flap, centered, in spaced typewriter caps */
.ec-line { position: absolute; left: 0; right: 0; bottom: 15%; z-index: 5; text-align: center; font-family: var(--font-type);
  text-transform: uppercase; letter-spacing: .14em; font-size: 3cqw; color: #4a3320; }

/* ---- wall ---- generous, uniform cards; the page may scroll ---- */
.garden { position: relative; z-index: 1; padding: clamp(42px, 6vh, 66px) 0 110px; }
#screen-daak .garden { max-width: min(1560px, 94vw); }
.wall-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 340px)); justify-content: center; align-items: start;
  gap: clamp(38px, 3.4vw, 62px) clamp(30px, 2.6vw, 46px); }
@media (max-width: 1180px) { .wall-grid { grid-template-columns: repeat(3, minmax(0, 320px)); } }
@media (max-width: 860px)  { .wall-grid { grid-template-columns: repeat(2, minmax(0, 320px)); } }
@media (max-width: 580px)  { .wall-grid { grid-template-columns: minmax(0, 330px); } }
.letter-card { display: block; width: 100%; border: none; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.letter-card .envelope-card { transition: transform var(--t-med) var(--ease); }
.letter-card:hover .envelope-card { transform: translateY(-6px); }
/* wall-only: readable truncation, full-width message, one flower behind a
   corner (alternating), header text kept small */
.ec-wall { width: 100%; }
.ec-wall .ec-msg { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; padding-right: 0; font-size: 5.8cqw; }
.ec-wall .ec-msg.is-typewriter { font-size: 4.4cqw; }
.ec-wall .ec-cardto, .ec-wall .ec-cardfrom { font-size: 4.4cqw; }
.ec-wall .ec-envcover { display: none; }   /* wall flower stays behind the corner */
.ec-wall .ec-flowers { position: absolute; z-index: 0; top: -7%; width: 31%; height: auto; display: block; }
.ec-wall .ec-flowers .flower-img { width: 100%; max-width: none; max-height: none; height: auto; }
.ec-wall .ec-flowers { z-index: 0; transform: none; top: -7%; width: 31%; }   /* wall keeps its behind-the-corner peek */
.ec-wall .ec-flowers-right { right: -1%; left: auto; }
.ec-wall .ec-flowers-left  { left: -1%; right: auto; transform: scaleX(-1) rotate(4deg); }
.wall-search { display: flex; justify-content: center; margin: 50px auto 0; max-width: 420px; }
.wall-search .text-field { text-align: center; }
.wall-empty { grid-column: 1/-1; text-align: center; font-family: var(--font-serif); font-style: italic; color: var(--fg-dim); font-size: 18px; }

/* ---- write (live split) ---- */
/* The write screen fills the viewport in one go: header + split + footer all
   fit, and ONLY the right form box scrolls (its own postcard frame + scroll). */
.write-split { display: grid; grid-template-columns: 1fr min(452px, 43vw); }
.write-preview { position: relative; display: grid; place-items: center; padding: 20px clamp(16px, 4vw, 50px); overflow: hidden; }
/* the postcard frame: a fixed double-rule card; the form scrolls inside it */
.write-panel-card {
  position: relative; margin: 14px 16px 14px 6px; border-radius: 10px; overflow: hidden;
  background: var(--bg-elev); display: flex;
  border: 1.5px solid color-mix(in srgb, var(--fg) 46%, transparent);
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
}
.write-panel-card::after { content: ''; position: absolute; inset: 5px; border: 1px solid color-mix(in srgb, var(--fg) 24%, transparent); border-radius: 7px; pointer-events: none; z-index: 4; }
/* a soft fade at the base signals there is more to scroll */
.write-panel-card::before { content: ''; position: absolute; left: 6px; right: 6px; bottom: 6px; height: 42px; z-index: 3; pointer-events: none; border-radius: 0 0 7px 7px;
  background: linear-gradient(to top, var(--bg-elev), color-mix(in srgb, var(--bg-elev) 0%, transparent)); }
.write-form {
  flex: 1 1 auto; overflow-y: scroll; padding: 22px 26px 34px clamp(16px, 2vw, 26px);
  scrollbar-width: none;   /* native hidden; a custom always-visible rail is used */
}
.write-form::-webkit-scrollbar { width: 0; height: 0; display: none; }
/* custom scroll rail on the right of the postcard box */
.wf-rail { position: absolute; top: 12px; bottom: 12px; right: 8px; width: 8px; border-radius: 5px; z-index: 5;
  background: color-mix(in srgb, var(--fg) 11%, transparent); }
.wf-thumb { position: absolute; left: 0; width: 100%; min-height: 28px; border-radius: 5px; cursor: grab;
  background: color-mix(in srgb, var(--fg) 46%, transparent); transition: background var(--t-med) var(--ease); }
.wf-thumb:hover { background: color-mix(in srgb, var(--fg) 64%, transparent); }
.wf-thumb.dragging { background: color-mix(in srgb, var(--fg) 74%, transparent); cursor: grabbing; }
/* the live envelope is the hero of the write page: size it by the available
   height so it fills the space and makes the live edits obvious */
.live-letter { width: auto; max-width: 94%; display: flex; justify-content: center; }
.write-preview .envelope-card { width: auto; height: min(72vh, 660px); }
@media (max-width: 880px) {
  .write-split { grid-template-columns: 1fr; }
  .write-preview { min-height: 320px; padding: 20px 16px; }
  .write-panel-card { margin: 12px; }
  .write-form { overflow-y: visible; }
  .live-letter { width: min(320px, 82%); max-width: 82%; }
  .write-preview .envelope-card { width: 100%; height: auto; }
}

/* write screen fits the viewport (desktop): header + split + footer in one go,
   only the right form scrolls. Mobile keeps normal page scroll. */
.ec-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
@media (min-width: 881px) {
  body.write-mode { overflow: hidden; }
  body.write-mode .app { height: 100vh; display: flex; flex-direction: column; }
  body.write-mode #main { flex: 1 1 auto; min-height: 0; display: flex; }
  body.write-mode #screen-write.is-active { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; width: 100%; }
  body.write-mode .back-link { flex: 0 0 auto; }
  body.write-mode .write-split { flex: 1 1 auto; min-height: 0; }
  body.write-mode .site-footer { flex: 0 0 auto; padding: 16px 20px; }
}

.field { margin-bottom: 22px; }
.field-label { display: block; font-family: var(--font-serif); font-style: italic; font-size: 18px; color: var(--fg); margin: 0 0 3px; }
.field-help { font-size: 13px; color: var(--fg-dim); margin: 0 0 9px; }
.field .counter { float: right; font-family: var(--font-ui); font-style: normal; font-size: 12px; color: var(--fg-dim); }
textarea.text-field { resize: vertical; min-height: 84px; }
.flower-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.flower-opt { position: relative; background: color-mix(in srgb, var(--fg) 6%, transparent); border: 1px solid var(--card-line); border-radius: 8px; padding: 8px 4px; aspect-ratio: 3/4; display: grid; place-items: center; transition: border-color var(--t-med) var(--ease), background var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
.flower-tick { position: absolute; top: 4px; right: 5px; width: 20px; height: 20px; border-radius: 50%; background: #2E8B57; color: #FFFFFF; font-size: 13px; font-weight: 700; line-height: 20px; text-align: center; display: none; z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.flower-opt[aria-pressed='true'] .flower-tick { display: block; }
.write-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.flower-opt .flower-img { height: 74px; width: auto; }
.flower-opt[aria-pressed='true'] { border-color: var(--wine-soft); background: color-mix(in srgb, var(--fg) 14%, transparent); }
body[data-theme='light'] .flower-opt[aria-pressed='true'] { border-color: var(--wine); }
.flower-opt:hover { transform: translateY(-2px); }
.flower-meaning { font-family: var(--font-serif); font-style: italic; font-size: 14px; color: var(--fg-dim); margin-top: 10px; min-height: 1.4em; }
.hand-list { display: flex; flex-direction: column; gap: 8px; }
.hand-opt { text-align: left; background: color-mix(in srgb, var(--fg) 6%, transparent); border: 1px solid var(--card-line); border-radius: 8px; padding: 10px 14px; color: var(--fg); transition: border-color var(--t-med) var(--ease), background var(--t-med) var(--ease); }
.hand-opt[aria-pressed='true'] { border-color: var(--wine-soft); background: color-mix(in srgb, var(--fg) 12%, transparent); }
body[data-theme='light'] .hand-opt[aria-pressed='true'] { border-color: var(--wine); }
.hand-opt .hand-name { font-family: var(--font-ui); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-dim); display: block; margin-bottom: 3px; }
.hand-opt .hand-sample { font-size: 22px; line-height: 1.2; }
.hand-opt[data-font='typewriter'] .hand-sample { font-size: 16px; }

/* ---- reading view: closed envelope opens on load, then the CTA ---- */
/* Beats: 1) closed envelope crossfades open (flap lifts, ~700ms) ->
   2) the letter slides up into view (~800ms) -> 3) the flower blooms and the
   stamp settles (~600ms) -> 4) the prompt + CTA fade in (~500ms). Two static
   images cross-fade for the open/closed envelope, same technique as the post
   animation; reduced motion skips straight to the final open state. */
.letter-view { position: relative; z-index: 1; min-height: calc(100vh - 210px); display: grid; place-items: center; padding: 10px 0 90px; text-align: center; }
.reading { width: min(520px, 90vw); margin: 0 auto; }

.ec-sealedimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 6; pointer-events: none;
  filter: drop-shadow(0 16px 26px rgba(0,0,0,.30)); opacity: 0; }
.reading.anim .ec-sealedimg { opacity: 1; }
.reading.anim.revealed .ec-sealedimg { animation: ecSealFade 700ms var(--ease) forwards; }

.reading.anim .ec-card { opacity: 0; transform: translateY(10%); }
.reading.anim.revealed .ec-card { animation: ecCardIn 800ms var(--ease) 820ms forwards; }

.reading.anim .ec-flowers { opacity: 0; transform: scale(.6); }
.reading.anim.revealed .ec-flowers { animation: ecFlowerIn 600ms var(--ease) 1720ms forwards; }

.reading.anim .ec-stamp { opacity: 0; transform: scale(1.3) rotate(3deg); }
.reading.anim.revealed .ec-stamp { animation: ecStampIn 600ms var(--ease) 1720ms forwards; }

.reading.anim .reading-prompt { opacity: 0; transform: translateY(8px); }
.reading.anim.revealed .reading-prompt { animation: ecPromptIn 500ms var(--ease) 2420ms forwards; }

@keyframes ecSealFade  { to { opacity: 0; } }
@keyframes ecCardIn    { to { opacity: 1; transform: none; } }
@keyframes ecFlowerIn  { to { opacity: 1; transform: scale(1); } }
@keyframes ecStampIn   { 0% { opacity: 0; transform: scale(1.3) rotate(3deg); } 60% { opacity: 1; transform: scale(.96) rotate(3deg); } 100% { opacity: 1; transform: scale(1) rotate(3deg); } }
@keyframes ecPromptIn  { to { opacity: 1; transform: none; } }

.reading-prompt { margin-top: 34px; }
.reading-prompt p { font-family: var(--font-serif); font-style: italic; color: var(--fg-dim); font-size: 19px; margin-bottom: 16px; }
.reading-cta { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
/* on-site reading view only (View 1): copy this letter / reuse it as a
   starting draft, alongside the "Write a letter" CTA */
.reuse-btn { background: transparent; border: none; color: var(--fg-dim); font-family: var(--font-serif); font-style: italic; font-size: 16px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px 4px; transition: color var(--t-med) var(--ease); }
.reuse-btn:hover { color: var(--fg); }
.copy-icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--card-line); background: transparent; color: var(--fg); display: grid; place-items: center; transition: background var(--t-med) var(--ease), border-color var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
.copy-icon-btn:hover { background: color-mix(in srgb, var(--fg) 9%, transparent); transform: translateY(-1px); }
.copy-icon-btn svg { width: 17px; height: 17px; }
.copy-icon-btn.copied { border-color: var(--fg); }

/* ---- standalone recipient page (open.html): no header, no wall, no
   ambient layers, just the letter, the CTA, and the footer link, on the
   same plain maroon background ---- */
.open-page { display: flex; flex-direction: column; min-height: 100vh; }
.open-main { flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  padding: calc(48px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); }
@media (max-width: 480px) {
  .open-main { padding: calc(34px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); }
  .reading { width: min(360px, 84vw); }
}

/* ---- post animation (centered, full page) ---- */
.post-overlay { position: fixed; inset: 0; z-index: 90; display: none; overflow-y: auto; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); text-align: center; }
.post-overlay.is-open { display: block; animation: fadeUp var(--t-med) var(--ease); }
/* The send animation: the letter slides into the OPEN envelope (envelope.png),
   then we cross-fade to the CLOSED envelope (envelope-sealed.png) and the stamp
   presses flat onto it. Two static images, no faked CSS flap. */
.post-stage { position: relative; width: min(360px, 82vw); aspect-ratio: 1328 / 1184; margin: 0 auto; container-type: inline-size; }
.p2-flower { position: absolute; z-index: 1; top: -8%; right: 4%; width: 30%; transform: rotate(4deg); pointer-events: none; }
.p2-flower img { width: 100%; height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.22)); }

/* open envelope + the letter sliding in (visible during steps 1-2) */
.p2-open { position: absolute; inset: 0; z-index: 2; }
.p2-envimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 16px 30px rgba(0,0,0,.30)); }
.p2-card { position: absolute; left: 13.5%; right: 13.5%; top: 7%; height: 40%; z-index: 2; overflow: hidden;
  background: linear-gradient(150deg, var(--card), var(--card-lo)); border-radius: 2px;
  box-shadow: 0 5px 13px rgba(80,60,30,.16); padding: 5.5cqw 6cqw;
  transform: translateY(-32%); transform-origin: 50% 100%; }
.p2-card .ec-msg { font-size: 4.6cqw; color: var(--card-ink); margin: 0; line-height: 1.36; }

/* the closed envelope it seals into (the final resting frame) */
.p2-sealed { position: absolute; left: 6%; right: 6%; top: 15%; bottom: 3%; z-index: 3; opacity: 0; }
.p2-sealedimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 16px 30px rgba(0,0,0,.34)); }
/* the stamp lands flat in the MIDDLE of the sealed envelope */
.p2-stamp { position: absolute; top: 33%; left: 50%; margin-left: -11%; width: 22%; z-index: 5; opacity: 0; transform: scale(1.3) rotate(3deg); filter: drop-shadow(0 4px 8px rgba(0,0,0,.3)); }
.p2-line { position: absolute; left: 9%; bottom: 15%; z-index: 4; font-family: var(--font-type); text-transform: uppercase; letter-spacing: .14em; font-size: 4cqw; color: #4a3320; }

/* step 1: the letter slides down into the open envelope (0.8s) */
@keyframes cardIn { 0% { transform: translateY(-32%); } 100% { transform: translateY(0); } }
/* step 2: cross-fade open -> sealed, settling gently (0.8s) */
@keyframes openOut  { to { opacity: 0; } }
@keyframes sealedIn { 0% { opacity: 0; transform: translateY(-3%) scale(1.015); } 100% { opacity: 1; transform: none; } }
/* step 3: the stamp presses flat onto the sealed envelope (1.0s) */
@keyframes stampIn { 0% { opacity: 0; transform: scale(1.3) rotate(3deg); } 60% { opacity: 1; transform: scale(.97) rotate(3deg); } 100% { opacity: 1; transform: scale(1) rotate(3deg); } }
.folding .p2-card   { animation: cardIn 800ms var(--ease) forwards; }
.folding .p2-open   { animation: openOut 640ms var(--ease) 900ms forwards; }
.folding .p2-sealed { animation: sealedIn 700ms var(--ease) 860ms forwards; }
.folding .p2-stamp  { animation: stampIn 1000ms var(--ease) 1650ms forwards; }
.sealed .p2-card { transform: translateY(0); }
.sealed .p2-open { opacity: 0; }
.sealed .p2-sealed { opacity: 1; }
.sealed .p2-stamp { opacity: 1; transform: scale(1) rotate(3deg); }

.post-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
.post-cta { width: min(460px, 90vw); margin-top: 26px; opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity 600ms var(--ease), transform 600ms var(--ease); }
.post-cta.show { opacity: 1; transform: none; pointer-events: auto; }
.post-msg { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .1em; font-size: 20px; margin: 0; }
.post-said { font-family: var(--font-serif); font-style: italic; color: var(--fg-dim); margin: 8px auto 18px; max-width: 40ch; }
.share-row { display: flex; gap: 8px; max-width: 420px; margin: 0 auto 12px; }
.share-row .text-field { font-size: 13px; min-width: 0; }
.share-row .btn { flex: 0 0 auto; }
.post-actions { max-width: 420px; margin: 0 auto; }

/* footer / toast */
.site-footer { position: relative; z-index: 4; text-align: center; padding: 40px 20px calc(30px + env(safe-area-inset-bottom)); border-top: 1px solid var(--card-line); font-family: var(--font-serif); font-style: italic; color: var(--fg-dim); font-size: 15px; }
.site-footer a { color: var(--fg); font-size: 18px; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; transition: color var(--t-med) var(--ease); }
.site-footer a:hover { color: var(--fg-dim); }
.site-footer .link-arrow { text-decoration: none; display: inline-block; margin-left: 6px; font-size: 1em; font-style: normal; transition: transform var(--t-med) var(--ease); }
.site-footer a:hover .link-arrow { transform: translateX(3px); }

/* ---- section heads + "Your letters" collection (#6) ---- */
.wall-sec-head { text-align: center; margin: 4px 0 26px; }
.wall-sec-head h2 { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .11em; font-size: 22px; }
.wall-sec-sub { font-family: var(--font-serif); font-style: italic; color: var(--fg-dim); margin: 7px 0 0; }
#mineSection { margin-bottom: 18px; }
#mineSection:empty { display: none; }
.mine-card { display: flex; flex-direction: column; }
.mine-controls { display: flex; align-items: center; gap: 8px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }
.mine-badge { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--card-line); color: var(--fg-dim); }
.mine-badge.is-draft { color: var(--fg); border-color: var(--wine-soft); }
body[data-theme='light'] .mine-badge.is-draft { border-color: var(--wine); }
.mine-btn { background: transparent; border: 1px solid var(--card-line); color: var(--fg); border-radius: 20px; padding: 4px 13px; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .06em; font-size: 10px; cursor: pointer; transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease), border-color var(--t-med) var(--ease); }
/* comfortable tap targets on touch screens */
@media (max-width: 640px) {
  .mine-controls { gap: 10px; }
  .mine-badge { font-size: 11px; padding: 8px 12px; }
  .mine-btn { font-size: 11px; padding: 10px 16px; min-height: 44px; }
}
.mine-btn:hover { background: color-mix(in srgb, var(--fg) 9%, transparent); }
.mine-del.confirming { border-color: #D24B3E; color: #E86A5C; }
body[data-theme='light'] .mine-del.confirming { color: #B23A2E; border-color: #B23A2E; }

/* ---- share screen: one-pager preview + Back/Done (#5, #7) ---- */
.share-preview { margin: 2px auto 16px; }
.share-preview-label { font-family: var(--font-serif); font-style: italic; color: var(--fg-dim); font-size: 14px; margin: 0 0 8px; }
.ec-preview { width: 208px; margin: 0 auto; }
.post-endrow { display: flex; gap: 10px; }
.post-endrow .btn { flex: 1; justify-content: center; }
.toast { position: fixed; bottom: calc(30px + env(safe-area-inset-bottom)); left: 50%; max-width: calc(100vw - 32px); transform: translateX(-50%) translateY(20px); background: var(--fg); color: var(--bg); padding: 12px 22px; border-radius: 40px; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .07em; font-size: 12px; z-index: 95; opacity: 0; pointer-events: none; transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
.toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .01ms !important; } }
@media (max-width: 720px) { .btn { padding: 11px 14px; font-size: 12px; } }
