/* ============================================================
   Site token layer - non-color tokens mapped 1:1 from the kit's
   DTCG source (tokens/typography.json, spacing.json, borders.json,
   shadows.json, motion.json, breakpoints.json). Colors come from
   theme.css (generated by scripts/build_tokens.mjs).
   This block is the only place raw values may appear.
   ============================================================ */
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  --text-xs: 0.75rem;    /* 12 */
  --text-sm: 0.875rem;   /* 14 */
  --text-base: 1rem;     /* 16 */
  --text-lg: 1.125rem;   /* 18 */
  --text-xl: 1.25rem;    /* 20 */
  --text-2xl: 1.5rem;    /* 24 */
  --text-3xl: 1.875rem;  /* 30 */
  --text-4xl: 2.25rem;   /* 36 */

  --leading-tight: 1.25;
  --leading-normal: 1.5;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-focus-ring: 0 0 0 2px var(--color-surface-page), 0 0 0 4px var(--color-interactive-focus-ring);

  --duration-fast: 150ms;
  --duration-base: 200ms;
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  --measure: 65ch;
  --container: 880px;

  --size-icon: 16px;
  --size-icon-lg: 20px;
  --size-control: 36px;
  --size-checkbox: 20px;
  --size-checkmark: 12px;
  --size-target-min: 24px;
  --size-card-min: 260px;
}

/* Dark-mode remap for component-level color tokens: the generated theme.css
   swaps only semantic tokens, so component tokens that resolved to light
   literals are re-aliased here to their dark semantic equivalents. */
:root[data-theme="dark"] {
  --color-card-bg: var(--color-surface-card);
  --color-card-border: var(--color-border-default);
  --color-interactive-selected-bg: var(--color-surface-raised);
  --color-interactive-selected-border: var(--color-border-strong);
  --color-badge-neutral-bg: var(--color-surface-raised);
  --color-badge-neutral-text: var(--color-text-secondary);
  --color-badge-primary-bg: var(--color-surface-raised);
  --color-badge-primary-text: var(--color-text-link);
  --color-button-secondary-bg: var(--color-action-secondary);
  --color-button-secondary-bg-hover: var(--color-action-secondary-hover);
  --color-action-secondary-active: var(--color-action-secondary-hover);
  --color-input-bg: var(--color-surface-raised);
  --color-feedback-info-bg: var(--color-surface-raised);
  --color-feedback-info-text: #93c5fd;
  --color-feedback-info-border: var(--color-border-default);
  --color-feedback-warning-bg: var(--color-surface-raised);
  --color-feedback-warning-text: #fcd34d;
  --color-feedback-warning-border: var(--color-border-default);
  --color-feedback-success-bg: var(--color-surface-raised);
  --color-feedback-success-text: #86efac;
  --color-feedback-success-border: var(--color-border-default);
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background: var(--color-surface-page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-4);
}
h1 { font-size: var(--text-4xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); font-weight: var(--weight-semibold); margin-top: var(--space-16); }
h3 { font-size: var(--text-xl); font-weight: var(--weight-semibold); margin-top: var(--space-8); }
h4 { font-size: var(--text-base); font-weight: var(--weight-semibold); }

p, ul, ol { margin: 0 0 var(--space-4); max-width: var(--measure); }
ul, ol { padding-inline-start: var(--space-6); }
li { margin-bottom: var(--space-2); }
li::marker { color: var(--color-text-tertiary); }

a { color: var(--color-text-link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--color-text-link-hover); }
a:focus-visible { outline: none; border-radius: var(--radius-sm); box-shadow: var(--shadow-focus-ring); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  overflow-wrap: anywhere;
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

hr { border: 0; border-top: 1px solid var(--color-border-default); margin: var(--space-12) 0; }

strong { font-weight: var(--weight-semibold); }

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: calc(-1 * var(--space-20));
  z-index: 100;
  background: var(--color-surface-card);
  color: var(--color-text-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: top var(--duration-fast) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); }

/* ============================================================
   Header / nav
   ============================================================ */
.site-header {
  border-bottom: 1px solid var(--color-border-default);
  background: var(--color-surface-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.site-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  text-decoration: none;
  white-space: nowrap;
}
.site-title:hover { color: var(--color-text-link); }

.site-nav {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-inline-start: auto;
}
.site-nav a {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  white-space: nowrap;
  min-height: var(--size-target-min);
}
.site-nav a:hover { color: var(--color-text-primary); background: var(--color-action-secondary); }
.site-nav a:active { background: var(--color-action-secondary-hover); }
.site-nav a[aria-current="page"] {
  color: var(--color-text-link);
  background: var(--color-interactive-selected-bg);
}
.site-nav a:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }

.theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--size-control);
  height: var(--size-control);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  background: var(--color-button-secondary-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
.theme-toggle:hover { background: var(--color-button-secondary-bg-hover); color: var(--color-text-primary); }
.theme-toggle:active { background: var(--color-action-secondary-active); }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ============================================================
   Layout
   ============================================================ */
main {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-10) var(--space-4) var(--space-20);
}

.page-intro {
  color: var(--color-text-secondary);
  font-size: var(--text-lg);
  max-width: var(--measure);
}

