/*
 * "How late is the T?": a poster in the MBTA's own colours, built like a thumbnail.
 * One huge figure, big flat fields of line colour, ink type on light paper, and a
 * black departure board. Archivo throughout (condensed and heavy for display).
 */
:root {
  color-scheme: light;
  --paper: #f2f1ee;
  --paper-2: #e8e6e1;
  --ink: #111214;
  --ink-2: #3c3d40;
  --ink-3: #6b6c70;
  --board: #0f1012;
  --board-2: #1b1c1f;
  --board-ink: #ffd24a;      /* departure-board amber */
  --board-dim: #a19a86;
  --late: #ff6a4d;
  /* MBTA line colours, used as fields and as data */
  --red: #da291c;
  --orange: #ed8b00;
  --green: #00843d;
  --blue: #003da5;
  --bus: #ffc72c;
  --cr: #80276c;
  --ferry: #006f85;
  --gutter: clamp(16px, 3vw, 40px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --display: "Archivo", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121315; --paper-2: #1c1d20; --ink: #f3f2ee; --ink-2: #c9c8c3; --ink-3: #94938e;
  }
}
:root[data-theme="dark"] { color-scheme: dark; --paper: #121315; --paper-2: #1c1d20; --ink: #f3f2ee; --ink-2: #c9c8c3; --ink-3: #94938e; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.5 var(--display); font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
.num, td, .tnum { font-variant-numeric: tabular-nums; }

/* ── Nav ───────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 14px var(--gutter); background: color-mix(in srgb, var(--paper) 94%, transparent);
}
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 800; font-stretch: 80%; font-size: 20px; text-decoration: none; letter-spacing: -0.01em; }
.t-roundel { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-size: 17px; font-weight: 900; font-stretch: 100%; transition: transform 0.6s var(--spring); }
.wordmark:hover .t-roundel { transform: rotate(-12deg) scale(1.1); }
.nav nav { display: flex; gap: 22px; margin-left: auto; }
.nav nav a { text-decoration: none; color: var(--ink-2); font-size: 15px; position: relative; }
.nav nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform 0.35s var(--ease); }
.nav nav a:hover::after { transform: scaleX(1); }
.nav-action { text-decoration: none; background: var(--ink); color: var(--paper); padding: 9px 18px; border-radius: 99px; font-weight: 600; font-size: 15px; transition: transform 0.25s var(--ease); }
.nav-action:hover { transform: translateY(-2px); }
.nav-action:active { transform: scale(0.96); }

main { padding: 0 var(--gutter); }

/* ── Hero: the thumbnail ───────────────────────────────── */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; padding-top: 14px; min-height: min(86vh, 820px); }
.hero-card {
  background: var(--bus); color: #111214; border-radius: 28px; padding: clamp(28px, 4vw, 56px);
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.hero-card::after { /* the route roundel, enlarged into the corner */
  content: "T"; position: absolute; right: -6%; bottom: -18%; font-size: clamp(260px, 34vw, 520px); font-weight: 900;
  line-height: 1; color: #11121410; pointer-events: none;
}
h1 { font-size: clamp(34px, 4.2vw, 64px); font-weight: 800; font-stretch: 78%; letter-spacing: -0.02em; line-height: 1; }
.big { font-size: clamp(140px, 17vw, 280px); font-weight: 900; font-stretch: 70%; line-height: 0.82; letter-spacing: -0.05em; margin-top: 20px; font-variant-numeric: tabular-nums; }
.big .pct { font-size: 0.42em; vertical-align: 0.95em; margin-left: 0.04em; letter-spacing: 0; }
.big-label { font-size: clamp(22px, 2.2vw, 34px); font-weight: 700; font-stretch: 85%; line-height: 1.08; max-width: 16ch; margin-top: 10px; }
.hero-sub { margin-top: 26px; font-size: 17px; max-width: 46ch; color: #2b2b2b; }

/* Departure board */
.board { background: var(--board); color: var(--board-ink); border-radius: 28px; padding: clamp(22px, 2.6vw, 36px); display: flex; flex-direction: column; min-width: 0; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.board h2 { font-size: 22px; font-weight: 700; font-stretch: 85%; color: #fff; }
.board-time { color: var(--board-dim); font-size: 15px; font-variant-numeric: tabular-nums; }
.board-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; align-content: start; perspective: 800px; }
.board-row {
  display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 14px;
  background: var(--board-2); border-radius: 12px; padding: 10px 14px 10px 10px;
  transform-origin: top center; animation: flap 0.7s var(--ease) both; animation-delay: calc(var(--i) * 70ms);
}
@keyframes flap { from { transform: rotateX(-90deg); opacity: 0; } to { transform: none; opacity: 1; } }
.bullet {
  height: 34px; min-width: 34px; padding: 0 8px; border-radius: 99px; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; font-stretch: 85%; color: #fff; justify-self: start; white-space: nowrap;
}
.bullet.dark-ink { color: #111214; }
.board-stop { min-width: 0; }
.board-stop strong { display: block; color: #fff; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-stop span { color: var(--board-dim); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.board-late { font-size: 26px; font-weight: 800; font-stretch: 80%; color: var(--board-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-late small { font-size: 14px; font-weight: 600; color: var(--board-dim); margin-left: 2px; }
.board-late.very { color: var(--late); }
.board-foot { color: var(--board-dim); font-size: 13.5px; margin-top: 14px; }

/* ── Section rhythm ───────────────────────────────────── */
section.modes, section.fleet, section.split, section.routes, section.method { margin-top: clamp(80px, 10vw, 150px); }
.section-title { font-size: clamp(34px, 4.6vw, 72px); font-weight: 800; font-stretch: 75%; letter-spacing: -0.025em; line-height: 0.95; margin-bottom: 28px; max-width: 26ch; }
.section-sub { color: var(--ink-2); margin: -14px 0 22px; }

/* Mode fields */
.mode-row { display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 14px; }
.mode {
  border-radius: 24px; padding: 24px 24px 22px; color: #fff; min-height: 300px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform 0.5s var(--spring);
}
.mode:hover { transform: translateY(-8px) rotate(-0.6deg); }
.mode[data-mode="Bus"] { background: var(--bus); color: #111214; }
.mode[data-mode="Subway"] { background: var(--red); }
.mode[data-mode="Light rail"] { background: var(--green); }
.mode[data-mode="Commuter rail"] { background: var(--cr); }
.mode[data-mode="Ferry"] { background: var(--ferry); }
.mode-name { font-size: 22px; font-weight: 700; font-stretch: 85%; }
.mode-pct { font-size: clamp(72px, 7.4vw, 124px); font-weight: 900; font-stretch: 70%; line-height: 0.85; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.mode-pct small { font-size: 0.4em; vertical-align: 0.9em; letter-spacing: 0; }
.mode-meta { font-size: 15px; }

/* Panels with charts */
.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { margin: 0; background: var(--paper-2); border-radius: 24px; padding: 24px; min-width: 0; transition: transform 0.4s var(--ease); }
.panel:hover { transform: translateY(-3px); }
.panel figcaption { display: grid; gap: 2px; margin-bottom: 14px; }
.panel figcaption strong { font-size: 19px; font-weight: 700; font-stretch: 90%; }
.panel figcaption span { color: var(--ink-2); font-size: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend i { width: 12px; height: 4px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.chart { position: relative; height: 260px; }
.chart.tall { height: 300px; }
.caveat { color: var(--ink-2); font-size: 14px; margin-top: 10px; }

/* Routes table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 14px; padding: 10px 12px; }
td { padding: 12px; background: var(--paper-2); }
tr td:first-child { border-radius: 14px 0 0 14px; }
tr td:last-child { border-radius: 0 14px 14px 0; }
tbody tr { transition: transform 0.3s var(--ease); }
tbody tr:hover { transform: translateX(6px); }
table { border-spacing: 0 6px; border-collapse: separate; }
.num { text-align: right; white-space: nowrap; }
.route-cell { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.delay-bar { display: inline-block; height: 10px; border-radius: 5px; background: var(--late); margin-right: 10px; vertical-align: middle; transform-origin: left; animation: grow 1s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes grow { from { transform: scaleX(0); } }

/* Method */
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.method-grid p { font-size: 16px; color: var(--ink-2); }
.method-grid strong { color: var(--ink); display: block; font-size: 19px; font-stretch: 90%; margin-bottom: 4px; }

/* Footer: the name returns at full width */
.footer { margin-top: clamp(90px, 10vw, 160px); padding: 0 var(--gutter) 40px; }
.footer-mark { font-size: clamp(56px, 11.5vw, 210px); font-weight: 900; font-stretch: 68%; letter-spacing: -0.045em; line-height: 0.85; }
.footer-note { color: var(--ink-3); margin-top: 18px; font-size: 14px; }

/* ── Motion ────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }
.mode { opacity: 0; transform: translateY(40px) scale(0.96); }
.mode.in { opacity: 1; transform: none; transition: opacity 0.7s var(--ease), transform 0.8s var(--spring); transition-delay: calc(var(--i) * 90ms); }
.mode.in:hover { transform: translateY(-8px) rotate(-0.6deg); transition-delay: 0ms; }
.hero-card .big { transform-origin: left bottom; }
.hero-card.in .big { animation: pop 1.1s var(--spring) both 0.15s; }
@keyframes pop { from { transform: scale(0.8) translateY(20px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal, .mode { opacity: 1 !important; transform: none !important; }
}

/* ── Tablet and phone ──────────────────────────────────── */
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .mode-row { grid-template-columns: repeat(2, 1fr); }
  .split-grid { grid-template-columns: 1fr; }
  .method-grid { grid-template-columns: 1fr 1fr; }
  .nav nav { display: none; }
  .nav-action { margin-left: auto; }
}
@media (max-width: 560px) {
  .mode-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mode { min-height: 200px; padding: 18px; }
  .method-grid { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: 46px 1fr auto; gap: 10px; }
  .board-late { font-size: 22px; }
  th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4), th:nth-child(6), td:nth-child(6) { display: none; }
  table { font-size: 14.5px; }
  td, th { padding: 10px 8px; }
  .delay-bar { display: none; }
  .fleet-row { grid-template-columns: 1fr; }
  .chart, .chart.tall { height: 240px; }
}

/* ── Fleet: four photo thumbnails ─────────────────────── */
.fleet-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 0.9fr; gap: 16px; align-items: start; }
.shot { margin: 0; }
.shot-img { border-radius: 22px; overflow: hidden; aspect-ratio: 4 / 5; background: var(--paper-2); }
.shot:first-child .shot-img { aspect-ratio: 4 / 4.4; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.12); transition: transform 1.6s var(--ease); }
.shot.in img { transform: scale(1.02); }
.shot:hover img { transform: scale(1.08); transition-duration: 0.8s; }
.shot figcaption { display: grid; gap: 4px; margin-top: 12px; font-size: 15px; color: var(--ink-2); }
.shot-tag { justify-self: start; color: #fff; font-weight: 700; font-stretch: 85%; font-size: 14px; padding: 4px 12px; border-radius: 99px; }
.shot-tag.dark { color: #111214; }
.shot-stat { font-size: clamp(32px, 3.2vw, 48px); font-weight: 900; font-stretch: 72%; color: var(--ink); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.credits { color: var(--ink-3); font-size: 13px; margin-top: 10px; max-width: 110ch; }
.credits a { color: var(--ink-2); }
@media (max-width: 1000px) { .fleet-row { grid-template-columns: 1fr 1fr; } }

.shot-line { display: flex; align-items: center; gap: 8px; }
.shot-line i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
