/* =====================================================================
   基础：重置、排版、纸面、玻璃工具类
   ===================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + var(--sp-4));
}

body {
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  color: var(--text);
  background-color: var(--bg);
  /* 纸面：左上暖光、右下微冷，中间留白。三层极淡渐变，不抢内容。 */
  background-image:
    radial-gradient(120% 80% at 50% -20%, #FFFDF8 0%, rgba(255, 253, 248, 0) 58%),
    radial-gradient(80% 60% at 100% 0%, rgba(214, 196, 166, .28) 0%, rgba(214, 196, 166, 0) 60%),
    radial-gradient(70% 70% at 0% 100%, rgba(196, 178, 148, .18) 0%, rgba(196, 178, 148, 0) 60%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: lining-nums;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-slow) var(--ease-out),
              color var(--dur-slow) var(--ease-out);
}

:root[data-theme='dark'] body {
  background-image:
    radial-gradient(120% 80% at 50% -20%, #221D16 0%, rgba(34, 29, 22, 0) 60%),
    radial-gradient(80% 60% at 100% 0%, rgba(120, 90, 50, .10) 0%, rgba(120, 90, 50, 0) 60%),
    radial-gradient(70% 70% at 0% 100%, rgba(60, 70, 90, .10) 0%, rgba(60, 70, 90, 0) 60%);
}

/* ---------- 纸纹 ---------- */
.atmos { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.atmos::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='1'/></svg>");
  opacity: var(--paper-noise);
  mix-blend-mode: multiply;
}

:root[data-theme='dark'] .atmos::before { mix-blend-mode: screen; }

.atmos::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: var(--glow);
  background:
    radial-gradient(58% 44% at 76% -6%, rgba(217, 179, 106, .10), transparent 70%),
    radial-gradient(46% 40% at 10% 2%,  rgba(143, 176, 201, .10), transparent 72%);
  transition: opacity var(--dur-slow) var(--ease-out);
}

/* ---------- 排版 ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--text);
}

h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }

.deva {
  font-family: var(--font-deva);
  line-height: var(--lh-deva);
  letter-spacing: 0;
}

.num, .en {
  font-family: var(--font-en);
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: 'tnum' 1;
  letter-spacing: .01em;
}

.zh-serif { font-family: var(--font-zh); }
code, .mono { font-family: var(--font-mono); font-size: .92em; }

/* 小字距标签：每个区块上方那一行「今日 · TODAY」 */
.eyebrow {
  font-family: var(--font-ui);
  font-size: var(--t-meta);
  font-weight: 600;
  letter-spacing: var(--track-meta);
  text-transform: uppercase;
  color: var(--text-3);
}

.iast {
  font-family: var(--font-en);
  font-style: italic;
  color: var(--text-2);
  letter-spacing: .01em;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

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

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- 工具类 ---------- */
.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;
}

.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.wrap    { flex-wrap: wrap; }
.grow    { flex: 1; min-width: 0; }
.center  { justify-content: center; }
.between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.muted   { color: var(--text-2); }
.faint   { color: var(--text-3); }
.tiny    { font-size: var(--t-small); }
.small   { font-size: var(--t-small); }
.bold    { font-weight: 600; }
.tc      { text-align: center; }
.hide    { display: none !important; }

/* ---------- 材质工具类 ---------- */

/* 玻璃：只给悬浮在页面之上的层 */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
}

/* 刻线：只留给页面标题与复习卡 */
.hair     { border-top: 1px solid var(--line); }
.hair-ink { border-top: 1.5px solid var(--rule-ink); }

/* ---------- 首屏 / 致命提示 ---------- */
.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  text-align: center;
}

.boot-card {
  max-width: 520px;
  padding: var(--sp-7);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--inner-light), var(--shadow-lg);
}

.boot-card h1 { font-size: 22px; margin-bottom: var(--sp-3); }
.boot-card p  { color: var(--text-2); margin-bottom: var(--sp-3); }
.boot-card code {
  display: block;
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  text-align: left;
  user-select: all;
}

/* ---------- 动效开关 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

html[data-motion='reduced'] *,
html[data-motion='reduced'] *::before,
html[data-motion='reduced'] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
