/* Chart lab: ten chart styles on the landing's frame and tokens (../styles.css).
   The vector-editor motifs carry over from the page: dotted selection boxes with dark
   L brackets, square anchors, round-knob bezier handles, dims tags, and measurements in
   vermilion (the reference-line color). Outline view (html.lab-outline) strips every
   mark to its path, like a vector editor's wireframe mode. */

:root {
  --lab-soft: 58%;          /* a family's soft shade: its ink mixed toward the chart */
  --deep-mix: light-dark(#000, #fff);
}

/* ---------- page head ---------- */
.lab-top { padding-block: 72px 44px; display: flex; flex-direction: column; gap: 18px; }
.lab-top h1 { font-size: clamp(42px, 6.4vw, 88px); line-height: 0.95; letter-spacing: -0.045em; max-width: 13ch; }
.lab-top .section-lede { max-width: 62ch; }
.lab-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 6px; font: 400 11px/1 var(--mono); text-transform: uppercase; color: var(--muted); }
kbd { font: 400 10.5px/1 var(--mono); padding: 3px 5px 2px; border: var(--line) solid var(--stroke-strong); border-bottom-width: 2px; border-radius: 3px; color: var(--text); background: var(--surface); }

.lab-index { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: calc(-1 * var(--pad)); }
.lab-index a { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-content: start; padding: 18px 20px 20px; text-decoration: none; border-left: 1px dotted var(--guide); border-top: 1px dotted var(--guide); }
.lab-index a:nth-child(5n + 1) { border-left-color: transparent; }
.lab-index a:nth-child(-n + 5) { border-top-color: transparent; }
.lab-index .ico { grid-row: span 2; margin-top: 1px; }
.lab-index b { font: 600 15px/1.2 var(--heading-face); letter-spacing: -0.02em; }
.lab-index small { font: 400 11px/1.3 var(--mono); color: var(--muted); text-transform: uppercase; }
.lab-index a:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- a chart section ---------- */
.lab-copy { display: flex; flex-direction: column; gap: 14px; padding-block: 44px 36px; }
.lab-copy h2 { font-size: clamp(30px, 3.4vw, 46px); max-width: 18ch; }
.lab-deck { margin: 0; font-size: 17px; line-height: 1.55; color: var(--muted); max-width: 56ch; }
.lab-ctl { display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; padding-block: 44px 36px; }
.lab-hint { margin: 0; font: 400 11px/1.6 var(--mono); text-transform: uppercase; color: var(--muted); }
.lab-readout { margin: 0; font: 400 14px/1.5 var(--sans); color: var(--text); min-height: 1.5em; }
.lab-readout b { font-weight: 600; }
.lab-stage { padding: 30px var(--pad) 58px; }
.lab-fig { background: var(--chart-bg); }
/* the caption carries the export buttons at its right: the chart as a PNG, its intro as a GIF */
.lab-fig .dims { position: relative; }
.fig-tools { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; }
.fig-btn { font: 400 9.5px/1 var(--mono); letter-spacing: 0.06em; padding: 4px 6px; min-width: 34px; border: var(--line) solid var(--stroke); border-radius: 3px; background: var(--surface); color: var(--muted); cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.fig-btn:hover { color: var(--text); border-color: var(--stroke-strong); }
.fig-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.fig-btn[disabled] { cursor: progress; color: var(--text); }
.lab-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.lab-svg.drag { touch-action: pan-y; cursor: grab; }
.lab-svg.drag:active { cursor: grabbing; }
.lab-svg.crosshair { cursor: crosshair; }
.lab-note { margin: 34px 0 0; font: 400 11px/1.6 var(--mono); color: var(--muted); max-width: 120ch; }

/* ---------- controls ---------- */
.lab-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
/* a switch never runs wider than its row: on a phone its buttons wrap inside the box (a wider one lets
   iPhone Safari pan the page sideways, whatever the page's overflow says) */
.seg { position: relative; display: inline-flex; flex-wrap: wrap; max-width: 100%; min-width: 0; border: var(--line) solid var(--stroke-strong); border-radius: var(--radius); background: var(--surface); padding: 2px; gap: 2px; }
.seg-pill { position: absolute; top: 2px; left: 0; height: 26px; width: 0; border-radius: 2px; background: var(--ink); pointer-events: none; transition: transform 0.32s cubic-bezier(0.3, 0.75, 0.2, 1), width 0.32s cubic-bezier(0.3, 0.75, 0.2, 1), opacity 0.15s; }
.seg.cold .seg-pill { transition: none; }
.seg-b { position: relative; z-index: 1; appearance: none; border: 0; background: none; color: var(--text); font: 400 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.02em; height: 26px; padding: 0 10px; border-radius: 2px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: color 0.2s; }
.seg-b:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.seg-b[aria-checked="true"] { color: var(--on-ink); }
.seg-b[aria-checked="true"]:hover { background: none; }
.seg-b:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.seg-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }

