/* css/folio-tokens.css — design tokens for Folio.
   Implements the Sam Ngo Universal Design System (see /design.md).
   Dark is the default canvas; light activates via [data-theme="light"] on <html>.

   Token NAMES are preserved (--paper, --ink, --accent, …) so the bulk of
   folio.css cascades unchanged after the value swap; new design-system
   primitives (--accent-hover, --accent-glow, --nav-bg, --hero-*) are added. */

:root,
[data-theme="dark"] {
  /* ── Surfaces ─────────────────────────────────────────────────── */
  --paper:       #000000;                          /* bg-primary */
  --paper-soft:  #13131a;                          /* bg-card */
  --paper-soft2: #1a1a24;                          /* bg-card-alt */
  --paper-rule:  #1f1f2e;                          /* border */
  --paper-rule2: #2a2a3a;                          /* border-strong */

  /* ── Ink ──────────────────────────────────────────────────────── */
  --ink:         #e8e8ed;                          /* text-primary */
  --ink-soft:    #9ca3af;                          /* text-secondary */
  --ink-muted:   #6b7280;                          /* text-muted */

  /* ── Accent triplet (single warm orange) ──────────────────────── */
  --accent:        #FF6B00;
  --accent-hover:  #FF8C42;
  --accent-glow:   rgba(255, 107, 0, 0.15);
  --accent-soft:   rgba(255, 107, 0, 0.22);        /* legacy alias for selection */

  /* ── Tags ─────────────────────────────────────────────────────── */
  --tag-bg:        #1a1a24;
  --tag-text:      #FF6B00;

  /* ── Shadow scale (orange-tinted on dark; black is invisible) ─── */
  --shadow:        0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-hi:     0 8px 30px rgba(0, 0, 0, 0.3), 0 0 24px rgba(255, 107, 0, 0.06);

  /* ── Navbar surface ───────────────────────────────────────────── */
  --nav-bg:        rgba(0, 0, 0, 0.92);
  --nav-text:      #e8e8ed;

  /* ── Hero surface + decorations ───────────────────────────────── */
  --hero-bg:               #000000;
  --hero-text:             #e8e8ed;
  --hero-muted:            #6b7280;
  --hero-orbit:            rgba(255, 107, 0, 0.12);
  --hero-orbit-lg:         rgba(255, 107, 0, 0.06);
  --hero-btn-border:       rgba(255, 255, 255, 0.2);
  --hero-pic-shadow:       0 0 30px rgba(255, 107, 0, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
  --hero-pic-shadow-hover: 0 0 40px rgba(255, 107, 0, 0.25), 0 20px 60px rgba(0, 0, 0, 0.5);

  /* ── Grain overlay opacity (decorative dot grid; design.md §11) ── */
  --grain-opacity: 0.04;

  /* ── Type families ────────────────────────────────────────────── */
  --font-display: 'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-body:    'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
  --font-cjk:     'Songti TC', 'Songti SC', 'Noto Serif TC', 'Noto Serif CJK TC',
                  'PingFang TC', 'Microsoft JhengHei', serif;

  /* ── Type scale (kept in px to preserve Folio's information density) */
  --t-hero:  72px;
  --t-h1:    40px;
  --t-h2:    23px;     /* tightened slightly to match design.md 1.3rem feel */
  --t-h3:    19px;
  --t-body:  15px;
  --t-meta:  13px;
  --t-micro: 12px;

  /* ── Spacing (4px base) ───────────────────────────────────────── */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;   /* used by the Play pill and the phone chapters sheet: undefined, it zeroed their padding */
  --s-6:  24px;
  --s-8:  32px;
  --s-12: 48px;
  --s-16: 64px;
  --s-24: 96px;

  /* ── Radius (design.md §4) ────────────────────────────────────── */
  --r-sm: 2px;   /* sections, cards — deliberately understated */
  --r-md: 4px;   /* buttons, inputs, badges */
  --r-lg: 8px;   /* FABs, larger CTAs */

  /* ── Motion (design.md §10) ───────────────────────────────────── */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);   /* ease-out-quart */
  --t-fast:  200ms;
  --t-mid:   350ms;
  --t-slow:  500ms;
  --t-sheet: 400ms;

  /* ── Line heights ─────────────────────────────────────────────── */
  --lh-tight:  1.05;
  --lh-snug:   1.4;
  --lh-normal: 1.5;
  --lh-loose:  1.65;

  /* ── Layout ───────────────────────────────────────────────────── */
  --max-w-lib: 1100px;
  --max-w-main: 1100px;
  --tap-min:   44px;
  --nav-h:     60px;   /* the fixed navbar; body pads by it and the readers subtract it */
}

