/* ==========================================================================
   Giáo án 30 ngày — DGX Spark · stylesheet
   Design system: 1 accent, 4-level text ramp, tonal surfaces over borders,
   flat cards (elevation reserved for floating UI), restrained motion.
   Markup is pandoc-generated (build.py) — selectors mirror that output.
   ========================================================================== */
:root {
  color-scheme: dark;
  /* --- surfaces ------------------------------------------------------- */
  --bg: #08090C;
  --surface: rgba(255, 255, 255, .032);   /* cards, panels — tonal, no border needed */
  --surface-2: rgba(255, 255, 255, .062); /* hover / emphasized panel */
  --surface-sunken: #0C0E14;               /* code blocks: distinct from page bg */

  /* --- text ramp (all AA-passing on --bg) ----------------------------- */
  --fg: #F4F5F7;        /* 18.0:1  headings, emphasis, primary controls */
  --fg-2: #BFC3CB;      /* 10.9:1  lead text, cell values */
  --fg-body: #CCD0D7;   /* 12.6:1  running prose */
  --muted: #A3A7AF;     /*  7.9:1  secondary, table headers, TOC */
  --muted-2: #8E9299;   /*  6.2:1  micro-labels, footer (was 4.1:1 — failed AA) */

  /* --- lines ---------------------------------------------------------- */
  --hairline: rgba(255, 255, 255, .075);
  --hairline-2: rgba(255, 255, 255, .14);

  /* --- accent: kept as brand identity, deliberately scarce ------------ */
  --accent: #34D399;
  --accent-hi: #62E1B0;
  --accent-dim: rgba(52, 211, 153, .06);
  --accent-line: rgba(52, 211, 153, .42);
  --ring: rgba(52, 211, 153, .7);

  /* text-vs-fill split: brand mint is a FILL; text needs a themed, AA-safe green */
  --accent-text: #34D399;
  --hairline-strong: rgba(255, 255, 255, .32);
  --selection: rgba(52, 211, 153, .24);
  --code-inline-bg: rgba(255, 255, 255, .055);
  --callout-fg: #CBEDE0;
  --header-bg: rgba(8, 9, 12, .8);
  --header-bg-scrolled: rgba(8, 9, 12, .9);
  --btt-bg: rgba(15, 17, 22, .84);
  --scroll-thumb: rgba(255, 255, 255, .13);
  --scroll-thumb-hover: rgba(255, 255, 255, .22);
  --inverse-bg: #F4F5F7;
  --inverse-bg-hover: #FFFFFF;
  --inverse-ink: #08090C;
  --check-ink: #08090C;
  --wash: radial-gradient(58% 40% at 50% -8%, rgba(52, 211, 153, .055), transparent 72%);
  --link-line: rgba(52, 211, 153, .3);
  --link-line-hover: rgba(98, 225, 176, .7);

  /* --- code token palette (editor-grade, low-chroma) ------------------ */
  --tk-cmt: #838994;
  --tk-kw: #5FE0AE;
  --tk-str: #EBC08A;
  --tk-num: #A8C7E8;
  --tk-fn: #EAEEF4;
  --tk-var: #C6CDD8;
  --tk-op: #9398A2;
  --tk-err: #EFA79E;

  /* --- geometry ------------------------------------------------------- */
  --container: 1240px;
  --gutter: clamp(1rem, 4vw, 2rem);
  --measure: 72ch;                 /* prose line length */
  --header-h: 60px;
  --r-sm: 6px; --r-md: 9px; --r-lg: 12px;
  --pad-card: 1.45rem 1.6rem;
  --gap-card: 10px;

  /* --- type ----------------------------------------------------------- */
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --label: .7rem;                 /* micro-label floor ≈ 11px */

  /* --- motion / elevation -------------------------------------------- */
  --ease: cubic-bezier(.32, .72, 0, 1);
  --dur: 150ms;
  --dur-2: 200ms;
  --shadow-pop: 0 12px 32px -14px rgba(0, 0, 0, .72);
}

