/* ═══════════════════════════════════════════════════════════════════════════
 * COMPONENT PRIMITIVES — DO NOT OVERWRITE
 *
 * Base styles, animations, layout utilities, and component classes.
 * Theme tokens live in tokens.css (set by the blog-brand skill).
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
 * DEFENSIVE ALIASES
 * Safety net — resolved by tokens.css if it defines the canonical names.
 * These ensure components work regardless of which naming convention
 * tokens.css uses (template placeholders vs styleguide-derived output).
 * ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Color aliases (component names → canonical names) */
  --color-text: var(--color-foreground);
  --color-text-secondary: var(--color-muted-foreground);
  --color-surface-elevated: color-mix(in oklch, var(--color-surface, oklch(0.97 0 0)), white 5%);
  --color-accent: var(--color-primary);
  --color-accent-foreground: var(--color-primary-foreground);
  --color-warning: var(--color-cta);
  --color-primary-light: color-mix(in oklch, var(--color-primary) 60%, white);
  --color-primary-dark: color-mix(in oklch, var(--color-primary) 80%, black);

  /* Static tokens (theme-independent) */
  --shadow-xl: 0 20px 25px -5px oklch(0.2 0 0 / 0.1), 0 8px 10px -6px oklch(0.2 0 0 / 0.05);
  --duration-slower: 1s;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * BASE STYLES
 * ═══════════════════════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

::selection {
  background: var(--color-primary);
  color: white;
}

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

