/* StudyCentral design tokens + components.
 * Colours are RGB triplets so Tailwind utilities can apply alpha:
 *   bg-surface, text-muted, border-line, bg-accent/10 …
 * Theme: <html data-theme="light|dark" data-accent="indigo|blue|teal|green|orange|rose">
 */

:root, [data-theme="light"] {
  --bg: 250 250 250;
  --surface: 255 255 255;
  --subtle: 244 244 245;
  --line: 228 228 231;
  --line-strong: 212 212 216;
  --fg: 24 24 27;
  --muted: 82 82 91;
  --faint: 130 130 140;
  --good: 22 163 74;
  --warn: 202 138 4;
  --bad: 220 38 38;
  --info: 37 99 235;
  --map-ocean: 241 242 244;
  --map-land: 220 222 226;
  --map-stroke: 255 255 255;
  --map-target: 176 180 190;
  --map-hover: 120 126 138;
  --shadow-sm: 0 1px 2px rgb(16 16 20 / 0.05);
  --shadow-lg: 0 10px 30px -8px rgb(16 16 20 / 0.18), 0 2px 6px rgb(16 16 20 / 0.06);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: 11 11 13;
  --surface: 20 20 23;
  --subtle: 30 30 34;
  --line: 39 39 44;
  --line-strong: 58 58 66;
  --fg: 240 240 242;
  --muted: 165 165 175;
  --faint: 115 115 125;
  --good: 74 222 128;
  --warn: 250 204 21;
  --bad: 248 113 113;
  --info: 96 165 250;
  --map-ocean: 15 15 18;
  --map-land: 40 40 46;
  --map-stroke: 11 11 13;
  --map-target: 78 78 88;
  --map-hover: 120 120 132;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 12px 32px -8px rgb(0 0 0 / 0.6), 0 2px 6px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

/* Accents: a darker shade for light mode, a lighter one for dark mode. */
:root, [data-accent="indigo"] { --accent: 79 70 229;  --accent-fg: 255 255 255; }
[data-accent="blue"]          { --accent: 37 99 235;  --accent-fg: 255 255 255; }
[data-accent="teal"]          { --accent: 13 148 136; --accent-fg: 255 255 255; }
[data-accent="green"]         { --accent: 22 163 74;  --accent-fg: 255 255 255; }
[data-accent="orange"]        { --accent: 234 88 12;  --accent-fg: 255 255 255; }
[data-accent="rose"]          { --accent: 225 29 72;  --accent-fg: 255 255 255; }
[data-theme="dark"][data-accent="indigo"], [data-theme="dark"]:not([data-accent]) { --accent: 129 140 248; --accent-fg: 12 12 20; }
[data-theme="dark"][data-accent="blue"]   { --accent: 96 165 250;  --accent-fg: 8 14 28; }
[data-theme="dark"][data-accent="teal"]   { --accent: 45 212 191;  --accent-fg: 4 20 18; }
[data-theme="dark"][data-accent="green"]  { --accent: 74 222 128;  --accent-fg: 6 22 12; }
[data-theme="dark"][data-accent="orange"] { --accent: 251 146 60;  --accent-fg: 28 12 2; }
[data-theme="dark"][data-accent="rose"]   { --accent: 251 113 133; --accent-fg: 30 6 12; }

html { background: rgb(var(--bg)); }
body {
  background: rgb(var(--bg));
  color: rgb(var(--fg));
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}
/* Lets unbroken strings (long usernames, emails) wrap instead of widening their box. */
.wrap-anywhere { overflow-wrap: anywhere; }
::selection { background: rgb(var(--accent) / 0.25); }
:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; border-radius: 6px; }
.theme-transition, .theme-transition * { transition: background-color .2s ease, border-color .2s ease, color .2s ease !important; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 2.25rem; padding: 0 .875rem; border-radius: .5rem;
  font-size: .875rem; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(0.5px); }
