/*
 * Type: Concourse carries everything functional, from real files only (3 and 4
 * regular, 3 and 4 bold); the wordmark alone uses Valkyrie A bold, the face
 * the critique panel picked over Advocate 34 narrow (ISA Decisions).
 * font-synthesis is off so no weight is ever faked.
 */
@font-face {
  font-family: "Concourse";
  src: url("/fonts/concourse_3_regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Concourse";
  src: url("/fonts/concourse_4_regular.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Concourse";
  src: url("/fonts/concourse_3_bold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Concourse";
  src: url("/fonts/concourse_4_bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Valkyrie";
  src: url("/fonts/valkyrie_a_bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #000000;
  --ink: #ededea;
  --ink-soft: #b3b3ae;
  --muted: #b0b0ab;
  --faint: #6c6c68;
  --rule: rgba(255, 255, 255, 0.075);
  --rule-v: rgba(255, 255, 255, 0.05);
  --surface: #0b0b0b;
  --surface-raised: #161616;
  --line: #262626;
  --focus: #ffffff;
  --face: "Concourse", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  --display: "Valkyrie", "Concourse", ui-sans-serif, sans-serif;
  --display-weight: 700;
  --display-size: 31px;
  --display-track: -0.01em;
  --switch: cubic-bezier(0.33, 0, 0.15, 1);
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
}

body {
  font-family: var(--face);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.page {
  display: flex;
  flex-direction: column;
  height: 100svh;
  min-height: 600px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 36px 18px;
}

/* Header band: wordmark and caption left, controls right, at most 80px tall. */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  min-height: 56px;
  max-height: 80px;
}

.brand { min-width: 0; }

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-weight: var(--display-weight);
  font-size: var(--display-size);
  letter-spacing: var(--display-track);
  line-height: 1;
  color: var(--ink);
}

.caption {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.3;
  color: var(--ink-soft);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.chart:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.picker-placeholder {
  color: var(--muted);
  font-size: 14px;
  padding: 0 12px;
}

/* Model picker */
.picker { position: relative; }

.picker-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 14px 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: border-color 160ms ease-out, background-color 160ms ease-out;
}

.picker-button:hover,
.picker-button[aria-expanded="true"] {
  border-color: #3a3a3a;
  background: var(--surface-raised);
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}

.chevron {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease-out;
}

.picker-button[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.picker-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: min(72svh, 600px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0a0a0a;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.picker-panel[hidden] { display: none; }

.picker-tools {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line);
}

.picker-filter {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.picker-filter::placeholder { color: var(--faint); }

.picker-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 7px;
  min-height: 32px;
}

.text-button:hover { color: var(--ink); background: var(--surface-raised); }

.picker-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 10px;
}

.lab-group + .lab-group { border-top: 1px solid #161616; }

.lab-name {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.lab-count {
  margin-left: auto;
  font-weight: 400;
  color: var(--muted);
}

.lab-group ul { list-style: none; margin: 0; padding: 0 6px; }

.model-row {
  display: grid;
  grid-template-columns: 18px 28px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.model-row:hover { background: var(--surface-raised); }

.model-row input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: #ededea;
}

.sample { width: 28px; height: 10px; overflow: visible; }
.sample line { stroke: var(--c); stroke-width: 2; stroke-linecap: round; }
.sample circle { fill: var(--c); }

.model-name { color: var(--ink); }

.older-tag {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
}

.peak {
  color: var(--muted);
  font-size: 13px;
}

.picker-empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--muted);
}

/* Linear | Log: a thumb slides on the same curve and clock as the chart. */
.seg {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.seg-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: #262626;
  transition: transform 420ms var(--switch);
}

.seg[data-scale="log"] .seg-thumb { transform: translateX(100%); }

.seg button {
  position: relative;
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  transition: color 200ms ease-out;
}

.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { color: var(--ink); }

/* Chart */
.chart {
  position: relative;
  flex: 1 1 auto;
  min-height: 380px;
  margin: 10px 0 6px;
}

.chart svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

svg text { font-family: var(--face); font-variant-numeric: lining-nums tabular-nums; }

.measure { position: absolute; left: -10000px; top: 0; visibility: hidden; }

.gridline { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.gridline-v { stroke: var(--rule-v); }

.tick {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 400;
  dominant-baseline: central;
}

.tick-y { text-anchor: end; }
.tick-x { text-anchor: middle; }

.axis-title {
  fill: #b4b4af;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  font-feature-settings: "case" 1;
  dominant-baseline: central;
}

.axis-title-x { text-anchor: middle; }

.release { transition: opacity 180ms ease-out; }
.release.muted { opacity: 0.5; }

.curve {
  fill: none;
  stroke: var(--c);
  stroke-width: 2.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.casing {
  fill: none;
  stroke: var(--ground);
  stroke-width: 5.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.release.older .curve {
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: butt;
}

.release.muted .curve { stroke-width: 1.75; }

.dot {
  fill: var(--c);
  stroke: var(--ground);
  stroke-width: 1.5;
}

.label {
  fill: var(--c);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: var(--ground);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}

.label.older { font-weight: 400; }

.tag {
  fill: var(--c);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: var(--ground);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}

.leader {
  stroke: var(--c);
  stroke-width: 1;
  stroke-linecap: round;
}

svg.compact .label { font-size: 11.5px; stroke-width: 3px; }
svg.compact .tag { font-size: 10.5px; }

.label-wrap, .tag-wrap, .leader-wrap { transition: opacity 160ms ease-out; }
.label-wrap { cursor: default; }
.tag-wrap { opacity: 0.92; }
.leader-wrap { opacity: 0.6; }
.label-wrap[data-idle="0"],
.tag-wrap[data-idle="0"],
.leader-wrap[data-idle="0"] { opacity: 0; pointer-events: none; }
.tag-wrap[data-none="1"] { display: none; }

/* Focus: the active line comes forward with every effort tag; the others drop to a quarter. */
svg.focusing .release:not(.is-active) { opacity: 0.25; }
svg.focusing .release.is-active { opacity: 1; --c: var(--c-focus); }
svg.focusing .label-wrap.is-active,
svg.focusing .tag-wrap.is-active { opacity: 1; }
svg.focusing .leader-wrap.is-active { opacity: 0.9; }
svg.focusing .label-wrap[data-idle="1"]:not(.is-active),
svg.focusing .leader-wrap[data-idle="1"]:not(.is-active) { opacity: 0.5; }
svg.focusing .tag-wrap[data-idle="1"]:not(.is-active) { opacity: 0.3; }
svg.focusing .tag-wrap[data-idle="0"]:not(.is-active) { opacity: 0; }
svg.focusing .tag-wrap.under-readout { opacity: 0; }

/* Hover: dotted crosshair to both axes with value chips; a readout beside the dot. */
.crosshair { opacity: 0; pointer-events: none; transition: opacity 120ms ease-out; }
.crosshair.on { opacity: 1; }
.crosshair path { fill: none; stroke: var(--c); stroke-width: 1; stroke-dasharray: 1 3; stroke-linecap: round; opacity: 0.8; }
.chip rect { fill: var(--c); }
.chip text {
  fill: #000;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
}

.readout { pointer-events: none; opacity: 0; transition: opacity 120ms ease-out; }
.readout.on { opacity: 1; }
.readout text {
  dominant-baseline: central;
  paint-order: stroke;
  stroke: var(--ground);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.ro-name { fill: var(--c); font-size: 13px; font-weight: 600; }
.ro-step { fill: var(--ink); font-size: 12px; font-weight: 400; }
svg.compact .ro-name { font-size: 12px; }
svg.compact .ro-step { font-size: 11.5px; }

/* Reduced motion: an opacity crossfade, no positions in between. */
@keyframes cf-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes cf-in { from { opacity: 0; } to { opacity: 1; } }
.crossfade-out { animation: cf-out 180ms linear forwards; pointer-events: none; }
svg.crossfade-in > :not(.crossfade-out) { animation: cf-in 180ms linear both; }

@media (prefers-reduced-motion: reduce) {
  .seg-thumb, .release, .label-wrap, .tag-wrap, .leader-wrap, .crosshair, .readout { transition-duration: 1ms; }
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-soft);
}

.empty[hidden] { display: none; }
.empty p { margin: 0; }

.empty button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
}

.noscript {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* Footer: the legend and the source on one line. */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.foot p { margin: 0; }

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  color: var(--ink-soft);
}

.legend-hint { color: var(--muted); }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.legend svg { display: block; overflow: visible; }
.legend-dot { fill: var(--ink-soft); stroke: var(--ground); stroke-width: 1; }
.legend-dash { stroke: var(--ink-soft); stroke-width: 2; stroke-dasharray: 5 4; }

.source a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: #4a4a47;
  text-underline-offset: 3px;
}

.source a:hover { color: var(--ink); text-decoration-color: var(--ink); }

/* Phones */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .page {
    height: 100svh;
    min-height: 640px;
    padding: 14px 16px 14px;
  }
  .bar { max-height: none; gap: 12px; }
  .wordmark { font-size: calc(var(--display-size) * 0.82); }
  .caption { font-size: 13px; margin-top: 4px; }
  .controls { width: 100%; }
  .picker { flex: 1 1 auto; min-width: 0; }
  .picker-button { width: 100%; min-height: 42px; }
  .picker-count { overflow: hidden; text-overflow: ellipsis; }
  .chevron { margin-left: auto; }
  .picker-panel { left: 0; right: auto; width: calc(100vw - 32px); max-height: 64svh; }
  .seg button { min-height: 36px; padding: 0 13px; }
  .chart { flex: 1 1 auto; min-height: 330px; margin: 12px 0 8px; }
  .foot { font-size: 12.5px; gap: 8px; }
  .legend { gap: 6px 14px; }
}