/* ==========================================================================
   1. Base
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  scroll-padding-bottom: 4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: content-box; }

body {
  background: var(--bg);
  color: var(--fg-body);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

/* Ambient wash — one accent-tinted light source, static.
   (Indigo/blue orb pair removed: decorative only, and it was the tell.) */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--wash);
}

h1, h2, h3, h4 { text-wrap: balance; color: var(--fg); }
p, li, td { overflow-wrap: break-word; text-wrap: pretty; }
::selection { background: var(--selection); color: var(--fg); }

/* micro-label primitive: the one uppercase mono treatment, reused */
.site-header nav a, .eyebrow, .sec-label, .statline,
.toc-title, .cell .day, .content th { font-feature-settings: "tnum" 1; }

/* ==========================================================================
   2. Header — glass is kept only because it overlays scrolling content
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 max(var(--gutter), env(safe-area-inset-left)) max(0px, env(safe-area-inset-right));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  background: var(--header-bg);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  border-bottom: 1px solid var(--hairline);
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.site-header.is-scrolled {
  background: var(--header-bg-scrolled);
  border-bottom-color: var(--hairline-2);
}

.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--mono); font-size: .78rem; font-weight: 600;
  letter-spacing: .12em; color: var(--fg); text-decoration: none;
  padding: .65rem .25rem; min-height: var(--header-h);
}
.brand svg { color: var(--accent-text); flex: none; }
.brand-sub { color: var(--muted-2); font-weight: 500; }

.site-header nav { margin-left: auto; display: flex; align-items: center; gap: .2rem; }
.site-header nav a {
  color: var(--muted); text-decoration: none;
  font-size: .845rem; font-weight: 500; letter-spacing: -.005em;
  padding: .5rem .7rem; border-radius: var(--r-sm);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  display: inline-flex; align-items: center; gap: .42rem;
}
.site-header nav a svg { opacity: .75; flex: none; }
.site-header nav a:hover { color: var(--fg); background: var(--surface-2); }
.site-header nav a:hover svg { opacity: 1; }

/* ==========================================================================
   3. Hero — editorial, left-aligned; display size carried down a step
   ========================================================================== */
.hero {
  max-width: var(--container); margin: 0 auto;
  padding: clamp(3.5rem, 9vh, 6rem) var(--gutter) 3.25rem;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--mono); font-size: var(--label); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.eyebrow svg { color: var(--accent-text); flex: none; transform: translateY(.5px); }

.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.15rem, 5.2vw, 3.3rem);
  font-weight: 640; line-height: 1.08; letter-spacing: -.03em;
  margin: 1.15rem 0 1.15rem; max-width: 22ch;
}
.hero h1 .accent { color: var(--accent-text); }
.hero .lead {
  color: var(--fg-2); font-size: 1.0625rem; line-height: 1.62;
  max-width: 60ch; margin-bottom: 1.6rem;
}

.statline {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: .45rem 1.35rem; margin-bottom: 2rem;
  font-family: var(--mono); font-size: .72rem; font-weight: 500;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted-2);
}
.statline b { color: var(--fg); font-weight: 600; font-size: .8rem; letter-spacing: .02em; }

/* ==========================================================================
   4. Buttons — one height, one radius, explicit hierarchy
   ========================================================================== */
.cta-row { display: flex; flex-wrap: wrap; gap: .65rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .55rem; min-height: 40px;
  font-weight: 560; font-size: .9375rem; letter-spacing: -.01em;
  text-decoration: none; border: 1px solid transparent;
  border-radius: var(--r-md); padding: .5rem 1.3rem;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease);
  cursor: pointer;
}
.btn svg { flex: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--inverse-bg); color: var(--inverse-ink); }
.btn-primary:hover { background: var(--inverse-bg-hover); transform: translateY(-1px); }
.btn-ghost { color: var(--fg); border-color: var(--hairline-2); background: transparent; }
.btn-ghost:hover { border-color: var(--hairline-strong); background: var(--surface); }