/* .pick, the picker (kit.js picker()), is styled in ../../styles.css: it is also the theme control in every nav. */

.layers { display: flex; flex-wrap: wrap; gap: 4px; }
.layer { appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 6px; border: var(--line) solid var(--stroke); border-radius: var(--radius); background: var(--surface); color: var(--text); font: 400 11px/1 var(--mono); cursor: pointer; }
.layer svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.layer .e3 { display: none; }
.layer i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.layer[aria-pressed="false"] { color: var(--muted); border-style: dashed; }
.layer[aria-pressed="false"] i { background: none; box-shadow: inset 0 0 0 1px var(--c); }
.layer[aria-pressed="false"] .e3 { display: inline; }
.layer[aria-pressed="false"] .e2 { display: none; }
.layer:hover { border-color: var(--stroke-strong); }
.layer:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.yr { display: flex; align-items: flex-end; gap: 12px; width: 100%; max-width: 520px; }
.yr-play { flex: none; width: 30px; height: 30px; border-radius: 50%; border: var(--line) solid var(--stroke-strong); background: var(--surface); color: var(--text); cursor: pointer; position: relative; }
.yr-play::before { content: ""; position: absolute; left: 11px; top: 9px; border-style: solid; border-width: 6px 0 6px 9px; border-color: transparent transparent transparent currentColor; }
.yr-play.on::before { left: 10px; top: 9px; width: 3px; height: 12px; border: 0; background: currentColor; box-shadow: 6px 0 0 currentColor; }
.yr-play:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.yr-track { position: relative; flex: 1; height: 34px; cursor: ew-resize; touch-action: none; margin-inline: 12px; }
.yr-track:focus-visible { outline: 2px solid var(--text); outline-offset: 6px; border-radius: 2px; }
.yr-scale { position: absolute; inset: 0; border-bottom: var(--line) solid var(--stroke-strong); }
.yr-t { position: absolute; bottom: 0; width: 1px; height: 9px; background: var(--stroke-strong); }
.yr-t.minor { height: 5px; }
.yr-t.cur b { visibility: hidden; }
.yr-t b { position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%); font: 400 10px/1 var(--mono); color: var(--muted); white-space: nowrap; }
.yr-head { position: absolute; bottom: -1px; width: 0; height: 100%; transition: left 0.18s ease; pointer-events: none; }
.yr-head::before { content: ""; position: absolute; left: -0.75px; bottom: 0; width: 1.5px; height: 12px; background: var(--vermilion); }
.yr-head span { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); padding: 3px 6px; border-radius: 3px; background: var(--vermilion); color: #fff; font: 400 10.5px/1 var(--mono); white-space: nowrap; }

