:root {
  --paper: #f3e9d2;
  --paper-2: #ead9b6;
  --ink: #2b2018;
  --ink-soft: #5b4a3a;
  --verm: #c0412b;
  --teal: #1e4c58;
  --ochre: #b98a2f;
  --line: rgba(43, 32, 24, .28);
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --display: "Ruslan Display", "Cormorant Garamond", Georgia, serif;
  --hebrew: "Frank Ruhl Libre", "Times New Roman", serif;
  --hand: "Caveat", "Bradley Hand", cursive;
  --ease: cubic-bezier(.22, .8, .2, 1);
  --bar-h: 58px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(900px 700px at 90% 90%, rgba(185,138,47,.12), transparent 60%),
    var(--paper);
  color: var(--ink);
  font: 400 clamp(19px, 1.25vw, 22px)/1.5 var(--serif);
  overflow-x: hidden;
}
img, video { display: block; max-width: 100%; }
a { color: var(--verm); }
.ru { font-family: var(--serif); }
.he { font-family: "Frank Ruhl Libre", "Noto Serif Hebrew", "Arial Hebrew", serif; font-style: normal; font-weight: 500; font-size: .92em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
i { font-style: italic; }

/* ---------- loading gate ---------- */
body.is-loading .titlebox > *:not(.tb-line) { opacity: 0; }
body.is-loading .tb-line { transform: scale(0); }

/* =========================================================
   STAGE: fixed plates that crossfade by chapter
   ========================================================= */
.stage {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0; transition: opacity .9s var(--ease);
}
body[data-active]:not([data-active="0"]):not([data-active="11"]) .stage { opacity: 1; }

.plate {
  --pw: min(64vw, calc((88vh - var(--bar-h)) * (var(--ar))));
  position: absolute; margin: 0;
  width: var(--pw); aspect-ratio: var(--ar);
  right: 4vw; top: calc(50% - var(--bar-h) / 2);
  transform: translate3d(var(--px, 0), calc(-50% + var(--py, 0px)), 0) scale(.985);
  opacity: 0; transition: opacity 1s var(--ease), transform 1.2s var(--ease);
  container-type: inline-size;
  box-shadow: 0 30px 60px -30px rgba(43,32,24,.45), 0 2px 0 rgba(43,32,24,.1);
}
.plate.is-on { opacity: 1; transform: translate3d(var(--px, 0), calc(-50% + var(--py, 0px)), 0) scale(1); }
.plate { overflow: hidden; }
/* the picture and its captions share one wrapper, so the slow zoom moves them together */
.art { position: absolute; inset: 0; transform-origin: 55% 45%; }
.art img, .art picture { display: block; width: 100%; height: 100%; object-fit: cover; }
.plate.is-on .art { animation: kenburns 18s ease-in-out infinite alternate; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.035) translate(-.6%, -.4%); } }

/* Anna's portrait (wide screens only; on phones the opening already shows her) */
.plate--anna, .plate--tall { --ar: 670/1200; --pw: min(34vw, calc((88vh - var(--bar-h)) * (var(--ar)))); right: 18vw; }
/* a looping video laid over its still; it fades in once it is actually playing */
.art-loop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .8s; }
.art-loop.is-playing { opacity: 1; }

/* ---------- overlays measured on each image ---------- */
.ov { position: absolute; left: var(--l); top: var(--t); width: var(--w); height: var(--h, auto); }
.cart {
  display: grid; place-items: center; align-content: center; text-align: center;
  font: 600 2.1cqw/1.1 var(--serif); color: var(--ink);
  letter-spacing: .01em; padding: 0 1.2cqw; white-space: nowrap;
}
.cart--date { font-size: 3.1cqw; font-style: italic; }
.cart--top { font-size: 4.6cqw; }
.cart .short { display: none; }
.pb-only { display: none; }
.cart--two { font-size: 2.55cqw; line-height: 1.16; }
.cart--banner .b-name { font: 400 9.5cqw/1 var(--display); }
.cart--banner .b-title { font: italic 600 5.2cqw/1.15 var(--serif); }
.typo { text-decoration: none; position: relative; color: var(--verm); }
.typo::after {
  content: ""; position: absolute; left: -2%; right: -2%; bottom: -.12em; height: .12em;
  background: var(--verm); border-radius: 2px; transform: scaleX(0); transform-origin: left;
  transition: transform .8s .6s var(--ease);
}
.plate.is-on .typo::after { transform: scaleX(1); }

