/* base.css — 变量 / reset / 排版
 * fushu.net 复数工具站 v1.0.0
 * 全站零外部依赖，字体走系统栈。 */

/* ---------- 设计令牌 ---------- */
:root {
  /* 主题轴：浅色为默认，[data-theme="dark"] 覆盖 */
  --bg: #FBFAF7;
  --bg-sunken: #F2F0EA;
  --bg-raised: #FFFFFF;
  --bg-overlay: rgba(251, 250, 247, 0.92);

  --ink: #1C1B19;
  --ink-soft: #4A4844;
  --ink-mute: #78756E;
  --ink-faint: #9A978F;

  --line: #E0DDD4;
  --line-strong: #C9C5B9;

  /* 复数语义色：实部 / 虚部 / 结果 */
  --re: #1F5C99;      /* 实轴：墨蓝 */
  --re-soft: #E7EFF7;
  --im: #B4531F;      /* 虚轴：赭石 */
  --im-soft: #F9EDE4;
  --res: #0F7A63;     /* 结果：青绿 */
  --res-soft: #E4F2EE;
  --warn: #A32D2D;
  --warn-soft: #FBECEC;

  /* 网格 */
  --grid-minor: rgba(28, 27, 25, 0.06);
  --grid-major: rgba(28, 27, 25, 0.16);
  --axis: rgba(28, 27, 25, 0.55);

  /* 交互态 */
  --accent: var(--re);
  --accent-ink: #FFFFFF;
  --focus: #1F5C99;
  --shadow-sm: 0 1px 2px rgba(28, 27, 25, 0.06);
  --shadow-md: 0 4px 16px rgba(28, 27, 25, 0.08);

  /* 尺寸 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --gap: 16px;
  --gap-lg: 28px;
  --shell: 1180px;
  --nav-h: 60px;

  /* 字体栈：无外链 */
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
          "Source Han Sans SC", "Noto Sans CJK SC", system-ui, -apple-system,
          "Segoe UI", Roboto, sans-serif;
  --serif: "Songti SC", "SimSun", "Source Han Serif SC", "Noto Serif CJK SC",
           Georgia, "Times New Roman", serif;
  --math: "Cambria Math", "Latin Modern Math", Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono",
          Menlo, monospace;

  /* 字号阶 */
  --fs-display: clamp(2.2rem, 6vw, 3.6rem);
  --fs-h1: clamp(1.5rem, 3.4vw, 2rem);
  --fs-h2: 1.25rem;
  --fs-h3: 1.05rem;
  --fs-body: 0.9375rem;
  --fs-small: 0.8125rem;
  --fs-tiny: 0.75rem;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 200ms;
}

[data-theme="dark"] {
  --bg: #14161A;
  --bg-sunken: #0F1115;
  --bg-raised: #1C1F25;
  --bg-overlay: rgba(20, 22, 26, 0.92);

  --ink: #ECEAE4;
  --ink-soft: #C3C0B9;
  --ink-mute: #908D86;
  --ink-faint: #6B6963;

  --line: #2B2F37;
  --line-strong: #3D424C;

  --re: #6FAEE8;
  --re-soft: #16242F;
  --im: #E39A63;
  --im-soft: #2C211A;
  --res: #5FC9AB;
  --res-soft: #14261F;
  --warn: #EE8B8B;
  --warn-soft: #2E1C1C;

  --grid-minor: rgba(236, 234, 228, 0.07);
  --grid-major: rgba(236, 234, 228, 0.18);
  --axis: rgba(236, 234, 228, 0.55);

  --accent: var(--re);
  --accent-ink: #101318;
  --focus: #6FAEE8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.7;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { text-decoration: underline; }

img, svg, canvas { max-width: 100%; display: block; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--gap-lg) 0;
}

/* ---------- 可访问性 ---------- */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.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;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--bg-raised);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* ---------- 排版工具类 ---------- */
.math {
  font-family: var(--math);
  font-style: italic;
  font-size: 1.06em;
  letter-spacing: 0.01em;
}
.math-up { font-style: normal; }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.94em;
}

.lead {
  font-size: 1.0625rem;
  color: var(--ink-soft);
  line-height: 1.75;
}

.muted { color: var(--ink-mute); }
.faint { color: var(--ink-faint); }
.small { font-size: var(--fs-small); }
.tiny  { font-size: var(--fs-tiny); }

.tint-re  { color: var(--re); }
.tint-im  { color: var(--im); }
.tint-res { color: var(--res); }

.nowrap { white-space: nowrap; }

/* ---------- 选区 ---------- */
::selection {
  background: var(--res-soft);
  color: var(--res);
}
