/* demo-2026 english trainer — shares the site's theme tokens so light/dark
   match, and reuses the segmented-control look from /diagrams/. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --fg: #1a1c1f;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --danger: #b91c1c;
  --success: #15803d;
  /* Timeline zone hues: past / present / future. Present reuses the accent so
     the "now" band stays the page's primary colour. */
  --zone-past: #d97706;
  --zone-present: var(--accent);
  --zone-future: #0f766e;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --fg: #e7e9ee;
  --muted: #9aa1ad;
  --card: #171a21;
  --border: #262b34;
  --accent: #8b8cf7;
  --accent-fg: #0f1115;
  --danger: #f87171;
  --success: #4ade80;
  --zone-past: #f59e0b;
  --zone-present: var(--accent);
  --zone-future: #2dd4bf;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --fg: #e7e9ee;
    --muted: #9aa1ad;
    --card: #171a21;
    --border: #262b34;
    --accent: #8b8cf7;
    --accent-fg: #0f1115;
    --danger: #f87171;
    --success: #4ade80;
    --zone-past: #f59e0b;
    --zone-future: #2dd4bf;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Wider than the plain demos: the reference view holds a four-column table. */
.card {
  width: 100%;
  max-width: 880px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 40px -20px rgba(0, 0, 0, 0.4);
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
}

h1 {
  margin: 0 0 12px;
  font-size: 40px;
  letter-spacing: -0.02em;
}

.lede { margin: 0 0 20px; color: var(--muted); }

/* Mode switcher: a native radio group styled as a segmented control, same as
   the /diagrams/ toolbar. */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.field-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--muted);
}

.switcher {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  transition: color 0.15s ease, background 0.15s ease;
}

/* The radio itself is visually hidden; the label is the clickable pill. */
.seg input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.seg:has(input:checked) {
  background: var(--accent);
  color: var(--accent-fg);
}

.seg:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Sub-tabs inside a module (Справочник / Практика). Reuses .switcher/.seg. */
.subtabs { margin: 0 0 16px; }

.view { border-top: 1px solid var(--border); padding-top: 20px; }
.view[hidden] { display: none; }

.view-intro { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

/* Timeline legend above the table: the same track the rows use, once, labelled
   past / now / future so each row's mini-timeline reads without repeating text. */
.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.legend-track {
  position: relative;
  flex: 1 1 220px;
  min-width: 200px;
  height: 26px;
}

.legend-ends {
  display: flex;
  justify-content: space-between;
  flex: 1 1 220px;
  min-width: 200px;
}

.legend-key { display: inline-flex; align-items: center; gap: 6px; }

.legend-swatch {
  width: 14px;
  height: 8px;
  border-radius: 4px;
  background: var(--z, var(--muted));
}

.legend-key.past { --z: var(--zone-past); }
.legend-key.present { --z: var(--zone-present); }
.legend-key.future { --z: var(--zone-future); }

/* Reference table: one row per tense, grouped by zone. Scrolls sideways on
   narrow screens rather than crushing the four columns. */
.table-scroll { overflow-x: auto; }

.tenses {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tenses th,
.tenses td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.tenses thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.tenses .zone-row th {
  padding-top: 16px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--z, var(--fg));
}

.zone-row.past { --z: var(--zone-past); }
.zone-row.present { --z: var(--zone-present); }
.zone-row.future { --z: var(--zone-future); }

.zone-note { color: var(--muted); font-weight: 400; text-transform: none; }

.tense-name { font-weight: 600; white-space: nowrap; }
.tense-form { color: var(--fg); }
.tense-when { color: var(--muted); }
.tense-when .markers { color: var(--fg); opacity: 0.8; }
.tense-col-tl { width: 190px; }

/* Mini-timeline: a shared track with a dashed "now" line; each tense draws a
   dot (point action), a bar (process) and/or a cap (completion boundary),
   positioned by percent along past→future. Colour comes from the zone. */
.tl {
  position: relative;
  height: 24px;
  min-width: 160px;
  color: var(--z, var(--muted));
}

.tl.past { --z: var(--zone-past); }
.tl.present { --z: var(--zone-present); }
.tl.future { --z: var(--zone-future); }

.tl-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: var(--border);
  border-radius: 2px;
}

.tl-now {
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 2px;
  border-left: 1px dashed var(--muted);
}

.tl-seg {
  position: absolute;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  background: currentColor;
  border-radius: 5px;
}

.tl-dot {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%);
  background: currentColor;
  border-radius: 50%;
}

.tl-cap {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 15px;
  transform: translate(-50%, -50%);
  background: currentColor;
  border-radius: 2px;
}

/* Practice view. */
.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.quiz-kind {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.quiz-score { font-size: 13px; color: var(--muted); }
.quiz-score b { color: var(--fg); }

.quiz-prompt {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--muted);
}

.quiz-focus {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
}

.quiz-focus .quiz-when {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quiz-opt {
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.quiz-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quiz-opt:disabled { cursor: default; }

.quiz-opt.is-correct {
  border-color: var(--success);
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}

.quiz-opt.is-wrong {
  border-color: var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.quiz-feedback {
  margin: 16px 0 0;
  min-height: 1.5em;
  font-size: 14px;
}

.quiz-feedback .verdict { font-weight: 600; }
.quiz-feedback.ok .verdict { color: var(--success); }
.quiz-feedback.no .verdict { color: var(--danger); }
.quiz-feedback .explain { color: var(--muted); }

.quiz-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.quiz-next {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--accent-fg);
  padding: 8px 16px;
  border-radius: 10px;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.quiz-next:hover { filter: brightness(1.08); }
.quiz-next:active { transform: translateY(1px); }
.quiz-next:disabled { opacity: 0.5; cursor: default; }

.quiz-reset {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.quiz-reset:hover { color: var(--fg); }

@media (max-width: 640px) {
  .card { padding: 24px; }
  .quiz-options { grid-template-columns: 1fr; }
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

footer button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 10px;
  transition: transform 0.08s ease, filter 0.15s ease;
}

footer button:hover { filter: brightness(1.08); }
footer button:active { transform: translateY(1px); }
