/*
 * site.css: the whole visual system for episode 02. One stylesheet, no build step.
 *
 * The page is an excavation: a dark soil field (CSS gradients + grain), a WebGL
 * city floating in it, and a reading column that sits to the right of the model on
 * wide screens and on top of a scrim on narrow ones. Colour carries meaning in
 * exactly one place, the four survival bands, which are an ordinal ramp: single
 * warm family, lightness rising with survival, so the order is readable in the
 * colour and not only in the label.
 *
 * Layer order (z): strata -1 → canvas 0 → vignette 1 → content 2 → rail/hud 5.
 * Nothing in the content layer depends on the canvas existing.
 *
 * Read alongside: index.html (structure), page.js (which classes it toggles).
 */

@import url('fonts.css');

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
ol, ul { padding: 0; list-style: none; }

:root {
  --void:    #0a0806;
  --soil-1:  #150f0a;
  --soil-2:  #201709;
  --ink:     #ece2cd;
  --dim:     #a2947c;
  --faint:   #6f6352;
  --rule:    rgba(236,226,205,0.13);

  --minium:  #c2402a;   /* cinnabar: the one hot accent */
  --ochre:   #c79a44;
  --verd:    #5f8d78;   /* bronze patina: the river, structural marks */

  --b-weeks:    #a3301c;
  --b-months:   #c06229;
  --b-years:    #c99a3f;
  --b-lifetime: #cfd8bd;

  --disp: 'Instrument Serif', 'Big Caslon', Georgia, serif;
  --caps: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Spectral', Georgia, 'Times New Roman', serif;
  --mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --pad:  clamp(1.15rem, 4vw, 5rem);
  --rail-w: 54px;
}

body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 300;
  font-size: clamp(1.02rem, 0.45vw + 0.94rem, 1.16rem);
  line-height: 1.72;
  overflow-x: hidden;
}

/* ---------- background layers ---------- */

/* Soil: warm at the top of the page, colder and deeper further down. The bands are
   deliberately uneven, like fill, and they do not line up with the centuries. */