/* envelope address block, tilted with the envelope */
.addr { transform: rotate(7.4deg); transform-origin: 0 0; font-size: 2.15cqw; line-height: 1; }
.addr .line {
  margin: 0; height: 3.25cqw; display: flex; align-items: flex-end; white-space: nowrap;
  font-family: var(--hand); font-size: 2.45cqw; color: #2a3b55;
}

.stampbox { transform: rotate(var(--r)); }
.stampbox img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 4%;
  mix-blend-mode: multiply; opacity: 0; transform: scale(1.8) rotate(-12deg);
  transition: opacity .35s, transform .45s cubic-bezier(.3,1.6,.5,1);
}
.stampbox.is-on img { opacity: .92; transform: scale(1) rotate(-6deg); }

.scrollnote span {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%) rotate(2deg);
  font: italic 600 1.18cqw/1 var(--serif); color: #3b2a1c; white-space: nowrap;
  opacity: 0; transition: opacity 1.2s .5s;
}
.plate.is-on .scrollnote span { opacity: .92; }



/* =========================================================
   OPENING
   ========================================================= */
.hero { position: relative; min-height: 100vh; min-height: 100svh; display: grid; z-index: 3; }
.hero-art {
  position: absolute; inset: 0; display: grid; place-items: center end;
  padding: 0 4vw;
}
.hero-plate {
  position: relative; width: min(66vw, calc(86vh * 1.791)); aspect-ratio: 1920/1072; overflow: hidden;
  container-type: inline-size; box-shadow: 0 40px 80px -40px rgba(43,32,24,.55);
}
.hero-plate .art { animation: kenburns 22s ease-in-out infinite alternate; }
.hero-plate .cart { font-size: 2.2cqw; font-style: italic; }
.hero-tall { display: none; }

.titlebox {
  position: relative; z-index: 2; align-self: center;
  margin-left: 6vw; width: min(420px, 34vw);
  padding: 28px 30px 30px;
  background: rgba(243,233,210,.86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tb-line { position: absolute; background: var(--ink); transition: transform 1.2s var(--ease); }
.tb-t, .tb-b { left: 0; right: 0; height: 1px; transform-origin: left; }
.tb-t { top: 0; } .tb-b { bottom: 0; transform-origin: right; }
.tb-l, .tb-r { top: 0; bottom: 0; width: 1px; transform-origin: top; }
.tb-l { left: 0; transform-origin: bottom; } .tb-r { right: 0; }
.titlebox > *:not(.tb-line) { transition: opacity 1s .9s var(--ease); }

.wordmark {
  margin: 0; font: 400 clamp(38px, 3.5vw, 56px)/1 var(--display);
  letter-spacing: -.01em; color: var(--ink); white-space: nowrap;
}
.tb-sub { margin: 16px 0 18px; font-size: 1.05em; line-height: 1.3; font-style: italic; color: var(--ink-soft); }
.toc { list-style: none; margin: 0 0 22px; padding: 0; columns: 1; }
.toc li { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); }
.toc li:last-child { border-bottom: 1px solid var(--line); }
.toc a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 3px 0; font-size: .98em; }
.toc a:hover { color: var(--verm); }
.toc i { font-style: normal; color: var(--ink-soft); font-size: .95em; }

