/* Baldwin — "By the hour": the scroll-directed homepage.
   Every transform reads --p (0..1) written by motion.js. With html.motion-off (reduced motion,
   Save-Data, or no JS) every rule below collapses to its resting state. */

:root { --rail-w: 0px; }

/* ---------- opening: pinned stage ---------- */
.open { position: relative; height: 240vh; overflow: clip; }
/* Top-anchored rather than centred: at landing the site header sits above the stage, so centred
   content would clip at the bottom of the first viewport. */
.open-stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; display: grid; align-items: start; padding-top: clamp(16px, 5vh, 64px); box-sizing: border-box; background: var(--paper); }
.open-grid { display: grid; gap: 22px; align-items: center; }
.open-meter { font: 800 clamp(4.4rem, 14vw, 12rem)/0.85 var(--f-display); letter-spacing: -0.05em; color: var(--brown); font-variant-numeric: tabular-nums; margin: 0; }
.open-meter small { display: block; font: 700 0.78rem/1.2 var(--f-body); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.open-lines { margin: 8px 0 0; font-size: clamp(2rem, 5.2vw + 0.6rem, 5.2rem); line-height: 0.96; letter-spacing: -0.035em; }
.open-lines .l { display: block; }
.open-lines .accent { color: var(--brown); }
.open-sub { max-width: 34em; margin: 22px 0 0; }
.open-cta { margin-top: 20px; }
.open-photos { position: relative; height: min(58vh, 560px); }
.open-photos .photo { position: absolute; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.open-photos .p1 { left: 0; top: 0; width: 56%; aspect-ratio: 4 / 5; }
.open-photos .p2 { right: 0; bottom: 0; width: 50%; aspect-ratio: 4 / 5; }
.open-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font: 700 0.72rem/1 var(--f-body); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.open-hint::after { content: ""; display: block; width: 2px; height: 26px; margin: 8px auto 0; background: var(--olive); }

/* --e is a load-time entrance (0 → 1 over ~1.5 s, set by motion.js). The composition — headline
   lines, lede, CTAs, the two stills — takes it as a floor so the stage lands composed; the meter,
   the scroll hint and the fade-out stay on scroll progress alone. */
.motion-on .open { --q: max(var(--p, 0), var(--e, 0) * 0.55); }
.motion-on .open-lines .l { opacity: calc((var(--q, 0) - var(--d, 0)) * 6); transform: translateY(calc((1 - clamp(0, (var(--q, 0) - var(--d, 0)) * 6, 1)) * 34px)); }
.motion-on .open-lines .l:nth-child(1) { --d: -0.2; }
.motion-on .open-lines .l:nth-child(2) { --d: 0.10; }
.motion-on .open-lines .l:nth-child(3) { --d: 0.18; }
.motion-on .open-sub, .motion-on .open-cta { opacity: clamp(0, (var(--q, 0) - 0.28) * 5, 1); transform: translateY(calc((1 - clamp(0, (var(--q, 0) - 0.28) * 5, 1)) * 18px)); }
.motion-on .open-photos .p1 { --k: clamp(0, max(var(--p, 0) * 2.2, var(--e, 0) * 1.1), 1); transform: translate3d(calc((1 - var(--k)) * 34vw), calc((1 - var(--k)) * 12vh), 0) rotate(calc((1 - var(--k)) * -6deg)); }
.motion-on .open-photos .p2 { --k: clamp(0, max((var(--p, 0) - 0.08) * 2.2, var(--e, 0) * 1.25 - 0.25), 1); transform: translate3d(calc((1 - var(--k)) * 60vw), calc((1 - var(--k)) * -6vh), 0) rotate(calc((1 - var(--k)) * 5deg)); }
.motion-on .open-hint { opacity: calc(1 - var(--p, 0) * 4); }
.motion-on .open-stage::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40vh; background: linear-gradient(180deg, transparent, var(--paper)); opacity: calc((var(--p, 0) - 0.75) * 4); pointer-events: none; }

@media (min-width: 900px) {
  .open-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: clamp(30px, 5vw, 80px); }
  .open-photos { height: min(70vh, 640px); }
}
@media (min-width: 900px) and (max-height: 960px) {
  .open-meter { font-size: clamp(4rem, 10.5vw, 8.5rem); }
  .open-lines { font-size: clamp(2rem, 4.4vw + 0.4rem, 4.4rem); }
  .open-photos { height: min(62vh, 560px); }
}
@media (max-width: 899px) {
  .open { height: 200vh; }
  .open-grid { gap: 14px; }
  .open-photos { height: min(30vh, 270px); order: -1; }
  .open-meter { font-size: clamp(3.2rem, 15vw, 5.4rem); }
  .open-meter small { margin-top: 4px; }
  .open-lines { font-size: clamp(1.75rem, 7.6vw, 2.6rem); }
  .open-sub { font-size: 0.98rem; margin-top: 12px; }
  .open-cta { margin-top: 14px; }
  .open-hint { display: none; }
}
.motion-off .open, .no-js .open { height: auto; }
.motion-off .open-stage, .no-js .open-stage { position: static; height: auto; padding: clamp(28px, 5vw, 64px) 0; }
.motion-off .open-hint, .no-js .open-hint { display: none; }

