/* AI Engineering Roadmap — course styles.
   Colours, fonts and radii come from the shared /assets/tokens.css (light by
   default, night via html[data-theme="dark"]). Nothing in this file names a
   colour; edit tokens.css instead and bump VERSION in sw.js. */

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  background: var(--grain), var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent-soft); }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
em { font-style: italic; }

.skip { position: absolute; left: -999px; top: 12px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--r-s); z-index: 300; }
.skip:focus { left: 12px; }

/* ───────── PROGRESS RAIL & TOPNAV ───────── */
.progress-rail { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--line); z-index: 210; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s ease; }

.topnav {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  padding: 16px clamp(20px, 3vw, 32px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topnav .brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.brand-name { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 18px; text-decoration: none; white-space: nowrap; }
.brand-dot { color: var(--accent); }
.topnav .crumbs { display: flex; gap: 10px; align-items: baseline; font-size: 15px; color: var(--ink-2); }
.topnav .crumbs a { text-decoration: none; color: var(--ink-2); }
.topnav .crumbs a:hover { color: var(--ink); }
.topnav .crumbs .sep { color: var(--ink-3); }
.topnav-right { display: flex; gap: 16px; align-items: baseline; flex: none; }
.progress-stats { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); letter-spacing: 0.02em; white-space: nowrap; }
.progress-stats .pct { color: var(--ink); }
.tn-btn { background: none; border: 0; padding: 2px 0; cursor: pointer; font-size: 14px; color: var(--ink-2); transition: color .2s ease; }
.tn-btn:hover { color: var(--ink); }

/* ───────── BUTTONS (one vocabulary with the landing) ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 42px; padding: 10px 20px; border-radius: var(--r); border: 0;
  background: var(--ink); color: var(--paper);
  font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: opacity .2s ease, background .2s ease;
}
.btn:hover { opacity: 0.88; }
.btn.btn-quiet { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.btn-quiet:hover { opacity: 1; background: var(--surface-2); }

/* ───────── CONTAINERS ───────── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 clamp(20px, 3vw, 32px); position: relative; }
.container.hero { padding-top: clamp(56px, 9vh, 96px); padding-bottom: 24px; }
section.container { padding-top: clamp(64px, 10vh, 104px); }
.content { max-width: var(--content-w); margin: 0 auto; }

/* ───────── HERO (index) ───────── */
.hero-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(40px, 6.4vw, 84px); line-height: 1.02; letter-spacing: -0.015em; max-width: 14ch; text-wrap: balance; }
.hero-title em, .section-title em, .tools-title em, .notes-title em { font-style: italic; color: var(--accent-strong); }
.hero-deck { margin-top: 24px; font-size: 18px; color: var(--ink-2); max-width: 58ch; }
.hero-facts { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 6px 0; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); letter-spacing: 0.02em; }
.hero-facts span + span::before { content: '·'; margin: 0 10px; color: var(--accent); }
.hero-actions { margin-top: 28px; }

/* ───────── SECTIONS ───────── */
.section-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(27px, 3.4vw, 40px); line-height: 1.14; letter-spacing: -0.01em; max-width: 24ch; text-wrap: balance; }
.section-intro { margin-top: 12px; color: var(--ink-2); max-width: 62ch; }

/* landscape: the dated block */
.landscape { margin-top: 32px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px 40px; }
.landscape-group h3 { font-family: var(--font-display); font-weight: 600; font-size: 20px; margin-bottom: 8px; }
.landscape-group ul { list-style: none; padding: 0; margin: 0; }
.landscape-group li { position: relative; padding: 10px 0 10px 20px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); }
.landscape-group li:last-child { border-bottom: 1px solid var(--line); }
.landscape-group li::before { content: ''; position: absolute; left: 1px; top: 18px; width: 6px; height: 6px; background: var(--accent); transform: rotate(45deg); }