.btn-sm { height: 2rem; padding: 0 .65rem; font-size: .8125rem; gap: .375rem; }
.btn-lg { height: 2.75rem; padding: 0 1.25rem; font-size: .9375rem; }
.btn-block { width: 100%; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-sm.btn-icon { width: 2rem; }
.btn-primary { background: rgb(var(--accent)); color: rgb(var(--accent-fg)); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: rgb(var(--accent) / 0.88); }
.btn-secondary { background: rgb(var(--surface)); color: rgb(var(--fg)); border-color: rgb(var(--line-strong)); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: rgb(var(--subtle)); }
.btn-ghost { color: rgb(var(--muted)); }
.btn-ghost:hover { color: rgb(var(--fg)); background: rgb(var(--subtle)); }
.btn-danger { color: rgb(var(--bad)); border-color: rgb(var(--bad) / 0.35); background: transparent; }
.btn-danger:hover { background: rgb(var(--bad) / 0.08); }
.btn-danger-solid { background: rgb(var(--bad)); color: #fff; }
.btn-danger-solid:hover { background: rgb(var(--bad) / 0.88); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; box-shadow: none; }

/* -------------------------------------------------------------- surfaces */
.card { background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); border-radius: .875rem; }
.card-hover { transition: border-color .15s, box-shadow .15s; }
.card-hover:hover { border-color: rgb(var(--line-strong)); box-shadow: var(--shadow-lg); }
.divider { height: 1px; background: rgb(var(--line)); }
.eyebrow { font-size: .75rem; font-weight: 500; color: rgb(var(--faint)); }
.link { color: rgb(var(--accent)); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.kbd {
  display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .3rem;
  font: 500 .6875rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: rgb(var(--muted));
  border: 1px solid rgb(var(--line-strong)); border-bottom-width: 2px; border-radius: .3rem; background: rgb(var(--surface));
}
.tile {
  display: grid; place-items: center; flex-shrink: 0; border-radius: .75rem;
  background: rgb(var(--subtle)); border: 1px solid rgb(var(--line));
}

/* ------------------------------------------------------------------ chips */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; height: 1.375rem; padding: 0 .5rem;
  border-radius: 9999px; font-size: .75rem; font-weight: 500; white-space: nowrap;
  background: rgb(var(--subtle)); color: rgb(var(--muted));
}
.chip-good   { background: rgb(var(--good) / 0.12); color: rgb(var(--good)); }
.chip-warn   { background: rgb(var(--warn) / 0.14); color: rgb(var(--warn)); }
.chip-bad    { background: rgb(var(--bad) / 0.12);  color: rgb(var(--bad)); }
.chip-info   { background: rgb(var(--info) / 0.12); color: rgb(var(--info)); }
.chip-accent { background: rgb(var(--accent) / 0.12); color: rgb(var(--accent)); }
[data-theme="light"] .chip-warn { color: rgb(161 98 7); }
.dot { width: .5rem; height: .5rem; border-radius: 9999px; background: currentColor; flex-shrink: 0; }

/* --------------------------------------------------------------- progress */
.progress { height: .375rem; border-radius: 9999px; background: rgb(var(--subtle)); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: rgb(var(--accent)); transition: width .4s ease; }
.progress-good > span { background: rgb(var(--good)); }

/* ------------------------------------------------------------------ forms */
.label { display: block; font-size: .8125rem; font-weight: 500; margin-bottom: .375rem; color: rgb(var(--fg)); }
.hint { font-size: .8125rem; color: rgb(var(--faint)); }
.input {
  width: 100%; height: 2.5rem; padding: 0 .75rem; border-radius: .5rem; font-size: .875rem;
  background: rgb(var(--surface)); color: rgb(var(--fg)); border: 1px solid rgb(var(--line-strong));
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: rgb(var(--faint)); }
.input:focus { outline: none; border-color: rgb(var(--accent)); box-shadow: 0 0 0 3px rgb(var(--accent) / 0.18); }
.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex-shrink: 0; cursor: pointer;
  width: 2.25rem; height: 1.25rem; border-radius: 9999px; background: rgb(var(--line-strong)); transition: background .15s;
}
.switch::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 1rem; height: 1rem; border-radius: 9999px;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s;
}
.switch:checked { background: rgb(var(--accent)); }
.switch:checked::before { transform: translateX(1rem); }

