/* The kit (CLEW-162): one class per component, theme tokens only. Loaded after washi.css.
 * Names start with k- so the old page rules keep working until CLEW-163/164 move each page over.
 * No font family, color literal, inline style or external font here (tests/test_kit.py).
 * Every color is a theme token, so each component renders in all seven themes. */

:root[data-theme] {
  --k-gap: 16px;
  --k-pad: 22px;
  --k-card-radius: 26px 22px 28px 20px;
  --k-target: 44px;
  --k-target-lg: 56px;
  --k-measure: 46rem;
}

/* Page frame: one column, side padding, clear of the top bar, one H1 */
.k-page { box-sizing: border-box; width: 100%; max-width: var(--k-measure); margin: 0 auto; padding: calc(var(--bar-h) + 24px) 16px 64px; color: var(--ink); font-family: var(--font-ui); }
.k-page > h1 { margin: 0 0 12px; font-size: 32px; line-height: 1.2; font-weight: 900; }
.k-page h2 { margin: 0 0 10px; font-size: 22px; line-height: 1.3; font-weight: 900; }
.k-page p { line-height: 1.6; }
.k-page-wide { max-width: 72rem; }
@media (min-width: 720px) { .k-page { padding-left: 24px; padding-right: 24px; } }

/* Section rule: brush divider, then a heading with its plain-word label */
.k-section { margin: 40px 0 0; }
.k-section > .k-rule { margin-bottom: 14px; }
.k-rule { display: block; height: 12px; border: 0; margin: 0; background: var(--ink); opacity: 0.22; -webkit-mask: var(--brush) center / 100% 100% no-repeat; mask: var(--brush) center / 100% 100% no-repeat; }
.k-label { margin: 0 0 4px; font-size: 14px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink-2); }

/* Card */
.k-card { box-sizing: border-box; padding: var(--k-pad); border-radius: var(--k-card-radius); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
.k-card + .k-card { margin-top: var(--k-gap); }

/* Control row: label, control, live value; stacks on a phone */
.k-row { display: grid; grid-template-columns: 1fr; gap: 6px; align-items: center; margin: 12px 0; }
.k-row > label, .k-row > .k-row-label { font-weight: 700; color: var(--ink); }
.k-row > output, .k-row > .k-value { font-variant-numeric: tabular-nums; color: var(--ink-2); }
@media (min-width: 560px) { .k-row { grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) 5rem; gap: 14px; } }

/* Button: primary 56 px, quiet 44 px, pill */
.k-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; min-height: var(--k-target-lg); padding: 0 26px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: inherit; font-size: 17px; font-weight: 700; text-decoration: none; cursor: pointer; }
.k-btn:hover { filter: brightness(1.08); }
.k-btn-quiet { min-height: var(--k-target); padding: 0 18px; border: 1.5px solid var(--edge); background: var(--surface); color: var(--ink); font-size: 16px; }
.k-btn:disabled, .k-btn[aria-disabled="true"] { opacity: 0.55; cursor: default; filter: none; }

/* Chip: 30 px to the eye, 44 px to the thumb */
.k-chip { position: relative; display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border: 1.5px solid var(--edge); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.k-chip::after { content: ""; position: absolute; inset: -7px 0; }
.k-chip[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--ink); }
.k-chip[aria-pressed="true"]::before { content: "\2713\00a0"; }

/* Segmented control: pick one of a few (aria-pressed), the pick also shows a tick */
.k-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 4px; border-radius: 999px; background: var(--substrate); }
.k-seg > button { min-height: 36px; min-width: var(--k-target); padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.k-seg > button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.k-seg > button[aria-pressed="true"]::before { content: "\2713\00a0"; }

/* Slider: a labeled range with its value shown beside it (use inside .k-row) */
.k-slider { width: 100%; min-height: var(--k-target); margin: 0; accent-color: var(--accent); background: transparent; }

/* Tally bars: label, bar, number */
.k-bars { display: grid; gap: 8px; margin: 12px 0; padding: 0; list-style: none; }
.k-bar { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) 3.5rem; gap: 10px; align-items: center; }
.k-bar-name { overflow-wrap: anywhere; color: var(--ink); }
.k-bar-track { height: 14px; border-radius: 999px; background: var(--substrate); overflow: hidden; }
.k-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); width: calc(var(--k-share, 0) * 1%); }
.k-bar-num { font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-2); }