/* ───────── DIAGNOSTIC ───────── */
.diagnostic-layout { margin-top: 32px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.diagnostic-result { background: var(--paper-2); border-radius: var(--r-l); padding: 26px 26px 28px; position: sticky; top: 84px; }
.diagnostic-score { font-family: var(--font-display); font-weight: 600; font-size: 34px; line-height: 1; }
.diagnostic-result h3 { margin-top: 12px; font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.diagnostic-result p { margin-top: 8px; font-size: 15px; color: var(--ink-2); }

/* ───────── OFFICIAL TRACKS ───────── */
.track-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.track-card {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px;
  padding: 22px 24px 20px; border-radius: var(--r);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  text-decoration: none; transition: background .2s ease;
}
.track-card:hover { background: var(--surface-2); }
.track-org { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--ink-3); }
.track-card h3 { font-family: var(--font-display); font-weight: 600; font-size: 21px; line-height: 1.2; }
.track-card p { font-size: 15px; color: var(--ink-2); }
.track-foot { font-size: 13.5px; color: var(--ink-3); }

/* ───────── PHASE CARDS (index) ───────── */
.phase-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.phase-card {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px;
  padding: 22px 24px; border-radius: var(--r);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  text-decoration: none; transition: background .2s ease;
}
.phase-card:hover { background: var(--surface-2); }
.phase-card-num { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 38px; line-height: 1; color: var(--accent-strong); }
.phase-card-body { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; }
.phase-card-title { font-family: var(--font-display); font-weight: 600; font-size: 21px; line-height: 1.2; }
.phase-card-goal { font-size: 14.5px; color: var(--ink-2); }
.phase-card-progress { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.phase-card-progress .bar, .phase-progress .bar, .phase-rail-mini { display: block; height: 3px; border-radius: 3px; background: var(--line-strong); overflow: hidden; }
.phase-card-progress .bar-fill, .phase-progress .bar-fill, .phase-rail-mini > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.phase-card-progress .duration { white-space: nowrap; }

/* ───────── WEEK PLAN ───────── */
.week-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 32px; }
.week-card { padding: 16px 0 18px; border-top: 1px solid var(--line); }
.week-card span { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.week-card h3 { margin-top: 4px; font-family: var(--font-display); font-weight: 600; font-size: 18px; line-height: 1.2; }
.week-card p { margin-top: 6px; font-size: 14px; color: var(--ink-2); }

/* ───────── CROSS-CUTTING THEMES ───────── */
.skill-map { margin: 28px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 40px; }
.skill-map li { padding: 14px 0; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); }
.skill-map strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--ink); margin-bottom: 4px; }

/* ───────── FOOTER TOOLS (index) ───────── */
.footer-tools { margin-top: clamp(64px, 10vh, 104px); background: var(--paper-2); border-radius: var(--r-l); padding: clamp(24px, 4vw, 40px); }
.tools-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: center; }
.tools-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.2; }
.tools-grid p { margin-top: 10px; font-size: 15px; color: var(--ink-2); max-width: 48ch; }
.tools-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ───────── LESSON PAGE HEADER ───────── */
.lesson-header.container { padding-top: clamp(48px, 8vh, 84px); }
.lesson-num { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: clamp(48px, 7vw, 84px); line-height: 1; color: var(--accent-strong); }
.lesson-title { margin-top: 6px; font-family: var(--font-display); font-weight: 600; font-size: clamp(32px, 4.6vw, 56px); line-height: 1.06; letter-spacing: -0.012em; max-width: 20ch; text-wrap: balance; }
.lesson-goal { margin-top: 18px; font-size: 18px; color: var(--ink-2); max-width: 60ch; }
.lesson-meta { margin-top: 14px; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); }

/* ───────── GROUP HEADERS ───────── */
.sub-head { margin: 44px 0 14px; font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.2; scroll-margin-top: 80px; }
.content > .sub-head:first-child, .status-filter + .sub-head { margin-top: 24px; }