/* Radio "option cards" (theme, quiz length …) */
.option { position: relative; display: block; cursor: pointer; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option > span {
  display: flex; align-items: center; justify-content: center; gap: .5rem; height: 2.5rem; padding: 0 .75rem;
  border: 1px solid rgb(var(--line-strong)); border-radius: .5rem; font-size: .875rem; font-weight: 500;
  color: rgb(var(--muted)); background: rgb(var(--surface)); transition: all .15s;
}
.option:hover > span { color: rgb(var(--fg)); }
.option input:checked + span { border-color: rgb(var(--accent)); color: rgb(var(--fg)); box-shadow: 0 0 0 1px rgb(var(--accent)); }
.option input:focus-visible + span { box-shadow: 0 0 0 3px rgb(var(--accent) / 0.3); }
.swatch > span { width: 2.25rem; height: 2.25rem; padding: 0; border-radius: 9999px; border: 0; }
.swatch input:checked + span { box-shadow: 0 0 0 2px rgb(var(--surface)), 0 0 0 4px rgb(var(--fg)); }

/* ------------------------------------------------------------- navigation */
.nav-link {
  display: inline-flex; align-items: center; gap: .4rem; height: 2rem; padding: 0 .7rem; border-radius: .45rem;
  font-size: .875rem; font-weight: 500; color: rgb(var(--muted));
}
.nav-link:hover { color: rgb(var(--fg)); background: rgb(var(--subtle)); }
.nav-link.is-active { color: rgb(var(--fg)); background: rgb(var(--subtle)); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid rgb(var(--line)); }
.tab {
  position: relative; display: inline-flex; align-items: center; height: 2.5rem; padding: 0 .75rem;
  font-size: .875rem; font-weight: 500; color: rgb(var(--muted)); cursor: pointer; background: none; border: 0;
}
.tab:hover { color: rgb(var(--fg)); }
.tab.is-active { color: rgb(var(--fg)); }
.tab.is-active::after { content: ""; position: absolute; left: .5rem; right: .5rem; bottom: -1px; height: 2px; border-radius: 2px; background: rgb(var(--accent)); }
.pill-tabs { display: inline-flex; gap: .25rem; padding: .25rem; border-radius: .6rem; background: rgb(var(--subtle)); }
.pill-tab { height: 1.85rem; padding: 0 .75rem; border-radius: .4rem; font-size: .8125rem; font-weight: 500; color: rgb(var(--muted)); }
.pill-tab:hover { color: rgb(var(--fg)); }
.pill-tab.is-active { background: rgb(var(--surface)); color: rgb(var(--fg)); box-shadow: var(--shadow-sm); }

/* Dropdown menus built on <details> */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 60; min-width: 14rem; padding: .3rem;
  max-width: min(18rem, calc(100vw - 2rem)); /* long titles truncate instead of widening the page */
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); border-radius: .75rem; box-shadow: var(--shadow-lg);
  animation: pop .12s ease-out;
}
.menu-panel.left { left: 0; right: auto; max-width: 16rem; }
.menu-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .6rem; border-radius: .45rem;
  font-size: .875rem; color: rgb(var(--fg)); text-align: left; background: none; border: 0; cursor: pointer;
}
.menu-item:hover { background: rgb(var(--subtle)); }
.menu-item.danger { color: rgb(var(--bad)); }
.menu-item svg { color: rgb(var(--faint)); }
.menu-item.danger svg { color: currentColor; }
.menu-label { padding: .4rem .6rem .25rem; font-size: .75rem; color: rgb(var(--faint)); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------- dialogs & toasts */
dialog.modal {
  width: calc(100% - 2rem); max-width: 26rem; padding: 0; border: 1px solid rgb(var(--line)); border-radius: 1rem;
  background: rgb(var(--surface)); color: rgb(var(--fg)); box-shadow: var(--shadow-lg);
}
dialog.modal[open] { animation: pop .15s ease-out; }
dialog.modal::backdrop { background: rgb(0 0 0 / .45); backdrop-filter: blur(2px); }
.toast-stack { position: fixed; z-index: 80; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; max-width: min(24rem, calc(100% - 2rem)); }
.toast {
  display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .85rem; border-radius: .75rem; font-size: .875rem;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); box-shadow: var(--shadow-lg); animation: pop .2s ease-out;
}
/* Cookie consent: bottom-left on desktop so it never covers toasts (bottom-right). */
.cookie-banner {
  position: fixed; z-index: 70; left: 1rem; right: 1rem; bottom: 1rem;
  opacity: 0; transform: translateY(1rem); transition: opacity .4s ease, transform .4s ease;
}
.cookie-banner.is-visible { opacity: 1; transform: none; }
@media (min-width: 768px) { .cookie-banner { right: auto; width: 24rem; } }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all .25s; }