/* ═══════════════════════════════════════════════════════════════════════════
 * ANIMATION KEYFRAMES
 * ═══════════════════════════════════════════════════════════════════════════ */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes successRing {
  from { opacity: 0.6; transform: scale(0.8); }
  to { opacity: 0; transform: scale(1.6); }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * ANIMATION UTILITIES
 * Use these classes on elements for entrance animations
 * ═══════════════════════════════════════════════════════════════════════════ */

.fade-up {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeUp var(--duration-slow) var(--ease-out) forwards;
}

.fade-in {
  opacity: 0;
  animation: fadeIn var(--duration-slow) var(--ease-out) forwards;
}

.slide-in-left {
  opacity: 0;
  transform: translateX(-40px);
  animation: slideInLeft var(--duration-slow) var(--ease-out) forwards;
}

.slide-in-right {
  opacity: 0;
  transform: translateX(40px);
  animation: slideInRight var(--duration-slow) var(--ease-out) forwards;
}

.scale-in {
  opacity: 0;
  transform: scale(0.9);
  animation: scaleIn var(--duration-slow) var(--ease-spring) forwards;
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

.success-ring {
  animation: successRing 0.8s var(--ease-out) forwards;
}

/* Animation Delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }

/* Hover Effects */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.hover-scale {
  transition: transform var(--duration-normal) var(--ease-spring);
}
.hover-scale:hover {
  transform: scale(1.02);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * LAYOUT UTILITIES
 * ═══════════════════════════════════════════════════════════════════════════ */

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (min-width: 768px) {
  .container { padding: 0 2rem; }
}

@media (min-width: 1024px) {
  .container { padding: 0 4rem; }
}

.section {
  padding: 5rem 0;
}

.section-sm {
  padding: 3rem 0;
}

@media (min-width: 768px) {
  .section { padding: 8rem 0; }
  .section-sm { padding: 4rem 0; }
}

.section-accent {
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
}

.section-accent h1,
.section-accent h2,
.section-accent h3,
.section-accent h4 {
  color: var(--color-accent-text);
}

.section-overlay {
  color: white;
}

.section-overlay h1,
.section-overlay h2,
.section-overlay h3,
.section-overlay h4 {
  color: white;
}

.section-alt {
  background: var(--color-surface);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * COMPONENT BASES
 * Minimal styles for common elements - extend as needed
 * ═══════════════════════════════════════════════════════════════════════════ */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.btn-primary {
  background: var(--color-cta);
  color: var(--color-cta-foreground);
  box-shadow: var(--shadow-cta-glow);
}

.btn-primary:hover {
  background: var(--color-cta-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-lg {
  padding: 1.25rem 2.5rem;
  font-size: 1.125rem;
}

.btn-sm {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
}

/* Inputs */
.input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-surface-elevated);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
}

.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--color-primary) 10%, transparent);
}

.input::placeholder {
  color: var(--color-muted-foreground);
}

.input-accent {
  background: var(--color-accent-surface);
  border-color: var(--color-accent-border);
  color: var(--color-accent-text);
}

.input-accent:focus {
  border-color: var(--color-primary);
}

/* Cards */
.card {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-accent {
  background: var(--color-accent-surface);
  border-color: var(--color-accent-border);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * SPECIAL EFFECTS
 * ═══════════════════════════════════════════════════════════════════════════ */

.gradient-text {
  background: linear-gradient(135deg, var(--color-primary), var(--color-cta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.noise-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.02;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════════════════════════════════════
 * RESPONSIVE UTILITIES
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * ACCESSIBILITY — REDUCED MOTION
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * BLOG DESIGN TOKENS
 *
 * This file is the single source of truth for color, type, space, motion.
 * Edit the values here to retheme the entire blog without touching components.
 *
 * Token names mirror the Context.dev styleguide response the blog-brand skill
 * receives from `extract_styleguide` (called through `mcp__code_mode__execute`):
 *   styleguide.colors.{accent,background,text} → --styleguide-* anchors below
 *   styleguide.typography.headings / .p        → --font-heading / --font-body
 *   styleguide.elementSpacing.{xs…xl}          → --spacing-{xs…xl}
 *   styleguide.shadows.{sm…xl,inner}           → --shadow-{sm…xl,inner}
 *
 * Loaded AFTER base.css (see globals.css), so the names declared here win
 * over base.css's defensive aliases.
 *
 * The blog-brand skill sets these from the company's website.
 * ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─────────────────────────────────────────────────────────────────────────
   * STYLEGUIDE ANCHORS — the only place a pasted literal belongs.
   *
   * Paste styleguide.colors.* from extract_styleguide VERBATIM (hex is fine —
   * `oklch(from …)` below converts natively). Every other color token derives
   * from these three, in both light and dark mode.
   *
   * If styleguide.mode is "dark", the extracted colors describe a dark UI:
   * paste accent verbatim, and swap the roles — feed background/text into the
   * DARK PALETTE formulas' L values and derive light here instead.
   *
   * No company domain? Pick anchors by hand from the proven palettes in
   * .claude/skills/blog-brand/references/color.md.
   * ───────────────────────────────────────────────────────────────────────── */
  --styleguide-accent: #ffffff;
  --styleguide-background: #07080f;
  --styleguide-text: #ffffff;
  --brand-logo-sun: #EBC65C;
  --brand-logo-sun-dark: #F0D27A;
  --brand-logo-ink-dark: #F5F5F7;
  --brand-logo-ink: var(--color-text);

  /* ─────────────────────────────────────────────────────────────────────────
   * COLOR — light mode. Anchors pass through; everything else derives in
   * OKLCH via relative color syntax, so perceptual discipline (chroma caps,
   * L targets) holds no matter what format the anchors were pasted in.
   * ───────────────────────────────────────────────────────────────────────── */
  /* Mihira's site is dark; light mode is derived from the same anchors. */
  --color-accent: oklch(from var(--styleguide-background) 0.28 min(c, 0.02) h);
  --color-background: oklch(from var(--styleguide-background) 0.985 min(c, 0.01) h);
  --color-text: oklch(from var(--styleguide-background) 0.17 min(c, 0.01) h);

  --color-background-elevated: oklch(from var(--color-background) calc(l + 0.005) c h);
  --color-text-muted: oklch(from var(--color-text) calc(l + 0.31) calc(c * 0.9) h);
  --color-border: oklch(from var(--color-text) calc(l + 0.73) calc(c * 0.3) h);
  --color-accent-strong: oklch(from var(--color-accent) calc(l - 0.07) calc(c * 1.1) h);
  --color-accent-soft: oklch(from var(--color-accent) 0.95 calc(c * 0.2) h);
  --color-focus: oklch(from var(--color-accent) calc(l + 0.06) calc(c * 1.05) h);

  /* Semantic (kept for plan/strategy widgets — template-owned, not styleguide) */
  --color-success: oklch(0.55 0.14 145);
  --color-warning: oklch(0.7 0.16 70);
  --color-error: oklch(0.55 0.2 25);

  /* ─────────────────────────────────────────────────────────────────────────
   * DARK PALETTE — precomputed from the same anchors. Both dark blocks below
   * assign from these, so the formulas live once and cannot drift.
   * ───────────────────────────────────────────────────────────────────────── */
  --dark-background: oklch(from var(--styleguide-background) 0.155 min(c, 0.01) h);
  --dark-background-elevated: oklch(from var(--dark-background) calc(l + 0.04) c h);
  --dark-text: oklch(from var(--styleguide-text) 0.94 min(c, 0.01) h);
  --dark-text-muted: oklch(from var(--dark-text) calc(l - 0.3) calc(c * 2.4) h);
  --dark-border: oklch(from var(--dark-text) calc(l - 0.66) calc(c * 1.6) h);
  --dark-accent: oklch(from var(--styleguide-accent) 0.94 calc(c * 0.85) h);
  --dark-accent-strong: oklch(from var(--dark-accent) calc(l + 0.06) calc(c * 1.05) h);
  --dark-accent-soft: oklch(from var(--dark-accent) 0.25 calc(c * 0.4) h);

  /* ─────────────────────────────────────────────────────────────────────────
   * TYPOGRAPHY — variable serif (Fraunces) + variable sans (Geist) + mono.
   * Maps: styleguide.typography.headings → --font-heading,
   *       styleguide.typography.p → --font-body (family + fontFallbacks).
   * When styleguide.fontLinks names a Google-hosted font, swap the families
   * in index.html's Bunny Fonts URL — never download font files.
   * Fonts load via Bunny Fonts in index.html. No @import here (would block).
   * ───────────────────────────────────────────────────────────────────────── */
  --font-heading: "Jost", "Jost Fallback", -apple-system, system-ui, sans-serif;
  --font-body: "Jost", "Jost Fallback", -apple-system, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "JetBrains Mono", "SF Mono", monospace;

  /* Clamp-driven type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem);
  --text-3xl: clamp(1.875rem, 1.4rem + 2.2vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.6rem + 3.2vw, 3.5rem);
  --text-display: clamp(2.75rem, 1.8rem + 4.8vw, 5.25rem);

  /* Editorial measures (line lengths) */
  --measure-body: 65ch;
  --measure-wide: 80ch;
  --measure-narrow: 45ch;
  --content-max: 1280px;
  /* Reading shell: holds a 65ch column + gap + TOC rail and is CENTERED, so
   * the article layout doesn't float a fixed grid against the left of the
   * 1280px landing width (which dumps dead space on the right). */
  --measure-reading: 60rem;   /* ~960px — article + rail, balanced margins */
  --toc-width: 15rem;         /* 240px sticky table-of-contents rail */

  /* ─────────────────────────────────────────────────────────────────────────
   * SPACING — 4pt scale with semantic names.
   * xs–xl map 1:1 to styleguide.elementSpacing (snap extracted values to the
   * 4pt grid); 3xs/2xs and 2xl–4xl are template extensions for editorial
   * rhythm that Context.dev doesn't report.
   * ───────────────────────────────────────────────────────────────────────── */
  --spacing-3xs: 0.125rem;   /*  2px */
  --spacing-2xs: 0.25rem;    /*  4px */
  --spacing-xs: 0.625rem;    /* 10px */
  --spacing-sm: 0.75rem;     /* 12px */
  --spacing-md: 1rem;        /* 16px */
  --spacing-lg: 1.5rem;      /* 24px */
  --spacing-xl: 2.5rem;      /* 40px */
  --spacing-2xl: 4rem;       /* 64px */
  --spacing-3xl: 6rem;       /* 96px */
  --spacing-4xl: 9rem;       /* 144px */

  /* Responsive section padding */
  --section-pad-y: clamp(var(--spacing-2xl), 5vw, var(--spacing-4xl));
  --section-pad-x: clamp(var(--spacing-md), 4vw, var(--spacing-2xl));

  /* ─────────────────────────────────────────────────────────────────────────
   * RADII — evidence source: styleguide.components.button.*.borderRadius →
   * --radius-md, styleguide.components.card.borderRadius → --radius-lg.
   * ───────────────────────────────────────────────────────────────────────── */
  --radius-sm: 0.25rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.5rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  /* ─────────────────────────────────────────────────────────────────────────
   * MOTION — three named easings, five durations, transform+opacity only
   * ───────────────────────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 0.4);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  /* --ease-spring kept for legacy components in base.css; do not use in new motion */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --duration-instant: 0.1s;
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;
  --duration-slower: 0.7s;

  /* ─────────────────────────────────────────────────────────────────────────
   * SHADOWS — soft, low-contrast, tinted from the text anchor.
   * sm–xl and inner map 1:1 to styleguide.shadows; when extracted evidence
   * exists, adapt its character (offset/blur/strength) into these tokens.
   * ───────────────────────────────────────────────────────────────────────── */
  --shadow-sm: 0 0 0 2px var(--color-border);
  --shadow-md: 0 2px 4px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 6%),
               0 4px 12px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 4%);
  --shadow-lg: 0 4px 8px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 6%),
               0 12px 24px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 6%);
  --shadow-xl: 0 8px 16px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 8%),
               0 24px 48px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 8%);
  --shadow-inner: inset 0 1px 2px oklch(from var(--styleguide-text) 0.1 min(c, 0.01) h / 8%);
  --shadow-cta-glow: none;

  /* Dark-mode shadows (assigned by both dark blocks below) */
  --dark-shadow-sm: 0 1px 2px oklch(0 0 0 / 0.4);
  --dark-shadow-md: 0 2px 4px oklch(0 0 0 / 0.35), 0 4px 12px oklch(0 0 0 / 0.3);
  --dark-shadow-lg: 0 4px 8px oklch(0 0 0 / 0.35), 0 12px 24px oklch(0 0 0 / 0.35);
  --dark-shadow-xl: 0 8px 16px oklch(0 0 0 / 0.4), 0 24px 48px oklch(0 0 0 / 0.4);
  --dark-shadow-inner: inset 0 1px 2px oklch(0 0 0 / 0.4);

  /* ─────────────────────────────────────────────────────────────────────────
   * BASE.CSS COMPATIBILITY — styles/base.css is locked and consumes these
   * names. They are pure aliases; never point components at them directly.
   * --color-*-foreground = text sitting ON that background: the background
   * anchor works in both modes (light: paper on deep accent; dark: near-black
   * on lightened accent).
   * ───────────────────────────────────────────────────────────────────────── */
  --color-foreground: var(--color-text);
  --color-primary: var(--color-accent);
  --color-primary-foreground: var(--color-background);
  --color-cta: var(--color-accent);
  --color-cta-hover: var(--color-accent-strong);
  --color-cta-foreground: var(--color-background);
  --color-surface: var(--color-background-elevated);
  --color-muted-foreground: var(--color-text-muted);
  --color-accent-bg: var(--color-accent);
  --color-accent-text: var(--color-background);
  --color-accent-surface: var(--color-accent-strong);
  --color-accent-border: var(--color-accent-strong);

  /* ─────────────────────────────────────────────────────────────────────────
   * TERMINAL — dark code-block palette. Stays dark in both light and dark
   * theme by design. Override per project if you need a light code aesthetic.
   * ───────────────────────────────────────────────────────────────────────── */
  --color-terminal-bg: oklch(0.16 0.01 264);
  --color-terminal-fg: oklch(0.92 0.005 80);
  --color-terminal-rule: oklch(0.22 0.01 264);
  --color-terminal-meta: oklch(0.6 0.005 80);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * DARK MODE — explicit choice (set by ThemeToggle / FOUC script)
 * Pure assignments from the precomputed --dark-* palette; every derived alias
 * (cta, surface, muted, …) re-resolves automatically through the anchors.
 * ═══════════════════════════════════════════════════════════════════════════ */

