/* ==========================================================================
   Selected work — the sideways rail, and the table the rest is dealt onto.

   Two scroll-driven acts, both opt-in. Nothing below applies until JS adds
   `.on`, so a phone, a reduced-motion visitor or a failed script keeps the
   vertical stacking cards and the plain reveals exactly as they were.

   Act I  .rail      the section pins and scroll pans the cards to the right,
                     with a marker between one project and the next
   Act II .rest      the other projects are dealt in and printed, scrubbed
   ========================================================================== */

/* The whole section is the page's own palette: matte black, one bright white.
   --acc is that white, and the only thing that changes between projects is
   how much of it is on screen. */
:root {
  --acc: #fff;
}

/* ==========================  ACT I — THE RAIL  ========================== */

/* Off by default: both wrappers are inert, and the cards stack as before. */
.rail-stage {
  display: contents;
}
.rail-hud {
  display: none;
}

/* ---------- On: full-bleed, pinned, panning ---------- */
.rail.on {
  /* --rvw is the viewport width without the scrollbar, and --rh the scroll
     distance; JS sets both. Breaking out of .wrap keeps the stage edge to edge. */
  width: var(--rvw, 100vw);
  margin-left: calc(50% - var(--rvw, 100vw) / 2);
  height: var(--rh, 100vh);
}

.rail.on .rail-stage {
  display: block;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  /* The wash is centred and fades out well inside the stage, so the moment
     the pinned stage lets go there is no seam against the black below it. */
  background:
    radial-gradient(100% 72% at 50% 48%, rgba(255, 255, 255, 0.05), transparent 68%),
    var(--black);
}

/* ---------- The track ---------- */
.rail.on .stack-cards {
  position: absolute;
  z-index: 1;
  top: var(--rail-top, 96px);
  bottom: var(--rail-bot, 88px);
  left: 0;
  display: flex;
  align-items: center;
  gap: var(--rail-gap, 56px);
  padding-inline: var(--rail-edge, 120px);
  will-change: transform;
}

/* The vertical stack writes a slot height and a card offset inline as it
   measures itself. Both systems share these elements, so the rail states its
   own geometry loudly rather than relying on the other one standing down. */
/* Between one project and the next: a hairline, the number of what is coming
   and its name, set along the rule. It pans with the track, so it costs
   nothing per frame and is legible the whole way past. */
