/* ============================================================================
   Tangled up in Blue — Troy School District -> University of Michigan
   Palette: Michigan navy/maize for chrome; the data series use a separately
   validated categorical set (see js/charts.js PALETTE) that clears CVD,
   lightness-band and contrast checks against the navy chart surface.
   ========================================================================== */

:root {
  --navy-900: #001426;
  --navy-800: #001c34;
  --navy-700: #04182e;
  --navy-surface: #06203f;    /* chart surface the palette was validated on */
  --navy-600: #0a2e56;
  --maize: #ffcb05;
  --maize-dim: #d9ac05;

  --text-primary: #f4f7fb;
  --text-secondary: #a9bdd4;
  --text-muted: #6f8aa8;

  --grid: rgba(169, 189, 212, 0.15);
  --axis: rgba(169, 189, 212, 0.4);
  --rule: rgba(169, 189, 212, 0.18);

  --troy: #c8cdd2;      /* Troy Colts silver — chrome accent only */
  --athens: #e05252;    /* Athens Red Hawks red — chrome accent only */

  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --player-h: 76px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--navy-900);
  color: var(--text-primary);
  font: 400 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--player-h);
  overflow-x: hidden;
}

/* subtle field texture so large navy areas aren't dead flat */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 203, 5, 0.07), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(58, 135, 229, 0.09), transparent 50%);
}

h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.022em;
  line-height: 1.08;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

a { color: var(--maize); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 1; }
.narrow { max-width: var(--measure); }

/* ---------------------------------------------------------------- hero --- */
.hero {
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  padding: 6rem 0 4rem;
}
.hero canvas.fieldlines {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0.5; z-index: 0;
}
.hero .wrap { z-index: 2; }
.hero .kicker {
  font-size: 0.78rem; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--maize); font-weight: 700; margin-bottom: 1.6rem;
}
.hero h1 {
  font-size: clamp(3.2rem, 13vw, 9.5rem);
  letter-spacing: -0.045em;
  line-height: 0.85;
  margin-bottom: 0.35em;
}
.hero h1 .blue {
  color: var(--maize);
  display: inline-block;
}
.hero .standfirst {
  font-size: clamp(1.05rem, 2.2vw, 1.4rem);
  color: var(--text-secondary);
  max-width: 40rem; margin: 0 auto 2.5rem;
}
.hero .scrollcue {
  font-size: 0.75rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-muted);
}
.hero .scrollcue span { display: block; font-size: 1.4rem; margin-top: 0.35rem; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) { .hero .scrollcue span { animation: none; } }

/* the big block M */
.blockm { width: clamp(70px, 9vw, 120px); height: auto; margin: 0 auto 1.75rem; display: block; }
.blockm path { fill: var(--maize); }

/* ------------------------------------------------------------- sections -- */
section { padding: clamp(4rem, 10vh, 8rem) 0; position: relative; z-index: 1; }
section.alt { background: var(--navy-800); }
section.deep { background: var(--navy-700); }

.act-label {
  font-size: 0.74rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--maize); font-weight: 700; margin-bottom: 0.9rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.act-label::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

section h2 { font-size: clamp(2rem, 5vw, 3.4rem); margin-bottom: 0.6em; }
section h3 { font-size: clamp(1.25rem, 2.6vw, 1.75rem); margin-bottom: 0.5em; }

.lede { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--text-secondary); max-width: 42rem; }
p { max-width: 42rem; color: var(--text-secondary); }
p strong, li strong { color: var(--text-primary); font-weight: 650; }

/* ------------------------------------------------------------ stat tiles - */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: 2.5rem 0;
}
.stat { background: var(--navy-900); padding: 1.5rem 1.35rem; }
section.alt .stat { background: var(--navy-800); }
section.deep .stat { background: var(--navy-700); }
.stat .n {
  font-size: clamp(2rem, 4.2vw, 2.9rem); font-weight: 800; letter-spacing: -0.03em;
  line-height: 1; color: var(--maize); font-variant-numeric: tabular-nums;
}
.stat .n.down { color: #ff8a80; }
.stat .n.flat { color: var(--text-primary); }
.stat .l { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.55rem; line-height: 1.4; }
.stat .sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }

/* -------------------------------------------------------- scrollytelling - */
.scrolly { display: grid; gap: 0; align-items: start; }
@media (min-width: 900px) {
  .scrolly { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.3fr); gap: clamp(1.5rem, 3.5vw, 3.5rem); }
}
.scrolly .steps { display: flex; flex-direction: column; }
.scrolly .step {
  min-height: 70vh; display: flex; flex-direction: column; justify-content: center;
  padding: 2rem 0;
  opacity: 0.32; transition: opacity 0.45s ease;
}
.scrolly .step.active { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .scrolly .step { opacity: 1; } }
.scrolly .sticky {
  position: sticky; top: 0; height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem 0;
}
.scrolly .sticky > div { width: 100%; }
.scrolly .sticky svg { display: block; width: 100%; height: auto; }
@media (max-width: 899px) {
  .scrolly .sticky { height: 62svh; top: 0; z-index: 3; background: inherit; }
  .scrolly .step { min-height: auto; padding: 1.25rem 0 2.5rem; opacity: 1; }
}
.step .stepnum {
  font-size: 0.72rem; letter-spacing: 0.2em; color: var(--maize);
  font-weight: 700; margin-bottom: 0.6rem;
}