/* ==========================================================================
   5. Section head + bento (flat: no card lift on hover)
   ========================================================================== */
.section-head {
  max-width: var(--container); margin: 0 auto;
  padding: 0 var(--gutter) 1rem;
  display: flex; align-items: baseline; gap: .9rem;
}
.sec-label {
  font-family: var(--mono); font-size: var(--label); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--accent-text);
}
.sec-title {
  font-family: var(--display); font-size: 1.3125rem; font-weight: 640;
  letter-spacing: -.02em; line-height: 1.25;
}

.bento {
  max-width: var(--container); margin: 0 auto;
  padding: 0 var(--gutter) 2.75rem;
  display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap-card);
}
.cell {
  grid-column: span 12;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: var(--pad-card);
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.cell:hover { background: var(--surface-2); border-color: var(--hairline-2); }
.cell .day {
  display: block; font-family: var(--mono); font-size: var(--label);
  font-weight: 600; letter-spacing: .13em; color: var(--accent-text);
}
.cell h3 {
  font-family: var(--display); font-size: 1.125rem; font-weight: 620;
  letter-spacing: -.015em; margin: .5rem 0 .4rem; line-height: 1.28;
}
.cell p { font-size: .9375rem; color: var(--fg-2); line-height: 1.58; }
.cell.wide { background: var(--surface-2); padding: 1.85rem 2rem; }
.cell.wide h3 { font-size: 1.25rem; }
.cell.wide p { max-width: 70ch; }

@media (min-width: 780px) {
  /* explicit spans: row 1 = 7/5, everything after spans full width.
     (odd/even spans left a 5-col hole behind when the count was odd.) */
  .bento .cell:nth-child(1) { grid-column: span 7; }
  .bento .cell:nth-child(2) { grid-column: span 5; }
}

/* ==========================================================================
   6. Cross-track banner
   ========================================================================== */
.music-banner { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter) 3.25rem; }
.music-banner a {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  padding: 1.2rem 1.5rem; text-decoration: none; color: var(--fg);
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.music-banner a:hover { border-color: var(--accent-line); background: var(--surface-2); }
.music-banner strong { display: block; font-weight: 600; font-size: .9375rem; letter-spacing: -.01em; }
.music-banner .sub { color: var(--muted); font-size: .875rem; display: block; margin-top: .25rem; line-height: 1.5; }
.music-banner .arrow {
  color: var(--accent-text); font-weight: 600; font-size: 1.1rem;
  transition: transform var(--dur-2) var(--ease);
}
.music-banner a:hover .arrow { transform: translateX(3px); }
@media (max-width: 640px) { .music-banner .arrow { display: none; } }

/* ==========================================================================
   7. Page grid + table of contents
   ========================================================================== */
.page {
  max-width: var(--container); margin: 0 auto;
  padding: 0 var(--gutter) 4.5rem;
  display: grid; grid-template-columns: 1fr; gap: 2.25rem;
}
aside.toc { display: none; }
@media (min-width: 1100px) {
  .page { grid-template-columns: 244px minmax(0, 1fr); }
  aside.toc {
    display: block; position: sticky; top: calc(var(--header-h) + 1.75rem);
    align-self: start; max-height: calc(100vh - var(--header-h) - 3.5rem);
    overflow-y: auto; padding-right: .6rem;
    scrollbar-width: thin;
  }
}
.toc-title {
  font-family: var(--mono); font-size: var(--label); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted-2); margin-bottom: .7rem;
}
.toc a {
  display: block; color: var(--muted); text-decoration: none;
  font-size: .8125rem; line-height: 1.42;
  padding: .3rem .5rem .3rem .85rem;
  border-left: 1px solid var(--hairline);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toc a.lv1 { font-weight: 620; color: var(--fg); margin-top: .55rem; font-size: .825rem; }
.toc a:hover { color: var(--fg); background: var(--surface); }
/* active rail is an inset shadow, not a thicker border: a 1px→2px border
   shift would nudge every label by 1px as you scroll. */
.toc a.active {
  color: var(--accent-text); font-weight: 560;
  box-shadow: inset 2px 0 0 var(--accent-text);
}

details.toc-mobile {
  display: block; margin-bottom: 2rem;
  background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  padding: 0 1rem;
}
details.toc-mobile summary {
  cursor: pointer; font-weight: 560; font-size: .9375rem; color: var(--fg);
  min-height: 46px; display: flex; align-items: center; gap: .5rem;
  list-style: none; letter-spacing: -.01em;
  transition: color var(--dur) var(--ease);
}
details.toc-mobile summary:hover { color: var(--accent-text); }
details.toc-mobile summary::-webkit-details-marker { display: none; }
details.toc-mobile summary::after {
  content: ''; margin-left: auto; width: 7px; height: 7px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); transition: transform var(--dur-2) var(--ease);
}
details.toc-mobile[open] summary::after { transform: rotate(-135deg); }
details.toc-mobile .toc { margin: 0 -.5rem .7rem; max-height: 52vh; overflow-y: auto; }
@media (min-width: 1100px) { details.toc-mobile { display: none; } }