.strata {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 18% 8%, rgba(199,154,68,0.16), transparent 62%),
    radial-gradient(90% 60% at 82% 92%, rgba(95,141,120,0.10), transparent 70%),
    linear-gradient(180deg, var(--soil-2) 0%, var(--soil-1) 34%, var(--void) 72%, #060504 100%);
}
/* Grain + vignette, over the canvas so the model sits in the same dirt as the page. */
.vign {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 100% at 50% 45%, transparent 38%, rgba(6,5,4,0.55) 88%, rgba(6,5,4,0.85) 100%);
  mix-blend-mode: multiply;
}
.vign::after {
  content: ''; position: absolute; inset: -200%;
  opacity: 0.14; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* The far edge of the ground plane meets the page gradient in a hard line. Fading
   the top of the canvas dissolves it, so the model sits in the soil rather than on
   a horizon. */
#city {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  opacity: 0; transition: opacity 1.4s ease 0.2s;
  -webkit-mask-image: linear-gradient(180deg, transparent 2%, #000 40%);
  mask-image: linear-gradient(180deg, transparent 2%, #000 40%);
}
#city.on { opacity: 1; }
/* Below the descent the model has said what it has to say, and the reading gets
   priority: it stays as atmosphere, at a fraction of the weight. */
#city.dim { opacity: 0.16; }

/* ---------- shared type ---------- */
.eyebrow {
  font-family: var(--caps); font-weight: 600;
  font-size: 0.66rem; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--dim);
}
.sec-title {
  font-family: var(--disp); font-weight: 400;
  font-size: clamp(1.9rem, 3.6vw, 3.2rem); line-height: 1.06;
  letter-spacing: -0.01em; margin-bottom: 1.6rem;
}
.col {
  position: relative; z-index: 2;
  max-width: 66ch; margin-inline: auto;
  padding-inline: var(--pad);
}
b, strong { font-weight: 600; color: #fff8ea; }
i, em { font-style: italic; }

/* ---------- gate ---------- */
.gate {
  position: relative; z-index: 2;
  min-height: 100svh; display: flex; flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 8vh, 7rem) var(--pad) 2.4rem;
}
.gate__inner { max-width: 1180px; margin-inline: auto; width: 100%; }
.gate__title {
  font-family: var(--disp); font-weight: 400;
  /* Height-aware: three lines of display type plus a lede has to fit a laptop
     viewport, so the vh term takes over on short screens. */
  font-size: clamp(3.2rem, min(11.8vw, 15.5vh), 10.5rem);
  line-height: 0.87; letter-spacing: -0.035em;
  margin: 1.3rem 0 1.5rem; text-wrap: balance;
}
.gate__title span { display: block; }
.gate__title .em {
  font-style: italic; color: var(--minium);
  text-shadow: 0 0 60px rgba(194,64,42,0.35);
}
.gate__lede {
  max-width: 46ch; font-size: 1.12em; color: var(--ink);
}
.gate__q {
  font-family: var(--disp); font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-style: italic; color: var(--ochre); margin-top: 1.1rem;
}
.gate__go {
  display: inline-flex; align-items: center; gap: 1rem;
  margin-top: 1.9rem; text-decoration: none;
  font-family: var(--mono); font-size: 0.74rem;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim);
  border: 1px solid var(--rule); border-radius: 2px;
  padding: 0.85rem 1.3rem 0.8rem;
  background: rgba(10,8,6,0.4); backdrop-filter: blur(3px);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.gate__go:hover { color: var(--ink); border-color: var(--minium); background: rgba(194,64,42,0.10); }
.gate__go svg { width: 13px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.gate__go:hover svg { animation: nudge 1.1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }
.gate__foot {
  max-width: 1180px; margin: auto auto 0; width: 100%;
  font-family: var(--mono); font-size: 0.76rem; color: var(--faint);
  border-top: 1px solid var(--rule); padding-top: 1rem;
}

/* staggered load-in, one orchestrated moment */
.reveal { animation: rise 1s cubic-bezier(.16,.8,.3,1) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(22px); filter: blur(6px); } }

/* ---------- terms ---------- */
.terms { position: relative; z-index: 2; padding: clamp(4rem, 12vh, 9rem) 0; }
.terms .col { background: rgba(8,6,5,0.72); backdrop-filter: blur(6px);
  border: 1px solid var(--rule); border-left: 2px solid var(--minium);
  padding: clamp(1.6rem, 4vw, 3rem); max-width: 62ch; }
.terms__list { counter-reset: t; margin-bottom: 1.8rem; }
.terms__list li {
  counter-increment: t; position: relative;
  padding: 0.75rem 0 0.75rem 3.2rem;
  border-top: 1px solid var(--rule);
}
.terms__list li::before {
  content: counter(t, upper-roman); position: absolute; left: 0; top: 0.9rem;
  font-family: var(--caps); font-size: 0.8rem; color: var(--minium); letter-spacing: 0.1em;
}
.terms__note {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.8; color: var(--dim);
  border-top: 1px solid var(--rule); padding-top: 1.4rem;
}
.key { margin-top: 2.6rem; max-width: 52ch; }
.key p:last-child { font-size: 0.95rem; color: var(--dim); margin-top: 0.6rem; }

/* ---------- the descent ---------- */
.descent { position: relative; z-index: 2; }

.cent {
  position: relative;
  min-height: 100svh; display: flex; align-items: center;
  padding: 9vh var(--pad);
}
/* Reading column pushed right on wide screens so the model owns the left half. */
.cent__body {
  margin-left: auto; margin-right: clamp(0px, 3.5vw, 84px);
  width: min(52ch, 46vw, 100%);
  font-size: 0.97em; line-height: 1.64;
  background: linear-gradient(180deg, rgba(8,6,5,0.86), rgba(8,6,5,0.74));
  backdrop-filter: blur(7px);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--band, var(--rule));
  padding: clamp(1.4rem, 3vw, 2.4rem);
  box-shadow: 0 40px 80px -40px #000;
}
.cent__head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 0.4rem; }
.cent__num {
  font-family: var(--caps); font-weight: 800; font-size: 2.4rem; line-height: 1;
  letter-spacing: 0.04em; color: var(--band);
}
.cent__yrs { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.12em; color: var(--dim); }
.cent__title {
  font-family: var(--disp); font-weight: 400; font-size: clamp(1.6rem, 2.6vw, 2.3rem);
  line-height: 1.08; margin: 0.6rem 0 1.1rem; text-wrap: balance;
}
.cent__body p { margin-bottom: 0.85rem; }
.cent__meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); margin: 1.1rem 0;
}
.cent__meta div { background: rgba(10,8,6,0.9); padding: 0.7rem 0.85rem; }
.cent__meta .k {
  display: block; font-family: var(--mono); font-size: 0.6rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.25rem;
}
.cent__meta .v { font-family: var(--mono); font-size: 0.95rem; color: var(--ink); }
.cent__meta .v.band { color: var(--band); }
.cent__pop {
  font-family: var(--mono); font-size: 0.68rem; line-height: 1.72;
  color: var(--dim); border-left: 2px solid var(--rule); padding-left: 0.9rem; margin-bottom: 1.1rem;
}
.cent__danger {
  font-size: 0.9rem; color: var(--dim);
  border-top: 1px solid var(--rule); padding-top: 0.95rem;
}
.cent__danger b {
  display: block; font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--minium); margin-bottom: 0.35rem;
}
.cent__ends {
  font-family: var(--disp); font-style: italic; font-size: 1.25rem;
  color: var(--band); margin-top: 1rem;
}

