/* ============================================================
   PIVOT — "Instrument" design system
   Dark steel bookends · warm paper body · one signal-orange
   accent. Hairlines, mono labels, sharp corners. No cards,
   no shadows, no decoration that doesn't carry information.
   ============================================================ */

:root {
  /* Dark surfaces (nav, hero, footer) */
  --dark-0: #0b0d10;
  --dark-1: #14171c;
  --dark-line: rgba(255, 255, 255, 0.12);
  --dark-grid: rgba(255, 255, 255, 0.034);
  --dark-ink: #f2f3f5;
  --dark-muted: #99a1ab;

  /* Light body — warm paper, deliberately not pure white */
  --paper: #faf9f7;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #5b6168;
  --line: #e6e3dd;

  /* One accent, two luminance steps of the same hue */
  --accent: #c2410c;        /* on light surfaces */
  --accent-bright: #ff6b35; /* on dark surfaces */

  --display: "Big Shoulders Display", "Archivo Black", Impact, sans-serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", Times, serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --w-prose: 680px;
  --w-content: 1000px;
  --w-media: 1200px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 68px; /* offset for sticky nav */
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(194, 65, 12, 0.18);
}

/* Shared width wrappers */
.wrap-content,
.wrap-media {
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.wrap-content { max-width: var(--w-content); }
.wrap-media { max-width: var(--w-media); }

/* Body video bands sit clearly narrower than the hero promo and the
   charts: the page breathes and text/figure proportions stay balanced */
.section .wrap-media { max-width: 880px; }
#results .wrap-media { max-width: var(--w-media); }

/* Vertical rhythm between figures inside a media band — one beat (48px)
   everywhere, whether figures are siblings or rows of a grid.
   (:not(:first-child) outranks the `.media { margin: 0 }` reset.) */
.wrap-media > :not(:first-child) { margin-top: 48px; }

/* The mono "instrument" label voice, reused everywhere */
.sec-eyebrow,
.cap-label,
.hook-sub,
.authors,
.venue,
.hero-eyebrow,
.quote cite,
.footer-note,
.nav-links a,
.nav-brand {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------------- Nav ---------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 13, 16, 0.88);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--dark-line);
}

