/* The bandwidth explorer. Loaded only by explorer.html; every rule is scoped
   to this page — a `.exp-` class or one of the page's own ids — so the landing
   page keeps the sheet it already has. Colour, type and radii come from
   site.css's tokens, never from a second palette.

   An alpha the palette has no token for is
   `color-mix(in srgb, var(--token) N%, transparent)`: the hue stays the token
   and only the mix is local. A pill is `--r-xl` — on a 20px badge or a 10px
   track the corner is clamped to half the box, so the round cap a `999px`
   literal bought is the one the token gives. */

/* The masthead is sticky, so an in-page anchor target lands under it, and its
   height follows the nav's wrap rather than a constant; explorer.js writes the
   measured box into this variable and the targets take their offset from it.
   The rem fallback covers a no-JS load. */
:root { --exp-masthead: 6rem; }

#main,
#own,
#top { scroll-margin-top: calc(var(--exp-masthead) + 0.5rem); }

/* A selection is painted on the ground it selects. The explorer's grounds are
   paper, band and card; the opaque wash with the ink is 10.73:1 on each, so one
   pair covers the page. */
.exp-page ::selection {
  background: var(--primary-wash);
  color: var(--ink);
}

.exp-intro { padding-top: 2.5rem; padding-bottom: 0.5rem; }

.exp-back {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 1.1rem;
  font-size: 0.875rem;
  color: var(--primary);
  border-bottom: 1px solid transparent;
}
.exp-back:hover { border-bottom-color: currentColor; }

.exp-kicker {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.exp-h1 {
  margin-top: 0.5rem;
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.032em;
}

.exp-h2 {
  margin-top: 0.15rem;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.exp-lede {
  margin-top: 1rem;
  max-width: 54rem;
  color: var(--muted);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.exp-lede-quiet { font-size: 0.9375rem; }

.exp-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.chip-link {
  color: var(--primary-deep);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  font-weight: 600;
}
.chip-link:hover { border-color: var(--primary-deep); }

/* One card per measurement */

.exp-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.exp-m {
  min-width: 0;
  padding: 1.15rem 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.exp-m-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.85rem;
}

.exp-m-title {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.012em;
}

.exp-m-id {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.exp-m-where {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.55;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.exp-m-where .sep { color: var(--muted); }

.exp-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 0.5rem;
  border-radius: var(--r-xl);
  border: 1px dashed color-mix(in srgb, var(--primary) 55%, transparent);
  background: transparent;
  color: var(--primary-deep);
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* 68ch is the note's own reading measure: the card is wide enough at a desktop
   width to run the line past 90ch, where the eye loses the return. */
.exp-note {
  margin-top: 0.6rem;
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.exp-prov {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.75rem;
  margin-top: 0.85rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xs);
  background: var(--band);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.exp-prov-tag {
  color: var(--primary-deep);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.exp-prov-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--primary-deep);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

.exp-prov-link:hover { text-decoration-color: var(--primary); }

.exp-pending-line {
  margin-top: 0.9rem;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid var(--accent);
  border-radius: var(--r-xs);
  background: var(--band);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
}

.exp-m.is-pending { background: var(--band); }

/* Controls */

.exp-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem 1.5rem;
  margin: 1.1rem 0 0.4rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}

.exp-flows {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(9.5rem, 100%), 1fr));
  gap: 0.15rem 0.9rem;
}

.exp-flows legend {
  padding: 0;
  margin-bottom: 0.3rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* A capture of dozens of streams scrolls its legend instead of wrapping into a
   column of chips taller than the chart it names. The fade at the bottom edge
   marks the cut as "more below" rather than as a clipped row. */
.exp-flows.is-many {
  max-height: 12rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: 0.25rem 0.9rem;
  padding: 0 0.25rem 0.15rem 0;
  mask-image: linear-gradient(#000 calc(100% - 1.6rem), transparent);
}

.exp-flows.is-many:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--r-xs); }

.exp-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.2rem 0.3rem;
  border-radius: var(--r-xs);
  font-size: 0.8125rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}

.exp-check:hover { background: var(--band); }

/* A lane name never wraps in a grid column: it truncates, and the swatch beside
   it still carries the colour that identifies the line. */
.exp-check > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* An unchecked lane reads as off — the row dims and its swatch drops its colour
   — so the legend states what is on the chart without a second icon. */
.exp-check:has(input:not(:checked)) { color: var(--muted); }
.exp-check:has(input:not(:checked)) .exp-swatch { opacity: 0.3; }

/* The box is drawn, not the platform's: a hairline square at reading weight
   that takes the accent's edge and tick when the lane is on. Twenty-five filled
   squares in one legend is a wall of colour; a tick and an edge carry the state
   without it. At 24px the lane's own control is a tap target. */
.exp-check input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  /* The unchecked box's edge is its only affordance, so it clears the 3:1
     non-text floor: ink at 60% over the card is 3.79:1. */
  border: 1px solid color-mix(in srgb, var(--ink) 60%, transparent);
  border-radius: 4px;
  background-color: var(--card);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}

.exp-check input:hover { border-color: var(--primary); }

.exp-check input:checked {
  border-color: var(--accent);
  background-color: var(--primary-wash);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2 4.9 8.1 9 3.7' fill='none' stroke='%23b84a10' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}

.exp-check input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.exp-swatch {
  flex: none;
  width: 15px;
  height: 3px;
  border-radius: var(--r-xs);
}

.exp-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
}

.exp-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.exp-field select,
.exp-field input {
  height: 2.5rem;
  padding: 0.2rem 0.4rem;
  /* --line is a hairline for rules, not a control edge: at 1.26:1 on paper a
     field had no boundary. Ink at 60% is 3.73:1. */
  border: 1px solid color-mix(in srgb, var(--ink) 60%, transparent);
  border-radius: var(--r-xs);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.exp-field input[type="number"] { width: 6.6rem; }

/* The UA's placeholder grey is 4.42:1 on this ground; --muted is 4.85:1. */
.exp-field input::placeholder { color: var(--muted); opacity: 1; }

.exp-field select:hover,
.exp-field input:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.exp-btn {
  height: 2.5rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  cursor: pointer;
}

.exp-btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--primary); }