/* ----------------------------------------------------------------- callouts */
.callout { border-radius: .75rem; padding: 1rem 1.1rem; border: 1px solid rgb(var(--line)); background: rgb(var(--surface)); }
.callout-accent { border-color: rgb(var(--accent) / 0.35); background: rgb(var(--accent) / 0.06); }
.callout-good { border-color: rgb(var(--good) / 0.35); background: rgb(var(--good) / 0.07); }
.callout-bad  { border-color: rgb(var(--bad) / 0.35);  background: rgb(var(--bad) / 0.06); }
.callout-warn { border-color: rgb(var(--warn) / 0.4);  background: rgb(var(--warn) / 0.07); }

/* ------------------------------------------------------------------- quiz */
.choice {
  display: flex; align-items: flex-start; gap: .75rem; width: 100%; padding: .9rem 1rem; text-align: left;
  border: 1px solid rgb(var(--line-strong)); border-bottom-width: 2px; border-radius: .75rem;
  background: rgb(var(--surface)); color: rgb(var(--fg)); font-size: .9375rem; cursor: pointer;
  transition: border-color .12s, background-color .12s, transform .05s;
}
.choice:hover { border-color: rgb(var(--accent) / 0.6); background: rgb(var(--accent) / 0.04); }
.choice:active { transform: translateY(1px); }
.choice[disabled] { cursor: default; }
.choice .kbd { margin-top: .05rem; }
.choice.is-correct { border-color: rgb(var(--good)); background: rgb(var(--good) / 0.08); }
.choice.is-wrong { border-color: rgb(var(--bad)); background: rgb(var(--bad) / 0.07); }
.choice.is-dim { opacity: .5; }
.quiz-footer { border-top: 1px solid rgb(var(--line)); }
.quiz-footer.is-good { background: rgb(var(--good) / 0.08); border-color: rgb(var(--good) / 0.3); }
.quiz-footer.is-bad { background: rgb(var(--bad) / 0.07); border-color: rgb(var(--bad) / 0.3); }
.pip { width: .5rem; height: .5rem; border-radius: 9999px; background: rgb(var(--line-strong)); }
.pip.on { background: rgb(var(--warn)); }

