/* ================================================================
   base.css — 设计系统基础
   变量 · 重置 · 排版 · 工具类
   ------------------------------------------------
   MusicMath AI 去 AI 化视觉重构
   ================================================================ */

/* ================================================================
   0. 字体引入 — 已改为本地自托管
   英文字体：assets/fonts/*.woff2，@font-face 定义在 css/typography.css
   中文：走系统字体栈（苹方 / 华文宋体 / 微软雅黑 / 宋体），不下载完整中文字库
   移除 Google Fonts @import 的原因：它会阻塞首屏渲染，且 6 个家族 21 个字重
   在国内网络与答辩现场容易加载失败，一旦失败全站字体退回默认，等于没设计。
   ================================================================ */

/* ================================================================
   1. CSS 变量 — 设计令牌（Design Tokens）
   ================================================================ */

:root {
    /* ---------- 字体 ---------- */
    --font-serif: 'Times New Roman', Times, 'Songti SC', 'SimSun', serif;
    --font-sans: 'Times New Roman', Times, 'LXGW WenKai', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;
    --font-math: 'STIX Two Math', 'Times New Roman', serif;
    --font-display: 'Times New Roman', Times, 'Songti SC', 'SimSun', serif;
    --font-ui: 'Times New Roman', Times, 'STFangsong', 'FangSong', 'Songti SC', 'SimSun', serif;

    /* ---------- 字号层级 ---------- */
    --fs-h1: clamp(2.5rem, 5vw, 3.5rem);     /* 40-56px */
    --fs-h2: clamp(1.75rem, 3vw, 2.25rem);   /* 28-36px */
    --fs-h3: 1.25rem;                         /* 20px */
    --fs-body: 0.9375rem;                     /* 15px */
    --fs-sm: 0.8125rem;                       /* 13px */
    --fs-xs: 0.75rem;                         /* 12px */

    /* ---------- 行高 ---------- */
    --lh-tight: 1.15;
    --lh-snug: 1.35;
    --lh-normal: 1.65;
    --lh-relaxed: 1.8;

    /* ---------- 间距系统（非均匀，有节奏） ---------- */
    --space-1: 0.25rem;    /* 4px */
    --space-2: 0.5rem;     /* 8px */
    --space-3: 0.75rem;    /* 12px */
    --space-4: 1rem;       /* 16px */
    --space-5: 1.5rem;     /* 24px */
    --space-6: 2rem;       /* 32px */
    --space-8: 3rem;       /* 48px */
    --space-10: 4rem;      /* 64px */
    --space-12: 6rem;      /* 96px */

    /* ---------- 圆角 ---------- */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* ---------- 阴影（克制，无发光） ---------- */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

    /* ---------- 过渡 ---------- */
    --transition-fast: 150ms ease-out;
    --transition-base: 250ms ease-out;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- 浅色模式（默认） ---------- */
:root {
    --bg-primary: #faf8f5;
    --bg-secondary: #f0ede8;
    --bg-tertiary: #f7f5f2;
    --bg-card: #ffffff;
    --bg-hover: #f5f3f0;
    --bg-active: #ebe8e3;

    --border-subtle: #ebe8e3;
    --border-default: #e0dcd5;
    --border-strong: #c9c4bd;

    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-tertiary: #7a7a7a;
    --text-muted: #a0a0a0;
    --text-inverse: #ffffff;

    --accent-primary: #0d9488;
    --accent-primary-hover: #0f766e;
    --accent-primary-active: #115e59;
    --accent-primary-soft: rgba(13, 148, 136, 0.08);

    --accent-amber: #b45309;
    --accent-amber-soft: rgba(180, 83, 9, 0.08);
    --accent-purple: #7c3aed;
    --accent-purple-soft: rgba(124, 58, 237, 0.08);
    --accent-red: #dc2626;
    --accent-red-soft: rgba(220, 38, 38, 0.08);
    --accent-green: #16a34a;
    --accent-green-soft: rgba(22, 163, 74, 0.08);
    --accent-pink: #be185d;
    --accent-pink-soft: rgba(190, 24, 93, 0.08);

    --hero-gradient: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(13, 148, 136, 0.08), transparent 70%);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1);

    /* ---------- 绿洲背景系统（全局网格 + 渐变光斑） ---------- */
    --bg-grid-color: 94, 234, 212;            /* 笛卡尔网格线颜色：浅绿 teal-300（RGB 分量） */
    --bg-grid-opacity: 0.03;                  /* 网格整体透明度：极淡，若隐若现 */
    --bg-grid-size: 72px;                     /* 网格单元格边长 */
    --bg-blob-color-1: rgba(153, 246, 228, 0.6);    /* 光斑 1：薄荷绿（呼应主色调） */
    --bg-blob-color-3: rgba(167, 243, 208, 0.55);   /* 光斑 3：浅薄荷绿 */
    --bg-blob-opacity: 0.3;                   /* 光斑透明度：水彩晕开感 */
    --bg-blob-blur: 80px;                     /* 光斑模糊半径 */
    --bg-parallax-strength: 5px;              /* 鼠标视差基础位移（反向） */
}

