/* Concepts gallery + visualizer chrome. Tokens only — no theme-scoped rules.
   Design pass follows the diagram-design node treatments (editorial accent
   discipline, hairline rules, masked labels) inside the project's two skins. */

/* ---------- gallery ---------- */

.concepts-hero { margin-bottom: var(--s4); }
.concepts-hero .concept-count {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: var(--t-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.concept-group { margin-bottom: var(--s5); }
.concept-group-head {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin-bottom: var(--s2);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hair);
}
.concept-group-head .g-name { color: var(--ink); }
.concept-group-head .g-count {
  font-family: var(--mono);
  font-size: var(--t-mono);
  color: var(--ink-3);
  letter-spacing: 0.06em;
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s2);
}

.concept-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--s2);
  padding-left: calc(var(--s2) + 4px);
  background: var(--surface);
  border: var(--border-2);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
/* editorial accent rail — the one focal mark per card */
.concept-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.08s ease;
}
.concept-card:hover { transform: var(--lift); box-shadow: var(--shadow); }
.concept-card:hover::before { opacity: 1; }
.concept-card:focus-visible { outline: var(--border-2); outline-offset: 2px; }
.concept-card.is-soon { opacity: 0.4; pointer-events: none; }

.concept-ch {
  font-family: var(--mono);
  font-size: var(--t-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.concept-name { font-weight: var(--fw-title); font-size: 1.05rem; line-height: 1.2; }
.concept-notice { font-size: var(--t-small); color: var(--ink-2); line-height: 1.45; }

/* ---------- structured concept doc ----------
   The teaching page: numbered sections (the number encodes learning order),
   the live viz slotted into "Try it", paired columns for symmetrical content
   (try/notice, gain/pay, before/after). Tokens only — reads in both skins. */

/* doc spans the full body width (its dividers align with the page); only the
   text blocks cap their line length so prose stays readable. */
.concept-doc { --measure: 72ch; }
.cdoc-sec { margin-bottom: var(--s4); }
.cdoc-lead, .cdoc-scenario, .cdoc-ul, .cdoc-steps, .cdoc-changed, .cdoc-take { max-width: var(--measure); }

.cdoc-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 var(--s2);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: var(--t-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.cdoc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  font-weight: var(--fw-title);
  letter-spacing: 0;
}

.cdoc-lead { font-size: 1.15rem; line-height: 1.5; color: var(--ink); margin: 0; }
.cdoc-scenario {
  font-size: var(--t-body);
  line-height: 1.55;
  color: var(--ink-2);
  border-left: 3px solid var(--accent);
  padding-left: var(--s2);
  margin: 0 0 var(--s2);
}

.cdoc-ul { margin: 0; padding-left: 1.15em; }
.cdoc-ul li { font-size: var(--t-body); line-height: 1.5; margin-bottom: 6px; color: var(--ink-2); }
.cdoc-steps { margin: 0; padding-left: 1.3em; }
.cdoc-steps li { font-size: var(--t-body); line-height: 1.5; margin-bottom: 10px; color: var(--ink); }

.cdoc-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-top: var(--s2);
}
@media (max-width: 620px) { .cdoc-grid2 { grid-template-columns: 1fr; } }

.cdoc-collbl {
  font-family: var(--mono);
  font-size: var(--t-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: var(--s3) 0 8px;
}
.cdoc-collbl:first-child { margin-top: 0; }
.cdoc-collbl.good { color: var(--good); }
.cdoc-collbl.bad  { color: var(--bad); }

/* before / after — each box sizes to its own diagram (no fixed column that would
   force a scrollbar) at a compact mono size; the pair sits side by side and wraps
   on narrow screens. Diagrams stay ≤ ~64 chars so they fit the doc width whole. */
.cdoc-ba { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--s2); }
.cdoc-bacol { display: flex; flex-direction: column; flex: 0 1 auto; min-width: 0; }
.cdoc-pre {
  margin: 0;
  flex: 1;
  width: fit-content;
  min-width: 200px;
  max-width: 100%;
  padding: var(--s3);
  background: var(--surface);
  border: var(--border-2);
  box-shadow: var(--shadow-sm);
  font-family: var(--mono);
  font-size: var(--t-small);
  line-height: 1.6;
  color: var(--ink);
  white-space: pre;
  overflow-x: auto;
}
.cdoc-changed { font-size: var(--t-body); line-height: 1.55; color: var(--ink-2); margin: var(--s2) 0 0; }

/* term → why lists (failures, metrics, use cases) */
.cdoc-dl { margin: 0; }
.cdoc-row {
  display: grid;
  grid-template-columns: minmax(160px, 34%) 1fr;
  gap: var(--s2);
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
}
@media (max-width: 620px) { .cdoc-row { grid-template-columns: 1fr; gap: 4px; } }
.cdoc-row dt { font-weight: var(--fw-title); font-size: var(--t-body); color: var(--ink); }
.cdoc-row dd { margin: 0; max-width: var(--measure); font-size: var(--t-body); line-height: 1.5; color: var(--ink-2); }

/* comparison table (X-vs-Y concepts) — two-way, equal columns */
.cdoc-cmp { max-width: var(--measure); }
.cdoc-cmp .cdoc-row { grid-template-columns: 1fr 1fr; }
.cdoc-cmp .cdoc-row dd { max-width: none; color: var(--ink-2); }
.cdoc-cmp .cmp-head { border-bottom: var(--border-2); }
.cdoc-cmp .cmp-head dt, .cdoc-cmp .cmp-head dd { font-weight: var(--fw-title); color: var(--ink); }

/* interview takeaway */
.cdoc-take {
  font-size: var(--t-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--good-soft);
  border-left: 3px solid var(--good);
  padding: var(--s2);
  margin: 0 0 var(--s2);
}

/* learn-next chips */
.cdoc-chips { display: flex; flex-direction: column; gap: var(--s1); }
.cdoc-chip {
  display: block;
  padding: 12px var(--s2);
  background: var(--surface);
  border: var(--border-2);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.cdoc-chip:hover { transform: var(--lift); box-shadow: var(--shadow); }
.cdoc-chip-name { display: block; font-weight: var(--fw-title); }
.cdoc-chip-rel { display: block; font-size: var(--t-small); color: var(--ink-2); line-height: 1.45; margin-top: 2px; }

/* ---------- single visualizer ---------- */

.concept-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

.viz-mount { margin-top: var(--s2); }

.viz-notice {
  font-size: var(--t-body);
  color: var(--ink-2);
  border-left: 3px solid var(--accent);
  padding-left: var(--s2);
  margin-bottom: var(--s3);
  line-height: 1.5;
}

.viz-stage {
  background: var(--surface);
  border: var(--border-2);
  box-shadow: var(--shadow-sm);
  padding: var(--s3);
  margin-bottom: var(--s3);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viz-svg { width: 100%; height: auto; max-height: 62vh; display: block; }

.viz-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2);
  background: var(--surface);
  border: var(--border-2);
  box-shadow: var(--shadow-sm);
}

.viz-btn {
  font-family: var(--mono);
  font-size: var(--t-small);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 14px;
  background: var(--surface);
  border: var(--border-2);
  box-shadow: var(--shadow-xs);
  color: var(--ink);
  cursor: pointer;
}
.viz-btn:hover { transform: var(--lift); }
.viz-btn:active { transform: var(--press); box-shadow: var(--press-shadow); }
.viz-btn.primary { background: var(--accent); color: #fff; }
.viz-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.viz-slider, .viz-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.viz-lbl {
  font-family: var(--mono);
  font-size: var(--t-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}
.viz-slider input[type="range"] { accent-color: var(--accent); width: 120px; }
.viz-slider-val {
  font-family: var(--mono);
  font-size: var(--t-small);
  min-width: 2.5em;
  color: var(--ink);
}

.viz-seg {
  font-family: var(--mono);
  font-size: var(--t-small);
  padding: 6px 10px;
  background: var(--surface);
  border: var(--border-2);
  color: var(--ink-2);
  cursor: pointer;
}
.viz-seg[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- shared SVG helpers (the viz files lean on these) ----------
   fill lives on the <svg> so it INHERITS to <text> — a per-element fill="…"
   attribute then wins, letting a viz colour individual marks via the attribute
   without an inline style. Node/edge helper classes keep the 31 viz visually
   consistent: apply a class for the default treatment, override with an
   attribute only for the 1–2 focal / state marks. */
.viz-svg { fill: var(--ink); font-family: var(--mono); }
.viz-svg text { font-family: var(--mono); }

.viz-title { font-size: 13px; font-weight: var(--fw-title); fill: var(--ink); }
.viz-label { font-size: 11px; fill: var(--ink-2); }
.viz-muted { font-size: 11px; fill: var(--ink-3); }
.viz-mono  { font-size: 10px; fill: var(--ink-2); }

/* node box: default backend/step treatment */
.viz-node { fill: var(--surface); stroke: var(--ink); stroke-width: var(--dg-stroke); }
.viz-node.store  { fill: var(--hair); stroke: var(--ink-2); }
.viz-node.ext    { fill: var(--bg);   stroke: var(--hair-2); }
.viz-node.focal  { fill: var(--accent-2); stroke: var(--accent); }
.viz-node.good   { fill: var(--good-tint); stroke: var(--good); }
.viz-node.bad    { fill: var(--bad-tint);  stroke: var(--bad); }
.viz-node.off    { fill: var(--bg); stroke: var(--hair-2); stroke-dasharray: 4 3; opacity: 0.6; }

/* edges/connectors: draw BEFORE nodes so lines sit behind boxes */
.viz-edge { fill: none; stroke: var(--ink-2); stroke-width: var(--dg-edge); }
.viz-edge.accent { stroke: var(--accent); }
.viz-edge.good   { stroke: var(--good); }
.viz-edge.bad    { stroke: var(--bad); }
.viz-edge.dashed { stroke-dasharray: 5 4; }

/* status pill / metric readout */
.viz-pill { font-size: 10px; font-weight: var(--fw-title); letter-spacing: 0.04em; }
.viz-metric { font-size: 22px; font-weight: var(--fw-title); fill: var(--ink); }
.viz-good { fill: var(--good); }
.viz-bad  { fill: var(--bad); }
.viz-accent { fill: var(--accent); }