[data-theme="dark"] {
  --color-background: var(--dark-background);
  --color-background-elevated: var(--dark-background-elevated);
  --color-text: var(--dark-text);
  --color-text-muted: var(--dark-text-muted);
  --color-border: var(--dark-border);
  --color-accent: var(--dark-accent);
  --color-accent-strong: var(--dark-accent-strong);
  --color-accent-soft: var(--dark-accent-soft);
  --color-focus: var(--dark-accent-strong);
  --brand-logo-sun: var(--brand-logo-sun-dark);
  --brand-logo-ink: var(--brand-logo-ink-dark);

  --shadow-sm: var(--dark-shadow-sm);
  --shadow-md: var(--dark-shadow-md);
  --shadow-lg: var(--dark-shadow-lg);
  --shadow-xl: var(--dark-shadow-xl);
  --shadow-inner: var(--dark-shadow-inner);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * DARK MODE — system preference (when user has NOT explicitly chosen).
 * Same assignments as [data-theme="dark"]; keep the two blocks identical.
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-background: var(--dark-background);
    --color-background-elevated: var(--dark-background-elevated);
    --color-text: var(--dark-text);
    --color-text-muted: var(--dark-text-muted);
    --color-border: var(--dark-border);
    --color-accent: var(--dark-accent);
    --color-accent-strong: var(--dark-accent-strong);
    --color-accent-soft: var(--dark-accent-soft);
    --color-focus: var(--dark-accent-strong);
    --brand-logo-sun: var(--brand-logo-sun-dark);
    --brand-logo-ink: var(--brand-logo-ink-dark);

    --shadow-sm: var(--dark-shadow-sm);
    --shadow-md: var(--dark-shadow-md);
    --shadow-lg: var(--dark-shadow-lg);
    --shadow-xl: var(--dark-shadow-xl);
    --shadow-inner: var(--dark-shadow-inner);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * TYPOGRAPHY DEFAULTS — applied at root so every block inherits
 * ═══════════════════════════════════════════════════════════════════════════ */

body {
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-background);
  transition: background-color var(--duration-normal) var(--ease-in-out),
              color var(--duration-normal) var(--ease-in-out);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--color-text);
}

