/* The Traffic Ladder: course index and lesson pages.
   Colors and type match the sales page (index.html). */

:root {
  --chalk: #F7F8F5;
  --ink: #12202B;
  --rung: #2F5BFF;
  --rung-dark: #1E43D6;
  --signal: #FF6B2C;
  --mist: #E6EAEE;
  --slate: #5A6672;
  --white: #ffffff;
  --tint: #EEF2FF;
  --accent: #2F5BFF;
  --accent-ink: #ffffff;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .grotesk {
  font-family: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.015em;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--rung); outline-offset: 3px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.wrap.wide { max-width: 960px; }
@media (max-width: 640px) {
  body { font-size: 17px; }
  .wrap { padding: 0 16px; }
}

.kicker {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--rung);
  margin-bottom: 14px;
}

/* Buttons */
.btn {
  display: inline-block;
  background: var(--rung);
  color: var(--white);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.3;
  padding: 16px 28px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--rung-dark); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(247, 248, 245, 0.95);
  border-bottom: 1px solid var(--mist);
  padding-top: env(safe-area-inset-top, 0px);
}
@supports (backdrop-filter: blur(8px)) {
  .topbar { backdrop-filter: blur(8px); background: rgba(247, 248, 245, 0.85); }
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.topbar a {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px;
  text-decoration: none; padding: 8px 0;
}
.topbar a:hover { color: var(--rung); }
.topbar-count { font-family: 'Space Grotesk', sans-serif; font-size: 14px; color: var(--slate); white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar .logout { font-weight: 500; color: var(--slate); }

/* Progress bar */
.bar { height: 8px; background: var(--mist); border-radius: 99px; overflow: hidden; }
.fill { display: block; height: 100%; width: 0; background: var(--rung); border-radius: 99px; transition: width 0.3s ease; }
.count { font-family: 'Space Grotesk', sans-serif; font-size: 15px; color: var(--slate); margin: 10px 0 0; }

/* Level tag */
.level-tag {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 4px;
}

/* ---------- Course index ---------- */
.course-hero { padding: 72px 0 56px; border-bottom: 1px solid var(--mist); }
.course-hero h1 { font-size: clamp(40px, 7vw, 64px); line-height: 1.02; font-weight: 700; }
.course-hero .sub { font-size: 19px; color: var(--slate); max-width: 34em; margin: 22px 0 30px; }
.course-hero .progress { max-width: 420px; margin-bottom: 30px; }

.rule { background: var(--ink); color: #c3cdd6; padding: 36px 0; }
.rule-line {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  font-size: clamp(22px, 3.4vw, 28px); line-height: 1.25; color: var(--white); margin: 0 0 8px;
}
.rule-note { margin: 0; font-size: 17px; }

.levels { padding-top: 24px; padding-bottom: 72px; }
.level { padding-top: 48px; }
.level-head { border-top: 4px solid var(--accent); padding-top: 20px; margin-bottom: 14px; }
.level-head h2 { font-size: clamp(24px, 3.6vw, 30px); line-height: 1.15; margin: 14px 0 6px; }
.level-covers { color: var(--slate); font-size: 16.5px; margin: 0 0 6px; }
.level-count { font-family: 'Space Grotesk', sans-serif; font-size: 14px; color: var(--slate); margin: 0; }

.lessons { list-style: none; margin: 0; padding: 0; }
.lesson-row a {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 16px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--mist);
  text-decoration: none;
  border-radius: 6px;
}
.lesson-row a:hover { background: var(--white); }
.lesson-row .num {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px;
  border: 2px solid var(--mist); color: var(--slate); background: var(--white);
  margin-top: 1px;
}
.lesson-row.is-done .num { background: var(--rung); border-color: var(--rung); color: transparent; position: relative; }
.lesson-row.is-done .num::after {
  content: ""; position: absolute; width: 7px; height: 13px;
  border: solid var(--white); border-width: 0 3px 3px 0;
  transform: rotate(45deg); top: 6px; left: 11px;
}
.lesson-title { display: block; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 18px; line-height: 1.3; }
.lesson-sub { display: block; color: var(--slate); font-size: 16px; line-height: 1.45; margin-top: 3px; }
.lesson-meta { font-family: 'Space Grotesk', sans-serif; font-size: 14px; color: var(--slate); white-space: nowrap; padding-top: 4px; }
.lesson-row.is-done .lesson-title { color: var(--slate); }
@media (max-width: 480px) {
  .lesson-row a { grid-template-columns: 32px 1fr; gap: 12px; }
  .lesson-meta { grid-column: 2; padding-top: 0; }
}

/* ---------- Lesson page ---------- */
.lesson-head { padding: 56px 0 36px; border-bottom: 1px solid var(--mist); }
.lesson-kicker { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; color: var(--slate); margin-bottom: 18px; }
.lesson-kicker .level-tag { margin-right: 8px; }
.lesson-head h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.06; font-weight: 700; text-wrap: balance; }
.lesson-head .subtitle { font-size: clamp(19px, 2.6vw, 22px); color: var(--slate); margin: 14px 0 0; line-height: 1.4; }
.lesson-head .meta { font-family: 'Space Grotesk', sans-serif; font-size: 15px; color: var(--slate); margin: 22px 0 0; }
.lesson-head .meta a { color: var(--rung); font-weight: 600; text-decoration: none; }
.lesson-head .meta a:hover { text-decoration: underline; }

.lesson-body { padding-top: 40px; padding-bottom: 8px; }
.lesson-body h2 { font-size: clamp(23px, 3.2vw, 27px); line-height: 1.2; margin: 56px 0 16px; }
.lesson-body h3 { font-size: 20px; line-height: 1.3; margin: 32px 0 10px; }
.lesson-body > :first-child { margin-top: 0; }
.lesson-body p, .lesson-body ul, .lesson-body ol { margin: 0 0 1.1em; }
.lesson-body ul, .lesson-body ol { padding-left: 1.4em; }
.lesson-body li { margin: 0.35em 0; }
.lesson-body li > ul, .lesson-body li > ol { margin: 0.35em 0 0; }
.lesson-body strong { font-weight: 600; }
.lesson-body a { color: var(--rung); }
.lesson-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em; background: #EDF0F3; padding: 0.12em 0.4em; border-radius: 4px;
  overflow-wrap: anywhere;
}

