/* style.css — one stylesheet, no preprocessor.
 * Colours are tokens on :root. Dark mode is defined twice on purpose:
 * once for "auto" (follow the OS, unless the user forced light) and once for
 * the explicit dark choice. */

:root {
  --bg: #f4f6f8;
  --fg: #1b1f24;
  --muted: #525a66;
  --card: #ffffff;
  --border: #d3d9e0;
  --accent: #1a5fb4;
  --accent-fg: #ffffff;
  --accent-soft: #e4edf9;
  --ok: #1b6b36;
  --ok-soft: #e3f3e8;
  --err: #b3261e;
  --err-soft: #fbe7e5;
  --warn: #6b4e00;
  --warn-soft: #fff4d6;
  --code-bg: #eef1f4;
  --focus: #c25e00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519;
    --fg: #e7eaee;
    --muted: #a3acb8;
    --card: #1b2027;
    --border: #323a44;
    --accent: #8ab4f8;
    --accent-fg: #0c1a2e;
    --accent-soft: #1f2d44;
    --ok: #7bd68f;
    --ok-soft: #163322;
    --err: #f5918a;
    --err-soft: #3b1d1b;
    --warn: #ffd37a;
    --warn-soft: #3a2e10;
    --code-bg: #262c35;
    --focus: #ffcc4d;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121519;
  --fg: #e7eaee;
  --muted: #a3acb8;
  --card: #1b2027;
  --border: #323a44;
  --accent: #8ab4f8;
  --accent-fg: #0c1a2e;
  --accent-soft: #1f2d44;
  --ok: #7bd68f;
  --ok-soft: #163322;
  --err: #f5918a;
  --err-soft: #3b1d1b;
  --warn: #ffd37a;
  --warn-soft: #3a2e10;
  --code-bg: #262c35;
  --focus: #ffcc4d;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute must win over any display rule below (e.g. the walkthrough grid). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.4em; }
li { margin-bottom: 0.4em; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}
code {
  background: var(--code-bg);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}
pre {
  margin: 0;
  padding: 12px 14px;
  background: var(--code-bg);
  border-radius: 8px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 8px;
}
.skip-link:focus { left: 16px; }

/* ---------- header ---------- */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--fg);
  text-decoration: none;
}
.brand-mark {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.controls { display: flex; gap: 8px; }

.tabs {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
}
.tabs a {
  display: block;
  padding: 10px 14px;
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  font-weight: 500;
}
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- layout ---------- */

main.wrap { padding-top: 24px; padding-bottom: 48px; }

.view-walkthrough {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.lead { font-size: 1.1rem; }
.meta { color: var(--muted); }
.kicker {
  color: var(--muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25em;
}
.callout {
  background: var(--warn-soft);
  color: var(--warn);
  border-left: 4px solid currentColor;
  padding: 10px 14px;
  border-radius: 6px;
}

.notice {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--accent-soft);
}
.notice-error { background: var(--err-soft); color: var(--err); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.actions-secondary { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.btn-choice {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg);
}
.btn-choice:hover { background: var(--accent-soft); }

/* ---------- stepper (walkthrough sidebar) ---------- */

.progress-text { margin: 0 0 6px; font-size: 0.9rem; color: var(--muted); }
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill { height: 100%; background: var(--ok); width: 0; }

.stepper { list-style: none; margin: 0; padding: 0; }
.stepper li { margin: 0; }
.stepper-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
}
.stepper-link:hover { background: var(--accent-soft); }
.stepper-link[aria-current="step"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.stepper-num {
  flex: none;
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
}
.stepper-link.is-done .stepper-num {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
:root[data-theme="dark"] .stepper-link.is-done .stepper-num { color: #0b1a10; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stepper-link.is-done .stepper-num { color: #0b1a10; }
}

/* ---------- step parts ---------- */

.part { margin-top: 28px; }
.part-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-left: 10px;
  border-left: 4px solid var(--accent);
  margin-bottom: 0.75em;
}
.part-check .part-label { border-color: var(--ok); }
.part-mistake .part-label { border-color: var(--err); }
.part-terms .part-label { border-color: var(--warn); }

.how-list li { margin-bottom: 0.6em; }

.shot { margin: 0 0 18px; }
.shot img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.shot figcaption { font-size: 0.875rem; color: var(--muted); margin-top: 6px; }
.shot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  padding: 24px 16px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--muted);
}
.shot-placeholder-title { font-weight: 600; color: var(--fg); }
.shot-placeholder-alt { font-size: 0.9rem; max-width: 48ch; }

.cmd { margin: 12px 0; }
.cmd-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.copy-status { font-size: 0.9rem; color: var(--ok); }

.terms { margin: 0; }
.terms dt { font-weight: 600; }
.terms dd { margin: 0 0 0.6em; color: var(--muted); }

.badge {
  display: inline-block;
  vertical-align: middle;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
}

/* quiz */
.quiz fieldset { border: 0; padding: 0; margin: 0 0 12px; }
.quiz legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
}
.option:hover { background: var(--bg); }
.option input { width: 1.25em; height: 1.25em; margin: 0.2em 0 0; flex: none; accent-color: var(--accent); }
.option label { cursor: pointer; flex: 1; }
.feedback { margin: 12px 0 0; padding: 0; border-radius: 8px; }
.feedback:not(:empty) { padding: 10px 14px; background: var(--accent-soft); }
.feedback.is-correct { background: var(--ok-soft); color: var(--ok); }
.feedback.is-wrong { background: var(--err-soft); color: var(--err); }

.step-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---------- troubleshooter ---------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs [aria-current="page"] { color: var(--fg); font-weight: 600; }

.ts-question { font-size: 1.125rem; font-weight: 600; }
.choices { margin-top: 12px; }

/* ---------- help form ---------- */

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.hint { font-size: 0.9rem; color: var(--muted); margin: 0 0 6px; }
.field input, .field textarea, .field select, .help-output {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}
.field textarea, .help-output { resize: vertical; }
.help-output { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.site-footer p { margin: 0; }

/* ---------- small screens ---------- */

@media (max-width: 820px) {
  .view-walkthrough { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .stepper-wrap { min-width: 0; }
  .stepper { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; }
  .stepper li { flex: none; }
  .stepper-link { padding: 6px 10px; }
  .stepper-title { white-space: nowrap; font-size: 0.9rem; }
  .card { padding: 18px 16px; }
  h1 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