/* Ghost numeral, set in the soil behind the column. */
.cent__ghost {
  position: absolute; left: clamp(1rem, 5vw, 6rem); top: 50%; transform: translateY(-50%);
  font-family: var(--caps); font-weight: 800;
  font-size: clamp(7rem, 20vw, 20rem); line-height: 0.8;
  color: transparent; -webkit-text-stroke: 1px rgba(236,226,205,0.10);
  pointer-events: none; user-select: none;
  transition: -webkit-text-stroke-color 0.8s;
}
.cent.is-live .cent__ghost { -webkit-text-stroke-color: rgba(236,226,205,0.2); }

/* ---------- interrupts (full-bleed statements between centuries) ---------- */
.beat {
  position: relative; z-index: 2;
  min-height: 78svh; display: flex; flex-direction: column; justify-content: center;
  padding: 10vh var(--pad);
  text-align: center;
  border-block: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(6,5,4,0), rgba(6,5,4,0.93) 28%, rgba(6,5,4,0.93) 72%, rgba(6,5,4,0));
}
.beat__yr {
  font-family: var(--mono); font-size: clamp(2.6rem, 9vw, 6rem); font-weight: 700;
  letter-spacing: -0.02em; color: var(--minium); line-height: 1;
}
.beat__h {
  font-family: var(--disp); font-size: clamp(1.7rem, 4.4vw, 3.4rem); line-height: 1.05;
  margin: 1rem auto 1rem; max-width: 22ch; text-wrap: balance;
}
.beat p { max-width: 56ch; margin-inline: auto; color: var(--ink); }
.beat--quiet .beat__yr { color: var(--verd); }

/* ---------- image slots ---------- */
.plate {
  position: relative; z-index: 2; padding: 6vh var(--pad) 7vh;
  background: linear-gradient(180deg, rgba(6,5,4,0), rgba(6,5,4,0.9) 14%, rgba(6,5,4,0.92) 86%, rgba(6,5,4,0));
}
.plate figure { max-width: 1180px; margin-inline: auto; }
.plate__img {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  border: 1px solid var(--rule);
}
.plate figcaption {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.8; color: var(--dim);
  margin-top: 0.9rem; max-width: 68ch;
}


/* ---------- the doors ----------
 * One per regime, at the moment the regime begins. Full-bleed and full-height so
 * the scroll has to stop: everything else on this page is either the WebGL city
 * (wide, cold, abstract) or a column of type, and a door is the one thing that is
 * close, material and in reach. The image is the argument; the three words on top
 * of it are the label.
 */