/* Examples and templates */
.lesson-body blockquote {
  margin: 1.4em 0;
  padding: 18px 22px;
  background: var(--white);
  border: 1px solid var(--mist);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  font-size: 17px;
  line-height: 1.65;
}
.lesson-body blockquote > :last-child { margin-bottom: 0; }
.lesson-body blockquote ul, .lesson-body blockquote ol { padding-left: 1.25em; }
.template-wrap { position: relative; margin: 1.4em 0; }
.template-wrap blockquote { margin: 0; padding-top: 46px; }
.template-label {
  position: absolute; top: 14px; left: 26px;
  font-family: 'Space Grotesk', sans-serif; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--slate);
}
.copy {
  position: absolute; top: 9px; right: 10px;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 14px;
  background: var(--tint); color: var(--rung-dark);
  border: 1px solid #D5DEFF; border-radius: 5px;
  padding: 6px 12px; cursor: pointer;
}
.copy:hover { background: #E1E8FF; }
.copy.copied { background: var(--rung); color: var(--white); border-color: var(--rung); }

/* Checklists */
.lesson-body li.task { list-style: none; position: relative; }
.lesson-body li.task .box {
  position: absolute; left: -1.35em; top: 0.3em;
  width: 16px; height: 16px; border: 2px solid var(--slate); border-radius: 3px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.4em 0;
  border: 1px solid var(--mist);
  border-radius: 6px;
  background: var(--white);
}
.lesson-body table { border-collapse: collapse; width: 100%; font-size: 16px; line-height: 1.45; }
.lesson-body th, .lesson-body td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--mist); }
.lesson-body th {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 14.5px;
  background: #F2F4F7; min-width: 110px;
}
.lesson-body tr:last-child td { border-bottom: 0; }
.lesson-body blockquote .table-wrap { margin: 0.6em 0; }

