/* =====================================================================
   LETTERS FROM DROSIE: styles
   Palette: ivory & parchment, forest green, soft plum, sepia ink, muted gold
   ===================================================================== */
:root {
  --ivory: #fbf6ea;
  --parchment: #f1e6cf;
  --cream: #f4ead4;
  --forest: #2f4a3a;
  --forest-deep: #1f3328;
  --plum: #5b2a45;
  --plum-soft: #7a3f5f;
  --sepia: #3e2b1f;        /* letter ink: 11.9:1 on ivory */
  --sepia-soft: #6b5440;
  --gold: #b8954a;
  --gold-soft: #d8bf85;
  --wood: #5a3420;
  --serif: "Lora", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --display: "Cormorant Garamond", "Lora", Georgia, serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --ts: 1;                 /* text-size scale, set by controls */
  --ease-soft: cubic-bezier(.22, .61, .36, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--serif); color: var(--sepia); line-height: 1.6;
  background: #2b1a10;
  overflow-x: clip;   /* 'clip' (not 'hidden') so position: sticky keeps working */
}
html { overflow-x: clip; }
body[data-scene="room"], body[data-scene="envelope"] { overflow: hidden; height: 100svh; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ivory); color: var(--sepia); padding: 10px 16px; border-radius: 8px; }
.skip-link:focus { left: 12px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
button { font: inherit; color: inherit; }
button:disabled { cursor: not-allowed; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 12px clamp(12px, 3vw, 28px);
  background: linear-gradient(180deg, rgba(31, 20, 12, .55), rgba(31, 20, 12, 0));
  color: var(--ivory);
}
body[data-scene="letter"] .topbar { position: sticky; background: rgba(36, 24, 15, .92); }
.home-link { color: var(--ivory); text-decoration: none; font-weight: 500; padding: 8px 12px; border-radius: 999px; background: rgba(251, 246, 234, .12); min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.home-link:hover { background: rgba(251, 246, 234, .22); }
.brand { margin: 0 auto; font-family: var(--hand); font-size: 1.55rem; letter-spacing: .3px; opacity: .92; }
.top-actions { display: flex; gap: 8px; }
.quiet-btn { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(251, 246, 234, .35); background: rgba(31, 20, 12, .35); color: var(--ivory); cursor: pointer; font-size: .92rem; }
.quiet-btn:hover { background: rgba(31, 20, 12, .55); }
body[data-scene="letter"] #skip-anim { display: none; }
.sound-icon { display: inline-block; width: 14px; height: 12px; margin-right: 6px; vertical-align: -1px; background: currentColor;
  clip-path: polygon(0 30%, 30% 30%, 65% 0, 65% 100%, 30% 70%, 0 70%); }
#sound-toggle[aria-pressed="false"] .sound-icon { opacity: .45; }
.home-link, .quiet-btn { white-space: nowrap; }
@media (max-width: 560px) { .brand { display: none; } .top-actions { margin-left: auto; } .quiet-btn { padding: 8px 12px; font-size: .85rem; } }
@media (max-width: 430px) {
  #sound-toggle .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #sound-toggle .sound-icon { margin-right: 0; }
  #sound-toggle { min-width: 44px; }
  .home-link { padding: 8px 10px; }
}

/* ---------- shared buttons ---------- */
.paper-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 12px 24px;
  border-radius: 14px; border: 1.5px solid rgba(62, 43, 31, .35); background: var(--ivory); color: var(--sepia);
  font-family: var(--serif); font-size: 1.05rem; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 6px 16px rgba(30, 18, 8, .22);
  transition: transform .2s var(--ease-soft), box-shadow .2s;
}
.paper-btn:hover { transform: translateY(-2px); box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 10px 22px rgba(30, 18, 8, .28); }
.paper-btn.primary { background: var(--plum); color: var(--ivory); border-color: #3f1830; }
.text-btn { background: none; border: 0; color: var(--sepia-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 44px; padding: 6px 8px; }
.text-btn.small { font-size: .92rem; }

/* =====================================================================
   SCENE ONE: THE LETTER ROOM
   ===================================================================== */
.scene-room { position: fixed; inset: 0; }
.room-viewport { position: absolute; inset: 0; overflow: hidden;
  background: linear-gradient(180deg, #e3dac3 0 52%, #7d4b2b 52% 100%); }
.stage { position: absolute; left: 0; top: 0; width: 1600px; height: 1000px; transform-origin: 0 0; }
.room-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sunbeam { mix-blend-mode: soft-light; animation: beam 9s ease-in-out infinite alternate; }
@keyframes beam { from { opacity: .75; } to { opacity: 1; } }
.dust { position: absolute; inset: 0; pointer-events: none; }
.dust i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff7d8; box-shadow: 0 0 6px 1px rgba(255, 244, 207, .8); opacity: 0;
  animation: drift var(--d, 14s) linear var(--delay, 0s) infinite; }
@keyframes drift {
  0% { opacity: 0; transform: translate(0, 0); }
  15% { opacity: var(--o, .7); }
  85% { opacity: var(--o, .7); }
  100% { opacity: 0; transform: translate(var(--dx, 40px), var(--dy, 120px)); }
}

/* mailbox */
.mailbox { position: absolute; left: 620px; top: 450px; width: 360px; height: 330px; cursor: pointer; }
.mailbox-body { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.mb-flag { transform-origin: 323px 270px; transform-box: view-box; animation: flag-hint 7s ease-in-out 3s infinite; }
@keyframes flag-hint { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-5deg); } 96% { transform: rotate(2deg); } }
.mailbox.opened .mb-flag { animation: none; transform: rotate(90deg); transition: transform .8s var(--ease-soft) .4s; }
.mb-door-hinge { position: absolute; left: 56px; top: 32px; width: 248px; height: 260px; perspective: 900px; perspective-origin: 50% 0%; z-index: 3; }
.mb-door { position: absolute; inset: 0; transform-origin: 50% 100%; transform-style: preserve-3d; }
.door-face { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.door-back { transform: rotateX(180deg); }
.mb-envelope { position: absolute; left: 112px; top: 190px; width: 136px; height: 88px; z-index: 2; transform-origin: 50% 100%;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45)); }
.mb-envelope svg { width: 100%; height: 100%; display: block; }
.mb-label { position: absolute; left: -142px; top: 238px; margin: 0; padding: 10px 18px 10px 26px; z-index: 4;
  font-family: var(--hand); font-size: 30px; color: var(--sepia); background: #e8d3a8;
  border-radius: 4px 14px 14px 4px; transform: rotate(-5deg); box-shadow: 0 6px 12px rgba(30, 15, 5, .35);
  clip-path: polygon(10% 0, 100% 0, 100% 100%, 10% 100%, 0 50%); }
.mb-label::before { content: ''; position: absolute; left: 9px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #7d4b2b; box-shadow: inset 0 0 0 2px #c9b083; }
.room-glow { position: absolute; left: 700px; top: 470px; width: 200px; height: 200px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 236, 180, .45), rgba(255, 236, 180, 0) 70%); animation: glow 5s ease-in-out infinite; mix-blend-mode: screen; }
@keyframes glow { 0%, 100% { opacity: .35; transform: scale(.95); } 50% { opacity: .8; transform: scale(1.05); } }
.mailbox:hover .mb-door .door-front { filter: brightness(1.08); }

.room-cta { position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(92vw, 520px); text-align: center; }
.whisper { margin: 0; font-family: var(--hand); font-size: clamp(1.5rem, 4.6vw, 2rem); color: var(--ivory); text-shadow: 0 2px 10px rgba(20, 10, 4, .8); }
.room-cta .paper-btn { width: 100%; max-width: 420px; }
body.sequence-running .room-cta { opacity: 0; pointer-events: none; transition: opacity .4s; }

/* =====================================================================
   SCENE TWO: THE ENVELOPE
   ===================================================================== */
.scene-envelope { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 45%, #8a5634 0%, #5a3420 55%, #2c190d 100%); }
.scene-envelope::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 10%, rgba(255, 240, 200, .25), transparent 55%); pointer-events: none; }
.env-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 80px 16px 40px; }
.envelope { position: relative; width: min(640px, 92vw); aspect-ratio: 640 / 420; perspective: 1600px; transform: rotate(-1.2deg);
  filter: drop-shadow(0 22px 26px rgba(20, 10, 3, .45)) drop-shadow(0 3px 4px rgba(20, 10, 3, .3)); }