/* ───────── CHECKLIST ───────── */
.checklist { display: flex; flex-direction: column; }
.check-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: start;
  padding: 16px 4px; border-top: 1px solid var(--line);
  cursor: pointer; transition: background .2s ease;
}
.checklist .check-item:last-child, .diagnostic-checks .check-item:last-child { border-bottom: 1px solid var(--line); }
.check-item:hover { background: var(--surface); }
.checkbox { width: 20px; height: 20px; margin-top: 3px; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--surface); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .15s ease, border-color .15s ease; }
.checkbox::after { content: ''; width: 10px; height: 5px; border-left: 2px solid var(--paper); border-bottom: 2px solid var(--paper); transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform .15s ease; }
.check-item.done .checkbox { background: var(--ink); border-color: var(--ink); }
.check-item.done .checkbox::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check-content { min-width: 0; }
.check-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.03em; display: flex; flex-wrap: wrap; gap: 4px 0; }
.check-source::before { content: '·'; margin: 0 8px; color: var(--accent); }
.check-title { margin-top: 3px; font-size: 17px; font-weight: 600; line-height: 1.35; }
.check-title a { text-decoration: none; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.check-title a:hover { text-decoration: underline; }
.check-desc { margin-top: 5px; font-size: 15px; color: var(--ink-2); }
.check-desc strong { color: var(--ink); }
.check-item.done .check-title, .check-item.done .check-desc, .check-item.done .check-meta { opacity: 0.55; }
.copy-btn { margin-left: 8px; background: none; border: 0; padding: 0 2px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); cursor: pointer; vertical-align: middle; }
.copy-btn:hover { color: var(--ink); }
.copy-btn.copied { color: var(--ok); }

/* status filter (lesson): text controls, active carries the weight */
.status-filter { margin-top: 28px; display: flex; gap: 18px; font-size: 14px; }
.status-chip { background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--ink-3); border-bottom: 2px solid transparent; }
.status-chip:hover { color: var(--ink); }
.status-chip.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.status-hidden, .filter-hidden { display: none !important; }

/* ───────── PHASE PROGRESS (lesson) ───────── */
.phase-progress { margin-top: 32px; display: grid; gap: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }
.phase-progress .count { color: var(--ink); }

/* ───────── LESSON BODY ───────── */
.lesson-body { margin-top: 36px; font-size: 17px; color: var(--ink-2); max-width: 64ch; }
.lesson-body p + p { margin-top: 14px; }

/* ───────── NOTES ───────── */
.notes-block { margin-top: 44px; background: var(--paper-2); border-radius: var(--r-l); padding: 24px; scroll-margin-top: 80px; }
.notes-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.notes-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.notes-status { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.notes-status.saved { color: var(--ok); }
.notes-textarea { margin-top: 14px; width: 100%; min-height: 160px; resize: vertical; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-family: var(--font-body); font-size: 15.5px; line-height: 1.55; }
.notes-textarea::placeholder { color: var(--ink-3); }
.notes-textarea:focus { outline: 2px solid var(--accent-strong); outline-offset: 1px; }

/* ───────── QUIZ ───────── */
.quiz-block { margin-top: 48px; scroll-margin-top: 80px; }
.quiz-question { padding: 24px 0 28px; border-top: 1px solid var(--line); }
.quiz-q-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); letter-spacing: 0.03em; }
.quiz-q-text { margin-top: 8px; font-family: var(--font-display); font-weight: 600; font-size: 21px; line-height: 1.3; max-width: 40ch; }
.quiz-options { margin-top: 16px; display: grid; gap: 8px; }
.quiz-option {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 12px 14px; border-radius: var(--r-s);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 15.5px; line-height: 1.45; cursor: pointer; transition: background .15s ease, box-shadow .15s ease;
}
.quiz-option:hover { background: var(--surface-2); }
.quiz-option-marker { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); line-height: 22px; }
.quiz-option.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.quiz-option.selected .quiz-option-marker { color: var(--accent-strong); }
.quiz-question.answered .quiz-option { cursor: default; }
.quiz-question.answered .quiz-option:hover { background: var(--surface); }
.quiz-question.answered .quiz-option.correct { background: var(--ok-soft); box-shadow: inset 0 0 0 2px var(--ok); }
.quiz-question.answered .quiz-option.correct .quiz-option-marker { color: var(--ok); }
.quiz-question.answered .quiz-option.wrong-pick { background: var(--danger-soft); box-shadow: inset 0 0 0 2px var(--danger); }
.quiz-question.answered .quiz-option.wrong-pick .quiz-option-marker { color: var(--danger); }
.quiz-explanation { display: none; margin-top: 14px; font-size: 15px; color: var(--ink-2); max-width: 64ch; }
.quiz-explanation strong { color: var(--ink); }
.quiz-question.answered .quiz-explanation { display: block; }
.quiz-controls { margin-top: 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quiz-score { margin-left: auto; font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); }
.quiz-score .pts { color: var(--ink); font-weight: 600; }
.quiz-score.perfect .pts { color: var(--ok); }