/* ── Light theme override (cream, NOT white; design.md §2) ─────── */
[data-theme="light"] {
  --paper:       #f5f5f0;
  --paper-soft:  #ffffff;
  --paper-soft2: #f0efe8;
  --paper-rule:  #e8e6e1;
  --paper-rule2: #d0cdc6;

  --ink:         #1a1a1f;
  --ink-soft:    #4a4a55;
  --ink-muted:   #8a8a95;

  --accent:        #D95A00;
  --accent-hover:  #FF6B00;
  --accent-glow:   rgba(217, 90, 0, 0.10);
  --accent-soft:   rgba(217, 90, 0, 0.18);

  --tag-bg:        #f0ede6;
  --tag-text:      #8A3500;

  --shadow:        0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hi:     0 8px 30px rgba(0, 0, 0, 0.08);

  --nav-bg:        rgba(245, 245, 240, 0.92);
  --nav-text:      #1a1a1f;

  --hero-bg:               #f5f5f0;
  --hero-text:             #1a1a1f;
  --hero-muted:            #6b7280;
  --hero-orbit:            rgba(217, 90, 0, 0.10);
  --hero-orbit-lg:         rgba(217, 90, 0, 0.05);
  --hero-btn-border:       rgba(26, 26, 31, 0.18);
  --hero-pic-shadow:       0 0 30px rgba(217, 90, 0, 0.12), 0 12px 40px rgba(0, 0, 0, 0.10);
  --hero-pic-shadow-hover: 0 0 40px rgba(217, 90, 0, 0.20), 0 12px 40px rgba(0, 0, 0, 0.12);

  --grain-opacity: 0.03;
}

/* ── Base font size (design.md §3 + Sam-Personal-Profile style.css) ─
   Canonical sets html font-size to 18px so every rem-based size in the
   design system resolves at the intended scale. Folio's component CSS
   (folio.css) uses pixel-based --t-* tokens so it is unaffected. */
html { font-size: 18px; }

/* ── Reduced motion floor (design.md §10) ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Theme toggle (circular 36px per design.md §5) ─────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--paper-rule);
  width: 36px; height: 36px;
  border-radius: 50%;
  padding: 0;
  color: var(--nav-text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out);
}
.theme-toggle:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}
.theme-toggle .theme-glyph-moon { display: none; }
[data-theme="dark"] .theme-toggle .theme-glyph-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-glyph-moon { display: inline; }
:root:not([data-theme="light"]) .theme-toggle .theme-glyph-sun { display: none; }
:root:not([data-theme="light"]) .theme-toggle .theme-glyph-moon { display: inline; }

.about-link {
  font: 500 0.92rem/1 var(--font-body);
  color: var(--nav-text);
  opacity: 0.65;
  text-decoration: none;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  transition: opacity var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out);
}
.about-link:hover { opacity: 1; color: var(--nav-text); }

/* ── About view (light retreatment to fit the dark canvas) ─────── */
.about {
  max-width: 65ch;
  margin: var(--s-24) auto var(--s-16);
  padding: 0 var(--s-6);
  color: var(--ink);
}
.about h1 {
  margin-bottom: var(--s-6);
  font: 900 var(--t-h1)/1.1 var(--font-display);
  letter-spacing: -0.02em;
}
.about h2 {
  font: 700 var(--t-h2)/1.2 var(--font-display);
  margin: var(--s-8) 0 var(--s-3);
  letter-spacing: -0.02em;
}
.about h2::before {
  content: '// ';
  color: var(--accent);
  font-weight: 400;
}
.about p { margin-bottom: var(--s-4); font: var(--t-body)/1.6 var(--font-body); }
.about .muted { color: var(--ink-muted); }
.about a { color: var(--accent); text-decoration: none; }
.about a:hover { color: var(--accent-hover); }
.kbd-list { list-style: none; padding: 0; }
.kbd-list li {
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--paper-rule);
  font: var(--t-body)/1.5 var(--font-body);
}
.kbd-list kbd {
  font: 500 var(--t-meta)/1 var(--font-mono);
  background: var(--paper-soft2);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: var(--r-md);
  margin-right: var(--s-2);
  letter-spacing: 0.02em;
}
