/* ============================================================
   Xiehe Nexus — design tokens
   No web-font requests: mainland China cannot reach fonts.googleapis.com
   reliably, so the type stack resolves locally on every device.
   ============================================================ */

:root {
  /* ---- type stacks ---------------------------------------- */
  --font-ui:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    "Source Han Sans SC", sans-serif;
  --font-display:
    "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Songti SC", "STSong", "SimSun", serif;
  --font-mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* ---- type scale ----------------------------------------- */
  --fs-micro: 0.75rem;
  --fs-meta: 0.8125rem;
  --fs-small: 0.875rem;
  --fs-body: 0.9375rem;
  --fs-lead: 1.0625rem;
  --fs-card: 1.0625rem;
  --fs-h3: 1.1875rem;
  --fs-h2: 1.4375rem;
  --fs-h1: 1.875rem;
  --fs-hero: 2.625rem;

  --lh-tight: 1.25;
  --lh-snug: 1.4;
  --lh-body: 1.6;
  --lh-loose: 1.75;

  --tracking-caps: 0.09em;
  --tracking-tight: -0.011em;

  /* ---- spacing (4px base) --------------------------------- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* ---- radii ---------------------------------------------- */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* ---- brand hues (light) ---------------------------------
     Sampled from the Xiehe Education crest: the indigo of the roundel
     (#3d4399) and its silver shield (#b3bac2), with the deeper azure the
     group site uses as its theme colour (#00499d). */
  --brand-900: #1e2260;
  --brand-800: #2e3477;
  --brand-700: #3d4399;   /* crest indigo — the primary */
  --brand-600: #4a51ad;
  --brand-500: #5a61c2;
  --brand-200: #c3c6e6;
  --brand-100: #e8e9f6;
  --brand-050: #f3f4fb;
  --azure-800: #00397c;
  --azure-700: #00499d;   /* group site theme colour */
  --silver-400: #b3bac2;  /* crest shield */
  --silver-200: #dbdfe6;

  --gold-700: #8a5c10;
  --gold-500: #b8811f;
  --gold-100: #f6ecd8;

  --crimson-700: #96302a;
  --crimson-500: #b8443c;
  --crimson-100: #fae9e7;

  --info-700: #1f4d92;
  --info-500: #2f66b5;
  --info-100: #e7effa;

  --violet-700: #5b3b96;
  --violet-100: #eee9f9;

  /* ---- semantic surfaces (light) -------------------------- */
  --bg: #f6f7fa;
  --bg-sunken: #eceef4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #fafbfd;
  --overlay: rgba(14, 17, 34, 0.52);

  --ink: #1a1d29;
  --ink-2: #494f60;
  /* #5a6072 clears 4.5:1 against every light surface, including the sunken
     grey behind segmented controls. A lighter grey failed there. */
  --ink-3: #5a6072;
  --ink-inverse: #ffffff;

  --line: #e2e5ee;
  --line-soft: #edeff5;
  --line-strong: #c8cdda;

  --accent: var(--brand-700);
  --accent-hover: var(--brand-800);
  --accent-soft: var(--brand-100);
  --accent-softer: var(--brand-050);
  --accent-border: var(--brand-200);
  --on-accent: #ffffff;

  --success: #1c7a54;
  --success-soft: #e3f3ec;
  --warning: #8a5c10;
  --warning-soft: #f6ecd8;
  --danger: #a8352d;
  --danger-soft: #fae9e7;
  --info: #1f4d92;
  --info-soft: #e7effa;

  --focus-ring: #4a51ad;

  /* Post-kind label colour. Kept as its own token because the violet that
     works on paper is unreadable on the dark surface. */
  --kind-news: var(--violet-700);
  --brand-gradient: linear-gradient(152deg, var(--brand-800) 0%, var(--azure-800) 58%, var(--brand-900) 100%);

  /* ---- elevation ------------------------------------------ */
  --shadow-xs: 0 1px 2px rgba(26, 29, 41, 0.06);
  --shadow-sm: 0 1px 2px rgba(26, 29, 41, 0.05), 0 2px 8px rgba(26, 29, 41, 0.06);
  --shadow-md: 0 2px 4px rgba(26, 29, 41, 0.05), 0 8px 24px rgba(26, 29, 41, 0.09);
  --shadow-lg: 0 8px 40px rgba(26, 29, 41, 0.18);

  /* ---- motion --------------------------------------------- */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 300ms;

  /* ---- layout --------------------------------------------- */
  --topbar-h: 60px;
  --sidebar-w: 244px;
  --rail-w: 300px;
  --content-max: 1400px;
  --z-sticky: 100;
  --z-drop: 200;
  --z-modal: 300;
  --z-toast: 400;
}

/* ---- reading-comfort scale (user setting) ----------------- */
html[data-textsize="lg"] {
  --fs-meta: 0.875rem;
  --fs-small: 0.9375rem;
  --fs-body: 1.0625rem;
  --fs-lead: 1.1875rem;
  --fs-card: 1.1875rem;
  --fs-h3: 1.3125rem;
  --fs-h2: 1.5625rem;
  --fs-h1: 2.0625rem;
}
html[data-textsize="xl"] {
  --fs-meta: 0.9375rem;
  --fs-small: 1rem;
  --fs-body: 1.1875rem;
  --fs-lead: 1.3125rem;
  --fs-card: 1.3125rem;
  --fs-h3: 1.4375rem;
  --fs-h2: 1.6875rem;
  --fs-h1: 2.1875rem;
}

/* Chinese text needs a looser line for the same perceived density. */
html[lang="zh-CN"] body {
  line-height: var(--lh-loose);
  letter-spacing: 0;
}

/* ---- dark theme ------------------------------------------ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10121c;
    --bg-sunken: #0a0c14;
    --surface: #171a26;
    --surface-raised: #1e2131;
    --surface-muted: #141724;
    --overlay: rgba(4, 5, 12, 0.7);

    --ink: #e9ebf3;
    --ink-2: #b4b9cb;
    --ink-3: #8d93a8;
    --ink-inverse: #0a0c14;

    --line: #2b2f42;
    --line-soft: #222639;
    --line-strong: #3c4257;

    --accent: #8a90e0;
    --accent-hover: #a0a6ee;
    --accent-soft: #23264a;
    --accent-softer: #1a1c38;
    --accent-border: #3a3f70;
    --on-accent: #0b0d1c;

    --success: #4cbf95;
    --success-soft: #13301f;
    --warning: #d9a34b;
    --warning-soft: #33270f;
    --danger: #e0796f;
    --danger-soft: #3a1c19;
    --info: #7aa6e6;
    --info-soft: #16243a;

    --focus-ring: #a0a6ee;
    --kind-news: #b39bef;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --bg: #10121c;
  --bg-sunken: #0a0c14;
  --surface: #171a26;
  --surface-raised: #1e2131;
  --surface-muted: #141724;
  --overlay: rgba(4, 5, 12, 0.7);

  --ink: #e9ebf3;
  --ink-2: #b4b9cb;
  --ink-3: #8d93a8;
  --ink-inverse: #0a0c14;

  --line: #2b2f42;
  --line-soft: #222639;
  --line-strong: #3c4257;

  --accent: #8a90e0;
  --accent-hover: #a0a6ee;
  --accent-soft: #23264a;
  --accent-softer: #1a1c38;
  --accent-border: #3a3f70;
  --on-accent: #0b0d1c;

  --success: #4cbf95;
  --success-soft: #13301f;
  --warning: #d9a34b;
  --warning-soft: #33270f;
  --danger: #e0796f;
  --danger-soft: #3a1c19;
  --info: #7aa6e6;
  --info-soft: #16243a;

  --focus-ring: #a0a6ee;
  --kind-news: #b39bef;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.55);
}
