/* Design tokens, page chrome and shared widgets.
   Loaded by the landing page and by every course under its own directory. */

/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #0e1117;
  --bg-raised: #151a23;
  --surface: #1a2029;
  --surface-hi: #222935;
  --border: #2a3240;
  --border-hi: #3a4454;
  --text: #e6eaf2;
  --text-dim: #9aa5b8;
  --text-faint: #6b7688;
  --accent: #ffd45e;
  --accent-ink: #2a1f00;
  --info: #5aa2f5;
  --ok: #56d68a;
  --ok-bg: rgba(86, 214, 138, .1);
  --bad: #f77d7d;
  --bad-bg: rgba(247, 125, 125, .1);
  --code-bg: #10141c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.7);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;

  --syn-kw: #ff9ec4;
  --syn-str: #a5e075;
  --syn-num: #f0b366;
  --syn-com: #66738a;
  --syn-fn: #7ec9ff;
  --syn-builtin: #ffd45e;
  --syn-const: #c39bfa;
  --syn-self: #ff9ec4;
  --syn-deco: #f0b366;
}

[data-theme="light"] {
  --bg: #fbfaf7;
  --bg-raised: #ffffff;
  --surface: #ffffff;
  --surface-hi: #f2f0ea;
  --border: #e2ded3;
  --border-hi: #cec9ba;
  --text: #1f2430;
  --text-dim: #5b6473;
  --text-faint: #8a93a3;
  --accent: #b8860b;
  --accent-ink: #fffdf5;
  --info: #1b62c4;
  --ok: #1a7f4b;
  --ok-bg: rgba(26, 127, 75, .09);
  --bad: #b32d2d;
  --bad-bg: rgba(179, 45, 45, .08);
  --code-bg: #f7f5f0;
  --shadow: 0 1px 2px rgba(30,25,10,.06), 0 8px 24px -14px rgba(30,25,10,.25);

  --syn-kw: #a3246c;
  --syn-str: #2c6e3f;
  --syn-num: #a8590c;
  --syn-com: #8a93a3;
  --syn-fn: #1b5fa8;
  --syn-builtin: #8a6100;
  --syn-const: #6b3fb5;
  --syn-self: #a3246c;
  --syn-deco: #a8590c;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd { font-family: var(--mono); }

.skip-link {
  position: absolute; left: -999px;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: var(--radius); z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

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

/* ---------------------------------------------------------------- chrome */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: .55rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-family: var(--mono); color: var(--accent); font-weight: 700; letter-spacing: -.06em; }
.brand-name { font-weight: 650; letter-spacing: -.015em; }
.brand-name em { font-style: normal; color: var(--text-dim); font-weight: 400; }

.topnav { display: flex; align-items: center; gap: clamp(.6rem, 2vw, 1.4rem); font-size: .9rem; }
.topnav > a { color: var(--text-dim); }
.topnav > a:hover { color: var(--text); text-decoration: none; }

.lang-picker { display: flex; align-items: center; gap: .4rem; color: var(--text-faint); font-size: .82rem; }
.lang-label { white-space: nowrap; }
.lang-picker select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  padding: .3rem .5rem; font: inherit; font-size: .82rem; cursor: pointer;
}

.icon-btn {
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 7px;
  width: 2rem; height: 2rem; cursor: pointer; font-size: .9rem; line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); }

main { max-width: 62rem; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) 5rem; }

.footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem clamp(1rem, 4vw, 2rem);
  color: var(--text-faint); font-size: .82rem; text-align: center;
}
.footer p { max-width: 46rem; margin: 0 auto; }
.footer code { color: var(--text-dim); }

/* ------------------------------------------------------------------ hero */
.hero { margin-bottom: 2.5rem; }
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.9rem); line-height: 1.1;
  letter-spacing: -.03em; margin: 0 0 .8rem; font-weight: 680;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { font-size: clamp(1rem, 2.2vw, 1.12rem); color: var(--text-dim); max-width: 44rem; margin: 0 0 1.5rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 2rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem 1.05rem; font: inherit; font-size: .92rem; font-weight: 500;
  cursor: pointer; transition: border-color .12s, background .12s, transform .06s;
}
.btn:hover { border-color: var(--border-hi); background: var(--surface-hi); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .38rem .7rem; font-size: .82rem; }

/* ----------------------------------------------------------------- stats */
.statbar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 2.5rem;
}
.stat { background: var(--bg-raised); padding: .9rem 1.1rem; }
.stat-value { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; font-family: var(--mono); }
.stat-label { font-size: .76rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .07em; margin-top: .1rem; }
.stat-value.good { color: var(--ok); }
.stat-value.warn { color: var(--bad); }

/* ---------------------------------------------------------------- topics */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.section-head h2 { font-size: 1.1rem; letter-spacing: -.01em; margin: 0; font-weight: 620; }
.section-head p { margin: 0; color: var(--text-faint); font-size: .85rem; }

.progress-track { flex: 1; height: 4px; background: var(--surface-hi); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.progress-fill.partial { background: var(--accent); }

/* ------------------------------------------------------------------ quiz */
.pill {
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 99px;
  border: 1px solid var(--border); color: var(--text-faint); background: var(--surface);
}
.pill.diff-1 { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.pill.diff-2 { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.pill.diff-3 { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }

/* ----------------------------------------------------------------- lists */
.card-list { display: grid; gap: .7rem; margin-bottom: 2.5rem; }
.list-card {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1.1rem; color: var(--text);
  transition: border-color .14s;
}
.list-card:hover { border-color: var(--border-hi); text-decoration: none; }
.list-card-body { flex: 1; min-width: 0; }
.list-card h3 { margin: 0 0 .15rem; font-size: .97rem; font-weight: 600; }
.list-card p { margin: 0; font-size: .84rem; color: var(--text-faint); }
.list-card .status { flex: none; font-size: .78rem; color: var(--text-faint); font-family: var(--mono); }
.list-card .status.done { color: var(--ok); }

.empty {
  text-align: center; padding: 3.5rem 1rem; color: var(--text-faint);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty h3 { color: var(--text-dim); margin: 0 0 .4rem; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 30rem; font-size: .92rem; }

.nav-row { display: flex; justify-content: space-between; gap: .7rem; flex-wrap: wrap; margin-top: 2rem; }

kbd {
  background: var(--surface-hi); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: .05em .38em; font-size: .8em; color: var(--text-dim);
}
  .statbar { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 640px) {
  .lang-picker .lang-label { display: none; }
  .topnav { gap: .5rem; }
  .statbar { grid-template-columns: repeat(2, 1fr); }
}

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