/* Sheets read in 2D over the candlelit desk: the letter, the attachments, the reply slip. */
:root {
  --paper: #efe4cc;
  --ink: #2b1d12;
  --ink-soft: #5d4630;
  --sepia: #7a4318;
  --gold: #b08a3e;
  --wax: #7e0f12;
  --f-hand: "Petit Formal Script", "Snell Roundhand", cursive;
  --f-type: "EB Garamond", Georgia, serif;
}

.veil { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; box-sizing: border-box; overflow-y: auto; background: radial-gradient(ellipse at 50% 45%, rgba(20,12,6,.55), rgba(3,2,1,.92) 75%); opacity: 0; transition: opacity .9s ease; }
.veil.on { opacity: 1; }
.veil.touchable { cursor: pointer; }

.sheet { position: relative; box-sizing: border-box; color: var(--ink); background-color: var(--paper); background-size: cover; box-shadow: 0 30px 80px rgba(0,0,0,.65), 0 2px 6px rgba(0,0,0,.4), inset 0 0 calc(var(--u, 8px) * 6) rgba(110,75,35,.18); transform: translateY(14px) scale(.985); transition: transform 1.1s cubic-bezier(.2,.7,.2,1); }
.veil.on .sheet { transform: none; }

/* ---------- the letter ---------- */
.sheet.letter { width: min(92vw, 64vh); aspect-ratio: 1 / 1.38; padding: calc(var(--u) * 8) calc(var(--u) * 8.5) calc(var(--u) * 6); overflow: hidden; font: calc(var(--u) * 2.95) / 1.46 var(--f-hand); touch-action: none; }
.letter p { margin: 0 0 .55em; }
.letter .place { text-align: right; }
.letter .subject { font-family: var(--f-type); font-style: italic; font-size: .82em; margin: 1.2em 0 1.1em; letter-spacing: .01em; }
.letter .salutation { margin-bottom: .7em; }
/* no first-line indent: with a swash script the indents read as random tabs */
.letter .body { margin-bottom: .7em; }
.letter .signature { text-align: right; font-size: 1.35em; margin: .5em 1.2em .6em 0; }
.letter .ps { font-size: .92em; }
.letter .w { white-space: nowrap; }
.letter .ch { opacity: 0; }
.letter .ch.on { opacity: 1; animation: dry 2.4s ease-out both; }
@keyframes dry { from { color: #0a0502; text-shadow: 0 0 .5px rgba(0,0,0,.6); } to { color: var(--ink); text-shadow: none; } }
.letter .emblem { position: absolute; left: calc(var(--u) * 6.5); top: calc(var(--u) * 4.2); width: calc(var(--u) * 12.5); opacity: .92; }
.letter .emblem svg { display: block; width: 100%; height: auto; }
.letter .secret { position: relative; height: calc(var(--u) * 13); margin-top: calc(var(--u) * .5); }
.letter .secret canvas { position: absolute; inset: 0; }
.letter .nib { position: absolute; left: 0; top: 0; width: calc(var(--u) * 3.8); height: calc(var(--u) * 11.4); margin: calc(var(--u) * -11.4) 0 0 calc(var(--u) * -1.9); transform-origin: 50% 100%; transition: transform 70ms linear, opacity .8s; pointer-events: none; filter: drop-shadow(2px 6px 4px rgba(40,20,5,.35)); }
.letter .nib svg { width: 100%; height: 100%; display: block; }
.letter .nib.away { opacity: 0; }
.letter .glow { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity .6s; --flick: 1; --lean: 0rad; --stretch: 1; }
.letter .glow.on { opacity: 1; }
.letter .glow i { position: absolute; left: 0; top: 0; border-radius: 50%; }
/* the light on the paper: wide, warm, breathing with the flame */
.letter .glow .halo { width: calc(var(--u) * 30); height: calc(var(--u) * 30); margin: calc(var(--u) * -15) 0 0 calc(var(--u) * -15); background: radial-gradient(circle, rgba(255,184,96,.5), rgba(255,150,60,.16) 40%, rgba(255,140,50,0) 70%); mix-blend-mode: overlay; transform: scale(var(--flick)); }
/* the flame itself: a tall soft core that leans away from the motion and stretches with speed */
.letter .glow .core { width: calc(var(--u) * 5); height: calc(var(--u) * 11); margin: calc(var(--u) * -9.5) 0 0 calc(var(--u) * -2.5); background: radial-gradient(ellipse 50% 50% at 50% 62%, rgba(255,246,214,.75), rgba(255,190,90,.42) 45%, rgba(255,140,40,0) 72%); mix-blend-mode: screen; transform-origin: 50% 86%; transform: rotate(var(--lean)) scale(calc(var(--flick) * .96), calc(var(--flick) * var(--stretch))); filter: blur(1.5px); }
.sheet.letter.candle { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='34' viewBox='0 0 22 34'%3E%3Cpath d='M11 1C6 9 4 13 4 19a7 7 0 0 0 14 0c0-6-2-10-7-18z' fill='%23ffb04a' stroke='%237a3b0c' stroke-width='1'/%3E%3Cpath d='M11 12c-2 4-3 6-3 8a3 3 0 0 0 6 0c0-2-1-4-3-8z' fill='%23fff3c4'/%3E%3C/svg%3E") 11 28, pointer; }

.sheet-action { font: italic 400 clamp(17px, 1.5vw, 21px) var(--f-type); letter-spacing: .02em; color: #f1e7d4; background: rgba(126,15,18,.85); border: 1px solid rgba(233,220,196,.35); border-radius: 999px; padding: .55em 1.5em; cursor: pointer; opacity: 0; transform: translateY(6px); transition: opacity .8s, transform .8s, background .3s; }
.sheet-action.on { opacity: 1; transform: none; }
.sheet-action:hover, .sheet-action:focus-visible { background: rgba(150,22,24,.95); outline: none; }
.sheet-action:focus-visible { box-shadow: 0 0 0 3px rgba(233,220,196,.5); }
.sheet-action:disabled { opacity: .45; cursor: default; background: rgba(126,15,18,.5); }

/* round icon controls (photos) and their position dots */
.icon { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(43,29,18,.35); background: rgba(255,255,255,.25); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold); }
.dots { display: flex; gap: 7px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- a card seen again from the reply slip ---------- */
.veil.review-veil { z-index: 17; gap: 14px; }
.card2d { margin: 0; position: relative; width: min(44vh, 78vw); aspect-ratio: 600 / 1030; box-sizing: border-box; background: #efe4cc; border: calc(min(44vh, 78vw) * .017) solid var(--gold); outline: 1px solid var(--ink); outline-offset: calc(min(44vh, 78vw) * -.03); box-shadow: 0 24px 60px rgba(0,0,0,.6); display: grid; grid-template-rows: 11% 1fr 13%; padding: 0 4.5%; grid-template-columns: 100%; transform: translateY(10px) scale(.98); transition: transform 1s cubic-bezier(.2,.7,.2,1); }
.veil.on .card2d { transform: none; }
.card2d .num, .card2d .arc { align-self: center; justify-self: center; color: var(--ink); font: 500 calc(min(44vh, 78vw) * .085) / 1 var(--f-type); }
.card2d .arc { font: italic calc(min(44vh, 78vw) * .075) / 1 var(--f-type); }
.card2d .window { justify-self: stretch; width: 100%; min-width: 0; overflow: hidden; border: 1px solid var(--ink); background: #2a1d12; }
.card2d .window img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .5s ease; }
.card2d .window img.in { opacity: 1; }
.reading.static { position: static; padding: 0; background: none; transform: none; }

/* ---------- the reply slip ---------- */
.sheet.reply { width: min(94vw, 780px); padding: clamp(20px, 3.4vw, 44px); font: clamp(15px, 1.25vw, 18px) / 1.5 var(--f-type); border-top: 2px dashed rgba(43,29,18,.4); }
.reply h2 { font: italic 400 clamp(28px, 3vw, 40px) / 1.1 var(--f-type); margin: 0 0 .3em; text-align: center; }
.reply .lead { text-align: center; font-family: var(--f-hand); font-size: 1.15em; margin: 0 0 1.2em; }
.reply h3 { font-variant: small-caps; letter-spacing: .12em; font-weight: 500; font-size: .95em; margin: 1em 0 .5em; color: var(--ink-soft); }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choices.venues { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.venue { display: grid; gap: 4px; justify-items: center; }
.choices [role="radio"] { font: inherit; color: var(--ink); background: rgba(255,255,255,.28); border: 1px solid rgba(43,29,18,.3); border-radius: 10px; padding: .55em 1em; cursor: pointer; transition: background .2s, border-color .2s, box-shadow .2s; }
.venues [role="radio"] { width: 100%; display: grid; justify-items: center; gap: 2px; padding: .8em .6em; }
.venues .num { color: var(--gold); font-weight: 500; }
.venues .arc { font-style: italic; color: var(--ink-soft); font-size: .9em; }
.venues .name { font-size: 1.12em; }
.choices [role="radio"]:hover { background: rgba(255,255,255,.5); }
.choices [role="radio"][aria-checked="true"] { border-color: var(--wax); background: rgba(126,15,18,.08); box-shadow: inset 0 0 0 1px var(--wax); }
.choices [role="radio"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.link { font: italic .88em var(--f-type); color: var(--ink-soft); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px; }
#r-other { margin-top: 10px; font: inherit; color: var(--ink); background: rgba(255,255,255,.45); border: 1px solid rgba(43,29,18,.35); border-radius: 8px; padding: .5em .8em; width: min(100%, 320px); }
#r-other:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.reply .message { font: 1.05em / 1.5 var(--f-hand); white-space: pre-wrap; margin: 1.2em 0 0; min-height: 4.5em; padding: .8em 1em; border-left: 2px solid rgba(126,15,18,.35); user-select: text; }
.reply .send { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 1em; }
.reply .send .sheet-action { background: var(--wax); }
.reply .state { margin: 0; color: var(--ink-soft); font-style: italic; }
.reply .state.ok { color: #2f5a2a; }
.reply .state.err { color: var(--wax); }

.sheet .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 720px) {
  .sheet.letter { width: 94vw; aspect-ratio: auto; min-height: 130vw; font-size: max(14px, calc(var(--u) * 3.6)); padding: 10vw 7vw 8vw; }
  .choices.venues { grid-template-columns: 1fr; }
  .veil { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .veil, .sheet, .sheet-action, .card2d, .card2d .window img, .letter .nib { transition: none; }
  .letter .ch.on { animation: none; }
}

/* cues sit in the dark margin under the letter, never on the paper */
body:has(.letter-veil) #sub { bottom: 1.2vh; }
/* once the drawn flame is lit it is the pointer: no second flame on top */
.sheet.letter.candle.lit { cursor: none; }

/* ---------- a card's reading: a few lines of ink under the living card ---------- */
.reading { position: fixed; left: 16px; right: 16px; bottom: 6vh; z-index: 12; display: grid; padding: 18px 0 6px; background: radial-gradient(ellipse 46% 60% at 50% 55%, rgba(6,3,1,.72), rgba(6,3,1,0) 100%); justify-items: center; gap: 10px; text-align: center; color: #efe3cc; text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 18px rgba(0,0,0,.6); opacity: 0; transform: translateY(6px); transition: opacity 1.2s ease, transform 1.2s ease; pointer-events: none; }
.reading.on { opacity: 1; transform: none; }
.reading .lines { max-width: 44em; display: grid; gap: .15em; }
.reading p { margin: 0; font: italic clamp(15px, 1.25vw, 19px) / 1.4 var(--f-type); }
.reading p.name { font: clamp(20px, 1.9vw, 28px) / 1.2 var(--f-hand); color: #f5e6c4; margin-bottom: .15em; }
.reading .photonav { display: flex; align-items: center; gap: 14px; pointer-events: auto; }
.reading .icon { color: #efe3cc; background: rgba(20,12,6,.35); border-color: rgba(239,227,204,.35); }
.reading .icon:hover, .reading .icon:focus-visible { background: rgba(60,36,18,.6); }
.reading .dots i { background: rgba(239,227,204,.3); }
.reading .dots i.on { background: #e0a060; }
/* the cue goes to the very bottom while a reading is showing */
body:has(.reading) #sub { bottom: 1.2vh; }
@media (max-width: 720px) { .reading { bottom: 7vh; } }
