/* Styles for the computer-science and maths widgets (js/widgets/set-cs.js). */

/* The one line of live commentary each widget keeps up to date. */
.w-bigo-take, .w-sorting-status, .w-binary-search-status, .w-graph-traversal-status, .w-vectors-status,
.w-gradient-descent-status, .w-neuron-status {
  margin-top: 12px; padding: 8px 12px; min-height: 2.5em; border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; background: var(--accent-soft); color: var(--text); font-weight: 550;
}

/* Axis and bar labels on the wide charts: a little larger than the kit default, so they stay
   readable when a narrow lesson column scales the chart down. */
.w-bigo .w-svg text, .w-sorting .w-svg text, .w-gradient-descent .w-svg text { font-size: 12px; }

/* Widgets with a panel beside the stage: in a narrow lesson column the panel drops below, and
   the stage stops growing and stays centred. */
.w-graph-traversal, .w-vectors, .w-neuron { container-type: inline-size; }
.w-graph-traversal .w-stage, .w-vectors .w-stage, .w-neuron .w-stage { width: 100%; max-width: 440px; justify-self: center; }
@container (max-width: 600px) {
  .w-graph-traversal .w-split, .w-vectors .w-split, .w-neuron .w-split { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- bigo */
.w-bigo { container-type: inline-size; }
.w-bigo .w-svg { cursor: ew-resize; }
.w-bigo .w-slider { width: clamp(150px, 40cqw, 320px); }
.w-bigo-cursor { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.w-bigo-dot { stroke: var(--code-bg); stroke-width: 1.5; }
.w-bigo-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.w-bigo-stats .w-stat { min-width: 0; padding: 6px 9px; border-left: 3px solid var(--wc); }
.w-bigo-stats .w-stat-label { font-size: 12px; letter-spacing: 0; text-transform: none; }
.w-bigo-stats .w-stat-value { font-size: 14px; }
@container (max-width: 540px) {
  .w-bigo-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- sorting */
.w-sorting > .w-controls:first-child { margin-top: 0; }
.w-sorting-about { min-height: 4.65em; margin: 10px 0 12px; }
.w-sorting-idle { --wc: color-mix(in srgb, var(--muted) 60%, var(--code-bg)); }
.w-sorting-cmp { --wc: var(--info); }
.w-sorting-write { --wc: var(--accent); }
.w-sorting-mark { --wc: var(--violet); }
.w-sorting-done { --wc: var(--ok); }
.w-sorting-buffer { --wc: var(--cyan); }
.w-sorting-dim { opacity: .4; }
.w-stage.w-sorting-sorted { border-color: var(--ok); }
.w-sorting-status.w-sorting-sorted { border-left-color: var(--ok); background: var(--ok-soft); }

/* ---------------------------------------------------------------- binary-search */
.w-binary-search-cell { cursor: pointer; outline: none; }
.w-binary-search-box { fill: var(--surface-2); stroke: var(--border-2); }
.w-svg .w-binary-search-cell text { fill: var(--text); font: 600 12px var(--mono); }
.w-svg .w-binary-search-cell .w-binary-search-small { font-size: 9px; }
.w-binary-search-flag { fill: var(--ok); visibility: hidden; }
.w-binary-search-target .w-binary-search-flag { visibility: visible; }
.w-binary-search-out .w-binary-search-box { fill: none; stroke: var(--border); }
.w-svg .w-binary-search-out text { fill: var(--muted); opacity: .6; }
.w-binary-search-seen .w-binary-search-box { fill: var(--info-soft); stroke: var(--info); }
.w-binary-search-next .w-binary-search-box { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.w-binary-search-found .w-binary-search-box { fill: var(--ok); stroke: var(--ok); }
.w-svg .w-binary-search-found text { fill: var(--bg); }
.w-binary-search-cell:hover .w-binary-search-box { stroke: var(--text-2); }
.w-binary-search-cell:focus-visible .w-binary-search-box { stroke: var(--text); stroke-width: 2.5; }
.w-binary-search-lo, .w-binary-search-hi { --wc: var(--text-2); }
.w-binary-search-mid { --wc: var(--accent); }
.w-binary-search-tick { fill: var(--wc); stroke: var(--wc); stroke-width: 1.2; }
.w-svg .w-binary-search-ptr {
  fill: var(--wc); font: 600 12px var(--mono); paint-order: stroke; stroke: var(--code-bg); stroke-width: 4px;
  stroke-linejoin: round;
}
.w-binary-search-lead { stroke: var(--border-2); }
.w-svg .w-binary-search-verdict { fill: var(--text); font: 650 12.5px var(--mono); }
.w-binary-search-gap { stroke: var(--ok); stroke-width: 2; stroke-dasharray: 4 3; }
.w-binary-search-key-next { --wc: var(--accent); }
.w-binary-search-key-seen { --wc: var(--info); }
.w-binary-search-key-out { --wc: var(--border-2); }
.w-binary-search-key-target { --wc: var(--ok); }
.w-binary-search-status.w-binary-search-done { border-left-color: var(--ok); background: var(--ok-soft); }

/* ---------------------------------------------------------------- hash-table */
.w-hash-table > .w-controls:first-child { margin-top: 0; }
.w-hash-table-entry { width: 150px; }
.w-hash-table-samples {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--text-2);
}
.w-hash-table-samples .w-label { margin-right: 4px; }
.w-hash-table-samples .btn { padding: 3px 10px; border-radius: 99px; font: 12.5px var(--mono); }
.w-hash-table-samples .w-hash-table-used { border-color: var(--ok); color: var(--ok); }
.w-hash-table-trace { min-height: 7.4em; margin-top: 12px; }
.w-hash-table-trace p { margin: 6px 0 0; }
.w-hash-table-trace p:first-child { margin: 0; }
.w-hash-table-goes { margin-left: 4px; color: var(--accent); font-weight: 650; }
.w-hash-table-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px 8px; margin-top: 12px; }
.w-hash-table-bucket {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 30px; padding: 3px 6px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--code-bg);
}
.w-hash-table-active { border-color: var(--accent); background: var(--accent-soft); }
.w-hash-table-index { min-width: 18px; margin-right: 3px; text-align: right; font: 600 11.5px var(--mono); color: var(--muted); }
.w-hash-table-key {
  max-width: 100%; padding: 1px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--border-2); border-radius: 99px; background: var(--surface-2); color: var(--text);
  font: 12.5px var(--mono);
}
.w-hash-table-new { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.w-hash-table-hit { border-color: var(--ok); background: var(--ok); color: var(--bg); }
.w-hash-table-hit::before { content: "= "; }
.w-hash-table-miss { border-color: var(--bad); color: var(--bad); }
.w-hash-table-miss::before { content: "\2260  "; }
.w-hash-table-grew .w-hash-table-bucket { animation: w-hash-table-grow .45s ease; }
@keyframes w-hash-table-grow { from { opacity: 0; transform: scale(.94); } }
.w-hash-table-meter { position: relative; display: block; height: 4px; margin: 4px 0 2px; border-radius: 2px; background: var(--surface-3); }
.w-hash-table-fill { display: block; max-width: 100%; height: 100%; border-radius: 2px; background: var(--accent); transition: width .2s; }
.w-hash-table-limit { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-2); }

/* ---------------------------------------------------------------- graph-traversal */
.w-graph-traversal-edge { stroke: var(--border-2); stroke-width: 1.5; }
.w-graph-traversal-tree { stroke: var(--ok); stroke-width: 3.5; }
.w-graph-traversal-node { cursor: pointer; outline: none; }
.w-graph-traversal-disc { fill: var(--surface-2); stroke: var(--border-2); stroke-width: 1.5; }
.w-graph-traversal-halo { fill: none; }
.w-graph-traversal-start .w-graph-traversal-halo { stroke: var(--text-2); stroke-dasharray: 3 3; }
.w-graph-traversal-node:hover .w-graph-traversal-disc { stroke: var(--text-2); }
.w-graph-traversal-node:focus-visible .w-graph-traversal-halo { stroke: var(--accent); stroke-width: 2; stroke-dasharray: none; }
.w-svg .w-graph-traversal-node text { fill: var(--text); font: 650 13px var(--sans); pointer-events: none; }
.w-svg .w-graph-traversal-node .w-graph-traversal-dist { fill: var(--text-2); font: 600 11px var(--mono); }
.w-graph-traversal-waiting .w-graph-traversal-disc { fill: color-mix(in srgb, var(--info) 20%, var(--code-bg)); stroke: var(--info); }
.w-graph-traversal-done .w-graph-traversal-disc { fill: color-mix(in srgb, var(--ok) 22%, var(--code-bg)); stroke: var(--ok); }
.w-graph-traversal-current .w-graph-traversal-disc { fill: var(--accent); stroke: var(--accent); }
.w-svg .w-graph-traversal-current text:first-of-type { fill: var(--accent-ink); }
.w-graph-traversal-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.w-graph-traversal-title:not(:first-child) { margin-top: 12px; }
.w-graph-traversal-list { display: flex; flex-wrap: wrap; gap: 5px; min-height: 27px; margin: 6px 0 0; padding: 0; list-style: none; }
.w-graph-traversal-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border: 1px solid var(--info); border-radius: 7px;
  background: var(--info-soft); color: var(--text); font-weight: 650;
}
.w-graph-traversal-chip small { color: var(--muted); font: 600 10.5px var(--mono); }
.w-graph-traversal-next { border-color: var(--accent); background: var(--accent-soft); }
.w-graph-traversal-next::after { content: "next"; color: var(--accent); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; }
.w-graph-traversal-stale { opacity: .55; text-decoration: line-through; }
.w-graph-traversal-seen { border-color: var(--ok); background: var(--ok-soft); }
.w-graph-traversal-none { color: var(--muted); font-size: 12.5px; font-style: italic; }
.w-graph-traversal-hint { margin: 6px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.w-graph-traversal-key-fresh { --wc: var(--border-2); }
.w-graph-traversal-key-waiting { --wc: var(--info); }
.w-graph-traversal-key-current { --wc: var(--accent); }
.w-graph-traversal-key-done, .w-graph-traversal-key-tree { --wc: var(--ok); }
.w-swatch.w-graph-traversal-key-tree { width: 16px; height: 4px; }

/* ---------------------------------------------------------------- vectors */
.w-svg .w-vectors-shaft { stroke-width: 2.5; }
.w-vectors-ghost { stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .6; }
.w-svg .w-vectors-name { font: 700 14px var(--sans); }
.w-vectors-grip { fill-opacity: .16; stroke-width: 1.5; cursor: grab; outline: none; }
.w-vectors-grip:hover { fill-opacity: .3; }
.w-svg .w-vectors-grip:focus-visible { fill-opacity: .35; stroke: var(--text); stroke-width: 2.5; }
.w-vectors-circle { fill: none; stroke: var(--muted); stroke-dasharray: 3 4; }
.w-vectors-guide { stroke: var(--border-2); stroke-dasharray: 2 5; }
.w-vectors-shadow { stroke-width: 7; stroke-linecap: round; opacity: .6; }
.w-vectors-drop { stroke: var(--text-2); stroke-dasharray: 4 3; }
.w-vectors-corner, .w-vectors-arc { fill: none; stroke: var(--text-2); stroke-width: 1.2; }
.w-svg .w-vectors-theta {
  fill: var(--text); font: 600 11.5px var(--mono); paint-order: stroke; stroke: var(--code-bg); stroke-width: 3px;
  stroke-linejoin: round;
}
.w-vectors-working { font: 12.5px/1.8 var(--mono); }
.w-vectors-working div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; }
.w-vectors-working b { color: var(--wc); font-weight: 650; }
.w-vectors-side .w-stats { margin-top: 10px; }
.w-vectors-side .w-stat { flex: 1 1 96px; }

