/* ─────────────────────────────────────────────────────────────────────────────
 * Design tokens (plan B7.1) — the only place a raw colour, radius, space or
 * shadow value is allowed to appear. Everything else references these.
 *
 * SINGLE CODE PACKAGE (2026-11-21): both CMS instances ship this exact file.
 * Colours and type are NOT baked in here — they come from the active theme row
 * via /theme.css (`--colors-*` / `--fonts-*`). The inline fallbacks below are
 * deliberately NEUTRAL COOL values: if /theme.css ever fails, the site must
 * degrade to clean white/slate, never to warm cream, gold or brown. Keeping the
 * fallbacks neutral is what makes one tokens.css safe for two different brands.
 *
 * Per-instance palette lives in MySQL `themes.tokens` only:
 *   cms01        -> "royalty_porcelain" (white + gold accent)
 *   diaochuang1  -> "academic_teal"     (white + deep academic teal)
 *
 * Two levels on purpose:
 *   1. `--colors-*` / `--fonts-*` / `--spacing-*` arrive from /theme.css
 *      (editable in the admin 主题 screen).
 *   2. `--brand`, `--color-*`, `--radius-*`, `--space-*` are the semantic
 *      aliases the components use, each with a neutral inline fallback.
 * ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Brand palette — values are entirely theme-driven. Gold is a legitimate
     brand colour for one instance, but it must never become a page ground. */
  --brand: var(--colors-brand, #334155);
  --brand-strong: var(--colors-brand_strong, #1E293B);
  --brand-soft: var(--colors-brand_soft, #E8EDF1);
  --accent: var(--colors-accent, #1A1D21);
  --accent-2: var(--colors-accent, #1A1D21);

  /* Page ground is always white. Warm porcelain / cream backgrounds were the
     main source of the "cheap / AI-generated" look and are intentionally gone. */
  --bg: var(--colors-bg, #FFFFFF);
  --surface: var(--colors-surface, #F5F7F7);
  /* alternating section band — a cool neutral, never a beige */
  --porcelain: var(--colors-surface_alt, var(--surface));
  --text: var(--colors-text, #1A1D21);
  --text-muted: var(--colors-text_muted, #667085);
  --border: var(--colors-border, rgba(16, 32, 31, 0.12));
  --header-bg: var(--colors-header_bg, #FFFFFF);
  --footer-bg: var(--colors-footer_bg, #0C2422);

  /* semantic aliases used across components */
  --gold: var(--colors-brand, #334155);
  --gold-strong: var(--colors-brand_strong, #1E293B);
  --gold-soft: var(--colors-brand_soft, #E8EDF1);
  --ink: var(--colors-accent, #1A1D21);
  --rose: var(--colors-rose, #8A9A95);
  --line: var(--colors-line, rgba(16, 32, 31, 0.08));

  /* supporting accents for the animation / publication blocks (shared code) */
  --green: var(--colors-accent_soft, #2E7D6B);
  --green-soft: var(--colors-accent_soft_bg, #EAF2F0);
  --grid-line: var(--colors-border, rgba(16, 32, 31, 0.10));

  /* colour roles */
  --color-gold: var(--colors-brand, #334155);
  --color-gold-strong: var(--colors-brand_strong, #1E293B);
  --color-gold-soft: var(--colors-brand_soft, #E8EDF1);
  --color-ink: var(--colors-accent, #1A1D21);
  --color-bg: var(--colors-bg, #FFFFFF);
  --color-surface: var(--colors-surface, #F5F7F7);
  --color-text: var(--colors-text, #1A1D21);
  --color-text-muted: var(--colors-text_muted, #667085);
  --color-header-bg: var(--colors-header_bg, #FFFFFF);
  /* deep section ground for the 亮—暗 narrative rhythm (B7.4).
     NEVER paint a dark band with var(--ink): base.css remaps --ink to #FFFFFF
     inside .section--dark, which would draw a white strip. */
  --surface-dark: var(--colors-surface_dark, #0C2422);
  --surface-dark-2: var(--colors-surface_dark, #0C2422);
  --color-on-dark: var(--colors-on_dark, #FFFFFF);
  --color-on-dark-muted: var(--colors-on_dark_muted, rgba(255, 255, 255, 0.72));
  --color-on-dark-line: var(--colors-on_dark_line, rgba(255, 255, 255, 0.14));
  /* Text on a filled primary button. Gold needs dark ink, deep teal needs
     white — so this too is a theme token, not a hard-coded value. */
  --color-on-brand: var(--colors-on_brand, #FFFFFF);

  /* type — the theme decides the serif stack, so the same template can be a
     fashion-clinic display face on one site and an academic journal face on
     the other. All fonts are loaded once in base.html. */
  --font-display: var(--fonts-heading, 'Source Serif 4', 'Noto Serif SC', serif);
  --font-heading: var(--fonts-heading, 'Source Serif 4', 'Noto Serif SC', serif);
  --font-body: var(--fonts-body, 'Inter', 'Noto Sans SC', sans-serif);

  /* type scale — the whole site picks from these, nothing is ad-hoc */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: clamp(1.35rem, 2.2vw, 1.75rem);
  --text-2xl: clamp(1.8rem, 3.4vw, 2.6rem);
  --text-3xl: clamp(2.2rem, 4.8vw, 3.6rem);
  /* section headlines — larger than --text-2xl so a left-aligned CJK title
     still reads as an editorial statement rather than a paragraph lead */
  --text-display: clamp(2rem, 3.8vw, 3rem);
  --text-hero: clamp(3.5rem, 9vw, 8rem);
  --leading-tight: 1.04;
  --leading-snug: 1.2;
  --leading-body: 1.85;

  /* radius / shadow */
  --radius: var(--radius-md, 8px);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-card: var(--shadow-card, 0 18px 40px rgba(16, 24, 28, 0.08));
  --shadow-soft: 0 8px 26px rgba(16, 24, 28, 0.06);
  --shadow-float: 0 28px 60px rgba(16, 24, 28, 0.14);

  /* spacing scale — 1..8, 10, 12, 14, 16 only. There is NO 9/11/13/15 and a
     declaration containing an undefined var is dropped wholesale (B7.1). */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 40px;
  --space-10: 56px; --space-12: 72px; --space-14: 96px; --space-16: 128px;

  /* measure */
  /* three widths only: listing/grid, detail/form, full-bleed visual */
  --container: var(--spacing-container, 1280px);
  --container-narrow: var(--spacing-container_narrow, 960px);
  --container-wide: var(--spacing-container_wide, 1440px);
  --section-y: var(--spacing-section_y, clamp(88px, 9vw, 168px));
  --reading-width: 68ch;
  --gutter: clamp(20px, 4vw, 48px);
  --header-h: 76px;
  --header-h-compact: 60px;

  /* Buttons are SOLID, not a gold gradient: a flat brand fill reads as a
     deliberate design decision rather than a generated template. The old names
     are kept so all existing component CSS keeps working unchanged. */
  --gold-gradient: var(--brand);
  --gold-gradient-strong: var(--brand-strong);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-lux: cubic-bezier(0.16, 1, 0.3, 1);
  --reveal-duration: 900ms;
  --reveal-distance: 26px;
}

/* ─── Dark mode (plan B7.12) ───────────────────────────────────────────────────
 * Section-level tonality is the normal case (`.section--dark`); the document-wide
 * switch below is wired for a future toggle and costs nothing to keep. Cool
 * neutrals only — no warm brown/ivory.
 */
[data-theme="dark"] {
  --bg: #10161A;
  --surface: #182126;
  --color-bg: #10161A;
  --color-surface: #182126;
  --text: #F2F5F6;
  --color-text: #F2F5F6;
  --text-muted: #A7B4BA;
  --color-text-muted: #A7B4BA;
  --line: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.18);
  --header-bg: rgba(16, 22, 26, 0.86);
  --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 26px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 28px 60px rgba(0, 0, 0, 0.55);
}