/* ───────── LESSON NAV (bottom) ───────── */
.lesson-nav { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: start; }
.lesson-nav-link { text-decoration: none; display: grid; gap: 4px; min-width: 0; }
.lesson-nav-link.next { text-align: right; }
.lesson-nav-link.disabled { color: var(--ink-3); pointer-events: none; }
.lesson-nav-direction { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.lesson-nav-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.3; }
.lesson-nav-link:hover .lesson-nav-title { color: var(--accent-strong); }
.lesson-nav-center { padding-top: 22px; }
.lesson-nav-center a { font-size: 14px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.lesson-nav-center a:hover { color: var(--ink); }

/* ───────── FOOTER ───────── */
footer { margin-top: clamp(72px, 12vh, 120px); background: var(--paper-2); padding: 28px 0 34px; }
.footer-row { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; flex-wrap: wrap; }
.footer-meta { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); }
.footer-link { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 16px; text-decoration: none; }

/* ───────── TOAST ───────── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 220; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--ok); }
.toast.error { background: var(--danger); }

/* ───────── SEARCH BAR ───────── */
.search-bar { display: none; position: sticky; top: 55px; z-index: 190; padding: 10px clamp(20px, 3vw, 32px); background: var(--paper); border-bottom: 1px solid var(--line); align-items: center; gap: 12px; }
.search-bar.open { display: flex; }
.search-bar input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: var(--r-s); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 15px; }
.search-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ───────── DESKTOP SIDE-RAILS ───────── */
.phase-rail, .lesson-toc { display: none; }
.phase-rail-title, .toc-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 12px; }
.phase-rail-item { display: block; padding: 8px 0; text-decoration: none; color: var(--ink-2); font-size: 13.5px; line-height: 1.3; border-top: 1px solid var(--line); }
.phase-rail-item:hover { color: var(--ink); }
.phase-rail-item.active { color: var(--ink); font-weight: 600; }
.phase-rail-item .pr-num { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-bottom: 2px; }
.phase-rail-item.active .pr-num { color: var(--accent-strong); }
.phase-rail-mini { margin-top: 7px; }
.lesson-toc a { display: block; padding: 5px 0 5px 12px; text-decoration: none; color: var(--ink-2); font-size: 13.5px; line-height: 1.35; border-left: 2px solid transparent; }
.lesson-toc a:hover { color: var(--ink); }
.lesson-toc a.active { color: var(--ink); font-weight: 600; border-left-color: var(--accent); }

@media (min-width: 1280px) {
  section.container.has-rails { max-width: 1480px; display: grid; grid-template-columns: 212px minmax(0, 1fr) 200px; gap: 44px; align-items: start; }
  section.container.has-rails > .content { max-width: none; margin: 0; min-width: 0; }
  section.container.has-rails > .phase-rail, section.container.has-rails > .lesson-toc { display: block; position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; padding-bottom: 24px; }
}
@media (min-width: 1660px) {
  section.container.has-rails { max-width: 1600px; grid-template-columns: 230px minmax(0, 1fr) 220px; }
}

/* ───────── RESPONSIVE ───────── */
@media (max-width: 980px) {
  .landscape { grid-template-columns: 1fr; gap: 20px; }
  .week-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .diagnostic-layout { grid-template-columns: 1fr; }
  .diagnostic-result { position: static; }
  .track-grid, .phase-grid { grid-template-columns: 1fr; }
  .skill-map { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topnav { flex-wrap: wrap; row-gap: 6px; }
  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav-link.next { text-align: left; }
  .lesson-nav-center { padding-top: 0; }
  .quiz-score { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .week-grid { grid-template-columns: 1fr; }
  .phase-card { grid-template-columns: 1fr; gap: 6px; }
  .phase-card-progress { grid-template-columns: auto 1fr; }
  .phase-card-progress .duration { grid-column: 1 / -1; }
  .hero-title { font-size: clamp(36px, 11vw, 48px); }
  .hero-facts { display: grid; gap: 4px; }
  .hero-facts span + span::before { content: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-fill, .bar-fill, .phase-rail-mini > span, .checkbox, .checkbox::after, .toast { transition: none; }
}
