/* Lesson interactives. An interactive is lesson content, so its frame is the hand-drawn line (sketch.js);
   the controls inside it (field, presets, toggles) stay clean 1.5px ink like the rest of the UI.
   Colour appears only as the watercolour wash on drawn data (bars, token chips). Tokens: b-app.css :root. */

.ix { position: relative; margin: var(--s-7) 0; padding: var(--s-5); border: var(--stroke) solid transparent; border-radius: var(--r-lg); background: #fff; }
.ix-head { margin-bottom: var(--s-4); }
.ix-head .kicker { margin-bottom: var(--s-1); }
.ix-head h3 { font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 700; letter-spacing: -.01em; margin: 0; }
.ix-head p { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); margin: var(--s-1) 0 0; }
.ix-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.ix-row + .ix-row, .ix-row + .ix-field, .ix-field + .ix-out { margin-top: var(--s-3); }
.ix-label { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--muted); margin-right: var(--s-1); }
.ix .chip { font-family: inherit; cursor: pointer; }
.ix .chip[aria-pressed="true"], .ix .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.ix-seg { display: inline-flex; border: var(--stroke) solid var(--line); border-radius: var(--r-pill); padding: 2px; margin-left: auto; }
.ix-seg .chip { border: 0; height: 28px; padding: 0 var(--s-3); }

.ix-field { display: block; position: relative; }
.ix-field textarea { display: block; width: 100%; min-height: 72px; resize: vertical; font: inherit; font-size: var(--t-sm); line-height: var(--lh-sm);
  color: var(--ink); background: #fff; border: var(--stroke) solid var(--line); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); }
.ix-field textarea:focus { outline: none; border-color: var(--ink); }

/* ---------- Tokenizer ---------- */
.tok-out { display: flex; flex-wrap: wrap; gap: 6px 4px; min-height: 48px; padding: var(--s-3) 0 var(--s-2); }
.tok { position: relative; display: inline-flex; flex-direction: column; align-items: center; padding: 3px 7px; border-radius: 7px;
  font-size: var(--t-sm); line-height: var(--lh-sm); white-space: pre; isolation: isolate; }
.tok::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--accent); filter: url(#wc-filter); }
.tok.k0::before { opacity: .62; }
.tok.k1::before { opacity: .32; }
.tok.k2::before { opacity: .46; }
.tok .ws, .ix-note .ws, .tok-line .ws { font-style: normal; color: var(--muted); padding: 0 1px; }
/* «␣» drawn in CSS so it looks the same in any font: an open box on the baseline */
.ws.sp { display: inline-block; width: .6em; height: .38em; margin: 0 .14em 0 .02em; padding: 0; border: 1.5px solid var(--ink-2); border-top: 0; border-radius: 0 0 2px 2px; vertical-align: baseline; opacity: .85; }
.tok-id { display: none; font-size: var(--t-xs); line-height: var(--lh-xs); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tok.partial .tok-t { color: var(--muted); }
.show-ids .tok-t { display: none; }
.show-ids .tok-id { display: block; font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink); }
.tok-msg { margin: 0; font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--muted); }
.ix.loading .tok-msg::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: var(--s-2); border: var(--stroke) solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: ixspin .8s linear infinite; vertical-align: -1px; }
@keyframes ixspin { to { transform: rotate(360deg); } }

.tok-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-4); padding-top: var(--s-3); border-top: 1px dashed var(--line); }
.tok-stats:empty { display: none; }
.tok-big { font-size: var(--t-sm); line-height: var(--lh-sm); }
.tok-big b { font-size: var(--t-xl); line-height: var(--lh-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.tok-sub { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--muted); }
.ix-note { margin: var(--s-3) 0 0; font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--muted); }

@media (max-width: 640px) {
  .ix { padding: var(--s-4); margin-left: calc(-1 * var(--s-1)); margin-right: calc(-1 * var(--s-1)); }
  .ix-seg { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .ix.loading .tok-msg::after { animation: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }


/* ---------- Step-through diagram («пошаговая схема», ix-walk.js) ----------
   A drawn scene the reader walks with «Дальше» / «Назад»; no autoplay. Without JS the step list reads as plain text.
   Pictures and ink stay black; colour is the course accent on the reader's bubble, the answer and flying tokens. */
.walk figcaption { font-weight: 600; margin-bottom: var(--s-3); }
.walk-stage { display: none; }
.walk.is-live .walk-stage { display: block; aspect-ratio: 640 / 360; margin: 0 calc(-1 * var(--s-2)); }
.walk.is-live .walk-stage.tall { aspect-ratio: 320 / 420; }
.walk-stage svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.walk-steps { margin: var(--s-3) 0 0; padding-left: 1.4em; font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); }
.walk.is-live .walk-steps { list-style: none; padding: 0; margin: 0; }
.walk.started .walk-steps { margin-top: var(--s-3); min-height: calc(2 * var(--lh-sm)); }
.walk-steps li + li { margin-top: var(--s-1); }
.walk.is-live .walk-steps li + li { margin-top: 0; }
.walk-bar { display: none; }
.walk.is-live .walk-bar { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
.walk-num { margin-right: auto; font-size: var(--t-xs); line-height: var(--lh-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.walk-bar button { white-space: nowrap; height: 36px; padding: 0 var(--s-4); border-radius: var(--r-pill); border: var(--stroke) solid var(--ink); font: inherit; font-size: var(--t-sm); font-weight: 600; cursor: pointer; }
.walk-prev { background: #fff; color: var(--ink); }
.walk-prev:disabled { border-color: var(--line); color: var(--muted); cursor: default; }
.walk-next { background: var(--ink); color: #fff; }
.walk-bar button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* scene parts (SVG user units ≈ px at the default stage width) */
.walk svg text { font-family: var(--sans); fill: var(--ink); }
.walk .w-node { transition: opacity .4s; }
.walk .w-node.dim, .walk .w-card.dim { opacity: .3; }
.walk .w-card { transition: opacity .4s; }
.walk .w-label { font-size: 13px; font-weight: 600; }
.walk .w-note { font-size: 12px; fill: var(--muted); }
.walk .w-title { font-size: 13px; font-weight: 600; }
.walk .w-ink, .walk .w-wire { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.walk .w-wire { stroke-dasharray: 2 7; }
.walk .w-paper { fill: #fff; }
.walk .w-bubble rect { fill: #fff; stroke: var(--ink); stroke-width: 1.4; }
.walk .w-bubble.mine rect { fill: var(--accent); stroke: none; }
.walk .w-bubble text { font-size: 13px; }
.walk .w-chip rect { fill: #fff; stroke: var(--ink); stroke-width: 1.4; }
.walk .w-chip.tok rect { fill: var(--accent); stroke: none; }
.walk .w-chip text { font-size: 12px; font-weight: 600; }
.walk .w-words { font-size: 13px; font-weight: 600; }
.walk .w-line.me { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.walk .w-line.ai { fill: var(--accent); }
@media (prefers-reduced-motion: reduce) { .walk .w-node, .walk .w-card { transition: none; } }
.walk:not(.started) .walk-prev { display: none; }
.walk .w-region .w-ink { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 3 6; }
.walk .w-region .w-paper { fill: none; }
.walk .w-region .w-title { fill: var(--muted); }
@media (max-width: 480px) { .walk.is-live .walk-bar { flex-wrap: wrap; justify-content: flex-end; } .walk-num { flex-basis: 100%; } }
.walk .w-row { font-size: 12px; fill: var(--ink-2); }
.walk .w-row.new { font-weight: 600; fill: var(--ink); }
.walk .w-bubble.out rect { stroke-dasharray: 3 4; }