/* Action Step */
.action {
  background: var(--ink);
  color: #dfe6ec;
  border-radius: 10px;
  padding: 30px 30px 14px;
  margin: 56px 0 8px;
}
.action h2 { color: var(--white); margin: 0 0 14px; }
.action h2::before {
  content: "Your move";
  display: block;
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: #8aa2ff; margin-bottom: 8px;
}
.action strong { color: var(--white); }
.action a { color: #aebfff; }
.action li::marker { color: #8aa2ff; font-family: 'Space Grotesk', sans-serif; font-weight: 600; }
@media (max-width: 640px) { .action { padding: 24px 20px 10px; margin-left: -4px; margin-right: -4px; } }

/* Done button and pager */
.done-box {
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 32px 0; margin-top: 24px; border-top: 1px solid var(--mist);
}
.done-box p { margin: 0; color: var(--slate); font-size: 16px; }
.btn[aria-pressed="true"] { background: var(--ink); }
.btn[aria-pressed="true"]::before { content: "\2713  "; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-bottom: 72px; }
.pager a {
  display: block; text-decoration: none;
  background: var(--white); border: 1px solid var(--mist); border-radius: 8px;
  padding: 16px 18px;
}
.pager a:hover { border-color: var(--rung); }
.pager .next { text-align: right; }
.pager-word { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 13.5px; color: var(--slate); }
.pager-title { display: block; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 17px; line-height: 1.3; margin-top: 4px; }
@media (max-width: 560px) {
  .pager { grid-template-columns: 1fr; }
  .pager .next { order: -1; text-align: left; }
}

/* ---------- Login ---------- */
.auth { display: grid; place-items: center; padding: 64px 16px 80px; min-height: calc(100vh - 160px); }
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--white); border: 1px solid var(--mist); border-radius: 10px;
  padding: 36px 32px;
}
.auth-card h1 { font-size: clamp(28px, 5vw, 34px); line-height: 1.1; font-weight: 700; margin-bottom: 12px; }
.auth-lead { color: var(--slate); font-size: 17px; margin: 0 0 26px; }
.auth-card label { display: block; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.auth-card input[type="email"] {
  width: 100%; font: inherit; font-size: 17px; line-height: 1.4;
  padding: 13px 14px; color: var(--ink); background: var(--white);
  border: 1px solid #C3CBD4; border-radius: 6px;
}
.auth-card input[type="email"]:focus { outline: 3px solid rgba(47, 91, 255, 0.35); outline-offset: 0; border-color: var(--rung); }
.auth-card .btn { width: 100%; text-align: center; margin-top: 14px; }
.btn[disabled] { opacity: 0.65; cursor: progress; }
.form-status { margin: 14px 0 0; font-size: 16px; line-height: 1.5; min-height: 1.5em; color: var(--slate); }
.form-status.ok { color: #1D6B3F; }
.form-status.error { color: #B3261E; }
.auth-help { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--mist); font-size: 15.5px; line-height: 1.6; color: var(--slate); }
.auth-help p { margin: 0 0 10px; }
.auth-help p:last-child { margin-bottom: 0; }
.auth-help strong { color: var(--ink); font-weight: 600; }
.auth-help a { color: var(--rung); }
@media (max-width: 480px) { .auth { padding-top: 40px; } .auth-card { padding: 28px 20px; } }

/* ---------- Welcome ---------- */
.access-status {
  max-width: 34em; margin: -8px 0 28px; padding: 14px 18px;
  border-radius: 8px; border: 1px solid var(--mist); background: var(--white);
  font-size: 16.5px; line-height: 1.55; color: var(--slate);
}
.access-status.ok { background: #EAF6EF; border-color: #BFE3CD; color: #1D6B3F; }
.access-status.warn { background: #FFF4EC; border-color: #FFD3B8; color: #8A3A10; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.btn-secondary {
  display: inline-block; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 17px;
  padding: 16px 8px; color: var(--ink); text-decoration: underline; text-underline-offset: 4px;
}
.btn-secondary:hover { color: var(--rung); }
.welcome-body { padding-top: 56px; padding-bottom: 72px; }
.welcome-body h2 { font-size: clamp(24px, 3.6vw, 30px); line-height: 1.15; margin-bottom: 18px; }
.steps { list-style: none; counter-reset: step; margin: 0 0 48px; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 20px 0 20px 56px; border-bottom: 1px solid var(--mist); }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 20px;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--rung); color: var(--white);
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px;
}
.steps strong { display: block; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 19px; line-height: 1.3; margin-bottom: 4px; }
.steps a { color: var(--rung); }
.welcome-note { background: var(--tint); border-radius: 8px; padding: 24px 26px; }
.welcome-note h2 { font-size: 21px; margin-bottom: 8px; }
.welcome-note p { margin: 0; color: var(--slate); }

footer {
  border-top: 1px solid var(--mist); padding: 32px 0 calc(32px + env(safe-area-inset-bottom, 0px));
  font-size: 15px; color: var(--slate); font-family: 'Space Grotesk', sans-serif;
}
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a { color: var(--slate); text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.welcome-note a { color: var(--rung); }

/* ---------- Terms, privacy, refunds ---------- */
.legal { padding-top: 56px; padding-bottom: 72px; }
.legal h1 { font-size: clamp(34px, 6vw, 48px); line-height: 1.08; font-weight: 700; margin-bottom: 10px; }
.legal .updated { font-family: 'Space Grotesk', sans-serif; font-size: 15px; color: var(--slate); margin: 0 0 32px; }
.legal .summary { background: var(--tint); border-radius: 8px; padding: 20px 24px; margin: 0 0 36px; }
.legal .summary p { margin: 0; }
.legal h2 { font-size: clamp(21px, 3vw, 24px); line-height: 1.25; margin: 40px 0 12px; }
.legal p, .legal ul { margin: 0 0 1.1em; }
.legal ul { padding-left: 1.3em; }
.legal li { margin: 0.35em 0; }
.legal a { color: var(--rung); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .fill { transition: none; }
}
@media print {
  .topbar, .done-box, .pager, .copy, footer { display: none; }
  .action { background: none; color: var(--ink); border: 2px solid var(--ink); }
  .action h2, .action strong { color: var(--ink); }
}