/* ---------- inspector ---------- */
.lab-tip { position: fixed; z-index: 60; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity 0.12s; min-width: 160px; max-width: 300px; padding: 9px 11px 8px; border: var(--line) solid var(--stroke-strong); border-radius: 4px; background: var(--surface); box-shadow: 0 8px 24px -12px rgb(0 0 0 / 0.35); font: 400 11.5px/1.45 var(--mono); color: var(--text); }
.lab-tip.on { opacity: 1; }
.tip-h { margin: 0 0 5px; padding-bottom: 5px; border-bottom: 1px dotted var(--guide); font-size: 10.5px; text-transform: uppercase; color: var(--muted); }
.tip-r { margin: 0; display: flex; align-items: center; gap: 7px; }
.tip-r i { flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.tip-r span { flex: 1; color: var(--muted); }
.tip-r b { font-weight: 500; font-variant-numeric: tabular-nums; }
.tip-r.s span, .tip-r.s b { color: var(--text); font-weight: 600; }
.tip-f { margin: 5px 0 0; padding-top: 5px; border-top: 1px dotted var(--guide); color: var(--muted); font-size: 10.5px; }

/* ---------- inside the charts ---------- */
.lab-svg text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.lab-svg .lbl { paint-order: stroke; stroke: var(--chart-bg); stroke-width: 3.5px; stroke-linejoin: round; }
.lab-svg .t-name { font-family: var(--sans); font-size: 13px; fill: var(--text); font-weight: 500; }
.lab-svg .t-name.sm { font-size: 11.5px; }
.lab-svg .t-val { fill: var(--text); font-variant-numeric: tabular-nums; }
.lab-svg .t-big { font-family: var(--heading-face); font-weight: 600; fill: var(--text); letter-spacing: -0.02em; }
.lab-svg .t-tick { font-size: 10.5px; }
.lab-svg .t-strong { fill: var(--text); font-weight: 600; }
.lab-svg .grid { stroke: var(--rule); stroke-width: 1; fill: none; }
.lab-svg .grid-dot { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 1 3; fill: none; }
.lab-svg .axis { stroke: var(--muted); stroke-width: 1; fill: none; }
.lab-svg .guide { stroke: var(--guide); stroke-width: 1; stroke-dasharray: 1 2; fill: none; }
.lab-svg .mk { fill: var(--c); }
.lab-svg .mk-l { fill: none; stroke: var(--c); }
.lab-svg .soft { fill: color-mix(in oklab, var(--c) var(--lab-soft), var(--chart-bg)); }

.sel-box { fill: none; stroke: var(--guide); stroke-dasharray: 1 2; }
.sel-l { fill: none; stroke: var(--tick); stroke-width: 1.5; }
.pill rect { fill: var(--tick); }
.pill text { fill: var(--chart-bg) !important; font-size: 10.5px !important; font-family: var(--mono); }
.pill.measure rect { fill: var(--vermilion); }
.pill.measure text { fill: #fff !important; }
.anchor { fill: var(--chart-bg); stroke: var(--text); stroke-width: 1; }
.anchor.on { fill: var(--text); }
.handle line { stroke: var(--text); stroke-width: 0.75; opacity: 0.7; }
.handle circle { fill: var(--chart-bg); stroke: var(--text); stroke-width: 1; }
.measure-l { stroke: var(--vermilion); stroke-width: 1; fill: none; }
.measure-band { fill: var(--vermilion); opacity: 0.06; }

/* 01 flow */
.lab-svg .rb { transition: opacity 0.2s, fill 0.2s; }
.lab-svg .rb.kept { fill: color-mix(in oklab, var(--c) 84%, var(--chart-bg)); stroke: var(--c); stroke-width: 0.75; stroke-opacity: 0.9; }
.lab-svg .cost { fill: color-mix(in srgb, var(--text) 10%, transparent); stroke: color-mix(in srgb, var(--text) 22%, transparent); stroke-width: 0.6; }
.lab-svg .cost.on { fill: color-mix(in srgb, var(--text) 26%, transparent); }
.lab-svg .sink { fill: var(--muted); }
.lab-svg g.focus .rb:not(.on) { opacity: 0.32; }

/* 02 measure */
.lab-svg .ln { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; transition: opacity 0.2s, stroke-width 0.2s; }
.lab-svg .ln.on { stroke-width: 3; }
.lab-svg g.focus .ln:not(.on) { opacity: 0.22; }
.lab-svg .end { transition: opacity 0.2s; }
.lab-svg .end.dim { opacity: 0.3; }
.lab-svg .m-panel-bg { fill: var(--chart-bg); stroke: var(--stroke); opacity: 0.94; }

/* 03 rank */
.lab-svg .bump-halo { fill: none; stroke: var(--chart-bg); stroke-width: 12; stroke-linecap: round; }
.lab-svg .bump { fill: none; stroke: var(--c); stroke-width: 5; stroke-linecap: round; }
.lab-svg .bump-dot { fill: var(--c); stroke: var(--chart-bg); stroke-width: 2; }
.lab-svg .bump-g { transition: opacity 0.25s; cursor: pointer; }
.lab-svg .bumps.focus .bump-g:not(.on) { opacity: 0.12; }
.lab-svg .bump-g .vals { display: none; }
.lab-svg .bump-g.on .vals { display: inline; }

/* 04 pool */
.lab-svg .mek { cursor: crosshair; }

/* 05 trails */
.lab-svg .tr-seg { fill: none; stroke-linecap: round; }
.lab-svg .tr-pt { fill: var(--chart-bg); stroke: var(--c); stroke-width: 1; cursor: crosshair; }
.lab-svg .tr-bub { fill: color-mix(in oklab, var(--c) 82%, var(--chart-bg)); stroke: var(--c); stroke-width: 1.2; cursor: crosshair; }
.lab-svg .trail { transition: opacity 0.2s; }
.lab-svg .trails.focus .trail:not(.on) { opacity: 0.14; }
.lab-svg .trail.on .tr-seg { stroke-width: 2.6 !important; }
.lab-svg .r40 { stroke-width: 1.2; }
.lab-svg .r40-l { fill: var(--vermilion) !important; }
.lab-svg .quad { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; }

/* 06 spiral */
.lab-svg .sp { fill: none; stroke-linecap: round; }
.lab-svg .sp-head { stroke: var(--chart-bg); stroke-width: 2; }
.lab-svg .season { fill: color-mix(in srgb, var(--text) 4%, transparent); }
.lab-btn { border: var(--line) solid var(--stroke-strong); background: var(--surface); }

/* 07 dots */
.lab-svg .dot { transition: transform 0.9s cubic-bezier(0.6, 0, 0.2, 1), opacity 0.15s; }
.lab-svg .dot.div { fill: color-mix(in oklab, var(--c) 42%, var(--chart-bg)); }
.lab-svg.no-tr .dot { transition: none !important; }
.lab-svg .dot-labels { opacity: 0; }
.lab-svg .dot-labels.in { animation: lab-fade 0.5s 0.55s forwards; }
@keyframes lab-fade { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lab-svg .dot { transition: none; } .lab-svg .dot-labels.in { animation: none; opacity: 1; } }

/* 08 heat */
.lab-svg .hrow { transition: transform 0.6s cubic-bezier(0.5, 0, 0.2, 1); }
.lab-svg .hc { fill: var(--chart-bg); transition: fill 0.35s; cursor: crosshair; }
.lab-svg .hc.na { fill: url(#heat-hatch); }
.lab-svg .hatch { stroke: var(--rule); stroke-width: 2.2; }
.lab-svg .hc-t { font-size: 10.5px; fill: var(--text); stroke: none; pointer-events: none; font-variant-numeric: tabular-nums; }
.lab-svg .hc-t.light { fill: var(--chart-bg); }
.lab-svg .hrow .dim { opacity: 0.35; }
.lab-svg .hc-bar { transition: width 0.35s, fill 0.35s; }

/* 09 pressure */
.lab-svg .g-face { fill: var(--surface); stroke: var(--stroke-strong); stroke-width: 1; }
.lab-svg .g-track { fill: none; stroke: var(--rule); stroke-width: 5; }
.lab-svg .g-range { fill: none; stroke: color-mix(in srgb, var(--text) 22%, transparent); stroke-width: 5; }
.lab-svg .g-val { stroke-width: 5; }
.lab-svg .g-val.neg { stroke: var(--cherry); }
.lab-svg .g-tick { stroke: var(--muted); stroke-width: 0.8; }
.lab-svg .g-tick.major { stroke: var(--text); stroke-width: 1.2; }
.lab-svg .g-num { font-size: 9px; }
.lab-svg .g-avg { fill: var(--vermilion); }
.lab-svg .g-needle { fill: var(--text); }
.lab-svg .g-hub { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.lab-svg .g-spark { stroke-width: 1.2; }
.lab-svg .gauge.off .g-needle, .lab-svg .gauge.off .g-value { opacity: 0.35; }

/* 10 build-out */
.lab-svg .tower { transition: opacity 0.2s; }
.lab-svg .tower .top { fill: color-mix(in oklab, var(--c) 70%, #fff); stroke: color-mix(in oklab, var(--c) 62%, #000); stroke-width: 0.6; stroke-linejoin: round; }
.lab-svg .tower .side { stroke: color-mix(in oklab, var(--c) 55%, #000); stroke-width: 0.5; stroke-linejoin: round; }
.lab-svg .tower .floors { fill: none; stroke: color-mix(in oklab, var(--c) 38%, #000); stroke-width: 0.7; opacity: 0.5; }
.lab-svg g.focus .tower:not(.on) { opacity: 0.26; }
.lab-svg .tower.on .top { fill: color-mix(in oklab, var(--c) 55%, #fff); }

/* Outline view: every mark becomes its path */
html.lab-outline .lab-svg .mk,
html.lab-outline .lab-svg .soft,
html.lab-outline .lab-svg .cost,
html.lab-outline .lab-svg .sink,
html.lab-outline .lab-svg .hc,
html.lab-outline .lab-svg .face { fill: none !important; stroke: var(--c, var(--text)) !important; stroke-width: 1px !important; }
html.lab-outline .lab-svg .mk-l { stroke-width: 1px !important; }
html.lab-outline .lab-svg .fill-only { fill: none !important; stroke: var(--text); stroke-width: 0.6px; }

@media (max-width: 960px) {
  .lab-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-index a { border-top-color: var(--guide) !important; border-left-color: var(--guide) !important; }
  .lab-index a:nth-child(odd) { border-left-color: transparent !important; }
  .lab-index a:nth-child(-n + 2) { border-top-color: transparent !important; }
  .lab-copy { padding-block: 36px 8px; }
  .lab-ctl { padding-block: 20px 28px; }
  .lab-stage { padding: 24px var(--pad) 48px; }
}
@media (max-width: 560px) {
  .lab-stage { padding: 20px 14px 44px; }
  .lab-deck { font-size: 15px; }
}