/* ---------- the program switch + hour rail ---------- */
.journey { position: relative; }
.rail-bar { position: sticky; top: var(--header-h); z-index: 30; background: rgba(255, 252, 245, 0.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.rail-bar .wrap { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.switch { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.switch::-webkit-scrollbar { display: none; }
.switch { display: flex; gap: 4px; padding: 4px; background: var(--cream); border-radius: 999px; }
.switch button { min-height: 40px; padding: 0 10px; flex: none; border: 0; border-radius: 999px; background: transparent; font: 700 0.86rem/1 var(--f-body); color: var(--muted); white-space: nowrap; }
.switch button[aria-selected="true"] { background: var(--brown); color: var(--paper); }
.rail-meter { margin-left: auto; display: flex; align-items: baseline; gap: 5px; font: 800 1.05rem/1 var(--f-display); letter-spacing: -0.02em; color: var(--brown); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rail-meter small { font: 600 0.72rem/1 var(--f-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.rail-chapter { display: none; font: 600 0.82rem/1.2 var(--f-body); color: var(--muted); }
.rail-line { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--line); }
.rail-line span { display: block; height: 100%; background: var(--olive); transform-origin: left; transform: scaleX(var(--f, 0)); }
@media (max-width: 899px) {
  .rail-bar .wrap { flex-wrap: wrap; row-gap: 0; padding-top: 8px; padding-bottom: 6px; min-height: 0; }
  .switch { flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; }
  .switch button { min-height: 36px; padding: 0 6px; font-size: 0.82rem; }
  .switch button .num { display: none; }
  .rail-chapter { display: block; flex: 1; margin: 0; padding: 4px 4px 0; border: 0; font-size: 0.78rem; }
  .rail-meter { padding-top: 4px; font-size: 1rem; }
  .rail-meter small:first-child { display: none; }
}
@media (min-width: 900px) {
  .rail-bar .wrap { min-height: 64px; }
  .rail-meter { font-size: 1.25rem; }
  .switch button { padding: 0 16px; font-size: 0.92rem; }
  .rail-chapter { display: block; margin-left: 18px; padding-left: 18px; border-left: 1px solid var(--line); }
}

/* chapters */
.chapter { position: relative; padding-block: clamp(56px, 8vw, 120px); }
.chapter-grid { display: grid; gap: 24px; align-items: center; }
.hour-mark { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 14px; font: 800 0.78rem/1 var(--f-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--olive-ink); }
.hour-mark b { font: 800 1.6rem/1 var(--f-display); letter-spacing: -0.02em; color: var(--brown); font-variant-numeric: tabular-nums; }
.on-dark .hour-mark { color: var(--olive); } .on-dark .hour-mark b { color: var(--paper); }
.chapter h2 { font-size: clamp(2rem, 3.2vw + 0.9rem, 3.6rem); }
.chapter .lede { margin-top: 16px; }
.chapter .photo { aspect-ratio: 4 / 5; }
.chapter .photo.wide { aspect-ratio: 4 / 3; }
.motion-on .chapter .photo img, .motion-on .chapter-photo img, .motion-on .archive .photo img { transform: scale(calc(1.12 - var(--p, 0) * 0.12)) translateY(calc((0.5 - var(--p, 0)) * 6%)); transform-origin: center; will-change: transform; }
.motion-on .rise { opacity: clamp(0, var(--p, 0) * 1.6, 1); transform: translateY(calc((1 - clamp(0, var(--p, 0) * 1.6, 1)) * 28px)); }
.motion-on .rise-2 { opacity: clamp(0, (var(--p, 0) - 0.12) * 1.6, 1); transform: translateY(calc((1 - clamp(0, (var(--p, 0) - 0.12) * 1.6, 1)) * 28px)); }
.motion-on .rise-3 { opacity: clamp(0, (var(--p, 0) - 0.24) * 1.6, 1); transform: translateY(calc((1 - clamp(0, (var(--p, 0) - 0.24) * 1.6, 1)) * 28px)); }
@media (min-width: 900px) {
  .chapter-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 80px); }
  .chapter-grid.flip > :first-child { order: 2; }
}

/* subject hours that fill as you pass */
.fill-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
.fill-list li { display: grid; gap: 6px; }
.fill-list .row { display: flex; justify-content: space-between; font-weight: 700; }
.fill-list .row span:last-child { font-variant-numeric: tabular-nums; color: var(--brown); }
.on-dark .fill-list .row span:last-child { color: var(--olive); }
.fill-list .bar { height: 10px; border-radius: 5px; background: rgba(34, 25, 11, 0.12); overflow: hidden; }
.on-dark .fill-list .bar { background: rgba(255, 255, 255, 0.12); }
.fill-list .bar i { display: block; height: 100%; background: var(--olive); transform-origin: left; transform: scaleX(var(--w, 1)); }
.motion-on .fill-list .bar i { transform: scaleX(calc(var(--w, 1) * clamp(0, (var(--p, 0) - 0.15) * 2.2, 1))); transition: none; }

/* the day: morning / afternoon split */
.day { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.day div { border-radius: 12px; padding: 14px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-on-dark); }
.day b { display: block; font: 800 1.15rem/1.1 var(--f-display); margin-bottom: 4px; }
.day span { font-size: 0.9rem; color: var(--muted-on-dark); }

/* ---------- counters / odometer ---------- */
.big-num { font-variant-numeric: tabular-nums; }
.odometer { font: 800 clamp(4rem, 12vw, 9rem)/0.9 var(--f-display); letter-spacing: -0.05em; color: var(--brown); font-variant-numeric: tabular-nums; margin: 0 0 8px; }
.odometer small { display: block; font: 700 0.75rem/1.2 var(--f-body); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* ---------- map draw ---------- */
.motion-on .map-figure path.road { stroke-dasharray: 1; stroke-dashoffset: calc(1 - clamp(0, (var(--p, 0) - 0.05) * 1.8, 1)); }
.motion-on .map-figure .map-pin { opacity: clamp(0, (var(--p, 0) - 0.45) * 4, 1); transform: translateY(calc((1 - clamp(0, (var(--p, 0) - 0.45) * 4, 1)) * -12px)); transform-box: fill-box; transform-origin: center; }

/* ---------- misc ---------- */
.motion-on .outcome { opacity: clamp(0, (var(--p, 0) - var(--d, 0)) * 3, 1); transform: translateY(calc((1 - clamp(0, (var(--p, 0) - var(--d, 0)) * 3, 1)) * 20px)); }
.motion-on .outcomes .outcome:nth-child(2) { --d: 0.08; } .motion-on .outcomes .outcome:nth-child(3) { --d: 0.16; }