.door {
  position: relative; z-index: 3;
  height: 100svh; min-height: 520px;
  display: grid; grid-template-areas: 'stack'; align-items: end;
  overflow: hidden;
  background: #06050400;
}
.door__img {
  grid-area: stack;
  width: 100%; height: 100%; object-fit: cover;
  /* The photographs are lit from one side and go black on the other, so the
     text sits in the dark half rather than needing a scrim across the whole
     frame. This only deepens what the picture already does. */
  mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
}
/* The scrim spans the whole frame; only the words are constrained. Putting the
   gradient on the text block itself drew a visible rectangle across the picture. */
.door::after {
  content: ''; grid-area: stack; pointer-events: none;
  background: linear-gradient(0deg, rgba(6,5,4,0.94) 6%, rgba(6,5,4,0.6) 34%, transparent 62%);
}
.door__text {
  grid-area: stack; position: relative; z-index: 1;
  padding: 0 var(--pad) clamp(3rem, 9vh, 7rem);
  max-width: 62ch;
}
.door__word {
  font-family: var(--caps); text-transform: uppercase;
  font-size: clamp(2.6rem, 9vw, 6.5rem); line-height: 0.9; letter-spacing: 0.02em;
  color: var(--ink); margin: 0 0 0.4rem;
}
.door__ask {
  font-family: var(--display); font-style: italic;
  font-size: clamp(1.2rem, 3vw, 2rem); color: var(--minium); margin: 0 0 1.1rem;
}
.door__cap {
  font-family: var(--mono); font-size: 0.74rem; line-height: 1.9;
  color: var(--dim); margin: 0; max-width: 56ch;
}

/* Instruments retreat while a door fills the screen. */
body.in-door .hud,
body.in-door #rail { opacity: 0; pointer-events: none; }
.hud, #rail { transition: opacity 320ms ease; }

@media (prefers-reduced-motion: reduce) {
  .door__img { mask-image: none; }
  .hud, #rail { transition: none; }
}

/* ---------- the finding ---------- */
.finding {
  position: relative; z-index: 2; padding: clamp(5rem, 14vh, 11rem) 0;
  background: linear-gradient(180deg, rgba(6,5,4,0) 0%, rgba(6,5,4,0.9) 12%, rgba(6,5,4,0.94) 100%);
}
.finding__h {
  font-family: var(--disp); font-weight: 400;
  font-size: clamp(2rem, 4.6vw, 3.8rem); line-height: 1.04; margin: 1rem 0 2.5rem;
  text-wrap: balance;
}
.finding__h em { color: var(--ochre); }
.big { font-size: 1.14em; max-width: 54ch; }

.mirror { max-width: 1180px; margin: 0 auto 3rem; padding-inline: var(--pad); }
.mirror__box {
  border: 1px solid var(--rule); background: rgba(9,7,5,0.94);
  padding: 0.6rem 0.4rem;
}
#mirror { width: 100%; height: clamp(300px, 42vh, 460px); }
.mirror figcaption { display: flex; flex-wrap: wrap; gap: 0.4rem 2rem; margin-top: 0.9rem; }
.mirror__k { font-family: var(--mono); font-size: 0.7rem; color: var(--faint); }
.mirror__k::before {
  content: ''; display: inline-block; width: 22px; height: 2px; margin-right: 0.6rem;
  vertical-align: middle;
}
.mirror__k.up::before { background: var(--ochre); }
.mirror__k.dn::before { background: var(--minium); }

.regimes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--rule); border-block: 1px solid var(--rule);
  max-width: 1180px; margin: 3.5rem auto 0;
}
.reg { background: #0a0806; padding: clamp(1.4rem, 3vw, 2.4rem); }
.reg__w {
  font-family: var(--caps); font-weight: 800; font-size: clamp(1.4rem, 2.6vw, 2rem);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--rw);
}
.reg__span { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; color: var(--faint); display: block; margin: 0.4rem 0 1rem; }
/* Specific enough to beat the `.reg p` rule below it. */
.reg .reg__ask {
  font-family: var(--disp); font-style: italic; font-size: 1.65rem; line-height: 1.2;
  color: var(--ink); margin-bottom: 0.9rem;
}
.reg p { font-size: 0.95rem; color: var(--dim); }