/* the wax seal: tap it and it cracks, then the story begins */
.seal-wrap { display: grid; justify-items: center; margin-top: 4px; }
.seal {
  --size: 124px;
  position: relative; width: var(--size); height: var(--size); padding: 0; border: 0; background: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 7px 8px rgba(70,22,10,.38));
  transition: transform .35s var(--ease);
}
.seal:hover { transform: translateY(-2px) rotate(-3deg); }
.seal:focus-visible { outline: 2px solid var(--ink); outline-offset: 6px; border-radius: 50%; }
.seal-half { position: absolute; inset: 0; }
.seal-half--l { clip-path: polygon(0 0, 52% 0, 47% 17%, 55% 33%, 46% 51%, 54% 68%, 47% 85%, 51% 100%, 0 100%); }
.seal-half--r { clip-path: polygon(52% 0, 100% 0, 100% 100%, 51% 100%, 47% 85%, 54% 68%, 46% 51%, 55% 33%, 47% 17%); }
.wax {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 47% 53% 51% 49% / 52% 47% 53% 48%;
  background: radial-gradient(circle at 33% 28%, #ec7558 0, #c93c27 34%, #a52b1a 64%, #741b0f 100%);
  box-shadow: inset 0 -7px 12px rgba(40,6,0,.35), inset 0 6px 10px rgba(255,190,160,.28);
}
.wax::before { /* the pressed ring */
  content: ""; position: absolute; inset: 12%; border-radius: 50%;
  background: radial-gradient(circle at 42% 36%, #d4492f, #ad3020 72%);
  box-shadow: inset 0 3px 4px rgba(40,6,0,.45), inset 0 -2px 3px rgba(255,180,150,.3), 0 1px 0 rgba(255,190,160,.35);
}
.wax::after { /* a slow sheen across the wax */
  content: ""; position: absolute; inset: -30%;
  background: linear-gradient(115deg, transparent 40%, rgba(255,235,220,.36) 50%, transparent 60%);
  transform: translateX(-70%); animation: sheen 5.5s ease-in-out infinite;
}
@keyframes sheen { 0%, 62% { transform: translateX(-70%); } 84%, 100% { transform: translateX(70%); } }
.seal .mark { position: absolute; left: 14%; top: 14%; width: 72%; height: 72%; }
.crumb {
  position: absolute; left: 50%; top: 50%; width: 7px; height: 6px; margin: -3px;
  border-radius: 40% 60% 50% 50%; background: #a52b1a; opacity: 0;
}
.seal.is-broken { pointer-events: none; }
.seal.is-broken .seal-half--l { animation: fall-l .85s cubic-bezier(.4,.05,.6,1) forwards; }
.seal.is-broken .seal-half--r { animation: fall-r .85s cubic-bezier(.4,.05,.6,1) forwards; }
.seal.is-broken .crumb { animation: crumb .7s cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes fall-l { 0% { transform: none; opacity: 1; } 14% { transform: translate(-5%, 1%) rotate(-5deg); opacity: 1; } 100% { transform: translate(-40%, 85%) rotate(-42deg); opacity: 0; } }
@keyframes fall-r { 0% { transform: none; opacity: 1; } 14% { transform: translate(5%, 0) rotate(6deg); opacity: 1; } 100% { transform: translate(44%, 92%) rotate(34deg); opacity: 0; } }
@keyframes crumb { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(160deg); } }
.seal.is-resealing { animation: reseal .6s var(--ease) both; }
@keyframes reseal { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }
.seal-hint { margin: 14px 0 0; font: italic 600 17px/1 var(--serif); color: var(--ink); opacity: 0; transition: opacity 1s; }
.seal-hint.is-on { opacity: 1; }
.seal-hint::before { content: "↑"; display: inline-block; margin-right: 6px; font-style: normal; color: var(--verm); animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-4px); } }
/* a soft ring pulses out from the seal until it is pressed */
.seal::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(192,65,43,.55); opacity: 0;
}
.seal.is-inviting::after { animation: halo 2.2s ease-out infinite; }
.seal.is-broken::after { display: none; }
@keyframes halo { 0% { transform: scale(.94); opacity: .8; } 100% { transform: scale(1.4); opacity: 0; } }

/* =========================================================
   CHAPTERS: cards scroll over the fixed stage
   ========================================================= */
main { position: relative; z-index: 2; }
.ch { position: relative; min-height: 150vh; padding: 30vh 0 20vh; }
.ch--steps { min-height: auto; }
.ch--steps .card { margin-bottom: 55vh; }
.ch--steps .card:last-child { margin-bottom: 30vh; }