.eyebrow {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-link);
  margin-bottom: var(--space-2);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-4) 0 var(--space-8);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-badge-neutral-bg);
  color: var(--color-badge-neutral-text);
}
.badge-primary { background: var(--color-badge-primary-bg); color: var(--color-badge-primary-text); }
.badge-success { background: var(--color-badge-success-bg); color: var(--color-badge-success-text); }

/* ============================================================
   Cards (index phase list)
   ============================================================ */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--size-card-min), 100%), 1fr));
  gap: var(--space-4);
  margin: var(--space-8) 0;
  padding: 0;
  list-style: none;
}
.phase-grid li { margin: 0; }

.phase-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  padding: var(--space-5);
  background: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.phase-card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-md); color: inherit; }
.phase-card:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }
.phase-card .eyebrow { margin-bottom: 0; }
.phase-card h3 { margin: 0; font-size: var(--text-lg); }
.phase-card p { color: var(--color-text-secondary); font-size: var(--text-sm); margin: 0; }
.phase-card .progress-note {
  margin-top: auto;
  padding-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: var(--space-1);
  border-radius: var(--radius-full);
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border-default);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  background: var(--color-action-primary);
  transition: width var(--duration-base) var(--ease-in-out);
}

/* ============================================================
   Week modules
   ============================================================ */
.week {
  margin: var(--space-8) 0;
  padding: var(--space-6);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-2xl);
}
.week-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.week-header h3 { margin: 0; }
.week-header .badge { flex-shrink: 0; margin-top: var(--space-1); }

.done-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline-start: auto;
  flex-shrink: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
}
.done-label:hover { background: var(--color-action-secondary); color: var(--color-text-primary); }
.done-label input {
  appearance: none;
  width: var(--size-checkbox);
  height: var(--size-checkbox);
  margin: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-input-bg);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}
.done-label input::before {
  content: "";
  width: var(--size-checkmark);
  height: var(--size-checkmark);
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
  background: var(--color-text-on-action);
  clip-path: polygon(14% 44%, 0 62%, 38% 100%, 100% 16%, 84% 4%, 38% 71%);
}
.done-label input:checked { background: var(--color-action-primary); border-color: var(--color-action-primary); }
.done-label input:checked::before { transform: scale(1); }
.done-label input:hover { border-color: var(--color-input-border-hover); }
.done-label input:checked:hover { background: var(--color-action-primary-hover); border-color: var(--color-action-primary-hover); }
.done-label input:active { border-color: var(--color-action-primary-active); }
.done-label input:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }

.week h4 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}
.week ul { margin-bottom: 0; }
.week p:last-child { margin-bottom: 0; }

.resource-note { font-size: var(--text-sm); color: var(--color-text-secondary); }

/* Callouts */
.callout {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-feedback-info-border);
  background: var(--color-feedback-info-bg);
  color: var(--color-feedback-info-text);
  margin: var(--space-6) 0;
  max-width: var(--measure);
}
.callout p, .callout ul { color: inherit; margin-bottom: 0; }
.callout p + p, .callout p + ul { margin-top: var(--space-2); }
.callout-title {
  display: block;
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}
.callout-warning {
  border-color: var(--color-feedback-warning-border);
  background: var(--color-feedback-warning-bg);
  color: var(--color-feedback-warning-text);
}
.callout-success {
  border-color: var(--color-feedback-success-border);
  background: var(--color-feedback-success-bg);
  color: var(--color-feedback-success-text);
}

/* Phase gate self-test disclosure */
.gate {
  margin: var(--space-8) 0;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-xl);
  background: var(--color-surface-sunken);
}
.gate summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-4) var(--space-5);
  font-weight: var(--weight-semibold);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-xl);
  min-height: var(--size-target-min);
}
.gate summary::-webkit-details-marker { display: none; }
.gate summary:hover { background: var(--color-action-secondary); }
.gate summary:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }
.gate summary .chevron { transition: transform var(--duration-fast) var(--ease-out); flex-shrink: 0; }
.gate[open] summary .chevron { transform: rotate(90deg); }
.gate-body { padding: 0 var(--space-5) var(--space-5); }
.gate-body ol li { margin-bottom: var(--space-3); }

/* Video embeds */
.video {
  margin: var(--space-6) 0;
  max-width: var(--measure);
}
.video iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-xl);
  background: var(--color-surface-sunken);
}
.video figcaption {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
}

/* Tables */
.table-wrap { overflow-x: auto; margin: var(--space-6) 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-sm);
}
th, td {
  text-align: start;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-default);
  vertical-align: top;
}
th {
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Pager (prev / next phase) */
.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-16);
  border-top: 1px solid var(--color-border-default);
  padding-top: var(--space-6);
}
.pager a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-medium);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  min-height: var(--size-target-min);
}
.pager a:hover { background: var(--color-action-secondary); }
.pager a:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring); }

.site-footer {
  border-top: 1px solid var(--color-border-default);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}
.site-footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}
.site-footer p { margin: 0; }

.icon { width: var(--size-icon); height: var(--size-icon); flex-shrink: 0; }
.icon-lg { width: var(--size-icon-lg); height: var(--size-icon-lg); }

@media (max-width: 480px) {
  h1 { font-size: var(--text-3xl); }
  main { padding-top: var(--space-6); }
  .week { padding: var(--space-4); }
  .week-header { flex-wrap: wrap; }
  .done-label { margin-inline-start: 0; }
}