/* ---------- paradox ---------- */
.paradox { position: relative; z-index: 2; padding: clamp(4rem, 12vh, 9rem) 0; background: rgba(6,5,4,0.94); }
.para__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.para__cell { background: #0a0806; padding: 1.4rem; }
.para__cell.wide { grid-column: 1 / -1; }
.para__yr { font-family: var(--mono); font-weight: 700; font-size: 2rem; color: var(--verd); display: block; margin-bottom: 0.5rem; }

/* ---------- finis ---------- */
.finis {
  position: relative; z-index: 2;
  padding: clamp(6rem, 20vh, 14rem) var(--pad);
  background: rgba(6,5,4,0.94);
  display: flex; flex-direction: column; gap: 0.2em;
}
.finis__l {
  font-family: var(--disp); font-weight: 400;
  font-size: clamp(1.9rem, 5.2vw, 4.4rem); line-height: 1.02;
  max-width: 24ch; text-wrap: balance;
}
.finis__l--b { font-style: italic; color: var(--ochre); margin-left: auto; text-align: right; }

/* ---------- close ---------- */
.close {
  position: relative; z-index: 2; padding: clamp(4rem, 12vh, 9rem) 0 6rem;
  border-top: 1px solid var(--rule); background: rgba(6,5,4,0.96);
}
.soft li { padding: 1rem 0; border-top: 1px solid var(--rule); font-size: 0.97rem; color: var(--dim); }
.srcs li { padding: 0.5rem 0; border-top: 1px solid var(--rule); }
.srcs a {
  font-family: var(--mono); font-size: 0.76rem; color: var(--dim);
  text-decoration: none; border-bottom: 1px solid transparent; transition: color 0.25s, border-color 0.25s;
}
.srcs a:hover { color: var(--ink); border-color: var(--minium); }

/* chart labels, set inside the SVG */
#mirror .mx {
  font-family: var(--caps); font-size: 14px; fill: var(--dim);
  text-anchor: middle; dominant-baseline: middle;
}
#mirror .mn { font-family: var(--mono); font-size: 13px; fill: var(--dim); }
.colophon { margin-top: 2.4rem; font-family: var(--mono); font-size: 0.72rem; color: var(--faint); line-height: 1.9; }

/* ---------- instruments ---------- */
.hud {
  position: fixed; left: var(--pad); bottom: clamp(1rem, 3vh, 2rem); z-index: 5;
  width: 232px; padding: 0.9rem 1rem;
  background: rgba(6,5,4,0.78); backdrop-filter: blur(8px);
  border: 1px solid var(--rule); border-left: 2px solid var(--band, var(--minium));
  font-family: var(--mono);
  opacity: 0; transform: translateY(14px); transition: opacity 0.6s, transform 0.6s, border-color 0.6s;
  pointer-events: none;
}
.hud.on { opacity: 1; transform: none; }
.hud__row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; padding: 0.22rem 0; }
.hud__k { font-size: 0.56rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint); }
.hud__v { font-size: 0.78rem; color: var(--ink); text-align: right; }
.hud__row--v { border-top: 1px solid var(--rule); margin-top: 0.35rem; padding-top: 0.45rem; }
.hud__row--v .hud__v { color: var(--band); font-size: 0.9rem; }

/* Right rail: navigation AND the survival chart. Tick length = months free. */
.rail {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 5; width: var(--rail-w);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-end;
  gap: 2px; padding-right: 10px;
  opacity: 0; transition: opacity 0.6s;
}
.rail.on { opacity: 1; }
.rail__t {
  position: relative; display: block; height: 1.35vh; min-height: 9px;
  width: var(--w); background: var(--band); opacity: 0.42;
  transition: opacity 0.3s, transform 0.3s;
  transform-origin: right center;
}
.rail__t::before {
  content: attr(data-r);
  position: absolute; right: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  font-family: var(--caps); font-size: 0.58rem; letter-spacing: 0.06em; color: var(--dim);
  opacity: 0; transition: opacity 0.25s; white-space: nowrap;
}
.rail__t:hover, .rail__t.is-live { opacity: 1; transform: scaleX(1.25); }
.rail__t:hover::before, .rail__t.is-live::before { opacity: 1; }