.card {
  position: relative; width: min(440px, 28vw); margin-left: 7.5vw;
  padding: 26px 28px;
  background: rgba(243,233,210,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px -28px rgba(43,32,24,.5);
}
.card p { margin: 0 0 .8em; }
.card b { font-weight: 600; color: #1d140e; }
.card p:last-child { margin-bottom: 0; }
.num { font-size: .82em; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.num i { font-style: normal; letter-spacing: 0; text-transform: none; color: var(--verm); font-size: 1.15em; }
.card h2 {
  margin: .1em 0 .45em; font: 400 clamp(34px, 2.85vw, 54px)/1 var(--display);
  color: var(--ink); letter-spacing: -.01em; text-wrap: balance;
}
.note { font-size: .9em; color: var(--ink-soft); font-style: italic; border-left: 2px solid var(--verm); padding-left: 12px; }
.note .ru { font-style: normal; }
.big { font: 600 1.35em/1.25 var(--serif); }
.hl { color: var(--verm); }
.nw { white-space: nowrap; }


/* =========================================================
   RAIL
   ========================================================= */
.rail {
  position: fixed; left: 1.4vw; top: 50%; z-index: 5; transform: translateY(-50%);
  opacity: 0; transition: opacity .6s;
}
body[data-active]:not([data-active="0"]) .rail { opacity: 1; }
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail a {
  display: flex; align-items: center; gap: 10px; padding: 3px 0;
  color: var(--ink-soft); text-decoration: none; font-size: 17px;
}
.rail i { font-style: normal; width: 1.6em; text-align: center; }
.rail span {
  opacity: 0; transform: translateX(-6px); white-space: nowrap; font-size: 15px;
  transition: opacity .3s, transform .3s; background: var(--paper); padding: 0 6px;
}
.rail a:hover span, .rail a:focus-visible span { opacity: 1; transform: none; }
.rail a.is-on { color: var(--verm); }
.rail a.is-on i { font-weight: 600; transform: scale(1.25); }

/* =========================================================
   THE ROUTE: a bar along the bottom that follows her journey
   ========================================================= */
.route {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 22px env(safe-area-inset-bottom, 0px);
  display: flex; align-items: center; gap: 22px;
  background: linear-gradient(to bottom, #f7efdc, var(--paper));
  box-shadow: 0 -12px 26px -20px rgba(43,32,24,.5);
  transform: translateY(110%); transition: transform .6s var(--ease);
}
.route::before { /* the folk-pattern edge, like the border of every picture */
  content: ""; position: absolute; left: 0; right: 0; top: -9px; height: 9px;
  background:
    linear-gradient(var(--ink), var(--ink)) top / 100% 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) bottom / 100% 1px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='9'%3E%3Cpath d='M6 1.5l3 3-3 3-3-3z' fill='%23c0412b'/%3E%3Cpath d='M18 2.5l2 2-2 2-2-2z' fill='%231e4c58'/%3E%3Ccircle cx='12' cy='4.5' r='.9' fill='%23b98a2f'/%3E%3Ccircle cx='0' cy='4.5' r='.9' fill='%23b98a2f'/%3E%3Ccircle cx='24' cy='4.5' r='.9' fill='%23b98a2f'/%3E%3C/svg%3E") center / 24px 9px repeat-x,
    var(--paper-2);
}
body.show-route .route { transform: none; }
.route-ch { margin: 0; display: flex; align-items: baseline; gap: 10px; width: 290px; flex: none; white-space: nowrap; overflow: hidden; }
.route-ch i { font: normal 600 21px/1 var(--serif); color: var(--verm); transition: opacity .25s; }
.route-ch span { font: 400 14px/1 var(--display); letter-spacing: .02em; color: var(--ink); transition: opacity .25s; overflow: hidden; text-overflow: ellipsis; }
.route-ch.is-swapping span, .route-ch.is-swapping i { opacity: 0; }
.route-track { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; }
.route-end { font: italic 600 14px/1 var(--serif); color: var(--ink-soft); white-space: nowrap; }
/* the line is drawn as a railway track: two rails and ties */
.route-line {
  position: relative; flex: 1; height: 8px; margin: 0 9px;
  background:
    linear-gradient(var(--ink), var(--ink)) top / 100% 1.3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) bottom / 100% 1.3px no-repeat,
    repeating-linear-gradient(90deg, rgba(43,32,24,.5) 0 1.3px, transparent 1.3px 8px);
}
.route-done {
  position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--at, 0) * 100%);
  background:
    linear-gradient(var(--verm), var(--verm)) top / 100% 1.3px no-repeat,
    linear-gradient(var(--verm), var(--verm)) bottom / 100% 1.3px no-repeat,
    repeating-linear-gradient(90deg, var(--verm) 0 1.3px, transparent 1.3px 8px), var(--paper);
  transition: width 1.2s var(--ease);
}
.stop {
  position: absolute; left: calc(var(--p) * 100%); top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  padding: 0; border: 0; background: none; cursor: pointer;
}
.stop::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px;
  border-radius: 50%; background: var(--paper); border: 1.6px solid var(--ink); box-sizing: border-box;
  transition: background .4s, border-color .4s;
}
.stop.is-past::before { background: var(--verm); border-color: var(--verm); }
.stop::after { /* the stop's name, on hover */
  content: attr(data-name); position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 4px);
  padding: 3px 8px; border-radius: 3px; background: var(--ink); color: var(--paper);
  font: 600 13px/1.2 var(--serif); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.stop:hover::after, .stop:focus-visible::after { opacity: 1; transform: translate(-50%, -2px); }
