/* /data — vehicle recall explorations.
   Palette is the validated default from the dataviz skill, checked against this
   site's own surfaces (#fafafa light, #1a1a1a dark) at 3 and 7 slots. In light
   mode aqua/yellow/magenta sit below 3:1 on the surface, so the relief rule
   applies: every chart ships direct labels and a table view. Don't re-step these
   hexes without re-running scripts/validate_palette.js. */

.viz-root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --hairline: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5;
  --seq-550: #1c5cab; --seq-700: #0d366b;
  --warn: #ec835a;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --hairline: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}

/* The site's main column is 640px; charts need the room. */
.viz-wide { max-width: 900px; margin: 0 auto; }
main:has(.viz-wide) { max-width: none; }

.viz-head { margin-bottom: 2rem; }
.viz-head h1 { margin: 0 0 .5rem; line-height: 1.2; }
.viz-lede { font-size: 1.05rem; color: var(--ink-2); }
.viz-q { color: var(--ink-muted); font-style: italic; margin: 0 0 .75rem; }
.viz-crumb { font-size: .85rem; margin-bottom: 1.5rem; }

.viz-callout {
  border-left: 3px solid var(--warn);
  padding: .6rem .9rem;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  font-size: .92rem;
}

/* AI disclosure. Sits above the charts and is meant to be read before them, so
   it gets more weight than .viz-callout — but not so much that it reads as a
   warning about the subject matter rather than about the method. */
.viz-disclosure {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--s1);
  border-radius: 8px;
  background: color-mix(in srgb, var(--s1) 5%, transparent);
  padding: 1rem 1.2rem;
  margin: 0 0 2.5rem;
}
.viz-disclosure p { margin: 0; font-size: .92rem; }
.viz-disclosure-tag {
  font-size: .72rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--s1); margin-bottom: .4rem !important;
}

/* Reference data — one block per section, at the foot of it. */
.viz-sources { margin: 1rem 0 0; padding-top: 1.5rem;
  border-top: 1px solid var(--hairline); }
.viz-sources h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.viz-sources ul { list-style: none; padding: 0; margin: 1rem 0 0; display: grid;
  gap: .8rem; }
.viz-sources li { display: grid; gap: .15rem; }
.viz-sources a { font-size: .92rem; }
.viz-sources .viz-note { margin: 0; }

/* Landing cards */
.viz-cards { list-style: none; padding: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.viz-card a {
  display: block; height: 100%; padding: 1.1rem 1.2rem;
  border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--surface-1); color: inherit; text-decoration: none;
}
.viz-card a:hover { border-color: var(--s1); }
.viz-card h2 { margin: 0 0 .35rem; font-size: 1.1rem; }
.viz-card.is-lead { grid-column: 1 / -1; }
.viz-card.is-lead h2 { font-size: 1.35rem; }
.viz-sum { font-size: .9rem; color: var(--ink-2); margin: 0; }
.viz-caveat { font-size: .8rem; color: var(--warn); margin: .5rem 0 0; }
.viz-foot { margin-top: 2.5rem; }

/* Controls */
.viz-controls {
  display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center;
  padding: .75rem 0; border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline); margin-bottom: 1.5rem;
  font-size: .88rem;
}
.viz-controls fieldset { border: 0; padding: 0; margin: 0; display: flex;
  gap: .75rem; align-items: center; }
.viz-controls legend { float: left; margin-right: .6rem; color: var(--ink-muted); }
.viz-controls label { display: inline-flex; gap: .3rem; align-items: center;
  cursor: pointer; }

/* Figures */
.viz-figure { margin: 0 0 3rem; }
.viz-figcaption { margin-bottom: .75rem; }
.viz-figcaption h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.viz-figcaption p { margin: 0; font-size: .88rem; color: var(--ink-2); }
.viz-plot { position: relative; }
.viz-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
/* Wide charts (the 40-column component heatmap) scroll inside their own figure
   rather than shrinking labels to nothing or pushing the page sideways. */
.viz-plot.is-scrollable { overflow-x: auto; overflow-y: hidden; }
.viz-plot.is-scrollable svg { height: auto; }
.viz-plot text { font-family: inherit; }

.viz-legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem;
  margin-top: .6rem; font-size: .8rem; color: var(--ink-2); }
.viz-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

.viz-table { margin-top: .75rem; font-size: .82rem; }
.viz-table summary { cursor: pointer; color: var(--ink-muted); }
.viz-table-body { overflow-x: auto; margin-top: .5rem; }
.viz-table table { border-collapse: collapse; width: 100%;
  font-variant-numeric: tabular-nums; }
.viz-table th, .viz-table td { text-align: left; padding: .2rem .6rem .2rem 0;
  border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.viz-note { font-size: .82rem; color: var(--ink-muted); margin: .5rem 0 0; }

/* Tooltip */
.viz-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 6px; padding: .45rem .6rem; font-size: .8rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12); max-width: 260px;
  font-variant-numeric: tabular-nums;
}
.viz-tip[hidden] { display: none; }
.viz-tip b { display: block; margin-bottom: .2rem; }

.viz-next { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .88rem;
  border-top: 1px solid var(--hairline); padding-top: 1rem; }

@media (max-width: 600px) {
  .viz-controls { gap: .75rem; }
  .viz-card.is-lead h2 { font-size: 1.15rem; }
}

/* Long topic page: in-page nav, sticky controls, section rhythm. */
.viz-jump { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .85rem;
  margin: 0 0 1.5rem; }
.viz-topic-section { margin-bottom: 3rem; }
.viz-section-heading { margin: 2rem 0 .5rem; font-size: 1.5rem; }
.viz-section { margin: 0 0 3.5rem; padding-top: 1.5rem;
  border-top: 1px solid var(--hairline); scroll-margin-top: 5rem; }
.viz-section-title { margin: 0 0 .35rem; font-size: 1.25rem; }
.viz-controls.is-sticky { position: sticky; top: 0; z-index: 10;
  background: var(--bg, var(--page)); backdrop-filter: blur(6px); }