/* The plot */

.exp-plotwrap {
  position: relative;
  margin-top: 0.6rem;
  min-width: 0;
}

.exp-svg {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--card);
  touch-action: pan-y;
}

.exp-svg:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.exp-plot-bg { fill: var(--card); }

.exp-grid { stroke: var(--line-soft); stroke-width: 1; }
.exp-grid-strong { stroke: var(--line); stroke-width: 1; }

.exp-ax {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--muted);
  letter-spacing: 0.01em;
}

.exp-ax-title {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--muted);
  letter-spacing: 0.04em;
}

.exp-line { fill: none; stroke-linejoin: round; stroke-linecap: round; stroke-width: 1.2; }

/* The aggregate is the envelope of every stream under it; drawn at the
   streams' weight it loses that reading. */
.exp-line.is-aggregate { stroke-width: 1.8; }

/* At a phone's width a dense capture's samples are a pixel or two apart; a
   thinner stroke keeps the trace readable instead of a solid block. */
@media (max-width: 680px) {
  .exp-line { stroke-width: 0.8; }
  .exp-line.is-aggregate { stroke-width: 1.3; }
}

.exp-cross-line { stroke: color-mix(in srgb, var(--ink) 40%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }
.exp-cross-dot { stroke: var(--card); stroke-width: 1.2; }

/* Tooltip */

.exp-tip {
  position: absolute;
  z-index: 6;
  top: 0.5rem;
  left: 0;
  min-width: 9rem;
  max-width: 15rem;
  padding: 0.5rem 0.6rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  box-shadow: var(--shadow-md);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--ink);
  pointer-events: none;
}

.exp-tip[hidden] { display: none; }

.exp-tip-head {
  display: block;
  margin-bottom: 0.3rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  letter-spacing: 0.04em;
}

.exp-tip-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
}

.exp-tip-key {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exp-tip-val { font-variant-numeric: tabular-nums; }

/* The zoom brush */

/* The brush is a drag surface and both its handles are sliders, so each is a
   24x24 target: a thumb, not only a mouse, has to land on one. */
.exp-brush {
  position: relative;
  height: 24px;
  margin: 0.55rem 0 0;
  touch-action: none;
}

.exp-brush-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 0.375rem;
  bottom: 0.375rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--band);
}

.exp-brush-dots {
  position: absolute;
  inset: 0.375rem 0;
  border-radius: var(--r-xl);
  background-image: linear-gradient(to right, color-mix(in srgb, var(--ink) 12%, transparent) 1px, transparent 1px);
  background-size: 10% 100%;
  pointer-events: none;
}

.exp-brush-band {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid color-mix(in srgb, var(--accent) 85%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--accent) 85%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: var(--r-xs);
  cursor: grab;
}

.exp-brush-band:focus-visible { outline: 2px solid var(--primary-deep); outline-offset: 2px; }

.exp-handle {
  position: absolute;
  top: 0;
  width: 24px;
  height: 24px;
  margin-left: -0.75rem;
  border-radius: var(--r-xs);
  background: var(--primary);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 25%, transparent);
  cursor: ew-resize;
  touch-action: none;
}