/* ---------- survival band colours (the only semantic colour on the page) ---------- */
.band-weeks    { --band: var(--b-weeks); }
.band-months   { --band: var(--b-months); }
.band-years    { --band: var(--b-years); }
.band-lifetime { --band: var(--b-lifetime); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  /* Room on the right for the tick rail, and at the bottom for the readout bar,
     both of which are fixed and would otherwise sit on top of the text. */
  body { padding-bottom: 4.6rem; }
  .cent { padding: 8vh calc(var(--pad) + 34px) 8vh var(--pad); min-height: auto; }
  .beat, .plate, .col { padding-right: calc(var(--pad) + 24px); }
  .cent__body { margin-inline: auto; width: 100%; }
  .cent__ghost { font-size: 22vw; left: auto; right: var(--pad); top: 0; transform: none; opacity: 0.7; }
  .regimes, .para__grid { grid-template-columns: 1fr; }
  .hud {
    left: 0; right: 0; bottom: 0; width: 100%;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 0.8rem;
    border-left: none; border-top: 2px solid var(--band, var(--minium));
    padding: 0.5rem var(--pad) 0.55rem;
  }
  .hud__row { flex-direction: column; align-items: flex-start; gap: 0; padding: 0.1rem 0; }
  .hud__row:nth-child(2) { display: none; }
  .hud__row--v { border-top: none; margin: 0; padding-top: 0.1rem; }
  .hud__v { text-align: left; font-size: 0.72rem; }
  .rail { width: 34px; padding-right: 6px; }
  .rail__t { height: 1.1vh; }
  .plate__box { aspect-ratio: 4 / 3; }
  /* On a phone the text lies directly over the model, so the model gives way. */
  #city { opacity: 0; }
  #city.on { opacity: 0.52; }
  #city.dim { opacity: 0.12; }
  .gate { background: linear-gradient(180deg, rgba(6,5,4,0.5) 0%, rgba(6,5,4,0.72) 45%, rgba(6,5,4,0.86) 100%); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { animation: none; }
  .gate__go:hover svg { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- the finds tray (plate lightbox, tray.js) ----------
 * A plate is a find: clicking one lifts it onto an examination surface. The
 * backdrop is the dig house after dark with one lamp on; the image is
 * uncovered under a pass of raking light; around it sit the record's
 * instruments: registration corner marks, catalogue tag, a minium-and-ink
 * ranging rod for pixel scale, the loupe, and the finds register of numerals.
 * Everything here is self-contained; nothing below this line is used above it.
 */

/* Registration corner marks, shared by the inline plates (hover cue) and the
   tray frame. Eight hairline gradients, two per corner. */
.marks { position: absolute; inset: 10px; pointer-events: none; }
.marks::before {
  content: ''; position: absolute; inset: 0;
  --c: rgba(236, 226, 205, 0.65);
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / 18px 1px,
    linear-gradient(var(--c), var(--c)) 0 0 / 1px 18px,
    linear-gradient(var(--c), var(--c)) 100% 0 / 18px 1px,
    linear-gradient(var(--c), var(--c)) 100% 0 / 1px 18px,
    linear-gradient(var(--c), var(--c)) 0 100% / 18px 1px,
    linear-gradient(var(--c), var(--c)) 0 100% / 1px 18px,
    linear-gradient(var(--c), var(--c)) 100% 100% / 18px 1px,
    linear-gradient(var(--c), var(--c)) 100% 100% / 1px 18px;
  background-repeat: no-repeat;
}

/* The inline trigger: the whole figure image is the button. */
.plate__open {
  display: block; position: relative; width: 100%;
  padding: 0; border: 0; background: none; color: inherit; font: inherit;
  cursor: zoom-in; -webkit-tap-highlight-color: transparent;
}
.plate__open .marks { opacity: 0; transition: opacity 0.35s; }
.plate__open .plate__lift {
  position: absolute; right: 14px; bottom: 12px;
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink);
  background: rgba(6, 5, 4, 0.72); border: 1px solid var(--rule);
  padding: 0.42rem 0.65rem 0.36rem;
  opacity: 0; translate: 0 4px; transition: opacity 0.35s, translate 0.35s;
  pointer-events: none;
}
.plate__open:hover .marks, .plate__open:focus-visible .marks,
.plate__open:hover .plate__lift, .plate__open:focus-visible .plate__lift {
  opacity: 1; translate: 0 0;
}
.plate__open:hover .plate__img { filter: brightness(1.07); }
.plate__img { transition: filter 0.35s; }
.plate__open:focus-visible { outline: 2px solid var(--ochre); outline-offset: 4px; }

/* Scroll stays where it was while the tray is open. */
html.tray-open { overflow: hidden; }

.tray {
  border: 0; padding: 0; margin: auto; outline: none;
  background: transparent; color: var(--ink);
  width: min(1560px, 100vw); max-width: none; max-height: none;
  overflow: visible;
}
/* The dig house after dark: soil gradient, one warm lamp, the page's grain. */
.tray::backdrop {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(90% 70% at 50% 38%, rgba(199, 154, 68, 0.09), transparent 62%),
    linear-gradient(180deg, rgba(10, 8, 6, 0.94), rgba(6, 5, 4, 0.97));
  backdrop-filter: blur(9px);
}

.tray__head {
  display: flex; align-items: baseline; gap: 1.4rem; flex-wrap: wrap;
  padding: 0 var(--pad); margin-bottom: 1rem;
}
.tray__pl {
  font-family: var(--caps); font-weight: 600; font-size: 0.66rem;
  letter-spacing: 0.34em; text-transform: uppercase; color: var(--dim);
}
.tray__pn {
  font-family: var(--caps); font-weight: 800; font-size: 1.7rem;
  letter-spacing: 0.06em; color: var(--ochre);
}
.tray__meta {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em;
  color: var(--dim);
}
.tray__close {
  margin-left: auto; cursor: pointer;
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--dim);
  background: rgba(10, 8, 6, 0.4); border: 1px solid var(--rule);
  padding: 0.6rem 0.9rem 0.55rem;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.tray__close:hover { color: var(--ink); border-color: var(--minium); background: rgba(194, 64, 42, 0.10); }
.tray__close:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }

.tray__stage { display: flex; justify-content: center; padding: 0 var(--pad); }
.tray__frame { position: relative; display: block; }
.tray__frame .marks { inset: -11px; }
.tray__img {
  display: block; width: auto; height: auto;
  max-width: calc(100vw - 2 * var(--pad));
  max-height: calc(100svh - 17rem);
  border: 1px solid var(--rule); background: #000;
  /* Fully uncovered at rest; the open animation slides this mask through. */
  -webkit-mask-image: linear-gradient(200deg, #000 55%, transparent 78%);
          mask-image: linear-gradient(200deg, #000 55%, transparent 78%);
  -webkit-mask-size: 100% 300%; mask-size: 100% 300%;
  -webkit-mask-position: 0 0; mask-position: 0 0;
}
.tray__img.is-swap { opacity: 0; }
.tray__img { transition: opacity 0.22s ease; }

/* Uncovering: the frame rises out of the soil, the mask brushes the image
   clear top-to-bottom, and one pass of raking light crosses it. */
.tray.is-open .tray__frame { animation: tray-rise 0.7s cubic-bezier(0.22, 0.75, 0.25, 1) both; }
@keyframes tray-rise {
  from { opacity: 0; transform: translateY(26px); }
}
.tray.is-open .tray__img { animation: tray-brush 0.9s cubic-bezier(0.3, 0.5, 0.2, 1) both; }
@keyframes tray-brush {
  from { -webkit-mask-position: 0 100%; mask-position: 0 100%; }
  to   { -webkit-mask-position: 0 0;    mask-position: 0 0; }
}
.tray__sweep {
  position: absolute; inset: 1px; pointer-events: none;
  mix-blend-mode: overlay; opacity: 0;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 218, 158, 0.95) 50%, transparent 68%);
  background-size: 320% 100%; background-repeat: no-repeat;
}
.tray.is-open .tray__sweep { animation: tray-rake 1.5s ease-out 0.25s; }
@keyframes tray-rake {
  0%   { opacity: 0; background-position: 130% 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; background-position: -60% 0; }
}

/* The loupe: actual pixels of the plate inside a brass ring. Shown only for
   fine pointers (tray.js gates the listeners the same way). */
.tray__loupe {
  position: absolute; width: var(--loupe-d, 300px); height: var(--loupe-d, 300px); border-radius: 50%;
  display: none; pointer-events: none; z-index: 2;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(199, 154, 68, 0.85);
  box-shadow: 0 0 0 6px rgba(6, 5, 4, 0.55), 0 22px 50px -12px #000,
              inset 0 0 34px rgba(6, 5, 4, 0.55);
  background-repeat: no-repeat; background-color: #0a0806;
}
.tray__frame.has-loupe .tray__loupe { display: block; }
.tray__frame.has-loupe .tray__img { cursor: none; }
.tray__lscale {
  position: absolute; left: 50%; top: calc(100% + 9px); transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.24em;
  color: var(--ochre); white-space: nowrap;
}

.tray__foot {
  display: grid; grid-template-columns: 1fr auto; align-items: end;
  gap: 0.35rem 3rem; padding: 1.1rem var(--pad) 0;
}
.tray__bar { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.55rem; }
/* The ranging rod: alternating minium and bone segments, the archaeologist's
   scale stick, except the unit is source pixels rather than centimetres. */
.tray__ruler { display: inline-flex; height: 6px; border: 1px solid rgba(236, 226, 205, 0.45); }
.tray__ruler i { display: block; height: 100%; flex: 1; }
.tray__ruler i:nth-child(odd)  { background: rgba(194, 64, 42, 0.8); }
.tray__ruler i:nth-child(even) { background: rgba(236, 226, 205, 0.75); }
.tray__px {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--faint);
}
.tray__what {
  font-family: var(--disp); font-style: italic; font-size: 1.12rem;
  line-height: 1.4; color: var(--ink); max-width: 64ch;
}
.tray__cap {
  font-family: var(--mono); font-size: 0.7rem; line-height: 1.8;
  color: var(--dim); max-width: 68ch; margin-top: 0.3rem;
}
/* The finds register: numerals as border-top ticks, kin to the rail. */
.tray__reg { grid-column: 2; grid-row: 1 / span 3; display: flex; gap: 2px; }
.tray__reg button {
  font-family: var(--caps); font-weight: 600; font-size: 0.74rem; letter-spacing: 0.08em;
  color: var(--faint); background: none; border: 0; cursor: pointer;
  border-top: 2px solid var(--rule); padding: 0.55rem 0.85rem 0.2rem;
  transition: color 0.25s, border-color 0.25s;
}
.tray__reg button:hover { color: var(--ink); }
.tray__reg button[aria-current] { color: var(--ochre); border-top-color: var(--ochre); }
.tray__reg button:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

@media (max-width: 900px) {
  .tray__head { gap: 0.6rem 1.2rem; margin-bottom: 0.7rem; }
  .tray__meta { order: 3; width: 100%; }
  .tray__img { max-height: calc(100svh - 15rem); }
  .tray__foot { grid-template-columns: 1fr; gap: 0.3rem; }
  .tray__reg { grid-column: 1; grid-row: auto; margin-top: 0.8rem; }
  .tray__what { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tray__img { -webkit-mask-image: none; mask-image: none; }
  .tray.is-open .tray__frame,
  .tray.is-open .tray__img,
  .tray.is-open .tray__sweep { animation: none; }
}