/* ---------------------------------------------------------------- gradient-descent */
.w-gradient-descent .w-svg { cursor: crosshair; }
.w-gradient-descent-trail { fill: none; stroke: var(--accent); stroke-width: 1.2; opacity: .55; }
.w-gradient-descent-past { fill: var(--accent); opacity: .5; }
.w-gradient-descent-tangent { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.w-gradient-descent-step { fill: none; stroke: var(--ok); stroke-width: 2; }
.w-gradient-descent-head { fill: var(--ok); }
.w-gradient-descent-landing { fill: var(--code-bg); stroke: var(--ok); stroke-width: 2; }
.w-gradient-descent-point { fill: var(--accent); stroke: var(--code-bg); stroke-width: 2; outline: none; }
.w-gradient-descent-point:focus-visible { stroke: var(--text); }
.w-gradient-descent-point.w-gradient-descent-off { fill: none; stroke: var(--bad); stroke-dasharray: 3 2; }
.w-gradient-descent-status[data-tone="good"] { border-left-color: var(--ok); background: var(--ok-soft); }
.w-gradient-descent-status[data-tone="bad"] { border-left-color: var(--bad); background: var(--bad-soft); }
.w-gradient-descent-status[data-tone="stuck"] { border-left-color: var(--violet); background: var(--violet-soft); }

/* ---------------------------------------------------------------- neuron */
.w-neuron-stop0 { stop-color: var(--info); }
.w-neuron-stop1 { stop-color: var(--accent); }
.w-neuron-class0 { fill: var(--info); }
.w-neuron-class1 { fill: var(--accent); }
.w-neuron-dot { stroke: var(--code-bg); stroke-width: 1.2; }
.w-neuron-dot.w-neuron-wrong { stroke: var(--bad); stroke-width: 2.5; }
.w-neuron-line { stroke: var(--text); stroke-width: 2.5; }
.w-neuron-side > * + * { margin-top: 10px; }
.w-neuron-side .w-label { min-width: 74px; }
.w-neuron-side .w-slider { flex: 1; width: auto; min-width: 60px; }
.w-neuron-formula { font-size: 12.5px; line-height: 1.75; }
.w-neuron-key0 { --wc: var(--info); }
.w-neuron-key1 { --wc: var(--accent); }
.w-neuron-key-wrong { --wc: var(--bad); }