/* ==========================================================================
   8. Curriculum prose — the product surface (pandoc output)
   ========================================================================== */
.content { min-width: 0; counter-reset: sec; }

/* Reading measure: prose is capped; tables and code stay full-bleed.
   Without this the 1240px column ran ~110 chars — unreadable. */
.content > p, .content ul, .content ol, .content blockquote,
.content h1, .content h2, .content h3, .content h4 { max-width: var(--measure); }

.content h1 {
  font-family: var(--display);
  font-size: clamp(1.55rem, 3.2vw, 2.05rem);
  font-weight: 640; letter-spacing: -.028em; line-height: 1.16;
  color: var(--fg);
  margin: 3.75rem 0 1.1rem; padding-top: 2.5rem;
  border-top: 1px solid var(--hairline);
  counter-increment: sec;
}
.content > h1:first-child { margin-top: 0; padding-top: 0; border-top: none; }
/* the one accent moment per section */
.content h1::before {
  content: counter(sec, decimal-leading-zero) ' — ';
  font-family: var(--mono); font-size: .6em; font-weight: 500;
  color: var(--accent-text); letter-spacing: .06em; vertical-align: middle;
  margin-right: .35em;
}
.content h2 {
  font-family: var(--display);
  font-size: 1.25rem; font-weight: 640; line-height: 1.32; letter-spacing: -.02em;
  color: var(--fg);
  margin: 2.5rem 0 .85rem; padding: .15rem 0 .15rem .8rem;
  /* neutral rail: 43 green bars made every section equally loud */
  border-left: 2px solid var(--hairline-2);
}
.content h3 {
  font-size: 1.0625rem; font-weight: 620; margin: 1.65rem 0 .55rem;
  letter-spacing: -.012em; line-height: 1.4; color: var(--fg);
}
.content h4 { font-size: 1rem; font-weight: 620; margin: 1.3rem 0 .45rem; color: var(--fg-2); }

.content p { margin: .72rem 0; color: var(--fg-body); }
.content strong { color: var(--fg); font-weight: 620; }
.content em { color: var(--fg-2); }

/* underline w/ offset instead of border-bottom: border-bottom clipped
   descenders (g, p, y) on every link in the document */
.content a {
  color: var(--accent-text); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: .22em;
  text-decoration-color: var(--link-line);
  transition: color var(--dur) var(--ease), text-decoration-color var(--dur) var(--ease);
}
.content a:hover { color: var(--accent-hi); text-decoration-color: var(--link-line-hover); }
/* 30 of the links are video tutorials — mark them so the doc scans */
.content a[href*="youtu"]::before {
  content: ''; display: inline-block; vertical-align: baseline;
  width: 0; height: 0; margin-right: .45em; transform: translateY(-1px);
  border-left: 5px solid current-color;
  border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
  opacity: .7;
}
.content a[href*="youtu"] { text-underline-offset: .26em; }