.nav-inner {
  max-width: var(--w-media);
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-brand {
  color: var(--dark-ink);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.16em;
}

.nav-links {
  display: flex;
  gap: 26px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  color: var(--dark-muted);
  text-decoration: none;
  font-size: 11px;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  transition: color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.is-active { color: var(--dark-ink); }

.nav-i {
  font-size: 10px;
  color: var(--accent-bright);
  opacity: 0.75;
}

/* Reading-progress hairline (element injected by js/nav.js) */
.nav-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 2px;
  background: var(--accent-bright);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

/* ---------------- Hero (engineering drafting sheet) ----------------
   A compact title block on dotted drafting paper; the promo video
   is the hero piece, embedded across the hero's bottom seam so it
   is almost fully visible at first glance. */
.hero {
  max-width: min(1200px, calc(100% - 40px));
  margin: 22px auto 0;
  background-color: var(--paper);
  /* fine dot lattice — quieter than ruled gridlines */
  background-image: radial-gradient(circle, rgba(21, 23, 26, 0.11) 1px, transparent 1.4px);
  background-size: 26px 26px;
  border: 1px dashed var(--accent);
  padding: clamp(28px, 4vh, 44px) 0 clamp(28px, 3.5vw, 44px);
  text-align: center;
}

.hero-inner {
  max-width: var(--w-media);
  margin: 0 auto;
  padding: 0 24px 6px;
}

/* The promo sits fully inside the hero plate */
.hero .hero-media {
  max-width: 1088px;
  margin: 16px auto 0;
  padding: 0 24px;
}

.title {
  font-family: var(--display);
  font-size: clamp(48px, 5.8vw, 76px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 0.9;
  color: var(--ink);
  margin: 0;
}

.subtitle {
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink);
  max-width: 76ch;
  margin: 14px auto 24px;
}

.subtitle .acro {
  color: var(--ink);
  font-weight: 600;
}

/* Drafting-sheet nameplate around the author block, with
   registration ticks in the corners */
.plate {
  position: relative;
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 10px 30px;
}

.plate::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background:
    linear-gradient(var(--accent), var(--accent)) left top / 9px 1px,
    linear-gradient(var(--accent), var(--accent)) left top / 1px 9px,
    linear-gradient(var(--accent), var(--accent)) right top / 9px 1px,
    linear-gradient(var(--accent), var(--accent)) right top / 1px 9px,
    linear-gradient(var(--accent), var(--accent)) left bottom / 9px 1px,
    linear-gradient(var(--accent), var(--accent)) left bottom / 1px 9px,
    linear-gradient(var(--accent), var(--accent)) right bottom / 9px 1px,
    linear-gradient(var(--accent), var(--accent)) right bottom / 1px 9px;
  background-repeat: no-repeat;
}

.authors {
  color: var(--ink);
  margin: 0;
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.authors sup,
.venue sup {
  font-size: 9px;
  color: var(--accent);
}

.venue {
  color: var(--muted);
  margin: 7px 0 0;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.03em;
}

.affil-note { margin-top: 4px; }

/* Staggered hero reveal */
.hero-inner > *,
.hero .hero-media {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.7s cubic-bezier(0.22, 0.7, 0.25, 1) forwards;
}

.title { animation-delay: 0.05s; }
.subtitle { animation-delay: 0.15s; }
.plate { animation-delay: 0.25s; }
.hero .hero-media { animation-delay: 0.35s; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

.hero-media video {
  border: 1px solid var(--line);
  background: var(--dark-1);
}

.media.hero-media figcaption {
  display: block;
  border-top: 0;
  text-align: center;
  max-width: 72ch;
  margin: 22px auto 0;
  padding-top: 0;
}

/* ---------------- Sections ---------------- */
.section {
  position: relative;
  padding: clamp(72px, 9vw, 120px) 0 0;
}

/* Body text sits on its own dashed-bordered sheet of white so it
   never tangles with the drifting sketch behind. Video captions
   stay outside on purpose. */
.section .wrap-content {
  background: rgba(255, 255, 255, 0.93);
  border: 1px dashed #c9c4ba;
  padding: 26px 36px 32px;
}

/* In Results the text sheet runs as wide as the chart band */
#results .wrap-content { max-width: var(--w-media); }

/* The drafting-sheet ghost: one sketch at a time, fixed to the
   viewport behind ALL content (z-index -1 — videos, chart panels,
   hero and footer always cover it) and enlarged to fill the bounds.
   Every few seconds js/nav.js slides the next sheet in along a
   diagonal while the current one slides out. */
.sheet-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.sheet-bg-layer {
  position: absolute;
  inset: -7%;
  background-repeat: no-repeat;
  background-position: left 8% center; /* per-slide: js alternates left / right */
  background-size: clamp(320px, 52vw, 860px) auto; /* whole drawing stays visible */
  mix-blend-mode: multiply;
  opacity: 0;
  transform: translate(5%, 4%);
  transition: opacity 2.4s ease, transform 2.4s ease;
  will-change: transform, opacity;
}

.sheet-bg-layer.is-entering {
  transition: none;
  opacity: 0;
  transform: translate(5%, 4%);
}

.sheet-bg-layer.is-active {
  opacity: 0.095;
  transform: translate(0, 0);
}

.sheet-bg-layer.is-leaving {
  opacity: 0;
  transform: translate(-5%, -4%);
}

.section:last-of-type {
  padding-bottom: clamp(88px, 10vw, 140px);
}

.sec-head {
  padding-top: 0;
}

.sec-eyebrow {
  display: flex;
  gap: 14px;
  margin: 0;
  color: var(--muted);
}

.sec-index { color: var(--accent); }

.sec-head h2 {
  font-size: clamp(30px, 3.5vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 16px 0 0;
  text-wrap: balance;
}

.prose {
  max-width: var(--w-prose);
  margin: 22px 0 0;
}

.wrap-content + .wrap-media { margin-top: 48px; }

/* ---------------- Epigraph (01 · Approach) ---------------- */
.quotes {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 760px;
  gap: clamp(36px, 5vw, 72px);
  margin: 56px 0;
}

.quote {
  position: relative;
  margin: 0;
  padding-top: 44px;
}

.quote::before {
  content: "\201C";
  position: absolute;
  top: -10px;
  left: -6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 110px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.16;
  pointer-events: none;
}

.quote p {
  font-family: var(--sans);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(20px, 2.2vw, 24px);
  line-height: 1.45;
  color: var(--ink);
  margin: 0 0 20px;
}

.quote cite {
  display: block;
  position: relative;
  padding-top: 14px;
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.quote cite::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 1px;
  background: var(--accent);
}

.lede {
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.75;
  max-width: var(--w-prose);
  margin: 0;
}

.lede strong {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

/* ---------------- Media + captions ---------------- */
.media {
  margin: 0;
}

.media video,
.media img {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border-radius: 2px;
}

/* Captions lead the figure: a mono label line, then a reading-size
   description in ink, then the video below. */
.media figcaption {
  margin: 0 0 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
}

.cap-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  margin-bottom: 8px;
  transition: color 0.2s ease;
}

.cap-label::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--accent);
}

.media:hover .cap-label { color: var(--accent); }

.cap-text {
  display: block;
  max-width: 75ch;
}

.cap-text strong {
  color: var(--ink);
  font-weight: 600;
}

/* Chart figures keep the classic figure-caption below, in the
   quieter reference style */
.media.chart figcaption {
  margin: 18px 0 0;
  padding-top: 14px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 6px 28px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
}

.media.chart .cap-label { margin-bottom: 0; }
.media.chart .cap-label::before { content: none; }
.media.chart .cap-text { max-width: none; }

/* ---------------- Custom video player ---------------- */
.player {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  background: #000;
  line-height: 0;
}

/* Centered play affordance while paused */
.player::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9.5 6.8v10.4l8.6-5.2z' fill='white'/></svg>") center / 26px no-repeat,
    rgba(11, 13, 16, 0.48);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 1;
}

.player.is-paused::before {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.player video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0;
  cursor: pointer;
}

.vc {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  line-height: normal;
}

/* Reveal on hover, while scrubbing, or whenever the video is paused. */
.player:hover .vc,
.player.is-scrubbing .vc,
.player.is-paused .vc,
.player:focus-within .vc {
  opacity: 1;
  transform: translateY(0);
}

.vc-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.vc-btn:hover { background: rgba(255, 255, 255, 0.18); }
.vc-btn svg { width: 100%; height: 100%; fill: currentColor; }

.vc-track {
  position: relative;
  flex: 1 1 auto;
  height: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

/* The visible rail is a thin bar centered in the taller hit area. */
.vc-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.vc-buffered,
.vc-played {
  position: absolute;
  left: 0;
  height: 3px;
  pointer-events: none;
}

.vc-buffered { background: rgba(255, 255, 255, 0.35); width: 0; }
.vc-played { background: var(--accent-bright); width: 0; }

.vc-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 11px;
  margin-left: -5px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%) scale(0);
  transition: transform 0.12s ease;
  pointer-events: none;
}