.env-back { position: absolute; inset: 0; background: #e9dbbb; border-radius: 3px 5px 4px 2px;
  clip-path: polygon(0 .6%, 18% 0, 47% .5%, 72% 0, 100% .7%, 99.7% 30%, 100% 66%, 99.6% 100%, 64% 99.5%, 33% 100%, 0 99.4%, .4% 58%); }
.env-letter { position: absolute; left: 6%; right: 6%; top: 7%; height: 84%; z-index: 1; border-radius: 2px;
  background: var(--ivory); box-shadow: 0 -2px 6px rgba(0, 0, 0, .08); }
.env-letter-lines { position: absolute; inset: 18% 10% 18%; background: repeating-linear-gradient(180deg, transparent 0 18px, rgba(62, 43, 31, .16) 18px 19.5px); }
.env-pocket { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; }
.env-address { position: absolute; z-index: 3; left: 0; right: 0; top: 69.5%; text-align: center; color: var(--sepia); pointer-events: none; }
.env-address p { margin: 0; }
.env-address .to { font-family: var(--hand); font-size: clamp(1.15rem, 3.9vw, 1.9rem); line-height: 1.1; }
.env-address .where { font-family: var(--display); font-style: italic; font-size: clamp(.82rem, 2.3vw, 1.08rem); color: var(--sepia-soft); margin-top: 2px; }
.env-address .from { font-family: var(--hand); font-size: clamp(.98rem, 2.9vw, 1.35rem); color: var(--plum); margin-top: clamp(2px, 1.1vw, 8px); }
.env-flap { position: absolute; left: 0; top: 0; width: 100%; height: 61.9%; z-index: 4; transform-origin: 50% 0; transform-style: preserve-3d; }
.env-flap svg { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; filter: drop-shadow(0 4px 3px rgba(60, 35, 15, .18)); }
.flap-back { transform: rotateX(180deg); }
.seal-half { position: absolute; width: clamp(62px, 13.5vw, 88px); aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; }
.seal-half svg { width: 100%; height: 100%; display: block; overflow: visible; }
.seal-top { left: 50%; top: 90.8%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.seal-bottom { left: 50%; top: 56.2%; z-index: 5; }
.seal-top .seal-svg { clip-path: polygon(0 0, 100% 0, 100% 52%, 84% 47%, 70% 55%, 57% 48%, 44% 57%, 31% 49%, 17% 56%, 0 50%); }
.seal-bottom .seal-svg { clip-path: polygon(0 50%, 17% 56%, 31% 49%, 44% 57%, 57% 48%, 70% 55%, 84% 47%, 100% 52%, 100% 100%, 0 100%); }
.seal-button { position: absolute; left: 50%; top: 56.2%; width: clamp(90px, 19vw, 124px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 50%; border: 0; background: transparent; cursor: pointer; z-index: 6; }
.seal-button:hover ~ .seal-bottom, .envelope:has(.seal-button:hover) .seal-half { filter: brightness(1.1); }
.seal-button:focus-visible { outline: 3px solid var(--ivory); outline-offset: 4px; }
.envelope.ready .seal-bottom, .envelope.ready .seal-top { animation: seal-breathe 3.2s ease-in-out infinite; }
@keyframes seal-breathe { 0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 220, 160, 0)); } 50% { filter: drop-shadow(0 0 10px rgba(255, 220, 160, .55)); } }
.env-hint { margin: 0; font-family: var(--hand); font-size: clamp(1.3rem, 4vw, 1.8rem); color: var(--ivory); text-shadow: 0 2px 8px rgba(0, 0, 0, .5); }