.content ul, .content ol { margin: .7rem 0 .7rem 1.25rem; color: var(--fg-body); }
.content ul { list-style: disc; }
.content li { margin: .32rem 0; padding-left: .15rem; }
.content li::marker { color: var(--muted-2); }
.content li > ul, .content li > ol { margin: .3rem 0 .3rem .9rem; }

.content blockquote {
  border-left: 2px solid var(--accent-line);
  background: var(--accent-dim);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: .85rem 1.15rem; margin: 1.25rem 0;
  color: var(--callout-fg); font-size: .9375rem;
}
.content blockquote p { color: inherit; margin: .28rem 0; }
.content blockquote strong { color: var(--fg); }

/* inline code: tonal chip, no border — a 1px box around every path in the
   document was the loudest thing on the page */
.content code {
  font-family: var(--mono); font-size: max(.82em, 12px);
  background: var(--code-inline-bg); border-radius: var(--r-sm);
  padding: .14em .38em; color: var(--tk-str); font-weight: 500;
}

/* code blocks sit on a lifted surface so they read as an object */
.content pre {
  background: var(--surface-sunken); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 1.05rem 1.2rem;
  overflow-x: auto; margin: 1.25rem 0; line-height: 1.62;
  -webkit-overflow-scrolling: touch;
}
.content pre code {
  background: none; padding: 0; border-radius: 0;
  color: var(--tk-var); font-size: .8125rem; line-height: inherit; font-weight: 400;
  overflow-wrap: normal;
}
/* pandoc `highlight` token classes — previously emitted but never styled,
   so every code block rendered in one flat colour */
.content pre .co, .content pre .an { color: var(--tk-cmt); }
.content pre .kw, .content pre .kw2, .content pre .kw3,
.content pre .cf, .content pre .bu, .content pre .sc { color: var(--tk-kw); }
.content pre .st, .content pre .ch, .content pre .ss { color: var(--tk-str); }
.content pre .cn, .content pre .dv, .content pre .fl,
.content pre .dec, .content pre .bn { color: var(--tk-num); }
.content pre .fu, .content pre .dt { color: var(--tk-fn); font-weight: 500; }
.content pre .va, .content pre .at, .content pre .im,
.content pre .pp, .content pre .ex { color: var(--tk-var); }
.content pre .op, .content pre .no, .content pre .ot { color: var(--tk-op); }
.content pre .er { color: var(--tk-err); }
.content pre .wa { color: var(--tk-str); }

/* tables: productivity-software density, tabular figures, no grid lines */
.content table {
  display: block; overflow-x: auto; width: 100%;
  border-collapse: collapse; font-size: .875rem; margin: 1.25rem 0;
  font-variant-numeric: tabular-nums; -webkit-overflow-scrolling: touch;
}
.content th, .content td {
  border: none; border-bottom: 1px solid var(--hairline);
  padding: .58rem .85rem; vertical-align: top; text-align: left;
}
.content th {
  font-family: var(--mono); font-size: .6875rem; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}
.content td { color: var(--fg-body); line-height: 1.5; }
.content thead tr { border-bottom: 1px solid var(--hairline-2); }
.content tbody tr { transition: background var(--dur) var(--ease); }
.content tbody tr:hover { background: var(--surface); }
.content tbody tr:last-child td { border-bottom-color: transparent; }
.content td code { white-space: normal; overflow-wrap: anywhere; }
.content td code, .content th code { font-size: .8em; }

/* code-block line anchors pandoc injects (<span id><a href="#cb…"></a>)
   must not inherit the prose link treatment */
.content pre a { color: inherit; text-decoration: none; }

/* ---- pandoc task lists: real study checklists, tickable in the browser --
   Unstyled these were OS-default checkboxes — white boxes on a dark page
   with a mismatched baseline. Drawn here, no image asset needed. */