/* Number panel: a big figure with a small caption */
.k-num { display: inline-flex; flex-direction: column; gap: 2px; padding: 12px 18px; border-radius: var(--radius-sm); background: var(--substrate); color: var(--ink); }
.k-num-fig { font-family: var(--font-mono); font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.1; }
.k-num-cap { font-size: 14px; color: var(--ink-2); }

/* Notice: a glyph and a word lead it, so the kind never rests on color */
.k-notice { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 14px 18px; border-radius: var(--radius-sm); border: 1.5px solid var(--edge); background: var(--accent-3-tint); color: var(--ink); }
.k-notice-k { grid-column: 1 / -1; margin: 0; font-weight: 900; color: var(--ink); }
.k-notice-k::before { content: "\25B2\00a0"; }
.k-notice > p { grid-column: 1 / -1; margin: 0; }
.k-notice-info { background: var(--accent-tint); }
.k-notice-info .k-notice-k::before { content: "\25CF\00a0"; }

/* Knot: Ariadne on the page */
.k-knot { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; align-items: start; margin: 24px 0; }
.k-knot-portrait { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--substrate); }
.k-knot-who { margin: 0 0 2px; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.k-knot-say { margin: 0; font-size: 18px; line-height: 1.5; color: var(--ink); }
.k-knot-ask { margin-top: 10px; }

/* Path knot: the thread with done, next and later stops */
.k-path { margin: 0; padding: 0 0 0 28px; list-style: none; border-left: 3px solid var(--hairline); }
.k-stop { position: relative; padding: 0 0 18px 18px; color: var(--ink-2); }
.k-stop::before { content: ""; position: absolute; left: -38px; top: 4px; box-sizing: border-box; width: 18px; height: 18px; border: 2px solid var(--edge); border-radius: 50%; background: var(--void); }
.k-stop[data-state="done"]::before { background: var(--thread); border-color: var(--thread); }
.k-stop[data-state="next"]::before { border-color: var(--thread); box-shadow: 0 0 0 4px var(--thread-glow); }
.k-stop[data-state="next"] { color: var(--ink); font-weight: 700; }
.k-stop-state { margin-left: 8px; font-size: 14px; font-weight: 700; color: var(--ink-2); }

/* Table and list row: one responsive list */
.k-table-wrap { max-width: 100%; overflow-x: auto; }
.k-list { margin: 0; padding: 0; list-style: none; }
.k-list-row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
@media (min-width: 560px) { .k-list-row { grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); gap: 14px; } }
.k-list-row > :first-child { font-weight: 700; color: var(--ink); }

/* Form field: label, input, hint, error; 44 px targets */
.k-field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.k-field > label { font-weight: 700; }
.k-field > input, .k-field > select, .k-field > textarea { box-sizing: border-box; min-height: var(--k-target); padding: 0 12px; border: 1.5px solid var(--edge); border-radius: 12px; background: var(--surface-raised); color: var(--ink); font: inherit; font-size: 16px; }
.k-field-hint { margin: 0; font-size: 14px; color: var(--ink-3); }
.k-field-error { margin: 0; font-size: 14px; font-weight: 700; color: var(--tension); }
.k-field-error::before { content: "\25B2\00a0Problem: "; }

/* Code and machine text */
.k-code { margin: 12px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--substrate); color: var(--ink); font-family: var(--font-mono); font-size: 14px; line-height: 1.5; overflow-x: auto; white-space: pre; }

@media (prefers-reduced-motion: reduce) { .k-btn, .k-chip, .k-seg > button { transition: none; } }