h1 { font-size: var(--text-4xl); font-weight: 600; letter-spacing: -0.03em; }
h2 { font-size: var(--text-3xl); font-weight: 600; }
h3 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.015em; }

.tabular,
[data-tabular] {
  font-variant-numeric: tabular-nums lining-nums;
}

.smallcaps,
[data-smallcaps] {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
  font-feature-settings: "smcp";
}

/* Long-form article rhythm (applied inside <article class="prose"> blocks) */
.prose {
  /* width:100% gives the article a DEFINITE size so it fills its grid track
   * and shrinks on mobile. Without it, margin-inline:auto makes the article
   * size to its max-content — a wide image or long code line then blows the
   * column past the viewport. max-width still caps the reading measure. */
  width: 100%;
  max-width: var(--measure-body);
  margin-inline: auto;
  font-size: var(--text-lg);
  line-height: 1.65;
}

.prose > * + * { margin-top: var(--spacing-lg); }
.prose > h2 { margin-top: var(--spacing-2xl); margin-bottom: var(--spacing-sm); }
.prose > h3 { margin-top: var(--spacing-xl); margin-bottom: var(--spacing-2xs); }
.prose > figure,
.prose > pre,
.prose > blockquote { margin-block: var(--spacing-xl); }
.prose a { color: var(--color-accent); text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 0.075em; }
.prose a:hover { color: var(--color-accent-strong); }
/* Inline code only — explicitly excludes <code> inside <pre> so CodeBlock keeps its dark Terminal styling */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.12em 0.4em;
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
  border-radius: 0;
  font-weight: inherit;
}
/* Article tables: hairline rows, a quiet uppercase header, figures that line
 * up. Full column width on desktop; below md the table scrolls sideways in
 * its own box, so posts never need a wrapper. */