.content ul.task-list { list-style: none; margin-left: 0; }
.content ul.task-list > li { margin: .34rem 0; padding-left: 0; }
.content ul.task-list label {
  display: flex; align-items: flex-start; gap: .6rem;
  cursor: pointer; border-radius: var(--r-sm);
  padding: .18rem .3rem; margin-left: -.3rem;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.content ul.task-list label:hover { background: var(--surface); }
.content ul.task-list label:has(input:checked) { color: var(--muted-2); }
.content ul.task-list input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  flex: none; position: relative; cursor: pointer;
  width: 15px; height: 15px; margin-top: .34em;
  border: 1px solid var(--hairline-2); border-radius: 4px;
  background: var(--surface);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.content ul.task-list input[type="checkbox"]:hover { border-color: var(--accent-line); }
.content ul.task-list input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.content ul.task-list input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 4.5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid var(--check-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.content hr { border: none; border-top: 1px solid var(--hairline); margin: 2.5rem 0; }
.content > em:last-child { display: block; color: var(--muted-2); margin-top: 2.5rem; }

/* ==========================================================================
   9. Back to top — the only genuinely floating surface
   ========================================================================== */
.btt {
  position: fixed; right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 60; width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--btt-bg); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--hairline-2); color: var(--fg);
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.btt.show { opacity: 1; transform: none; pointer-events: auto; }
.btt:hover { border-color: var(--accent-line); color: var(--accent-text); }

/* ==========================================================================
   10. Footer — left-aligned, two columns on desktop
   ========================================================================== */
.site-footer {
  max-width: var(--container); margin: 0 auto;
  border-top: 1px solid var(--hairline);
  padding: 1.85rem var(--gutter);
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: .5rem 2rem;
  color: var(--muted-2); font-size: .8125rem; line-height: 1.55;
}
.site-footer p { max-width: 72ch; }
.site-footer a {
  color: var(--muted); text-decoration: none;
  border-bottom: 1px solid var(--hairline-2); padding-bottom: .05em;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.site-footer a:hover { color: var(--accent-text); border-bottom-color: var(--accent-line); }

/* ==========================================================================
   11. Focus + skip link
   ========================================================================== */
:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}
.content a:focus-visible, .site-footer a:focus-visible, .toc a:focus-visible {
  outline-offset: 3px; border-radius: 3px;
}
.skip-link {
  position: fixed; left: 1rem; top: .5rem; z-index: 100;
  transform: translateY(-200%); pointer-events: none;
  background: var(--inverse-bg); color: var(--inverse-ink); font-weight: 620; font-size: .875rem;
  text-decoration: none; padding: .6rem .95rem; border-radius: var(--r-md);
}
.skip-link:focus-visible { transform: none; pointer-events: auto; outline-offset: 3px; }

/* ==========================================================================
   12. Mobile
   ========================================================================== */
@media (max-width: 640px) {
  :root { --header-h: 56px; --pad-card: 1.2rem 1.25rem; }
  .site-header { gap: .5rem; }
  .brand { font-size: .72rem; letter-spacing: .1em; gap: .45rem; }
  .brand-sub { display: none; }
  .site-header nav { gap: .05rem; }
  .site-header nav a { font-size: .8125rem; padding: .8rem .5rem; }
  .nl-hide-mobile { display: none !important; }
  .nl-long { display: none; }
  .nl-short { display: inline; }

  .hero { padding-top: 2.75rem; padding-bottom: 2rem; }
  .hero h1 { font-size: clamp(1.9rem, 8.4vw, 2.4rem); }
  .hero .lead { font-size: 1rem; }
  .statline { gap: .4rem 1rem; font-size: .6875rem; }
  .cta-row { gap: .55rem; }
  .btn { width: 100%; }

  .cell p { font-size: .9125rem; }
  .content h1 { margin-top: 2.9rem; padding-top: 1.9rem; }
  .content h2 { font-size: 1.125rem; margin-top: 2.1rem; padding-left: .65rem; }
  .content h3 { font-size: 1rem; }
  .content ul, .content ol { margin-left: 1.05rem; }
  .content table { font-size: .8125rem; }
  .content th, .content td { padding: .5rem .6rem; }
  .content pre { padding: .85rem .95rem; }
  .content pre code { font-size: .75rem; }
  .content blockquote { padding: .75rem .95rem; font-size: .8875rem; }
  details.toc-mobile .toc a {
    padding: .7rem .5rem .7rem .85rem;
    white-space: normal; overflow: visible; text-overflow: clip; min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:active, .btn-primary:hover { transform: none; }
}

/* ==========================================================================
   13. Print — this is a curriculum; people print curricula
   ========================================================================== */
@media print {
  @page { margin: 18mm; }
  body { background: #FFF; color: #14161A; font-size: 10.5pt; }
  body::before, .site-header, .btt, .cta-row, .music-banner,
  aside.toc, details.toc-mobile, .skip-link { display: none !important; }
  .hero { padding: 0 0 .8rem; max-width: none; }
  .hero h1, .content h1, .content h2, .content h3, .content h4, .sec-title { color: #14161A; }
  .hero .lead, .content p, .content li, .content td { color: #24272C; }
  .statline, .eyebrow { color: #5A606B; }
  .statline b { color: #14161A; }
  .page, .content { max-width: none; padding: 0; }
  .content h1 { border-top-color: #D5D8DE; }
  .content h2 { border-left-color: #C6CAD1; }
  .content a { color: #14161A; text-decoration: none; }
  .content a[href*="youtu"]::before { display: none; }
  .content a[href^="http"]::after {
    content: ' ¶[' attr(href) ']'; font-size: .78em; color: #5A606B;
    word-break: break-all; font-family: var(--mono);
  }
  .content code { background: none; color: #24272C; padding: 0; }
  .content pre, .content table, .cell, .content blockquote {
    background: #FFF; border-color: #D5D8DE; color: #24272C; break-inside: avoid;
  }
  .content pre code, .content pre .co, .content pre .fu, .content pre .st { color: #24272C; }
  .content ul.task-list input[type="checkbox"] { border-color: #C6CAD1; background: #FFF; }
  .content ul.task-list input[type="checkbox"]:checked { background: #24272C; border-color: #24272C; }
  .content ul.task-list input[type="checkbox"]:checked::after { border-color: #FFF; }
  h1, h2, h3 { break-after: avoid; }
  .site-footer { border-top-color: #D5D8DE; color: #5A606B; }
}

/* ==========================================================================
   14. Light theme — tuned independently, NOT an inversion of the dark ramp.
       Surfaces go from white-alpha overlays to ink-alpha overlays; the code
       tokens are re-derived for paper rather than darkened copies.
       Chosen by <html data-theme="light"> — set inline in <head> (no flash),
       persisted in localstorage, defaulting to the OS preference.
       The brand mint survives as a FILL only (checkbox): as TEXT it is 1.81:1
       on this background, so text greens below are separate, AA-checked values.
   ========================================================================== */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F7F8FA;
  --surface: rgba(9, 11, 15, .035);
  --surface-2: rgba(9, 11, 15, .062);
  --surface-sunken: #F1F3F6;
  --fg: #0E1115;              /* 17.8:1 */
  --fg-2: #3C424B;            /*  9.5:1 */
  --fg-body: #242A30;         /* 13.6:1 */
  --muted: #565D67;           /*  6.3:1 */
  --muted-2: #646B75;         /*  5.1:1 */
  --hairline: rgba(9, 11, 15, .085);
  --hairline-2: rgba(9, 11, 15, .15);
  --hairline-strong: rgba(9, 11, 15, .3);
  --accent-text: #0A6E4B;     /*  5.9:1 */
  --accent-hi: #085C3F;
  --accent-dim: rgba(10, 110, 75, .06);
  --accent-line: rgba(10, 110, 75, .32);
  --ring: rgba(10, 110, 75, .6);
  --selection: rgba(52, 211, 153, .32);
  --code-inline-bg: rgba(9, 11, 15, .05);
  --callout-fg: #1E4A38;      /*  9.5:1 */
  --header-bg: rgba(247, 248, 250, .82);
  --header-bg-scrolled: rgba(247, 248, 250, .93);
  --btt-bg: rgba(255, 255, 255, .86);
  --scroll-thumb: rgba(9, 11, 15, .16);
  --scroll-thumb-hover: rgba(9, 11, 15, .28);
  --inverse-bg: #0E1115;
  --inverse-bg-hover: #232830;
  --inverse-ink: #FFFFFF;
  --shadow-pop: 0 12px 32px -14px rgba(9, 11, 15, .3);
  --link-line: rgba(10, 110, 75, .32);
  --link-line-hover: rgba(8, 92, 63, .62);
  --wash: radial-gradient(58% 40% at 50% -8%, rgba(10, 110, 75, .07), transparent 72%);
  /* code tokens re-derived for paper — same roles, deepened to clear 4.5:1 */
  --tk-cmt: #646B75;  --tk-kw: #0B7A53;  --tk-str: #935A14;
  --tk-num: #1E5C8F;  --tk-fn: #14583C;  --tk-var: #2E3A47;
  --tk-op: #646B75;   --tk-err: #A0352A;
}

/* ---- theme toggle ------------------------------------------------------- */
.theme-toggle {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: .15rem; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  color: var(--muted);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.theme-toggle:hover { color: var(--fg); background: var(--surface-2); }
.theme-toggle svg { flex: none; }
.theme-toggle .ic-moon { display: block; }
.theme-toggle .ic-sun { display: none; }
:root[data-theme="light"] .theme-toggle .ic-moon { display: none; }
:root[data-theme="light"] .theme-toggle .ic-sun { display: block; }
@media (max-width: 640px) { .theme-toggle { width: 44px; height: 44px; } }

/* ==========================================================================
   15. Content roles + document aids for a 100 KB curriculum
   ========================================================================== */
/* phase tag — a typographic label where a corrupted decorative emoji was.
   The word already carried the meaning; the glyph only broke. */
.content .phase {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-family: var(--mono); font-size: var(--label); font-weight: 600;
  letter-spacing: .11em; text-transform: uppercase; color: var(--fg-2);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: .2rem .5rem;
}
/* the day's promised outcome — the most-scanned line of each of the 30 days */
.content .goal {
  display: block; max-width: var(--measure);
  color: var(--fg); font-size: 1.0625rem; font-weight: 500; line-height: 1.5;
  margin: .45rem 0 1.3rem;
}
.content .goal::before {
  content: 'ĐẦU RA'; display: block; margin-bottom: .25rem;
  font-family: var(--mono); font-size: var(--label); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2);
}
/* scroll progress — orientation in a very long document; rides the existing
   scroll handler, transform-only so it never touches layout */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 55; pointer-events: none;
}
.progress i {
  display: block; height: 100%; background: var(--accent-text);
  transform: scaleX(0); transform-origin: 0 50%;
}
/* deep-link affordance on section headings — the ids already existed, this
   only exposes them, and only where there is a gutter to put them in */
@media (min-width: 1100px) {
  .content h1, .content h2 { position: relative; }
  .content .plink {
    position: absolute; left: -.85em; top: .06em; width: .85em;
    font-family: var(--mono); font-weight: 500; color: var(--muted-2);
    text-decoration: none; opacity: 0;
    transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .content h1:hover .plink, .content h2:hover .plink, .content .plink:focus-visible { opacity: 1; }
  .content .plink:hover { color: var(--accent-text); }
}
/* honour the platform's contrast preference rather than ignoring it */
@media (prefers-contrast: more) {
  :root, :root[data-theme="light"] { --muted-2: var(--muted); --fg-2: var(--fg); }
  .content a { text-decoration-thickness: 2px; }
}