.route-me {
  position: absolute; left: calc(var(--at, 0) * 100%); top: 50%; width: 14px; height: 14px; margin: -7px;
  border-radius: 50%; background: var(--verm); pointer-events: none;
  box-shadow: 0 0 0 3px var(--paper), 0 0 10px 3px rgba(192,65,43,.55);
  transition: left 1.2s var(--ease);
}
.route-me::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--verm);
  animation: ping 1.8s infinite;
}
@keyframes ping { from { transform: scale(.5); opacity: 1; } to { transform: scale(2); opacity: 0; } }
.route-env, .route-map {
  flex: none; display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.35);
  font: 600 15px/1 var(--serif); color: var(--ink); cursor: pointer; white-space: nowrap;
  transition: background .25s, border-color .25s;
}
.route-env:hover, .route-map:hover { background: #fff8e8; border-color: var(--ink); }
.route-env svg { width: 26px; height: 18px; }
.route-music {
  flex: none; display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.35);
  font: 600 15px/1 var(--serif); color: var(--ink); cursor: pointer; white-space: nowrap;
  transition: background .25s, border-color .25s;
}
.route-music:hover { background: #fff8e8; border-color: var(--ink); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; width: 16px; height: 14px; }
.eq i { width: 3px; height: 4px; border-radius: 1px; background: var(--ink-soft); }
.eq i:nth-child(1) { height: 7px; } .eq i:nth-child(2) { height: 12px; } .eq i:nth-child(3) { height: 5px; }
.route-music[aria-pressed="true"] .eq i { background: var(--verm); animation: eq 1s ease-in-out infinite alternate; }
.route-music[aria-pressed="true"] .eq i:nth-child(2) { animation-duration: .7s; }
.route-music[aria-pressed="true"] .eq i:nth-child(3) { animation-duration: 1.3s; }
@keyframes eq { from { height: 3px; } to { height: 14px; } }
.route-map svg { width: 20px; height: 20px; }
.env-title { font: 500 19px/1 var(--hand); color: #2a3b55; min-width: 3.3em; text-align: left; transition: opacity .25s; }
.env-title:empty { display: none; }
.env-title.is-swapping { opacity: 0; }
.pin { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); }

.mapdlg {
  border: 0; padding: 0; background: none; max-width: 96vw; max-height: 96vh;
}
.mapdlg::backdrop { background: rgba(30,22,16,.72); backdrop-filter: blur(3px); }
.mapwrap { position: relative; width: min(94vw, calc(90vh * 1200 / 679)); aspect-ratio: var(--ar); container-type: inline-size; }
.mapwrap img { width: 100%; height: 100%; }
.mapwrap .cart { font-size: 1.7cqw; }
/* on the open map, the pin for her current chapter lights up */
.pin.is-here {
  background: var(--ink);
  box-shadow: 0 0 0 .25cqw var(--paper), 0 0 0 .55cqw var(--verm), 0 0 2.2cqw .7cqw rgba(192,65,43,.55);
  animation: here 1.8s ease-in-out infinite;
}
@keyframes here { 50% { transform: translate(-50%, -50%) scale(1.12); } }
.pin {
  font: 600 1.3cqw/1 var(--serif); color: var(--paper); background: var(--verm);
  padding: .35cqw .6cqw; border-radius: 99px; box-shadow: 0 0 0 .25cqw var(--paper);
}
.mapdlg .close {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--paper); color: var(--ink); font-size: 18px; cursor: pointer;
}

/* =========================================================
   THE LETTER: it travels with her, and each office corrects it.
   main.js drives its position and every pencil stroke from scroll position,
   so it can never be left hanging over the text.
   ========================================================= */