.prose table {
  width: 100%;
  margin-block: var(--spacing-xl);
  border-collapse: collapse;
  font-size: var(--text-base);
  line-height: 1.45;
  font-variant-numeric: tabular-nums lining-nums;
}
.prose th,
.prose td {
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-sm) 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}
.prose th {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom-color: var(--color-text-muted);
  white-space: nowrap;
}
.prose td:first-child { font-weight: 500; min-width: 8rem; }
.prose tbody tr:last-child td { border-bottom: none; }
@media (max-width: 767px) {
  .prose table { display: block; overflow-x: auto; }
}
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }

::selection {
  background: var(--color-accent-soft);
  color: var(--color-text);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * COMPONENT-LEVEL CSS — minimal rules that can't be expressed inline
 * (hover/focus pseudo-states for Footnote tooltip, drop caps, etc.)
 * ═══════════════════════════════════════════════════════════════════════════ */

.footnote {
  position: relative;
  display: inline;
  white-space: nowrap;
}

.footnote:hover .footnote-tooltip,
.footnote:focus-within .footnote-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* On touch there is no hover, and a popover beside the marker can overflow
 * the viewport near the column edge. A tap focuses the marker, so show the note
 * as a sheet along the bottom of the screen instead. */
@media (hover: none) {
  .footnote:focus-within .footnote-tooltip {
    position: fixed !important;
    left: var(--spacing-md) !important;
    right: var(--spacing-md) !important;
    bottom: var(--spacing-md) !important;
    width: auto !important;
    transform: none !important;
  }
}

.footnote a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Article TOC scroll-spy active link */
.toc-link[data-active="true"] {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}


/* The article's reading column + TOC grid collapses below lg, where the TOC is hidden */
@media (max-width: 1023px) {
  .article-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Two-column layout (lg+): the reading column sits flush-left under the title,
 * with the TOC rail to its right. When the grid collapses (below), .prose keeps
 * its default margin-inline:auto so the lone column stays centered — never
 * pinned hard-left in a wide single-column viewport. */
@media (min-width: 1024px) {
  .article-grid > .prose {
    margin-inline: 0;
  }
}

/* Atelier asymmetric hero: image left / title right on lg, stacked below */
@media (max-width: 1023px) {
  .atelier-hero {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}

/* Article layout. Width: body text keeps its 65ch line, while figures, visuals and
 * tables use the article column up to --measure-media. The reading shell is
 * wide enough for a 720-wide visual beside the On this page rail, and on
 * tablets and up a visual scales to fit instead of scrolling sideways. */
:root {
  --measure-reading: 72rem;
  --measure-media: 56rem;
}
/* Overrides the article's inline 65ch cap; the cap moves to its children. */
.article-grid > .prose { max-width: none !important; }
.prose > * { max-width: var(--measure-body); margin-inline: auto; }
.prose > figure,
.prose > table { max-width: var(--measure-media); }
/* Beside the rail, the column sits flush-left under the title. */
@media (min-width: 1024px) {
  .article-grid:has(> :nth-child(2)) > .prose > * { margin-inline: 0; }
}
@media (min-width: 768px) {
  .prose th { white-space: normal; }
  .prose figure svg { min-width: 0 !important; }
}
/* Lists: the base reset strips the indent, so bullets and numbers hung in the
 * page margin and were cut off on phones. Only lists written in the article
 * body; component card grids keep their own look. */
.prose > ul,
.prose > ol,
.prose li > ul,
.prose li > ol { padding-left: 1.5em; }
.prose > ul,
.prose li > ul { list-style: disc; }
.prose li > ul ul { list-style: circle; }
.prose > ol,
.prose li > ol { list-style: decimal; }
.prose li + li,
.prose li > ul,
.prose li > ol { margin-top: var(--spacing-2xs); }
.prose li::marker { color: var(--color-accent); }

/* ═══════════════════════════════════════════════════════════════════════════
 * LAYOUT UTILITIES — the complete allowed utility-class set
 *
 * This file replaces the Tailwind Play CDN (a dev-only runtime that shipped
 * ~100KB of render-blocking JS). Only the classes below exist — there is no
 * arbitrary utility generation. Anything visual (color, spacing values,
 * radius, motion) comes from tokens.css variables via inline style.
 *
 * Breakpoints match base.css: md = 768px, lg = 1024px.
 * Responsive variants come AFTER the base classes so `hidden md:flex`
 * resolves correctly (media-scoped rule wins at its breakpoint).
 * ═══════════════════════════════════════════════════════════════════════════ */

.block { display: block; }
.hidden { display: none; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

.rounded-md { border-radius: var(--radius-md); }

/* Named easing + tokened duration — no default `ease` curve. */
.transition-colors {
  transition:
    color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

/* Screen-reader-only content (accessibility). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 768px) {
  .md\:block { display: block; }
  .md\:hidden { display: none; }
  .md\:flex { display: flex; }
  .md\:grid { display: grid; }
}

@media (min-width: 1024px) {
  .lg\:block { display: block; }
  .lg\:hidden { display: none; }
  .lg\:flex { display: flex; }
  .lg\:grid { display: grid; }
}