/* ---------- 深色模式 ---------- */
[data-theme="dark"] {
    /* 背景：暖柔深灰，避免冷蓝黑，减少明暗切换时的视觉冲击 */
    --bg-primary: #1c1c22;
    --bg-secondary: #26262e;
    --bg-tertiary: #2f2f3a;
    --bg-card: #26262e;
    --bg-hover: #353542;
    --bg-active: #404050;

    /* 边框：更柔和，避免过于锐利的边界感 */
    --border-subtle: #2f2f3a;
    --border-default: #3d3d4d;
    --border-strong: #555568;

    /* 文字：柔和灰白色，降低刺眼感，保持 WCAG AA 对比度 */
    --text-primary: #c8c8d0;
    --text-secondary: #9898a5;
    --text-tertiary: #707080;
    --text-muted: #555565;
    --text-inverse: #1c1c22;

    /* 强调色：稍微调暗，深色模式下不刺眼 */
    --accent-primary: #18b5a4;
    --accent-primary-hover: #0d9488;
    --accent-primary-active: #0f766e;
    --accent-primary-soft: rgba(24, 181, 164, 0.12);

    --accent-amber: #c9921e;
    --accent-amber-soft: rgba(201, 146, 30, 0.12);
    --accent-purple: #9568e0;
    --accent-purple-soft: rgba(149, 104, 224, 0.12);
    --accent-red: #e84942;
    --accent-red-soft: rgba(232, 73, 66, 0.12);
    --accent-green: #3aa848;
    --accent-green-soft: rgba(58, 168, 72, 0.12);
    --accent-pink: #c95895;
    --accent-pink-soft: rgba(201, 88, 149, 0.12);

    /* 绿洲背景系统（深色适配：光斑更含蓄、网格更淡，避免喧宾夺主） */
    --bg-grid-color: 94, 234, 212;
    --bg-grid-opacity: 0.025;
    --bg-grid-size: 72px;
    --bg-blob-color-1: rgba(45, 212, 191, 0.32);
    --bg-blob-color-3: rgba(110, 231, 183, 0.24);
    --bg-blob-opacity: 0.22;
    --bg-blob-blur: 80px;
    --bg-parallax-strength: 5px;

    /* Hero 背景渐变（全站唯一一处渐变） */
    --hero-gradient: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(24, 181, 164, 0.12), transparent 70%);
}

/* ================================================================
   2. 基础重置
   ================================================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    /* 顶部/底部橡皮筋 overscroll 时露出与页面一致的底色，并禁止过度拉动 */
    background-color: var(--bg-primary);
    overscroll-behavior-y: none;
}

html body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.8;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* 正文与 UI 元素：统一无衬线字体 + 舒展行高（中文正文 1.8） */
body, p, div, span, button, input {
    font-family: var(--font-sans);
    line-height: 1.8;
}

/* 主题切换时的平滑过渡 — 覆盖主要 UI 元素的颜色属性 */
h1, h2, h3, h4, h5, h6, p, span, a, li, label,
button, input, textarea, select,
.card, .nav, header, footer, aside, section {
    transition: background-color var(--transition-base),
                color var(--transition-base),
                border-color var(--transition-base),
                fill var(--transition-base),
                stroke var(--transition-base);
}

/* ================================================================
   3. 排版 Typography
   ================================================================ */

/* 标题：衬线字体，建立清晰层级（600 不加粗 · letter-spacing 0.05em 微增高级感） */
h1, h2, h3, h4 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: var(--lh-tight);
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

h1 {
    font-size: var(--fs-h1);
}

h2 {
    font-size: var(--fs-h2);
}

h3 {
    font-size: var(--fs-h3);
}

h4 {
    font-size: 1rem;
}

h5, h6 {
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 600;
    letter-spacing: -0.005em;
}

/* 英文文本优化类 */
.text-en {
    font-family: var(--font-sans);
    letter-spacing: 0.005em;
    -webkit-font-feature-settings: "kern" 1, "liga" 1;
    font-feature-settings: "kern" 1, "liga" 1;
}

.text-en-serif {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

/* 英文术语/缩写优化 */
.term-en {
    font-family: var(--font-sans);
    font-weight: 500;
    letter-spacing: 0.02em;
    font-variant: all-small-caps;
}

/* 正文 */
p {
    line-height: var(--lh-normal);
    color: var(--text-secondary);
}

/* 链接 */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* 数字等宽 */
.font-mono,
.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* 数学公式 */
.math,
.formula {
    font-family: var(--font-math);
}

/* 文字颜色工具类 */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--accent-primary) !important; }
.text-amber { color: var(--accent-amber) !important; }
.text-purple { color: var(--accent-purple) !important; }

/* ================================================================
   4. 工具类
   ================================================================ */

/* 布局 */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

/* 间距 */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

/* 圆角 */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* 容器最大宽度 */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-5);
}

/* 隐藏 */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.opacity-0 { opacity: 0; }

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 选中文字 */
::selection {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
}

/* 焦点样式（无障碍） */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