/* =====================================================================
   SCENE THREE: THE LETTER
   ===================================================================== */
body[data-scene="letter"] { background:
  radial-gradient(ellipse at 40% 0%, rgba(255, 233, 186, .22), transparent 60%),
  linear-gradient(180deg, #5c3621, #3a2214 60%, #2a170c); background-attachment: fixed; }
.scene-letter { position: relative; padding: 24px clamp(12px, 3vw, 32px) 40px; }
.reader { display: grid; grid-template-columns: minmax(0, 720px) minmax(240px, 300px); gap: clamp(20px, 4vw, 48px); justify-content: center; align-items: start; max-width: 1120px; margin: 0 auto; }
.letter-col { min-width: 0; }
.letter-stack { position: relative; }

.letter {
  --pad: clamp(26px, 6vw, 68px);
  position: relative; padding: calc(var(--pad) * .9) var(--pad) calc(var(--pad) * .8);
  background-color: var(--ivory);
  background-image:
    linear-gradient(180deg, transparent calc(33.3% - 1px), rgba(120, 95, 60, .10) 33.3%, rgba(255, 255, 255, .5) calc(33.3% + 1px), transparent calc(33.3% + 2px)),
    linear-gradient(180deg, transparent calc(66.6% - 1px), rgba(120, 95, 60, .10) 66.6%, rgba(255, 255, 255, .5) calc(66.6% + 1px), transparent calc(66.6% + 2px)),
    radial-gradient(ellipse at 85% 8%, rgba(214, 190, 140, .18), transparent 40%),
    radial-gradient(ellipse at 6% 96%, rgba(196, 170, 120, .16), transparent 35%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='5'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .24 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  border-radius: 3px 4px 2px 5px;
  box-shadow: 0 1px 1px rgba(60, 35, 15, .15), 0 10px 24px rgba(20, 10, 3, .35), 0 30px 60px rgba(20, 10, 3, .35);
  color: var(--sepia);
  font-size: calc(1.14rem * var(--ts)); line-height: 1.85;
}
.letter::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 40px rgba(180, 150, 100, .16); }
.margin-art { position: absolute; width: 54px; height: 108px; color: #7d8a5c; opacity: .55; pointer-events: none; }
.margin-art.top-right { right: 18px; top: 18px; transform: rotate(18deg); }
.margin-art.bottom-left { left: 16px; bottom: 14px; transform: rotate(200deg); }
.letter-head { text-align: center; margin-bottom: 1.6em; }
.letter-no { margin: 0; font-family: var(--display); font-size: .95rem; letter-spacing: .22em; text-transform: uppercase; color: #8a6a2e; }
.letter-title { margin: .2em auto .25em; max-width: 22ch; font-family: var(--display); font-weight: 600; font-size: clamp(1.7rem, 4.6vw, 2.35rem); line-height: 1.15; color: var(--plum); }
.letter-sub { margin: 0 auto; max-width: 40ch; font-family: var(--display); font-style: italic; font-size: 1.12rem; color: var(--sepia-soft); }
.letter-head::after { content: ''; display: block; width: 120px; height: 10px; margin: 1em auto 0;
  background: radial-gradient(circle, var(--gold) 2.5px, transparent 3px) center / 12px 10px repeat-x; opacity: .6; }
.draft-note { display: inline-block; margin: .8em auto 0; padding: 2px 10px; border: 1px dashed #b48c4a; border-radius: 6px; font-size: .8rem; color: #7a5a26; font-family: var(--serif); }

.pages { display: grid; }
.page { grid-area: 1 / 1; min-width: 0; }
.page[aria-hidden="true"] { visibility: hidden; pointer-events: none; }
.page p { margin: 0 0 1em; }
.block-salutation { font-family: var(--hand); font-size: 1.75em; line-height: 1.3; color: var(--sepia); }
.block-closing { font-family: var(--hand); font-size: 1.55em; line-height: 1.25; margin: .2em 0 .1em !important; }
.block-closing + .block-closing { margin-top: .15em !important; }
.block-signature { position: relative; font-family: var(--hand); font-size: 2.6em; line-height: 1.1; color: var(--plum); margin: .1em 0 .7em !important; padding-left: .4em; }
.block-ps { font-style: italic; font-size: .93em; color: var(--sepia-soft); border-top: 1px solid rgba(184, 149, 74, .35); padding-top: .8em; margin-top: 1.2em !important; }
.block-closing, .block-signature { text-align: right; padding-right: 8%; }

/* phrases: ink reveal + gentle highlight */
.phrase { transition: color .9s ease, text-shadow .9s ease, background-size .6s ease; border-radius: 3px;
  background: linear-gradient(180deg, transparent 62%, rgba(216, 191, 133, .55) 62%) no-repeat 0 0 / 0% 100%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.letter.narrating .phrase { color: rgba(62, 43, 31, .26); text-shadow: 0 0 .6px rgba(62, 43, 31, .2); }
.letter.narrating .phrase.read { color: var(--sepia); text-shadow: none; }
.letter.narrating .block-signature .phrase.read, .block-signature .phrase { color: var(--plum); }
.letter.narrating .block-signature .phrase:not(.read) { color: rgba(91, 42, 69, .25); }
.phrase.current { color: var(--sepia); background-size: 100% 100%; }
.w.now { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 4px; }

.letter-foot { text-align: center; margin-top: .4em; }
.page-no { font-family: var(--display); font-style: italic; color: #8a6a2e; letter-spacing: .1em; font-size: 1rem; }
.page-no::before, .page-no::after { content: ''; display: inline-block; width: 26px; height: 1px; background: var(--gold); opacity: .6; vertical-align: middle; margin: 0 10px; }

/* the unfolding sheet (used for the transition only) */
.fold-sheet { position: absolute; left: 0; top: 0; width: 100%; height: 100%; perspective: 1800px; transform-style: preserve-3d; pointer-events: none; z-index: 5; display: none; transform-origin: 0 0; }
.fold-sheet.active { display: block; }
.fold { position: absolute; left: 0; width: 100%; height: 33.34%; transform-style: preserve-3d; }
.fold.p1 { top: 0; transform-origin: 50% 100%; }
.fold.p2 { top: 33.33%; }
.fold.p3 { top: 66.66%; transform-origin: 50% 0; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--ivory); }
.face.front { background:
  repeating-linear-gradient(180deg, transparent 0 26px, rgba(62, 43, 31, .12) 26px 28px) 12% 30% / 76% 60% no-repeat,
  linear-gradient(180deg, #fcf8ee, #f6efde); }
.fold.p1 .face.front { background: linear-gradient(180deg, transparent 0 20%, rgba(91, 42, 69, .18) 20% 26%, transparent 26%) 30% 0 / 40% 100% no-repeat,
  repeating-linear-gradient(180deg, transparent 0 26px, rgba(62, 43, 31, .12) 26px 28px) 12% 70% / 76% 34% no-repeat, linear-gradient(180deg, #fcf8ee, #f6efde); }
.face.back { transform: rotateX(180deg); background: linear-gradient(180deg, #efe4cb, #e8dbbd); box-shadow: inset 0 0 30px rgba(120, 90, 50, .15); }
.fold.p2 .face.front { box-shadow: 0 18px 40px rgba(20, 10, 3, .35); }

.ink-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 3; }
.ink-layer svg { position: absolute; overflow: visible; }
.ink-pen { transform-origin: 50% 100%; }

/* keepsake tab peeking from the bottom of the letter */
.keepsake-tab { position: absolute; left: 50%; bottom: -46px; transform: translateX(-50%); z-index: 4; border: 0; background: none; cursor: pointer; padding: 0 26px; min-width: 240px; height: 70px; white-space: nowrap; }
.keepsake-tab .tab-paper { position: absolute; inset: 0; background: linear-gradient(180deg, #f3e7cd, #eadbb9); border-radius: 3px; transform: rotate(-2deg);
  box-shadow: 0 8px 18px rgba(20, 10, 3, .35); clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
.keepsake-tab .tab-paper::after { content: ''; position: absolute; left: 0; right: 0; top: 48%; height: 1px; background: rgba(120, 90, 50, .25); }
.keepsake-tab .tab-text { position: relative; font-family: var(--hand); font-size: 1.35rem; color: var(--plum); line-height: 70px; }
.keepsake-tab:hover .tab-paper { transform: rotate(-1deg) translateY(-3px); }
.keepsake-tab.appear { animation: tab-in 1.1s var(--ease-soft) both; }
@keyframes tab-in { from { transform: translate(-50%, -40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 64px; }
.page-btn { width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid rgba(244, 234, 212, .5); background: rgba(251, 246, 234, .1); color: var(--ivory); font-size: 1.8rem; line-height: 1; cursor: pointer; }
.page-btn:hover:not(:disabled) { background: rgba(251, 246, 234, .22); }
.page-btn:disabled { opacity: .3; }
.page-dots { display: flex; gap: 10px; list-style: none; padding: 0; margin: 0; }
.page-dots button { width: 44px; height: 44px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; padding: 0; }
.page-dots button::before { content: ''; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--gold-soft); transition: background .3s; }
.page-dots button[aria-current="page"]::before { background: var(--gold-soft); }
.back-row { text-align: center; margin: 8px 0 0; }
.back-row .text-btn { color: rgba(244, 234, 212, .8); }

/* companion */
.companion { position: sticky; top: 92px; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--ivory); }
.drosie-frame { position: relative; width: 230px; height: 230px; display: grid; place-items: center; }
.drosie-glow { position: absolute; inset: 6%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 190, .5), rgba(255, 236, 190, .12) 55%, transparent 72%); transition: opacity 1s, transform 1s; opacity: .55; }
.drosie-frame.moment .drosie-glow { opacity: 1; transform: scale(1.12); }
.drosie-img { position: relative; max-width: 88%; max-height: 88%; width: auto; height: auto; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .35));
  animation: hover-float 6s ease-in-out infinite; }
@keyframes hover-float { 0%, 100% { transform: translateY(0) rotate(-.6deg); } 50% { transform: translateY(-7px) rotate(.6deg); } }
.drosie-frame.speaking .drosie-img { animation: hover-float 6s ease-in-out infinite, sway 2.4s ease-in-out infinite; }
@keyframes sway { 0%, 100% { rotate: 0deg; } 50% { rotate: 1.4deg; } }
.drosie-missing { position: relative; width: 70%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; text-align: center; padding: 16px;
  background: rgba(251, 246, 234, .12); border: 1.5px dashed rgba(251, 246, 234, .4); font-family: var(--hand); font-size: 1.3rem; }
.sparkles i { position: absolute; width: 12px; height: 12px; opacity: 0; background: #fff3c4;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%); }
.sparkles i:nth-child(1) { left: 14%; top: 18%; } .sparkles i:nth-child(2) { right: 12%; top: 26%; } .sparkles i:nth-child(3) { left: 20%; bottom: 16%; } .sparkles i:nth-child(4) { right: 18%; bottom: 22%; }
.drosie-frame.moment .sparkles i { animation: twinkle 1.8s ease-in-out both; }
.drosie-frame.moment .sparkles i:nth-child(2) { animation-delay: .25s; } .drosie-frame.moment .sparkles i:nth-child(3) { animation-delay: .5s; } .drosie-frame.moment .sparkles i:nth-child(4) { animation-delay: .7s; }
@keyframes twinkle { 0% { opacity: 0; transform: scale(.3); } 40% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.4) rotate(40deg); } }
.voice-dots { position: absolute; right: 2%; top: 38%; display: flex; gap: 4px; align-items: center; opacity: 0; transition: opacity .4s; }
.voice-dots span { width: 5px; height: 14px; border-radius: 3px; background: var(--gold-soft); animation: voice 1.1s ease-in-out infinite; }
.voice-dots span:nth-child(2) { animation-delay: .18s; } .voice-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes voice { 0%, 100% { transform: scaleY(.45); opacity: .6; } 50% { transform: scaleY(1.1); opacity: 1; } }
.drosie-frame.speaking .voice-dots { opacity: 1; }
.companion-say { margin: 0; max-width: 260px; text-wrap: balance; font-family: var(--hand); font-size: 1.45rem; text-align: center; min-height: 2.2em; line-height: 1.1; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.ctl { min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid rgba(244, 234, 212, .45); background: rgba(251, 246, 234, .1); color: var(--ivory); cursor: pointer; font-size: 1rem; }
.ctl:hover:not(:disabled) { background: rgba(251, 246, 234, .2); }
#btn-silent { grid-column: 1 / -1; }
.ctl.primary { grid-column: 1 / -1; background: var(--ivory); color: var(--plum); border-color: var(--ivory); font-weight: 500; font-size: 1.08rem; }
.ctl.primary:hover:not(:disabled) { background: #fff; }
.ctl:disabled { opacity: .4; }
.ctl[aria-pressed="true"] { background: rgba(184, 149, 74, .35); border-color: var(--gold-soft); }
.companion .text-btn { color: rgba(244, 234, 212, .9); }
.text-size { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.ctl.tiny { min-height: 44px; min-width: 52px; padding: 4px 10px; }
.voice-note { margin: 0; font-size: .82rem; line-height: 1.45; color: rgba(244, 234, 212, .72); text-align: center; font-style: italic; }
.privacy-note { max-width: 760px; margin: 36px auto 0; font-size: .82rem; color: rgba(244, 234, 212, .65); text-align: center; }

@media (max-width: 900px) {
  .reader { grid-template-columns: minmax(0, 1fr); }
  .companion { position: static; order: -1; display: grid; grid-template-columns: 96px 1fr; grid-template-areas: "img say" "ctl ctl" "rev rev" "size note"; gap: 8px 12px; align-items: center; width: 100%; max-width: 720px; margin: 0 auto; }
  .drosie-frame { grid-area: img; width: 96px; height: 96px; }
  .companion-say { grid-area: say; text-align: left; font-size: 1.3rem; min-height: 0; }
  .controls { grid-area: ctl; grid-template-columns: repeat(3, 1fr); }
  .ctl.primary { grid-column: span 3; }
  #btn-reveal { grid-area: rev; justify-self: start; }
  .text-size { grid-area: size; } .voice-note { grid-area: note; text-align: right; }
  .voice-dots { right: -6px; top: 30%; }
  .voice-dots span { width: 4px; height: 10px; }
}
@media (max-width: 480px) {
  .controls { grid-template-columns: repeat(2, 1fr); } .ctl.primary { grid-column: span 2; }
  .companion { grid-template-areas: "img say" "ctl ctl" "rev rev" "size size" "note note"; }
  .voice-note { text-align: left; }
  .letter { font-size: calc(1.06rem * var(--ts)); line-height: 1.8; }
  .margin-art { width: 34px; height: 68px; }
  .block-closing, .block-signature { padding-right: 2%; }
}

/* =====================================================================
   KEEPSAKE
   ===================================================================== */
.keepsake-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; overflow-y: auto;
  background: rgba(24, 14, 7, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.keepsake-dialog { position: relative; display: flex; flex-direction: column; align-items: center; gap: 24px; width: min(560px, 100%); padding: 40px 0 10px; }
.close-x { position: absolute; right: 0; top: 0; width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid rgba(244, 234, 212, .5); background: rgba(251, 246, 234, .12); color: var(--ivory); font-size: 1.7rem; line-height: 1; cursor: pointer; }
.note { position: relative; width: min(400px, 86vw); aspect-ratio: 3 / 4; perspective: 1800px; }
.note-inside { position: absolute; inset: 0; padding: 12% 12% 10%; display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(170deg, #fffaf0, #f6eddb); border-radius: 3px; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); color: var(--sepia);
  font-size: calc(1rem * var(--ts)); }
.note-inside::before { content: ''; position: absolute; inset: 10px; border: 1px solid rgba(184, 149, 74, .45); border-radius: 2px; pointer-events: none; }
.note-sprig { position: absolute; right: 16px; bottom: 14px; width: 30px; height: 60px; color: #7d8a5c; opacity: .6; }
.note-heading { margin: 0 0 .6em; font-family: var(--hand); font-size: 2em; color: var(--plum); line-height: 1.1; }
.note-lines p { margin: 0 0 .35em; font-family: var(--hand); font-size: 1.55em; line-height: 1.25; }
.note-signoff { margin: .5em 0 0; font-family: var(--hand); font-size: 1.5em; }
.note-sign { margin: 0; font-family: var(--hand); font-size: 1.9em; color: var(--plum); }
.note-inside .reveal { opacity: 0; transform: translateY(6px); }
.note-inside .reveal.in { opacity: 1; transform: none; transition: opacity .9s ease, transform .9s var(--ease-soft); }
.note-cover { position: absolute; inset: 0; border: 0; padding: 0; background: none; cursor: pointer; transform-origin: 0 50%; transform-style: preserve-3d; border-radius: 3px; }
.cover-face { position: absolute; inset: 0; border-radius: 3px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.cover-face.front { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(160deg, #efe2c4, #e4d2ab); box-shadow: 0 20px 50px rgba(0, 0, 0, .45), inset -14px 0 18px -14px rgba(90, 60, 20, .35);
  font-family: var(--hand); font-size: 1.9rem; color: var(--plum); }
.cover-face.front svg { width: 64px; height: 64px; fill: var(--plum); opacity: .8; }
.cover-face.back { transform: rotateY(180deg); background: linear-gradient(200deg, #fbf4e4, #efe3c8); }
.note.open .note-cover { pointer-events: none; }
.keepsake-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.keepsake-actions .paper-btn { min-height: 48px; padding: 10px 18px; font-size: 1rem; }
.pdf-help { flex-basis: 100%; margin: 4px 0 0; text-align: center; color: rgba(244, 234, 212, .85); font-size: .9rem; }

/* notice */
.notice { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); z-index: 60; max-width: min(92vw, 560px); padding: 12px 18px;
  background: var(--ivory); color: var(--sepia); border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); border-left: 4px solid var(--gold);
  opacity: 0; pointer-events: none; transition: opacity .4s, transform .4s; font-size: .98rem; }
.notice.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; inset: 40% 10% auto; background: var(--ivory); padding: 20px; border-radius: 12px; text-align: center; z-index: 99; }

/* =====================================================================
   REDUCED MOTION
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .dust { display: none; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
.reduce-motion .dust { display: none; }

/* =====================================================================
   PRINT (US Letter)
   ===================================================================== */
.print-root { display: none; }
@page { size: letter; margin: 0.75in; }
@media print {
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; color: #2e2016; font-family: Georgia, "Lora", serif; }
  .print-letter .pl-head { text-align: center; margin-bottom: 0.3in; }
  .print-letter .pl-no { font-size: 9pt; letter-spacing: .22em; text-transform: uppercase; color: #7a5a26; margin: 0; }
  .print-letter h1 { font-family: "Cormorant Garamond", Georgia, serif; font-size: 24pt; color: #5b2a45; margin: 6pt 0 4pt; font-weight: 600; }
  .print-letter .pl-sub { font-style: italic; color: #6b5440; margin: 0; font-size: 12pt; }
  .print-letter p { font-size: 12.5pt; line-height: 1.7; margin: 0 0 9pt; orphans: 3; widows: 3; }
  .print-letter .block-salutation { font-size: 20pt; } .print-letter .block-closing { font-size: 17pt; text-align: right; margin: 2pt 0; }
  .print-letter .block-signature { font-size: 30pt; text-align: right; color: #5b2a45; margin: 4pt 0 14pt; }
  .print-letter .block-ps { font-style: italic; font-size: 11.5pt; border-top: 0.75pt solid #c9b083; padding-top: 8pt; }
  .print-letter .pl-ornament { text-align: center; color: #b8954a; letter-spacing: .5em; margin: 6pt 0 14pt; }
  .print-letter .pl-foot { margin-top: 0.4in; text-align: center; font-size: 9pt; color: #8a7a66; }
  .print-keepsake { display: grid; place-items: center; min-height: 9in; }
  .print-keepsake .pk-card { width: 5.5in; padding: 0.7in 0.75in; border: 1.5pt solid #b8954a; outline: 0.75pt solid #b8954a; outline-offset: -8pt; text-align: left; position: relative; }
  .print-keepsake .pk-head { font-family: "Caveat", "Segoe Print", cursive; font-size: 30pt; color: #5b2a45; margin: 0 0 10pt; }
  .print-keepsake .pk-line { font-family: "Caveat", "Segoe Print", cursive; font-size: 22pt; margin: 0 0 4pt; line-height: 1.25; }
  .print-keepsake .pk-sign { font-family: "Caveat", "Segoe Print", cursive; font-size: 26pt; color: #5b2a45; margin: 0; }
  .print-keepsake .pk-from { margin-top: 0.35in; font-size: 9pt; color: #8a7a66; text-align: center; font-family: Georgia, serif; }
  .print-root svg { color: #7d8a5c; }
}
