/* ==========================================================================
   sections — hero → house → drum → lie → course → table → floor → contact
   ==========================================================================

   Two rules run through the whole file and are worth stating once.

   minmax(0, 1fr) rather than 1fr, everywhere a canvas or a <pre> lives in a
   grid. A grid item's default min-width is min-CONTENT, so one wide child
   pushes its column past the viewport and drags the entire page sideways.

   isolation: isolate on anything with a z-index:-1 pseudo-element fill. A
   negative z-index escapes to the nearest stacking context, and if the
   element does not make one the fill lands behind the page background —
   where it is invisible, and takes the label's contrast with it.
   ========================================================================== */

/* ── hero ──────────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  display: grid;
  align-content: end;
  gap: clamp(1.1rem, 3vh, 2.2rem);
  padding: calc(var(--gut) * 2 + 3rem) var(--gut) clamp(1.4rem, 4vh, 2.6rem);
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: grayscale(0.72) contrast(1.06) brightness(0.5);
}

/* The chart footage is warm and busy; the type sits on top of it. Two stops
   are not enough — a single top-to-bottom ramp leaves the middle of the
   frame, where the title actually is, at full noise. */
.hero__veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom,
      var(--ink) 0%, rgba(13, 20, 24, 0.55) 26%,
      rgba(13, 20, 24, 0.72) 58%, var(--ink) 96%),
    radial-gradient(120% 70% at 20% 90%, rgba(13, 20, 24, 0.85), transparent 70%);
}

.hero__eyebrow { display: flex; align-items: center; flex-wrap: wrap; }

.hero__title {
  font-family: var(--f-display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 96;
  font-weight: 500;
  font-size: var(--t-hero);
  line-height: 0.92;
  letter-spacing: -0.02em;
}

.hero__em { font-style: italic; color: var(--magenta); }

.hero__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(1rem, 3vw, 3rem);
  padding-top: clamp(0.7rem, 2vh, 1.2rem);
  border-top: 1px solid var(--line-2);
}

.hero__sub { max-width: 52ch; color: var(--paper-2); }
.hero__cue { display: flex; align-items: center; gap: 0.8em; }

.hero__cue-rule {
  position: relative;
  display: block;
  width: clamp(40px, 8vw, 90px);
  height: 1px;
  background: var(--line-2);
  overflow: hidden;
}

/* A needle swinging and settling, rather than a bar filling. */
.hero__cue-rule::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--magenta);
  transform-origin: left;
  animation: swing 2.9s var(--set) infinite;
}