.vc-track:hover .vc-thumb,
.player.is-scrubbing .vc-thumb { transform: translateY(-50%) scale(1); }

.vc-track:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.vc-time {
  flex: 0 0 auto;
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .vc-time { font-size: 11px; }
  .vc { gap: 7px; }
}

/* ---------------- Grid (task videos) ---------------- */
.grid {
  display: grid;
  gap: 48px 32px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-1 { grid-template-columns: 1fr; }

.grid > .media { margin: 0; }

/* ---------------- Result charts ---------------- */
.media.chart {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 28px 28px 20px;
}

.figrow {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chart-panel {
  min-width: 0; /* allow flex children to shrink below content size */
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--mono);
}

/* SVG text roles */
.chart-svg .ptitle {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: var(--ink);
}
.chart-svg .ylabel { font-size: 10px; fill: #5b6168; }
.chart-svg .tick   { font-size: 9px;  fill: #5b6168; }
.chart-svg .vlabel { font-size: 10px; }

/* Legend block (fig2 / fig3) */
.chart-legend {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 4px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
}

.leg-row { display: flex; align-items: center; gap: 7px; }

.leg-swatch {
  width: 15px;
  height: 11px;
  flex: 0 0 auto;
  border: 1px solid;
  border-radius: 1px;
}

.leg-label { color: var(--muted); white-space: nowrap; }

.leg-note {
  margin-top: 4px;
  font-size: 10px;
  font-style: italic;
  color: var(--muted);
}

/* --- Bar-growth animation (triggered by .run on .figrow) --- */
.chart-svg .bar {
  transform: scaleY(0);
  transform-box: fill-box;
  transform-origin: bottom;
  transition: transform 0.52s cubic-bezier(0.22, 0.7, 0.25, 1);
}
.chart-svg .err,
.chart-svg .vlabel {
  opacity: 0;
  transition: opacity 0.28s ease;
}
.figrow.run .chart-svg .bar { transform: scaleY(1); }
.figrow.run .chart-svg .err,
.figrow.run .chart-svg .vlabel { opacity: 1; }

/* End-of-document mark, echoing the hero eyebrow square */
.endmark {
  width: 7px;
  height: 7px;
  background: var(--accent);
  margin: clamp(72px, 9vw, 112px) auto 0;
}

/* ---------------- Footer (dark bookend) ---------------- */
.footer {
  background-color: var(--dark-0);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncA type='linear' slope='0.05'/></feComponentTransfer></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
    linear-gradient(var(--dark-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--dark-grid) 1px, transparent 1px);
  background-size: 160px 160px, 96px 96px, 96px 96px;
  border-top: 1px solid var(--dark-line);
  padding: 88px 0 72px;
}

.footer-inner {
  max-width: var(--w-media);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px 48px;
  flex-wrap: wrap;
}

.footer-brand {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--dark-ink);
  margin: 0;
}

.footer-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.footer-links a {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dark-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-links a:hover { color: var(--dark-ink); }

.footer-links a span {
  color: var(--accent-bright);
  opacity: 0.75;
  margin-right: 7px;
  font-size: 10px;
}

.footer-note {
  color: var(--dark-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin: 0;
  max-width: 64ch;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 960px) {
  .media.chart figcaption {
    grid-template-columns: 1fr;
    gap: 4px;
  }

}

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .quotes { grid-template-columns: 1fr; margin: 44px 0; }

  .nav-inner { gap: 16px; }
  .nav-links { gap: 18px; }
  .nav-i { display: none; }

  .wrap-media > :not(:first-child) { margin-top: 40px; }
  .grid { gap: 40px 32px; }
  .section .wrap-content { padding: 18px 20px 24px; }
  .media.chart { padding: 16px 16px 14px; }

  /* Stack chart panels vertically on narrow screens */
  .figrow {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }
  .chart-panel { flex: 1 1 auto !important; }
  .chart-svg { max-width: 440px; margin: 0 auto; }
  .chart-legend {
    flex-flow: row wrap;
    justify-content: center;
    align-self: stretch;
    gap: 6px 16px;
    padding-left: 0;
  }
  .leg-note { flex-basis: 100%; text-align: center; margin-top: 0; }
}

@media (max-width: 480px) {
  .footer { padding: 64px 0 56px; }
  .footer-brand { font-size: 28px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 22px; }
  .plate { padding: 14px 28px; }
  .player::before { width: 48px; height: 48px; background-size: 20px, auto; }
}

/* ---------------- Scroll reveals (class added by js/nav.js) ---------------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 0.7, 0.25, 1);
}

.reveal.is-in {
  opacity: 1;
  transform: none;
}

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

  .sheet-bg-layer { transition: none; }

  .hero-inner > *,
  .hero .hero-media {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .chart-svg .bar { transform: none; transition: none; }
  .chart-svg .err,
  .chart-svg .vlabel { opacity: 1; transition: none; }
}