.rail-gap {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: var(--rail-mark, 72px);
  height: 100%;
}
.rail-gap i {
  position: absolute;
  top: 12%;
  bottom: 12%;
  left: 50%;
  width: 1px;
  background: linear-gradient(180deg, transparent, #2b2b29 18%, #2b2b29 82%, transparent);
}
.rail-gap p {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin: 0;
  padding: 0.9rem 0;
  background: var(--black);
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.rail-gap b {
  font-weight: 400;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.rail-gap span {
  color: var(--dim);
}

.rail.on .card-slot {
  position: relative;
  flex: 0 0 auto;
  width: var(--sw);
  height: 100% !important;
  margin: 0;
}

/* Each card keeps its natural width and is scaled to fit the stage, so the
   whole layout stays legible instead of reflowing into a narrow column. */
.rail.on .pcard {
  position: absolute;
  top: 50% !important;
  left: 50%;
  width: var(--card-w);
  transform-origin: 50% 50%;
  /* JS writes the transform every frame; this is only the resting pose. */
  transform: translate(-50%, -50%) scale(var(--fit, 1));
  border-color: #2a2a28;
  background: #0b0b0a;
  box-shadow: 0 60px 120px -60px #000;
  transition:
    border-color 0.45s var(--ease),
    box-shadow 0.45s var(--ease);
}

/* The card at the centre of the stage is the one being read. */
.rail.on .pcard.is-live {
  border-color: #6f6f6a;
  box-shadow:
    0 60px 130px -55px #000,
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 100px -34px rgba(255, 255, 255, 0.4);
}
.rail.on .pcard.is-live .pcard-kind {
  border-color: #6f6f6a;
  color: var(--white);
}

/* The card in the middle is the one being read, so it is the only one at full
   strength: its panels settle up into place as it arrives, a beat apart. That
   is the arrival — there is nothing thrown around the card to announce it. */
.rail.on .pcard-lede,
.rail.on .pcard-details,
.rail.on .pcard-shot,
.rail.on .pcard-num {
  opacity: 0.42;
  transform: translateY(14px);
  transition:
    opacity 0.5s var(--ease),
    transform 0.65s var(--ease);
}
.rail.on .pcard-num {
  transform: none;
}
.rail.on .pcard.is-live .pcard-lede,
.rail.on .pcard.is-live .pcard-details,
.rail.on .pcard.is-live .pcard-shot,
.rail.on .pcard.is-live .pcard-num {
  opacity: 1;
  transform: none;
}
.rail.on .pcard.is-live .pcard-lede { transition-delay: 0.02s; }
.rail.on .pcard.is-live .pcard-details { transition-delay: 0.09s; }
.rail.on .pcard.is-live .pcard-shot { transition-delay: 0.05s; }

/* Trimmed so a whole card clears a laptop screen without shrinking too far. */
.rail.on .pcard {
  padding: 0.75rem;
}
.rail.on .pcard-top {
  padding: 0.25rem 0.6rem 0.9rem;
}
.rail.on .pcard-num {
  font-size: clamp(2.6rem, 6vw, 88px);
}
.rail.on .pcard-panel {
  padding: clamp(0.95rem, 1.6vw, 1.45rem);
}
.rail.on .pcard-feats {
  gap: 0.78rem;
}
.rail.on .pcard-shot {
  min-height: clamp(220px, 25vw, 400px);
}

/* ---------- The HUD ---------- */
/* Decorative only — the real route through the rail is tabbing the cards,
   which pans the track. Borrowed language: brackets, a station counter,
   a percentage and a row of dots. */
.rail.on .rail-hud {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.rail-hud .rb {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 0 solid rgba(255, 255, 255, 0.4);
  transition: border-color 0.55s var(--ease-soft);
}
.rail-hud .rb-tl { top: 64px; left: 26px; border-top-width: 1px; border-left-width: 1px; }
.rail-hud .rb-tr { top: 64px; right: 26px; border-top-width: 1px; border-right-width: 1px; }
.rail-hud .rb-bl { bottom: 26px; left: 26px; border-bottom-width: 1px; border-left-width: 1px; }
.rail-hud .rb-br { bottom: 26px; right: 26px; border-bottom-width: 1px; border-right-width: 1px; }

.rail-hud .rail-meta {
  position: absolute;
  top: 70px;
  right: 60px;
  color: var(--soft);
}
.rail-hud .rail-meta span {
  color: var(--grey);
}

.rail-hud .rail-pct {
  position: absolute;
  top: 86px;
  right: 60px;
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--white);
}
.rail-hud .rail-pct span {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--grey);
}

/* Bottom left: the instruction, with an arrow that nudges sideways. */
.rail-hud .rail-cue {
  position: absolute;
  bottom: 50px;
  left: 60px;
  color: var(--soft);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  line-height: 1.5;
}
.rail-hud .rail-cue i {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #2e2e2c;
  border-radius: 50%;
  color: var(--white);
  font-style: normal;
  font-size: 0.72rem;
  animation: rail-nudge 2.4s var(--ease-soft) infinite;
}
@keyframes rail-nudge {
  0%, 62%, 100% { transform: translateX(0); }
  78% { transform: translateX(4px); }
}
/* Once the pan is under way the prompt has done its job. */
.rail.moving .rail-cue {
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

/* Bottom centre: which project you are on. */
.rail-hud .rail-now {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  white-space: nowrap;
}
.rail-hud .rail-now b {
  font-weight: 400;
  color: var(--acc);
  font-variant-numeric: tabular-nums;
}
.rail-hud .rail-now i {
  width: 34px;
  height: 1px;
  background: #3a3a38;
}
.rail-hud .rail-now span {
  color: var(--white);
  letter-spacing: 0.1em;
}

/* Bottom right: one dot per project. */
.rail-hud .rail-dots {
  position: absolute;
  right: 60px;
  bottom: 56px;
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rail-hud .rail-dots li {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2f2f2d;
  transition:
    background-color 0.35s var(--ease),
    transform 0.35s var(--pop);
}
.rail-hud .rail-dots li.on {
  background: var(--acc);
  transform: scale(1.5);
}
/* Every dot behind the current one is already read. */
.rail-hud .rail-dots li.past {
  background: #4d4d4a;
}

/* The hairline at the very bottom of the stage. */
.rail-hud .rail-bar {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: #171716;
}
.rail-hud .rail-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.15), var(--acc));
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
}

/* On a phone the card takes nearly the whole width, so the readouts that sit
   beside it on a wide screen would sit on top of it instead. The corners and
   the title line stay — they say which project this is and how far along you
   are — and the rest steps out of the way. */
@media (max-width: 759px) {
  .rail-hud .rb-tl,
  .rail-hud .rb-tr { top: 52px; }
  .rail-hud .rb-tl,
  .rail-hud .rb-bl { left: 12px; }
  .rail-hud .rb-tr,
  .rail-hud .rb-br { right: 12px; }
  .rail-hud .rb-bl,
  .rail-hud .rb-br { bottom: 14px; }
  /* "Selected work / 008" has nowhere left to sit that the fixed nav does
     not already own, and the line along the bottom says which project this
     is and how many there are. */
  .rail-hud .rail-meta { display: none; }
  /* The percentage is the one readout with nowhere to go: it moves down to
     the cue's corner, which is empty on a touch screen anyway. */
  .rail-hud .rail-pct {
    top: auto;
    right: 16px;
    bottom: 14px;
  }
  .rail-hud .rail-pct strong { font-size: 1.15rem; }
  /* "Scroll" is not an instruction a thumb needs. */
  .rail-hud .rail-cue { display: none; }
  .rail-hud .rail-now { bottom: 38px; }
}

/* A short laptop trades the chrome around the card for the card itself, so
   the whole project still arrives at a readable size. */
@media (max-height: 790px) {
  .rail.on .pcard-shot { min-height: clamp(180px, 20vw, 300px); }
  .rail.on .pcard-panel { padding: clamp(0.8rem, 1.2vw, 1.15rem); }
  .rail.on .pcard-feats { gap: 0.62rem; }
  .rail.on .pcard-top { padding-bottom: 0.7rem; }
  .rail.on .pcard-num { font-size: clamp(2.2rem, 5vw, 66px); }
}

/* A little more air on wide screens, less on short laptops. */
@media (max-height: 820px) {
  .rail-hud .rb-tl, .rail-hud .rb-tr { top: 58px; }
  .rail-hud .rail-meta { top: 64px; }
  .rail-hud .rail-pct { top: 78px; font-size: 1.4rem; }
  .rail-hud .rail-cue { bottom: 38px; }
  .rail-hud .rail-now { bottom: 40px; }
  .rail-hud .rail-dots { bottom: 44px; }
}

/* ==================  ACT II — THE REST, DEALT AND PRINTED  ================= */

.rest {
  position: relative;
}


/* A spine down the left gutter that fills as the block is read. Decorative,
   and only where there is room beside the content for it. */
.rest-spine {
  display: none;
}
.rest.on .rest-spine {
  display: block;
  position: absolute;
  top: clamp(4rem, 9vw, 7rem);
  bottom: 0;
  left: -2.25rem;
  width: 1px;
  background: #1d1d1b;
}
.rest.on .rest-spine i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, var(--acc), transparent);
  transform: scaleY(var(--p, 0));
  transform-origin: 50% 0;
}
.rest.on .rest-spine::after {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(var(--p, 0) * 100%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.55);
  transform: translate(-50%, -50%);
}
@media (max-width: 1240px) {
  .rest.on .rest-spine { display: none; }
}

