/* Skin: TRACE. hyperplot's own skin, worn by its project page (Plate 001), the hub's Featured slot and its poster.
   1. An oscilloscope: a phosphor trace (the accent, CH1) on dark glass, set in a bezel so the screen separates
      from Signal black by its lit edge (3.5:1), not only by the frame's red corners (glass alone is 1.17:1).
   2. The Trace series in --hp-series-1..8. No red anywhere in the stage: red is never data, rule, link or focus.
   3. Source: riffs/hyperplot-brand/final/skin-hyperplot.css (block B of its tokens.css). Change it there, then
      here, in skin-hyperplot-tip.css and in site-data/projects.json "accent", together.
   Contract: riffs/specimen-v2/SPEC.md §6. The bezel is inset box-shadow on :scope: it paints inside the stage, under its content,
   and leaves every box property the frame owns (size, padding, overflow, background colour) untouched. */
@layer skin {
  @scope ([data-skin="hyperplot"]) {
    :scope {
      --skin-accent: oklch(0.909 0.18 102);   /* = projects.json accent; the frame sets black on it */
      --skin-bg: oklch(0.209 0.013 196);          /* glass, not Signal black */
      --skin-ink: oklch(0.94 0.029 101);          /* 14.9:1 on glass */
      color-scheme: dark;
      --phosphor: var(--skin-accent);
      --rim: oklch(0.339 0.02 196);
      --edge: oklch(0.499 0.022 196);             /* lit bezel edge: 3.5:1 on Signal black */
      --bezel: oklch(0.149 0.009 196);
      --muted: oklch(0.751 0.026 151);          /* 8.1:1 on glass */
      --grat: color-mix(in oklch, var(--skin-ink) 8%, transparent);
      --grat-dot: color-mix(in oklch, var(--skin-ink) 20%, transparent);
      --mono: 'IBM Plex Mono', 'IBM Plex Mono Fallback', ui-monospace, monospace;
      --serif: 'Instrument Serif', 'Instrument Serif Fallback', Georgia, serif;

      /* The glass sits in a bezel: a lit edge, a dark band, the rim, then the screen. Inset shadows paint over
         the stage's background and under its content, so the frame's box (size, padding, background) is untouched.
         Without this the stage is glass on Signal black at 1.17:1 and only the red corners say where it ends. */
      box-shadow:
        inset 0 0 0 1px var(--edge),
        inset 0 0 0 6px var(--bezel),
        inset 0 0 0 7px var(--rim),
        inset 0 0 28px 10px oklch(0 0 0 / 0.3);

      /* Graticule: 48px divisions, dotted subdivisions along each horizontal division */
      background-image:
        linear-gradient(var(--grat) 1px, transparent 1px),
        linear-gradient(90deg, var(--grat) 1px, transparent 1px),
        radial-gradient(circle at 1px 1px, var(--grat-dot) 0.8px, transparent 1.3px);
      background-size: 48px 48px, 48px 48px, 9.6px 48px;
      background-position: -1px -1px, -1px -1px, -1px -1px;
      font: 400 0.75rem / 1.45 var(--mono);
    }

    .plotter { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(18px, 3.2cqi, 36px) clamp(14px, 2.4cqi, 28px); }
    @container (inline-size > 68rem) {
      .plotter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .plotter__panel--wide, .plotter__block { grid-column: 1 / -1; }
    }

    /* Panel label = a channel readout: the figure number on a phosphor key, then the request */
    .plotter__label {
      display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.65rem;
      padding-block-end: 0.5rem; margin-block-end: 0.55rem;
      border-bottom: 1px solid var(--rim);
      color: var(--muted);
      & b { font: 500 0.6875rem / 1 var(--mono); padding: 0.24rem 0.42rem 0.2rem; border-radius: 3px; background: var(--phosphor); color: var(--skin-bg); }
      & code { font: 500 0.75rem / 1.3 var(--mono); color: var(--skin-ink); overflow-wrap: anywhere; }
      & i { font-style: normal; margin-inline-start: auto; }
    }
    .plotter__chart {
      & .hp { inline-size: 100%; }
      &:empty { aspect-ratio: 32 / 15; }
    }
    /* One chart in a fixed-height window (the hub's Featured slot): label and foot keep their lines and the
       chart takes the rest, letterboxed by its own viewBox, so the x axis is never cropped */
    .plotter--fit { block-size: 100%; display: flex; flex-direction: column; gap: 0; }
    .plotter--fit .plotter__chart { flex: 1; min-block-size: 0; & .hp { block-size: 100%; } }
    .plotter--fit :is(.plotter__label, .plotter__foot) { flex: none; font-size: 0.6875rem; line-height: 1.1; }
    .plotter--fit .plotter__label { padding-block-end: 0.3rem; margin-block-end: 0.35rem; }
    .plotter--fit .plotter__foot { margin-block-start: 0.35rem; padding-block-start: 0.3rem; }
    /* one line each at any width: the text gives way (ellipsis), the pins at the start of each part stay */
    .plotter--fit :is(.plotter__label, .plotter__foot) { flex-wrap: nowrap; }
    .plotter--fit :is(.plotter__label, .plotter__foot) > :not([data-note]) { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .plotter__foot {
      display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.25rem;
      margin-block-start: 0.55rem; padding-block-start: 0.45rem;
      border-top: 1px dashed var(--rim); color: var(--muted);
    }
    kbd {
      display: inline-block; min-inline-size: 1.7em; padding: 0.05rem 0.35rem; margin-inline: 0.1rem;
      border: 1px solid var(--rim); border-block-end-width: 2px; border-radius: 3px;
      background: color-mix(in oklch, var(--rim) 45%, var(--skin-bg));
      font: 500 0.6875rem / 1.3 var(--mono); text-align: center; color: var(--skin-ink);
    }
    /* Title block = the scope's status line */
    .plotter__block {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
      border: 1px solid var(--rim); border-radius: 4px; overflow: clip;
      background: color-mix(in oklch, var(--skin-bg) 80%, black);
      & div { padding: 0.45rem 0.6rem 0.55rem; box-shadow: -1px 0 0 var(--rim), 0 -1px 0 var(--rim); }
      & dt { font-size: 0.6875rem; color: var(--muted); }
      & dd { font-weight: 500; color: var(--skin-ink); overflow-wrap: anywhere; }
      & div:first-child dd { font: italic 400 1.5rem / 1 var(--serif); letter-spacing: -0.01em; }
      & div:first-child dd span { font-style: normal; }
    }

    /* Charts: the Trace series on glass. Slot 1 is the phosphor itself. No red anywhere in the stage:
       the SLO rule is drawn in the screen's ink, dashed, and labelled. */
    .hp {
      --hp-surface: var(--skin-bg);
      --hp-text: var(--skin-ink);
      --hp-text-muted: var(--muted);
      --hp-grid: color-mix(in oklch, var(--skin-ink) 13%, transparent);
      --hp-axis: color-mix(in oklch, var(--skin-ink) 34%, transparent);
      --hp-series-1: oklch(0.909 0.18 102);
      --hp-series-2: oklch(0.695 0.127 221);
      --hp-series-3: oklch(0.535 0.178 342);
      --hp-series-4: oklch(0.693 0.167 57);
      --hp-series-5: oklch(0.629 0.13 248);
      --hp-series-6: oklch(0.521 0.12 61);
      --hp-series-7: oklch(0.53 0.19 282);
      --hp-series-8: oklch(0.661 0.17 150);
      font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums;
      & text { font-family: var(--mono); }
      @container (inline-size > 55rem) { font-size: 12.5px; }
      & .hp-line { filter: drop-shadow(0 0 2.5px color-mix(in oklch, currentColor 75%, transparent)); }
      & .hp-end { filter: drop-shadow(0 0 3px currentColor); }
      & .hp-rule { stroke: var(--skin-ink); stroke-opacity: 0.7; stroke-dasharray: 5 4; }
      & .hp-rule-label { fill: var(--skin-ink); font-weight: 500; }
      & .hp-bar { stroke: var(--skin-bg); stroke-width: 1px; }
      & .hp-dot { stroke: var(--skin-bg); stroke-width: 1px; }
      & .hp-crosshair { stroke: var(--phosphor); stroke-dasharray: 2 3; }
      & .hp-band-hl { fill: var(--phosphor); fill-opacity: 0.07; stroke: var(--phosphor); }
      &:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 6px; border-radius: 2px; }
    }
    /* Percentiles are ordinal, not identities: on the latency chart p50, p95, p99 (slots 5-7) take
       sequential steps 3, 5 and 7, so the percentile reads as brightness and p99 is the full trace. */
    .hp:is(#latency, [id$="-latency"]) {
      --hp-series-5: oklch(0.589 0.106 98);
      --hp-series-6: oklch(0.749 0.144 100);
      --hp-series-7: oklch(0.909 0.18 102);
    }
    @media (forced-colors: active) { .hp .hp-line, .hp .hp-end { filter: none; } }
  }
}