@keyframes swing {
  0%   { transform: scaleX(0); transform-origin: left; }
  45%  { transform: scaleX(1); transform-origin: left; }
  55%  { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* ── the house ─────────────────────────────────────────────────────────── */

.house { padding: var(--sec) var(--gut); display: grid; gap: clamp(2.5rem, 7vh, 5rem); }

.house__body {
  max-width: 30ch;
  font-family: var(--f-display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 72;
  font-weight: 400;
  font-size: clamp(1.7rem, 4.2vw, 3.6rem);
  line-height: 1.12;
  letter-spacing: -0.012em;
}

.house__grid { display: grid; gap: clamp(1.6rem, 4vw, 3.2rem); grid-template-columns: minmax(0, 1fr); max-width: 1100px; }
@media (min-width: 760px) { .house__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.house__grid p { color: var(--paper-2); max-width: 36ch; }

.house__h {
  margin-bottom: 0.7rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--magenta);
  color: var(--magenta);
}

/* ── the drum ──────────────────────────────────────────────────────────── */

.drum {
  padding: var(--sec) var(--gut);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.8rem, 4.5vh, 3rem);
}

.drum__head { display: grid; gap: clamp(0.9rem, 2.4vh, 1.6rem); max-width: 66ch; }

.drum__h, .lie__h, .course__h, .table__h {
  font-family: var(--f-display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 96;
  font-weight: 500;
  font-size: var(--t-h2);
  line-height: 1;
  letter-spacing: -0.018em;
}

.drum__lead, .lie__lead, .course__lead, .table__lead {
  max-width: 62ch;
  color: var(--paper-2);
  font-size: var(--t-lead);
  line-height: 1.42;
}

/* Heading and lead side by side once there is room for it.
   Stacked, a display heading plus six lines of lead is five hundred pixels
   of head before the panel starts — on a laptop the interactive that the
   section exists for begins below the fold, and the entire right half of the
   screen is empty while that happens. Setting them as a spread costs nothing
   and puts the thing you are meant to touch on the first screen. */
@media (min-width: 1000px) {
  .drum__head, .lie__head, .course__head, .table__head {
    max-width: none;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    column-gap: clamp(2rem, 5vw, 5rem);
    align-items: end;
  }

  .drum__head > .meta, .lie__head > .meta, .course__head > .meta, .table__head > .meta {
    grid-column: 1 / -1;
  }

  .drum__lead, .lie__lead, .course__lead, .table__lead {
    grid-column: 2;
    grid-row: 2;
    max-width: 46ch;
    font-size: clamp(1rem, 1.15vw, 1.18rem);
    line-height: 1.55;
  }
}

.drum__panel, .lie__panel, .course__panel {
  display: grid;
  min-width: 0;
  gap: clamp(1rem, 2.6vh, 1.7rem);
  padding: clamp(0.9rem, 2.4vw, 1.8rem);
  background: var(--ink-2);
  border: 1px solid var(--line);
}

.drum__controls {
  display: grid;
  gap: clamp(0.8rem, 2vw, 1.6rem);
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: clamp(0.7rem, 1.8vh, 1.1rem);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) { .drum__controls { grid-template-columns: minmax(0, 1fr) auto; align-items: end; } }

.ctrl { display: grid; gap: 0.5rem; min-width: 0; }
.ctrl--right { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: flex-end; }
.ctrl__k { color: var(--paper-3); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chips button, .toggle {
  padding: 0.42em 0.85em;
  border: 1px solid var(--line-2);
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-3);
  transition: color 0.35s var(--swing), border-color 0.35s var(--swing),
              background-color 0.35s var(--swing);
}

.chips button:hover, .toggle:hover { color: var(--paper); border-color: var(--paper-3); }

.chips button.is-on, .toggle.is-on {
  background: var(--magenta);
  border-color: var(--magenta);
  color: #fff;
}

/* ── the drum stage ────────────────────────────────────────────────────── */

.drum__stage {
  display: grid;
  gap: clamp(0.9rem, 2.2vw, 1.6rem);
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

@media (min-width: 980px) {
  .drum__stage { grid-template-columns: minmax(0, 1fr) minmax(0, 20rem); align-items: start; }
}

.pane { margin: 0; display: grid; gap: 0.55rem; min-width: 0; }

.pane__cap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

.pane canvas {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  background: var(--ink);
  border: 1px solid var(--line);
  /* The drag has to work without stealing the page scroll. pan-y keeps a
     vertical swipe scrolling and hands a horizontal one to the map, which is
     the right split: the world turns left and right far more than up. */
  touch-action: pan-y;
}

/* The drum's aspect ratio is set from the projection's own extent in JS, so a
   Mercator is square, a Mollweide is a 2:1 ellipse and an orthographic is a
   circle in a square. This is the fallback for the first frame only — locking
   it at 16:9 leaves a square projection floating in half an empty canvas, and
   the SHAPE of a projection is half of what distinguishes it. */
.pane--map canvas { cursor: grab; aspect-ratio: 16 / 10; }
.pane--map canvas:active { cursor: grabbing; }
.pane--lie canvas { aspect-ratio: 16 / 7; }
.pane__hint { color: var(--paper-4); }

.key {
  display: inline-block;
  width: 10px; height: 3px;
  margin-right: 0.45em;
  vertical-align: 3px;
}

.key--rhumb { background: var(--magenta); }
.key--gc { background: var(--gc); margin-left: 0.6em; }

/* ── the verdict panel ─────────────────────────────────────────────────── */

.verdict {
  display: grid;
  gap: clamp(0.7rem, 1.8vh, 1.1rem);
  align-content: start;
  padding: clamp(0.9rem, 2vw, 1.2rem);
  background: var(--ink);
  border: 1px solid var(--line);
}

.verdict__blurb { color: var(--paper-2); font-size: 0.97rem; line-height: 1.5; min-height: 4.5em; }
.verdict__rows { display: grid; gap: 0; }

.vrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}

.vrow dt { flex: 1 1 auto; min-width: 0; }
/* nowrap because these are numeric ranges: "0.00° – 134.17°" broken over two
   lines reads as two separate figures. The label wraps instead. */
.vrow dd { flex: 0 0 auto; text-align: right; font-size: 0.98rem; white-space: nowrap; }

/* Magenta is the measured colour, so it marks the measured rows and nothing
   else. The two rows above these were read off a label. */
.vrow--calc dd { color: var(--magenta); font-family: var(--f-mono); font-size: 0.9rem; }
.vrow--calc dt { color: var(--magenta-2); }

.verdict__note { color: var(--paper-4); letter-spacing: 0.07em; line-height: 1.7; }

.drum__spec { border-top: 1px solid var(--line); padding-top: 1rem; }
.drum__spec summary { cursor: pointer; color: var(--paper-3); transition: color 0.3s var(--swing); }
.drum__spec summary:hover { color: var(--magenta); }
.drum__spec > * + * { margin-top: 0.9rem; }
.drum__spec p { color: var(--paper-3); font-size: 0.95rem; max-width: 66ch; }

.drum__spec pre {
  margin: 0;
  padding: 0.8rem 1rem;
  background: var(--ink);
  border-left: 2px solid var(--magenta);
  overflow-x: auto;
}

.drum__spec code { color: var(--paper-2); white-space: pre; }
.drum__spec p code { background: var(--ink); padding: 0.1em 0.35em; }

/* ── Greenland ─────────────────────────────────────────────────────────── */

.lie, .course, .table { padding: var(--sec) var(--gut); display: grid; gap: clamp(1.8rem, 4.5vh, 3rem); grid-template-columns: minmax(0, 1fr); }
.lie__head, .course__head, .table__head { display: grid; gap: clamp(0.9rem, 2.4vh, 1.6rem); max-width: 66ch; }

.chips--wide { gap: 0.4rem; }

.lie__stats, .course__stats {
  display: grid;
  gap: 0.6rem clamp(1rem, 3vw, 2.4rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  padding-top: clamp(0.7rem, 1.8vh, 1.1rem);
  border-top: 1px solid var(--line);
}

.stat { display: grid; gap: 0.2rem; }
.stat__k { color: var(--paper-3); }
.stat__v { font-family: var(--f-mono); font-size: clamp(1rem, 2vw, 1.35rem); color: var(--magenta); }
.stat__v--plain { color: var(--paper); }
.stat__n { color: var(--paper-4); font-size: 0.8rem; letter-spacing: 0.06em; }

.lie__kicker, .course__kicker {
  max-width: 60ch;
  font-family: var(--f-display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 48;
  font-size: clamp(1.15rem, 2.2vw, 1.7rem);
  line-height: 1.28;
  color: var(--paper);
}

.lie__kicker b { color: var(--magenta); font-weight: 500; font-style: italic; }
.course__kicker em { color: var(--magenta); }

/* ── the course ────────────────────────────────────────────────────────── */

.course__pair { display: grid; gap: clamp(0.9rem, 2.2vw, 1.6rem); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .course__pair { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); } }
.course__pair .pane:last-child canvas { aspect-ratio: 1; }

/* ── the table ─────────────────────────────────────────────────────────── */

.table__list { display: grid; gap: clamp(0.8rem, 2vw, 1.4rem); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }

.card {
  display: grid;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  align-content: start;
  padding: 0.7rem;
  border: 1px solid var(--line);
  background: var(--ink-2);
  transition: transform 0.4s var(--swing), border-color 0.4s var(--swing);
}

.card:hover { transform: translateY(-3px); border-color: var(--paper-4); }
.card.is-on { border-color: var(--magenta); }
.card canvas { width: 100%; aspect-ratio: 16 / 10; display: block; background: var(--ink); }

.card__t {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 1.04rem;
  line-height: 1.2;
}

.card__t em { font-style: normal; font-family: var(--f-mono); font-size: 0.68rem; color: var(--paper-4); letter-spacing: 0.1em; }
.card:hover .card__t { color: var(--magenta); }

.card__v {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.7rem;
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-4);
}

.card__v b { font-weight: 400; color: var(--magenta); }

/* ── the floor ─────────────────────────────────────────────────────────── */

.floor { padding: 0 var(--gut) var(--sec); display: grid; gap: clamp(2rem, 5vh, 3.5rem); }

.band { display: grid; gap: clamp(1rem, 2.4vw, 1.8rem); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .band { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.band__item { display: grid; gap: 0.45rem; align-content: start; }

.band__item video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--ink-2);
  filter: grayscale(0.6) contrast(1.05);
  transition: filter 0.6s var(--swing);
}

.band__item:hover video { filter: grayscale(0) contrast(1); }

.band__t {
  margin-top: 0.3rem;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  line-height: 1.15;
}

/* ── contact ───────────────────────────────────────────────────────────── */

.contact { padding: var(--sec) var(--gut); display: grid; gap: clamp(1.6rem, 4.5vh, 3rem); }

.contact__h {
  font-family: var(--f-display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 96;
  font-weight: 500;
  font-size: var(--t-hero);
  line-height: 0.92;
  letter-spacing: -0.02em;
}

.contact__em { font-style: italic; color: var(--magenta); }

.rows { display: grid; max-width: 900px; }
.rows li { border-top: 1px solid var(--line); }
.rows li:last-child { border-bottom: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1rem;
  padding: clamp(0.85rem, 2.4vh, 1.35rem) 0;
  transition: color 0.4s var(--swing);
}

@media (max-width: 620px) { .row { grid-template-columns: 5.5rem minmax(0, 1fr) auto; } }

.row__v { font-size: clamp(1.05rem, 2.2vw, 1.6rem); }

/* Label and value translate; the arrow holds. Shifting the whole row would
   carry the arrow past the section edge, and animating padding would lay the
   row out again on every frame. */
.row__k, .row__v { transition: transform 0.5s var(--swing); }
a.row:hover { color: var(--magenta); }
a.row:hover .row__k, a.row:hover .row__v { transform: translateX(0.7rem); }

.row__a { color: var(--paper-4); transition: color 0.4s var(--swing), transform 0.5s var(--swing); }
a.row:hover .row__a { color: var(--magenta); transform: translate(0.2rem, -0.2rem); }

/* ── footer ────────────────────────────────────────────────────────────── */

.foot {
  padding: clamp(2rem, 6vh, 4rem) var(--gut) clamp(1.5rem, 4vh, 2.5rem);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1.2rem;
}

.foot__row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.6rem 2rem; }
.foot__note { max-width: 74ch; color: var(--paper-4); letter-spacing: 0.07em; }

[data-rise] { will-change: transform, opacity; }
