/* Labs: gallery cards, lab host, and the kit's controls, stats, bars and charts. Theme variables only. */

/* gallery (also used by the practice hub) */
.lab-cat { display: flex; align-items: center; gap: 8px; }
.lab-cat[style]::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lab-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; text-decoration: none; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--c, var(--accent)); border-radius: 14px; box-shadow: var(--shadow); }
.lab-card:hover, .lab-card:focus-visible { border-color: var(--c, var(--accent)); outline: none; }
.lab-card b { font-weight: 600; font-size: 15px; }
.lab-card span { color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.lab-mark { font-size: 12px; color: var(--muted); }
.lab-mark.s3 { color: var(--accent); font-weight: 600; }
.lab-rel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 16px; }
.lab-rel > span { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.lab-after { margin-top: 24px; }
.lab-done { margin-top: 18px; }
.lab-done[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* lab frame */
.lab { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.k-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) { .k-layout { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); } .k-readout { grid-column: 1 / -1; } }
.k-controls, .k-viz, .k-readout { min-width: 0; }
.k-controls { display: flex; flex-direction: column; gap: 14px; }
.k-readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-content: start; }

/* controls */
.k-field { display: flex; flex-direction: column; gap: 4px; }
.k-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.k-field label { font-size: 13px; font-weight: 500; }
.k-val { font: 600 13px var(--mono); color: var(--accent); }
.k-field input[type="range"] { width: 100%; margin: 0; min-height: 28px; accent-color: var(--accent); }
.k-field input[type="number"], .k-field select { width: 100%; min-height: 38px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.k-field input:focus-visible, .k-field select:focus-visible, .lab .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.k-toggle { flex-direction: row; align-items: center; gap: 10px; min-height: 32px; }
.k-toggle input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.lab .btn { min-height: 38px; }

/* stats and bars */
.k-stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.k-stat-l { font-size: 12px; color: var(--muted); }
.k-stat-v { font: 600 18px var(--mono); margin-top: 2px; overflow-wrap: anywhere; }
.k-stat.good { border-color: #2b9a66; } .k-stat.good .k-stat-v { color: #2b9a66; }
.k-stat.warn { border-color: #d4a017; } .k-stat.warn .k-stat-v { color: #b78303; }
.k-stat.bad { border-color: #d6336c; } .k-stat.bad .k-stat-v { color: #d6336c; }
:root[data-theme="dark"] .k-stat.good .k-stat-v { color: #4cc88a; }
:root[data-theme="dark"] .k-stat.warn .k-stat-v { color: #f0c23c; }
:root[data-theme="dark"] .k-stat.bad .k-stat-v { color: #ff6b9a; }
.k-bar { display: grid; grid-template-columns: minmax(70px, 28%) minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; }
.k-bar-t { height: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.k-bar-f { height: 100%; width: 0; border-radius: 99px; transition: width .25s; }
.k-bar-v { font: 12px var(--mono); color: var(--muted); min-width: 4ch; text-align: right; }

/* chart */
.k-chart { width: 100%; }
.k-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.k-grid { stroke: var(--line); stroke-width: 1; }
.k-axis { stroke: var(--line-2); stroke-width: 1.5; }
.k-tick { fill: var(--muted); font: 11px var(--mono); }
.k-axl { fill: var(--muted); font: 12px var(--sans); }
.k-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.k-dot { stroke: var(--panel); stroke-width: 2; }
.k-mlabel { fill: var(--text); font: 600 12px var(--sans); paint-order: stroke; stroke: var(--panel); stroke-width: 4; }
.k-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.k-legend:empty { display: none; }
.k-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------- puzzles: gallery and article block ---------- */
.lab-sand { margin-top: 32px; }
.lab-card.soon { opacity: .6; box-shadow: none; border-style: dashed; }
.ar-solve { background: var(--accent-soft); border: 1px solid var(--line-2); border-radius: 14px; padding: 12px 16px; margin: 0 0 16px; }
.ar-solve .ar-hint { margin: 4px 0 10px; }

/* ---------- puzzle runner (labs/puzzle.js) ---------- */
.pz { --ok: #2b9a66; --no: #b7791f; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
:root[data-theme="dark"] .pz { --ok: #4cc88a; --no: #f0c23c; }
.pz [hidden] { display: none; }
.pz-dots { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.pz-dot { min-width: 44px; min-height: 44px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--panel); color: var(--muted); font: 600 15px var(--sans); cursor: pointer; transition: background .15s, border-color .15s; }
.pz-dot.solved { background: var(--accent-soft); border-color: var(--ok); color: var(--ok); }
.pz-dot.here { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.pz-dot:disabled { opacity: .45; cursor: default; }
.pz-dot:focus-visible, .pz .btn:focus-visible, .pz-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pz-stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pz-goal { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.45; }
.pz-board { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s; }
.pz-ok .pz-board { border-color: var(--ok); }
.pz .btn { min-height: 44px; padding: 8px 16px; }
/* Sticky so Check stays reachable under a tall board (phones). */
.pz-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: sticky; bottom: 0; z-index: 2; background: var(--panel); padding: 8px 0; margin: -8px 0; }
.pz-tries { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.pz-msg { margin: 0; min-height: 1.5em; line-height: 1.5; padding-left: 12px; border-left: 4px solid transparent; }
.pz-msg.no { border-color: var(--no); }
.pz-msg.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); padding: 8px 12px; border-radius: 0 10px 10px 0; font-weight: 500; }
.pz-hints { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pz-hint { margin: 0; padding: 8px 12px; background: var(--accent-soft); border-radius: 10px; font-size: 14px; line-height: 1.5; }
.pz-why { background: var(--panel); border: 1px solid var(--ok); border-radius: 14px; padding: 4px 16px 8px; line-height: 1.6; }
.pz-why h3 { margin: 12px 0 4px; font-size: 14px; color: var(--ok); }
.pz-nav { display: flex; }
.pz-end { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.pz-end h3 { margin: 0 0 8px; font-size: 20px; }
.pz-sub { margin: 14px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pz-recap { margin: 0; padding-left: 20px; line-height: 1.6; }
.pz-att { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.pz-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pz-end .pz-row { margin-top: 14px; }
.pz-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.pz-read { margin: 0; font-size: 14px; }

/* puzzle boards: message form, cells, log, scale */
.pz-form { display: flex; flex-direction: column; gap: 8px; }
.pz-l { font-size: 13px; font-weight: 500; }
.pz-form input { width: 100%; min-height: 44px; box-sizing: border-box; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; font: 15px var(--mono); color: var(--text); }
.pz-cells { display: grid; gap: 4px; max-width: 440px; width: 100%; }
.pz-cell { position: relative; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; min-width: 0; overflow: hidden; transition: background .15s, border-color .15s; }
.pz-cells.dense { gap: 2px; max-width: 360px; }
.pz-cells.dense .pz-cell { aspect-ratio: 1; border-radius: 3px; }
.pz-cells.named .pz-cell { min-height: 64px; padding: 4px 6px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.pz-n { font: 11px var(--mono); color: var(--muted); }
.pz-m { font: 600 12px var(--mono); overflow-wrap: anywhere; line-height: 1.3; }
.pz-cell.fill { background: var(--accent-soft); border-color: var(--accent); }
.pz-cell.target { border: 2px solid var(--accent); }
.pz-cell.hit { background: var(--ok); border-color: var(--ok); }
.pz-cell.hit .pz-m, .pz-cell.hit .pz-n { color: #fff; }
.pz-cell.last { outline: 2px solid var(--text); outline-offset: 1px; }
.pz-log { list-style: none; margin: 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.pz-log:empty { display: none; }
.pz-log span { color: var(--muted); }
.pz-scale { width: 100%; max-width: 560px; height: auto; display: block; overflow: visible; }
.pz-axis, .pz-tick { stroke: var(--line-2); stroke-width: 2; }
.pz-axl { fill: var(--muted); font: 11px var(--mono); }
.pz-lab { fill: var(--text); font: 600 12px var(--sans); }
.pz-run { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.pz-median { stroke: var(--ok); stroke-width: 3; stroke-linecap: round; }
.pz-static { fill: var(--muted); }

/* ---------- interaction primitives (labs/interact.js) ---------- */
.pz-dot, .ix-zone, .ix-chip, .ix-row, .ix-grip, .ix-mv, .ix-drop, .ix-place, .ix-sort, .pz-scale, .pz-cells, .pz-bar { -webkit-user-select: none; user-select: none; }
.ix-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ix-place { display: flex; flex-direction: column; gap: 10px; position: relative; }
.ix-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.ix-zone { background: var(--panel); border: 2px dashed var(--line-2); border-radius: 12px; padding: 6px; min-height: 88px; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, background .15s; min-width: 0; }
.ix-tray { min-height: 64px; background: transparent; }
.ix-zone.ix-over { border-color: var(--accent); background: var(--accent-soft); }
.ix-drop { min-height: 44px; background: none; border: 0; border-radius: 8px; color: var(--muted); font: 600 13px var(--sans); text-align: left; cursor: pointer; padding: 4px 6px; }
.ix-drop:hover { color: var(--text); }
.ix-zone-c { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; }
.ix-chip { min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--accent); background: var(--panel); color: var(--text); font: 600 14px var(--sans); cursor: grab; touch-action: none; user-select: none; transition: background .15s, box-shadow .15s; }
.ix-chip.ix-held { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ix-chip.ix-dragging { cursor: grabbing; position: relative; z-index: 5; box-shadow: var(--shadow); transition: none; opacity: .92; }
.ix-chip:focus-visible, .ix-drop:focus-visible, .ix-mv:focus-visible, .ix-grip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ix-sort { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.ix-row { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; min-height: 48px; transition: border-color .15s; }
.ix-row.ix-dragging { position: relative; z-index: 5; box-shadow: var(--shadow); border-color: var(--accent); transition: none; }
.ix-row.ix-before { box-shadow: 0 -3px 0 var(--accent); }
.ix-row.ix-after { box-shadow: 0 3px 0 var(--accent); }
.ix-grip { align-self: stretch; display: flex; align-items: center; justify-content: center; min-width: 44px; color: var(--muted); cursor: grab; touch-action: none; user-select: none; letter-spacing: -2px; }
.ix-txt { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 6px 0; }
.ix-mv { min-width: 44px; min-height: 44px; background: none; border: 0; border-radius: 8px; color: var(--text); font-size: 18px; cursor: pointer; }
.ix-mv:disabled { opacity: .3; cursor: default; }
.ix-handle { cursor: grab; outline: none; }
.ix-hit { fill: transparent; }
.ix-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 3; transition: r .15s; }
.ix-handle:hover .ix-dot, .ix-handle:focus-visible .ix-dot { r: 12; }
.ix-handle:focus-visible .ix-dot { stroke: var(--text); }
.ix-track { stroke: transparent; cursor: pointer; }

@media (max-width: 480px) { .pz-goal { font-size: 16px; } .pz-board { padding: 10px; } }
@media (prefers-reduced-motion: reduce) {
  .pz *, .pz *::before, .pz *::after, .ix-place *, .ix-sort *, .ix-dot { transition: none !important; animation: none !important; }
}