.exp-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 9px;
  margin: -0.28125rem 0 0 -1px;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--primary-ink) 90%, transparent);
}

.exp-handle:hover { background: var(--primary-hi); }
.exp-handle:focus-visible { outline: 2px solid var(--primary-deep); outline-offset: 2px; }

.exp-readout {
  margin-top: 0.4rem;
  min-height: 1.3em;
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.exp-hint {
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  color: var(--muted);
}

/* The numbers, in text */

.exp-tablewrap {
  margin-top: 1.15rem;
  min-width: 0;
  overflow-x: auto;
}

/* A table wide enough to scroll gets a tab stop from the script; the region is
   named for the card it belongs to, so two cards' regions stay distinguishable. */
.exp-tablewrap:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--r-xs); }

table.exp-table { table-layout: auto; }

.exp-table thead th { text-align: right; padding-bottom: 0.6rem; padding-left: 0.9rem; }
.exp-table thead th:first-child { text-align: left; padding-left: 0; }

.exp-table tbody td {
  text-align: right;
  padding: 0.7rem 0 0.7rem 0.9rem;
  font-variant-numeric: tabular-nums;
}

.exp-table tbody td.lane { text-align: left; padding-left: 0; }

.exp-table tbody td.lane { color: var(--ink); font-weight: 600; }

.exp-table tbody tr.is-off td { opacity: 0.45; }

.exp-lane-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.lane-sub {
  display: block;
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.5;
  color: var(--muted);
}

.lane-cover { color: var(--primary-deep); }

.exp-cap {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  line-height: 1.65;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.exp-cap .sep { color: var(--muted); }

.exp-status {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.exp-status:empty { display: none; }

/* The footer's links are this page's own chrome: site.css owns the component,
   the explorer sheet only raises its tap floor to 24px. */
.exp-foot .foot-list a,
.exp-foot .foot-bottom a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

/* Load your own */

.exp-load { margin-top: 2.5rem; margin-bottom: 4rem; }

.exp-load-card {
  padding: 1.2rem 1rem 1.25rem;
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  background: var(--band);
}

.exp-load-card .exp-lede { margin-top: 0.6rem; }

.exp-drop {
  display: block;
  margin-top: 1rem;
  padding: 1.1rem 0.9rem;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  text-align: center;
  cursor: pointer;
}

.exp-drop:hover,
.exp-drop:focus-within { border-color: var(--primary); }
.exp-drop.is-over { border-color: var(--primary); background: var(--primary-wash); }

.exp-drop-in { display: block; font-size: 0.9375rem; color: var(--ink); }
.exp-drop-cta { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.exp-drop-sub {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--muted);
}

/* The file input is the real control even though the label is what the eye
   sees, so it carries a control's 24px box rather than a 1px stub. */
.exp-file {
  position: absolute;
  width: 24px;
  height: 24px;
  opacity: 0;
  pointer-events: none;
}

/* The visible control is the label; the input is the real one, so it keeps the
   tab stop and lights the box it belongs to. */
.exp-load-card:has(.exp-file:focus-visible) .exp-drop {
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

@media (min-width: 900px) {
  .exp-m { padding: 1.5rem 1.65rem 1.6rem; }
  .exp-bar { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .exp-load-card { padding: 1.5rem 1.6rem 1.6rem; }
}

@media (max-width: 680px) {
  /* site.css turns every table into stacked label/value rows. The explorer's
     lane cell holds two lines of its own, so it must not be a flex row of
     label and value; the numeric cells keep that shape and their labels. */
  .exp-table tbody tr { padding: 0.85rem 0; }
  .exp-table tbody td { padding: 0.2rem 0; }
  .exp-table tbody td.lane { display: block; padding-bottom: 0.45rem; }
  .exp-table tbody td.lane::before { content: none; }
  .exp-table tbody td.lane .exp-lane-tag { font-size: 0.9375rem; }
  .exp-table tbody td.lane .lane-sub { margin-top: 0.15rem; }
  .exp-m-where { font-size: 0.625rem; }

  /* Four selects-and-fields and a reset button in one wrapped flex row puts
     `full range` on a row of its own, read as belonging to y max. A two-column
     grid keeps each label over its control and the reset spanning the pair it
     resets; every control is a full 40px tall and full-width inside its cell. */
  .exp-opts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 0.6rem;
  }
  .exp-field { min-width: 0; }
  .exp-field select,
  .exp-field input,
  .exp-field input[type="number"] { width: 100%; }
  .exp-btn { grid-column: 1 / -1; width: 100%; }
  .exp-check { min-height: 2.5rem; }
  .exp-flows { grid-template-columns: repeat(auto-fill, minmax(min(8.5rem, 100%), 1fr)); }
}