/* ---------- Dealt in: the two preview cards ---------- */
/* They start well outside the column, so the grid clips sideways while they
   arrive rather than letting the page report an overflow it cannot scroll. */
.rest.on .mini-grid {
  overflow-x: clip;
  overflow-y: visible;
}
/* --d runs 0 → 1 with scroll, so scrubbing back re-scatters them. */
.rest.on .mini {
  --d: 0;
  transform:
    translate3d(calc(var(--dx) * (1 - var(--d))), calc(var(--dy) * (1 - var(--d))), 0)
    rotate(calc(var(--rot) * (1 - var(--d))))
    scale(calc(0.9 + 0.1 * var(--d)));
  opacity: calc(0.12 + 0.88 * var(--d));
  will-change: transform, opacity;
}
.rest.on .mini:nth-child(odd) {
  --dx: -16vw;
  --dy: 46px;
  --rot: -7deg;
}
.rest.on .mini:nth-child(even) {
  --dx: 16vw;
  --dy: 72px;
  --rot: 6deg;
}
/* The one-shot reveal inside would fight the scrub, so it is settled up front. */
.rest.on .mini .mini-text[data-reveal] {
  opacity: 1;
  transform: none;
}

/* ---------- Printed in: the index rows ---------- */
.rest.on .index li {
  --d: 0;
  opacity: 1;
  transform: none;
  clip-path: inset(0 calc((1 - var(--d)) * 100%) 0 0);
  transition:
    background-color 0.3s,
    padding 0.4s var(--ease);
}
/* The printing head: a bright edge that sits where the row is being drawn. */
.rest.on .index li::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--d) * 100%);
  width: 2px;
  background: var(--acc);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.6);
  opacity: calc(var(--d) * (1 - var(--d)) * 4);
  pointer-events: none;
}
.rest.on .index li {
  position: relative;
}
.rest.on .index .tech {
  transform: translateX(calc((1 - var(--d)) * 26px));
  opacity: var(--d);
}

/* Reduced motion keeps everything settled and still. */
@media (prefers-reduced-motion: reduce) {
  .rail.on,
  .rest.on {
    animation: none;
  }
  .rail-hud .rail-cue i {
    animation: none;
  }
}