/* --------------------------------------------------------- lesson path */
.path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1.75rem; padding: 1.5rem 0 1rem; }
.path-row { position: relative; width: 100%; display: flex; justify-content: center; }
.path-row:has(.node-start) { margin-top: 1.75rem; }
.path-row:has(details[open]) { z-index: 20; }
.node-wrap { position: relative; display: flex; flex-direction: column; align-items: center; width: 9rem; }
.node {
  position: relative; display: grid; place-items: center; width: 4.25rem; height: 4.25rem; border-radius: 9999px; cursor: pointer;
  background: rgb(var(--subtle)); color: rgb(var(--faint)); border: 0;
  box-shadow: inset 0 -5px 0 rgb(0 0 0 / 0.12);
  transition: transform .1s, filter .15s;
}
.node:hover { filter: brightness(1.05); }
.node:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgb(0 0 0 / 0.12); }
.node[data-state="done"]    { background: rgb(var(--accent)); color: rgb(var(--accent-fg)); }
.node[data-state="review"]  { background: rgb(var(--warn)); color: #1c1402; }
.node[data-state="current"] { background: rgb(var(--accent)); color: rgb(var(--accent-fg)); }
.node[data-state="open"]    { background: rgb(var(--surface)); color: rgb(var(--accent)); box-shadow: inset 0 0 0 2px rgb(var(--accent) / .55), inset 0 -5px 0 rgb(var(--accent) / .2); }
.node[data-state="locked"]  { background: rgb(var(--subtle)); color: rgb(var(--faint)); }
.node-ring { position: absolute; inset: -7px; border-radius: 9999px; border: 3px solid rgb(var(--accent) / .3); pointer-events: none; }
.node[data-state="current"] .node-ring { animation: ring 2.2s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: .55; } }
.node-label { margin-top: .55rem; max-width: 9rem; text-align: center; font-size: .8125rem; font-weight: 500; line-height: 1.25; color: rgb(var(--fg)); }
.node-wrap[data-state="locked"] .node-label { color: rgb(var(--faint)); }
.node-start {
  position: absolute; bottom: calc(100% + .5rem); left: 50%; transform: translateX(-50%); z-index: 2;
  padding: .3rem .6rem; border-radius: .5rem; font-size: .75rem; font-weight: 700; letter-spacing: .04em;
  background: rgb(var(--surface)); color: rgb(var(--accent)); border: 2px solid rgb(var(--line)); white-space: nowrap;
  animation: bob 1.8s ease-in-out infinite;
}
.node-start::after {
  content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top-color: rgb(var(--line));
}
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }
.node-badge {
  position: absolute; top: -2px; right: -2px; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; border-radius: 9999px;
  display: grid; place-items: center; font-size: .6875rem; font-weight: 700;
  background: rgb(var(--warn)); color: #1c1402; border: 2px solid rgb(var(--bg));
}
.node-pop {
  position: absolute; top: calc(100% + .5rem); left: 50%; transform: translateX(-50%); z-index: 30; width: 17rem;
  padding: 1rem; border-radius: .875rem; background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); box-shadow: var(--shadow-lg);
  animation: pop .14s ease-out;
}
.node-pop::before {
  content: ""; position: absolute; bottom: 100%; left: 50%; margin-left: -7px; border: 7px solid transparent; border-bottom-color: rgb(var(--line));
}
.unit-band { border-radius: 1rem; padding: 1.1rem 1.25rem; background: rgb(var(--accent)); color: rgb(var(--accent-fg)); }
.unit-band.is-locked { background: rgb(var(--subtle)); color: rgb(var(--muted)); }
.unit-band .btn-band { background: rgb(var(--accent-fg) / 0.14); color: inherit; border: 1px solid rgb(var(--accent-fg) / 0.25); }
.unit-band .btn-band:hover { background: rgb(var(--accent-fg) / 0.22); }
.unit-band.is-locked .btn-band { background: rgb(var(--surface)); border-color: rgb(var(--line-strong)); color: rgb(var(--fg)); }

/* --------------------------------------------------------- content blocks */
.prose-sc { font-size: .9375rem; line-height: 1.7; color: rgb(var(--muted)); }
.prose-sc strong { color: rgb(var(--fg)); }
.block-title { font-size: .9375rem; font-weight: 600; color: rgb(var(--fg)); }
.block-kicker { font-size: .75rem; font-weight: 500; color: rgb(var(--accent)); }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .25rem 0; }
.katex { color: rgb(var(--fg)); }

/* timeline */
.tl { position: relative; margin-left: .35rem; border-left: 1px solid rgb(var(--line-strong)); }
.tl-item { position: relative; padding: 0 0 1.25rem 1.25rem; cursor: pointer; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -5px; top: .4rem; width: 9px; height: 9px; border-radius: 9999px;
  background: rgb(var(--surface)); border: 2px solid rgb(var(--accent));
}
.tl-item:hover::before { background: rgb(var(--accent)); }
.tl-year { font: 500 .8125rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: rgb(var(--accent)); }

.scroll-thin::-webkit-scrollbar { height: 6px; width: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: rgb(var(--line-strong)); border-radius: 9999px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  header.site-header, footer.site-footer, .cookie-banner, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}