/* ------------------------------------------------------------- figures --- */
figure { margin: 2.5rem 0; }
.figure-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
figure h4 { font-size: 1.05rem; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
figure .sub { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 1rem; max-width: none; }
figcaption { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.75rem; max-width: 44rem; }

.chart { width: 100%; background: var(--navy-surface); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }

.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; margin: 0.85rem 0 0; padding: 0; list-style: none; font-size: 0.82rem; }
.legend li { display: flex; align-items: center; gap: 0.45rem; color: var(--text-secondary); }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend .swatch.line { height: 3px; border-radius: 2px; width: 16px; }

.tablebtn {
  background: none; border: 1px solid var(--rule); color: var(--text-secondary);
  font: inherit; font-size: 0.76rem; padding: 0.3rem 0.7rem; border-radius: 4px; cursor: pointer;
}
.tablebtn:hover { border-color: var(--maize); color: var(--maize); }
.datatable { margin-top: 1rem; overflow-x: auto; }
.datatable[hidden] { display: none; }
.datatable table { border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; min-width: 100%; }
.datatable th, .datatable td { padding: 0.35rem 0.7rem; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.datatable th:first-child, .datatable td:first-child { text-align: left; }
.datatable thead th { color: var(--text-primary); font-weight: 700; border-bottom-color: var(--axis); position: sticky; top: 0; background: var(--navy-800); }
.datatable td { color: var(--text-secondary); }

/* tooltip */
.viz-tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0;
  transition: opacity 0.12s ease;
  background: #01101f; border: 1px solid var(--axis); border-radius: 6px;
  padding: 0.55rem 0.7rem; font-size: 0.8rem; line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55); max-width: 260px;
  font-variant-numeric: tabular-nums;
}
.viz-tip.on { opacity: 1; }
.viz-tip .t-title { font-weight: 700; color: #fff; margin-bottom: 0.3rem; }
.viz-tip .t-row { display: flex; align-items: center; gap: 0.45rem; color: var(--text-secondary); white-space: nowrap; }
.viz-tip .t-row .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.viz-tip .t-row .v { margin-left: auto; color: #fff; font-weight: 650; padding-left: 0.8rem; }

/* ------------------------------------------------------ campus panels ---- */
.campus { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; margin: 2rem 0; background: var(--navy-800); }
.campus .art { position: relative; background: var(--navy-700); }
.campus .art svg { display: block; width: 100%; height: auto; }
.campus .body { padding: 1.5rem clamp(1.1rem, 2.5vw, 2rem) 2rem; }
.campus .tag {
  font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 0.5rem;
}
/* Tag text stays in a legible ink; the chip beside it carries the exact
   official U-M hex being named, so the colour is accurate without asking
   small text to sit at 2.75:1 contrast. */
.campus .tag { color: var(--text-secondary); display: flex; align-items: center; gap: 0.5rem; }
.campus .tag .chip {
  width: 12px; height: 12px; border-radius: 3px; flex: none;
  box-shadow: 0 0 0 1px rgba(244,247,251,0.25);
}
.campus h3 { margin-bottom: 0.35em; }
.campus .cstats { display: flex; flex-wrap: wrap; gap: 1.75rem; margin: 1.35rem 0 0; }
.campus .cstat .n { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.campus .cstat .l { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ------------------------------------------------------------- ledger ---- */
.ledger { border: 1px solid var(--rule); margin: 2.5rem 0; }
.ledger .row {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr 1.1fr; gap: 1rem;
  padding: 0.95rem 1.2rem; border-bottom: 1px solid var(--rule); align-items: center;
  font-variant-numeric: tabular-nums; font-size: 0.92rem;
}
.ledger .row:last-child { border-bottom: 0; }
.ledger .row.head { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.ledger .row.total { background: rgba(255,203,5,0.07); font-weight: 700; }
.ledger .lbl { color: var(--text-primary); }
.ledger .v { text-align: right; color: var(--text-secondary); }
.ledger .chg { text-align: right; font-weight: 700; }
.ledger .chg.up { color: #ff8a80; }
.ledger .chg.down { color: #7ee0b8; }
.ledger .chg.n { color: var(--text-secondary); }
@media (max-width: 700px) {
  .ledger .row { grid-template-columns: 1fr 1fr; gap: 0.35rem 1rem; }
  .ledger .row.head { display: none; }
  .ledger .lbl { grid-column: 1 / -1; font-weight: 700; }
}

/* -------------------------------------------------------------- pullquote  */
.pull {
  border-left: 3px solid var(--maize); padding: 0.4rem 0 0.4rem 1.5rem;
  margin: 2.5rem 0; font-size: clamp(1.2rem, 2.6vw, 1.6rem); font-weight: 600;
  color: var(--text-primary); letter-spacing: -0.015em; line-height: 1.35; max-width: 40rem;
}

.callout {
  border: 1px solid var(--rule); border-left: 3px solid #3987e5;
  padding: 1.2rem 1.4rem; margin: 2rem 0; background: rgba(57,135,229,0.06);
  border-radius: 0 6px 6px 0;
}
.callout h4 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.callout p { font-size: 0.92rem; margin: 0; }

/* --------------------------------------------------------------- sources - */
.sources { font-size: 0.88rem; }
.sources dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem; align-items: baseline; }
.sources dt { color: var(--maize); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; }
.sources dd { margin: 0; color: var(--text-secondary); }
@media (max-width: 640px) { .sources dl { grid-template-columns: 1fr; gap: 0.15rem; } .sources dd { margin-bottom: 0.9rem; } }

footer { padding: 3rem 0 4rem; border-top: 1px solid var(--rule); color: var(--text-muted); font-size: 0.85rem; }

/* ---------------------------------------------------------- audio player - */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--player-h); z-index: 50;
  background: rgba(0, 16, 32, 0.93);
  backdrop-filter: blur(14px) saturate(1.2);
  border-top: 1px solid rgba(255, 203, 5, 0.28);
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
}
.player canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0.5; pointer-events: none;
}
.player > * { position: relative; z-index: 1; }
.pbtn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  border: 1px solid rgba(255,203,5,0.5); background: rgba(255,203,5,0.12);
  color: var(--maize); cursor: pointer; display: grid; place-items: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.pbtn:hover { background: rgba(255,203,5,0.25); }
.pbtn:active { transform: scale(0.94); }
.pbtn svg { width: 17px; height: 17px; fill: currentColor; }
/* Skip controls are real controls, not afterthoughts — same maize family as
   play, just a step down in weight so play still reads as primary. */
.pbtn.sm {
  width: 38px; height: 38px;
  border-color: rgba(255, 203, 5, 0.34);
  background: rgba(255, 203, 5, 0.06);
  color: var(--maize);
}
.pbtn.sm:hover { background: rgba(255, 203, 5, 0.2); border-color: rgba(255, 203, 5, 0.7); }
.pbtn.sm svg { width: 15px; height: 15px; }
.pbtn:focus-visible { outline: 2px solid var(--maize); outline-offset: 2px; }

.pmeta { min-width: 0; flex: 1; }
.ptitle {
  font-size: 0.86rem; font-weight: 700; color: #fff; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ptrack { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 1px; }

.pseek { display: flex; align-items: center; gap: 0.6rem; flex: 2; min-width: 0; }
@media (max-width: 780px) { .pseek { display: none; } }
.pbar { flex: 1; height: 4px; background: rgba(169,189,212,0.25); border-radius: 2px; cursor: pointer; position: relative; }
.pbar .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--maize); border-radius: 2px; }
.ptime { font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; }

.plist {
  position: absolute; right: clamp(0.75rem, 2vw, 1.5rem); bottom: calc(var(--player-h) - 4px);
  background: rgba(0,16,32,0.97); border: 1px solid rgba(255,203,5,0.28);
  border-radius: 8px 8px 0 0; overflow: hidden; min-width: 250px;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}
.plist[hidden] { display: none; }
.plist button {
  display: flex; width: 100%; gap: 0.6rem; align-items: center; text-align: left;
  background: none; border: 0; border-bottom: 1px solid rgba(169,189,212,0.12);
  color: var(--text-secondary); font: inherit; font-size: 0.82rem;
  padding: 0.6rem 0.9rem; cursor: pointer;
}
.plist button:last-child { border-bottom: 0; }
.plist button:hover { background: rgba(255,203,5,0.09); color: #fff; }
.plist button[aria-current="true"] { color: var(--maize); font-weight: 700; }
.plist .idx { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 0.72rem; }
.plist button[aria-current="true"] .idx { color: var(--maize); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* inline colour chip used in captions to show a sampled brand value */
.chip-i {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 2px; vertical-align: baseline;
  box-shadow: 0 0 0 1px rgba(244,247,251,0.3);
}

/* the word "Blue": an SVG cut-out filled with a shimmering blue field and
   drifting campus objects. The visible glyphs are a clip path, so a
   screen-reader copy of the word rides alongside inside the span. */
.bluefx {
  display: inline-block;
  vertical-align: baseline;
  line-height: 0;
}
.bluefx svg { display: block; overflow: visible; }
/* lift the blue word off the navy field so it reads as a solid mass */
.bluefx svg { filter: drop-shadow(0 0 26px rgba(77, 155, 240, 0.35)); }