.letter {
  position: fixed; z-index: 7; left: 0; top: 0;
  width: 260px; height: 163px;
  pointer-events: none; opacity: 0; transform-origin: 50% 50%;
  will-change: transform, opacity;
}
.letter.is-gliding { transition: transform .55s var(--ease), opacity .35s; }
.letter-paper {
  position: absolute; inset: 0; border-radius: 3px; overflow: hidden;
  background:
    radial-gradient(120% 90% at 18% 8%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(90% 80% at 92% 100%, rgba(185,138,47,.2), transparent 70%),
    #f1e3c3;
  border: 1px solid rgba(43,32,24,.22);
  box-shadow: 0 18px 34px -16px rgba(43,32,24,.6), 0 2px 0 rgba(43,32,24,.08);
  font-family: var(--hand); color: #2a3b55;
}
.l-boxes { position: absolute; left: 6%; top: 9%; display: flex; gap: 7px; }
.l-box {
  width: 35px; height: 41px; display: grid; place-items: center;
  border: 2px dotted rgba(43,32,24,.35); border-radius: 2px; background: rgba(255,255,255,.22);
}
.l-box img {
  width: 31px; height: 31px; border-radius: 50%;
  opacity: 0; transform: scale(1.9) rotate(-18deg);
  transition: opacity .2s, transform .35s cubic-bezier(.3,1.6,.5,1);
}
.l-box.is-on img { opacity: .95; transform: scale(1) rotate(-6deg); }
.l-seals { position: absolute; left: 5%; bottom: 9%; display: flex; }
.l-seals i {
  width: 19px; height: 19px; border-radius: 50%; margin-right: -5px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.25);
}
.l-seals i:nth-child(1) { background: radial-gradient(circle at 35% 35%, #e0644b, #b3372a 60%, #7d2416); }
.l-seals i:nth-child(2) { background: radial-gradient(circle at 35% 35%, #4b8a95, #1e5560 60%, #123840); }
.l-seals i:nth-child(3) { background: radial-gradient(circle at 35% 35%, #ecc56a, #c79a3a 60%, #8a6420); }
.l-line { position: absolute; left: 26%; margin: 0; font-size: 16px; line-height: 1; white-space: nowrap; }
.l-line--1 { top: 52%; } .l-line--2 { top: 65%; } .l-line--3 { top: 78%; }
.l-t { position: absolute; white-space: nowrap; line-height: 1; }
.l-t .w { display: inline-block; clip-path: inset(-40% calc(100% - var(--w, 0) * 100%) -40% -10%); }
.l-t .strike {
  position: absolute; left: -8%; right: -8%; top: 50%; height: 2px; border-radius: 2px;
  background: var(--verm); transform: rotate(-5deg) scaleX(var(--s, 0)); transform-origin: left center;
}
.l-t--tsarit { left: 63%; top: 52%; font-size: 16px; color: #2a3b55; }
.l-t--knyazhna { left: 59%; top: 38%; font-size: 15px; color: #6b6b6b; transform: rotate(-4deg); }
.l-t--tsaritsa { left: 66%; top: 24.5%; font-size: 17px; color: #1d1d2b; transform: rotate(-2deg); }
.l-t--khan {
  left: 72%; top: 8%; font: 400 15px/1 var(--display); letter-spacing: .08em; color: var(--verm);
  border: 2px solid var(--verm); border-radius: 3px; padding: 3px 6px 2px; mix-blend-mode: multiply;
  opacity: 0; transform: scale(1.9) rotate(-22deg);
  transition: opacity .2s, transform .35s cubic-bezier(.3,1.6,.5,1);
}
.l-t--khan .w { clip-path: none; }
.l-t--khan.is-on { opacity: .92; transform: scale(1) rotate(-9deg); }


/* =========================================================
   FINAL
   ========================================================= */
.final {
  position: relative; z-index: 3; min-height: 100vh; padding: 20vh 6vw 18vh;
  display: grid; justify-items: center; text-align: center;
  background: linear-gradient(to bottom, transparent, var(--paper) 14vh);
}
[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 1.2s var(--ease), transform 1.2s var(--ease); }
[data-reveal].is-in { opacity: 1; transform: none; }


.order { margin: 0 0 1.1em; font: italic 600 clamp(24px, 2.4vw, 34px)/1.3 var(--serif); color: var(--verm); }
.imagine { margin-top: 2vh; width: min(720px, 100%); display: grid; justify-items: center; }
.imagine-btn {
  font: 600 20px var(--serif); background: none; color: var(--ink); cursor: pointer;
  border: 1px solid var(--ink); border-radius: 999px; padding: 10px 26px;
  transition: background .3s, color .3s;
}
.imagine-btn:hover { background: var(--ink); color: var(--paper); }
.imagine-frame { width: 100%; aspect-ratio: 16/9; margin-top: 18px; }
.imagine-frame iframe { width: 100%; height: 100%; border: 0; }

/* the title ladder: three guesses struck, the name left standing */
.ladder { margin-top: 12vh; display: grid; gap: 10px; justify-items: center; }
.ladder.is-in { opacity: 1; transform: none; }
.rung {
  margin: 0; display: flex; align-items: center; gap: 14px;
  font: 600 clamp(22px, 2.4vw, 34px)/1 var(--serif); color: var(--ink-soft);
  opacity: 0; transform: translateY(12px);
  transition: opacity .8s calc(var(--i) * .5s) var(--ease), transform .8s calc(var(--i) * .5s) var(--ease);
}
.rung .ru { font-family: var(--display); font-weight: 400; }
.rung img { width: 1.6em; height: 1.6em; border-radius: 50%; }
.rung s { text-decoration: none; position: relative; }
.rung s::after {
  content: ""; position: absolute; left: -3%; right: -3%; top: 52%; height: 3px; background: var(--verm);
  transform: scaleX(0); transform-origin: left;
  transition: transform .6s calc(var(--i) * .5s + 2.2s) var(--ease);
}
.ladder.is-in .rung { opacity: 1; transform: none; }
.ladder.is-in .rung s::after { transform: scaleX(1); }
.rung--khan { color: var(--ink); font-size: clamp(30px, 3.2vw, 46px); }
.rung--khan b { font-weight: 600; transition: text-shadow 1.6s 4.4s, color 1.6s 4.4s; }
.ladder.is-in .rung--khan b { color: #8a5a12; text-shadow: 0 0 22px rgba(214,165,58,.75), 0 0 2px rgba(214,165,58,.9); }
.rung--back s::after { transition: transform .6s 2.2s var(--ease), opacity .8s 5.8s; }
.ladder.is-in .rung--back s::after { opacity: 0; }
.rung--back .ru { position: relative; transition: color 1.2s 6s, text-shadow 1.2s 6s; }
.ladder.is-in .rung--back .ru { color: #8a5a12; text-shadow: 0 0 22px rgba(214,165,58,.75), 0 0 2px rgba(214,165,58,.9); }
.reigns {
  position: absolute; left: 50%; bottom: 88%; transform: translateX(-50%) rotate(-4deg);
  font: 500 .92em/1 var(--hand); color: var(--verm); white-space: nowrap; text-shadow: none;
  padding: 0 .15em; clip-path: inset(-30% 100% -30% -10%);
  transition: clip-path 1.2s 6.3s cubic-bezier(.45,.1,.3,1);
}
.ladder.is-in .reigns { clip-path: inset(-30% -10% -30% -10%); }

.sig { margin: 8vh 0 0; display: grid; justify-items: center; }
.sig-face { width: min(230px, 50vw); height: auto; }
.sig-path {
  fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: var(--len, 2000); stroke-dashoffset: var(--len, 2000);
  transition: stroke-dashoffset 4.5s .4s cubic-bezier(.45,.1,.3,1);
}
.sig.is-in .sig-path { stroke-dashoffset: 0; }
.sig-name {
  margin: -.2em 0 0; padding: .05em .25em .12em; font: 500 clamp(40px, 4.4vw, 64px)/1 var(--hand); color: var(--ink);
  clip-path: inset(0 100% 0 0); transition: clip-path 2.6s 4.4s cubic-bezier(.45,.1,.3,1);
}
.sig.is-in .sig-name { clip-path: inset(0 0 0 0); }
.credit { margin: 9vh 0 0; font: italic 400 14px/1.4 var(--serif); color: var(--ink-soft); }
.note-final { margin: 7vh 0 0; font: italic 600 clamp(26px, 2.6vw, 40px)/1.3 var(--serif); color: var(--ink); }

/* =========================================================
   II. THE NAME: one line of letter tiles that flip between alphabets
   ========================================================= */
.plate--name {
  width: min(62vw, 980px); aspect-ratio: auto; height: auto; overflow: visible;
  box-shadow: none; container-type: normal;
}
.namepanel {
  padding: clamp(40px, 9vh, 90px) clamp(16px, 3vw, 48px);
  background: rgba(234,217,182,.55); border: 1px solid var(--line);
  outline: 1px solid var(--line); outline-offset: 6px;
}
.board {
  position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: .4em .7em; font: 600 clamp(28px, 3.2vw, 58px)/1 var(--serif); color: var(--ink);
}
.word { display: flex; gap: .07em; }
.slot {
  position: relative; display: inline-flex; justify-content: center; align-items: center;
  box-sizing: content-box; height: 1.4em; padding: 0 .08em; border-radius: .07em; overflow: hidden;
  background: linear-gradient(to bottom, #f7efdd 0 49.6%, #efe3c7 50.4% 100%);
  border: 1px solid rgba(43,32,24,.22); box-shadow: 0 .07em .14em -.07em rgba(43,32,24,.5);
  perspective: 5em; transition: width .45s var(--ease);
}
.slot::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(43,32,24,.16); }
.glyph { display: inline-block; white-space: nowrap; letter-spacing: .02em; backface-visibility: hidden; }
.slot.k { background: linear-gradient(to bottom, #f8e4da 0 49.6%, #f1d7ca 50.4% 100%); border-color: rgba(192,65,43,.5); }
.slot.k .glyph { color: var(--verm); }
.slot.s { background: linear-gradient(to bottom, #e2ebe8 0 49.6%, #d4e1de 50.4% 100%); border-color: rgba(30,76,88,.5); }
.slot.s .glyph { color: var(--teal); }
.glyph.measure { position: absolute; visibility: hidden; left: 0; top: 0; pointer-events: none; }
.board.is-static { display: grid; justify-items: center; gap: .45em; }
.board.is-static p { margin: 0; letter-spacing: .05em; }
.board.is-static .k { color: var(--verm); } .board.is-static .s { color: var(--teal); }
.ch--name .card:last-child { margin-bottom: 110vh; }
.card--line .big { font-size: 1.7em; line-height: 1.2; margin: 0; }

/* phones read the story as a picture book: main.js puts a copy of each picture above its card */
.pb { display: none; }

/* =========================================================
   PHONES
   ========================================================= */
@media (max-width: 899px) {
  body { font-size: 18px; }
  .stage { display: none; }

  /* the picture book: picture, then its text, no empty stretches */
  .ch { min-height: 0; padding: 0; }
  .ch--steps .card, .ch--steps .card:last-child, .ch--name .card:last-child { margin-bottom: 0; }
  .card { width: auto; margin: 0 16px; padding: 20px; }
  .card + .card { margin-top: 14px; }
  .card h2 { font-size: clamp(36px, 10vw, 48px); }
  .pb { display: block; margin: 40px 0 16px; container-type: inline-size; }
  .pb .art { position: relative; inset: auto; animation: none; }
  .pb .art img, .pb .art picture { height: auto; }
  /* captions stay in the picture's own frame, sized up for a phone */
  .pb .ov { left: var(--ml, var(--l)); top: var(--mt, var(--t)); width: var(--mw, var(--w)); height: var(--mh, var(--h, auto)); }
  .pb .cart { font-size: 3.5cqw; padding: 0 1cqw; }
  .pb .cart--two { font-size: 3.05cqw; line-height: 1.12; }
  .pb .cart .long { display: none; }
  .pb .cart .short { display: inline; }
  .pb--arrival .cart { font-size: 4.9cqw; }
  .pb .typo::after { transform: scaleX(1); }
  .pb .addr .line { font-size: 2.9cqw; height: 3.6cqw; }
  .pb .scrollnote { display: none; }
  .pb .namepanel { margin: 0 12px; padding: 30px 10px; }
  .pb .board { font-size: clamp(22px, 6.6vw, 32px); gap: .35em .55em; }

  .hero-art { padding: 0; }
  .hero-plate { display: none; }
  .hero-tall { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
  .hero-loop { opacity: 0; transition: opacity .8s; }
  .hero-loop.is-playing { opacity: 1; }
  .titlebox {
    align-self: end; margin: 0 16px calc(24px + env(safe-area-inset-bottom, 0px)); width: auto;
    background: rgba(243,233,210,.9);
  }
  .toc { display: none; }
  .wordmark { font-size: clamp(44px, 13vw, 60px); }

  .rail { display: none; }

  :root { --bar-h: 54px; }
  .route { padding: 0 10px env(safe-area-inset-bottom, 0px) 14px; gap: 10px; }
  .route-ch { width: auto; min-width: 34px; }
  .route-ch span, .route-end, .route-map span, .route-music span:not(.eq), .env-title { display: none; }
  .route-env, .route-map, .route-music { height: 36px; padding: 0 9px; }
  .stop::after { display: none; }
  /* card text fades out just above the bar */
  body.show-route::after {
    content: ""; position: fixed; left: 0; right: 0; z-index: 4; pointer-events: none;
    bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px)); height: 40px;
    background: linear-gradient(to bottom, rgba(243,233,210,0), var(--paper));
  }
  .pb .pb-only { display: grid; }
  .seal { --size: 96px; }
  .mapdlg { width: 100vw; height: 100svh; max-width: 100vw; max-height: 100svh; margin: 0; }
  .mapdlg[open] { display: grid; align-content: center; }
  .mapscroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior: contain; scrollbar-width: none; }
  .mapscroll::-webkit-scrollbar { display: none; }
  .mapwrap { height: min(62svh, 540px); width: calc(min(62svh, 540px) * 1200 / 679); }
  .mapdlg .close { top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px; }
  .ladder { margin-top: 8vh; }
  /* the closing section follows straight on from chapter X */
  .final { padding-top: 56px; min-height: 0; }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; transition-delay: 0s !important; }
  .plate.is-on .art, .hero-plate .art { animation: none; }
}

