/* ==========================================================================
   Editorial Minimal — Design System (shared base)
   Web Design skill · /root/.codex/skills/web-design
   --------------------------------------------------------------------------
   本站统一视觉底座。所有改版页面 <link> 本文件后，可直接复用其中 tokens
   与组件类。设计即“组合 tokens”，不要用魔法数字覆盖它。
   参考：references/design-tokens.md（完整 token 说明）。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens — 暖中性 + 单一赤陶点缀，无蓝紫、无渐变
   -------------------------------------------------------------------------- */
:root {
  /* Color — warm neutrals + single accent. No blue/violet, no gradients. */
  --bg:         #FAFAF7;  /* 页面画布，暖白 */
  --surface:    #F3F1EA;  /* 卡片 / 面板 / 内嵌区 */
  --ink:        #1A1A1A;  /* 主文字，绝不 #000 */
  --muted:      #6B6B66;  /* 次要文字 */
  --rule:       #E4E1D8;  /* 发丝线边框 */
  --rule-strong:#C9C4B6;  /* 发丝线，深一阶（hover） */
  --accent:     #B5532A;  /* 赤陶 —— 唯一点缀色 */
  --accent-hover:#9A4623; /* 赤陶，深一阶 */
  --accent-ink: #7A3A1E;  /* 赤陶作浅底文字（AA 安全校正） */

  /* Status —— 土色、去饱和，绝不作主色 */
  --positive:   #4F7A52;  /* 鼠尾草绿 */
  --caution:    #8A5E1A;  /* 深琥珀（文字 AA 安全，5.4:1） */
  --critical:   #9B3D2F;  /* 牛血红 */

  /* Type */
  --font-display: "Fraunces", "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono:    ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;

  /* Fluid modular scale（1.250 大三度），随视口 clamp */
  --step--1: clamp(0.79rem, 0.76rem + 0.15vw, 0.83rem);  /* 12.6 → 说明文字 */
  --step-0:  clamp(1.00rem, 0.96rem + 0.22vw, 1.06rem);  /* 17   → 正文    */
  --step-1:  clamp(1.25rem, 1.19rem + 0.31vw, 1.33rem);
  --step-2:  clamp(1.56rem, 1.47rem + 0.46vw, 1.66rem);
  --step-3:  clamp(1.95rem, 1.82rem + 0.67vw, 2.08rem);  /* h2   */
  --step-4:  clamp(2.44rem, 2.25rem + 0.95vw, 2.61rem);  /* h1   */
  --step-5:  clamp(3.05rem, 2.78rem + 1.34vw, 3.27rem);  /* hero 大标题 */

  /* Spacing —— 4px 基础节奏 */
  --space-3xs: 2px;  --space-2xs: 4px;  --space-xs: 8px;
  --space-s:  12px;  --space-m:  16px;  --space-l:  24px;
  --space-xl: 32px;  --space-2xl:48px;  --space-3xl:64px;
  --space-4xl:96px;  --space-5xl:128px;

  /* Radius —— 小而利落 */
  --radius-xs: 2px;  --radius-sm: 4px;  --radius-md: 8px;

  /* Shadow —— 克制，仅用于真正浮起的表面 */
  --shadow-sm: 0 1px 2px rgba(26,26,26,.04);
  --shadow-md: 0 6px 20px rgba(26,26,26,.07);

  /* Motion —— 舒适、ease-out、短促 */
  --ease:        cubic-bezier(.2,.7,.2,1);
  --ease-in-out: cubic-bezier(.4,0,.2,1);
  --dur-1: 120ms;  --dur-2: 200ms;  --dur-3: 320ms;

  /* Layout */
  --measure: 66ch;    /* 阅读舒适的最大行宽 */
  --gutter:  24px;    /* 页面两侧留白，大屏加宽 */
  --container: 1200px;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
.editorial-scope, .editorial-scope * { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.editorial-scope { min-height: 100vh; line-height: 1.6;
       -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.editorial-scope img, .editorial-scope svg { display: block; max-width: 100%; height: auto; }
.editorial-scope input, .editorial-scope button,
.editorial-scope textarea, .editorial-scope select { font: inherit; color: inherit; }
.editorial-scope button { background: none; border: none; cursor: pointer; }
.editorial-scope p, .editorial-scope h1, .editorial-scope h2,
.editorial-scope h3, .editorial-scope h4 { overflow-wrap: break-word; }
.editorial-scope :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: inherit;
}

/* --------------------------------------------------------------------------
   3. Base typography & elements（仅 .editorial-scope 作用域，避免污染旧页）
   -------------------------------------------------------------------------- */
.editorial-scope {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: var(--bg);
}

.editorial-scope h1, .editorial-scope h2, .editorial-scope h3, .editorial-scope h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.editorial-scope h1 { font-size: var(--step-4); letter-spacing: -0.02em; }
.editorial-scope h2 { font-size: var(--step-3); }
.editorial-scope h3 { font-size: var(--step-2); }
.editorial-scope h4 { font-size: var(--step-1); }
.editorial-scope h1, .editorial-scope h2, .editorial-scope h3, .editorial-scope h4 { margin-bottom: var(--space-xs); }

.editorial-scope p { max-width: var(--measure); }
.editorial-scope p + p { margin-top: var(--space-m); }

.editorial-scope a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--dur-1) var(--ease);
}
.editorial-scope a:hover { color: var(--ink); }

.editorial-scope strong { font-weight: 600; color: var(--ink); }
.editorial-scope small { font-size: var(--step--1); }

.editorial-scope hr { border: none; border-top: 1px solid var(--rule); margin: var(--space-2xl) 0; }

.editorial-scope code, .editorial-scope kbd, .editorial-scope samp {
  font-family: var(--font-mono); font-size: 0.92em;
  background: var(--surface); padding: 2px var(--space-2xs);
  border-radius: var(--radius-xs);
}
.editorial-scope pre {
  font-family: var(--font-mono); font-size: var(--step--1);
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); padding: var(--space-l);
  overflow-x: auto; line-height: 1.5;
}
.editorial-scope pre code { background: none; padding: 0; font-size: inherit; }

.editorial-scope img { border-radius: var(--radius-md); }

/* --------------------------------------------------------------------------
   4. Components —— 均以 .editorial-scope 为前缀，避免与旧样式冲突
   -------------------------------------------------------------------------- */

/* Buttons */
.editorial-scope .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  font-family: var(--font-sans); font-size: var(--step-0); font-weight: 500;
  line-height: 1; padding: 0 var(--space-l); min-height: 44px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease);
}
.editorial-scope .btn-primary { background: var(--accent); color: var(--bg); }
.editorial-scope .btn-primary:hover { background: var(--accent-hover); color: var(--bg); }
.editorial-scope .btn-secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
.editorial-scope .btn-secondary:hover { border-color: var(--ink); }
.editorial-scope .btn-ghost { background: transparent; color: var(--ink); padding-inline: var(--space-m); }
.editorial-scope .btn-ghost:hover { background: var(--surface); }
.editorial-scope .btn-danger { background: var(--critical); color: var(--bg); }
.editorial-scope .btn-danger:hover { filter: brightness(0.92); }
.editorial-scope .btn:active { transform: translateY(1px); }
.editorial-scope .btn:disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }
.editorial-scope .btn-block { width: 100%; }

/* Form fields */
.editorial-scope .field { display: grid; gap: var(--space-2xs); max-width: var(--measure); }
.editorial-scope .field-label { font-size: var(--step--1); font-weight: 500; color: var(--ink); }
.editorial-scope .field input, .editorial-scope .field select, .editorial-scope .field textarea {
  font-family: var(--font-sans); color: var(--ink);
  padding: var(--space-s) var(--space-m); min-height: 44px;
  background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.editorial-scope .field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.editorial-scope .field input::placeholder, .editorial-scope .field textarea::placeholder { color: var(--muted); }
.editorial-scope .field input:hover, .editorial-scope .field select:hover, .editorial-scope .field textarea:hover { border-color: var(--rule-strong); }
.editorial-scope .field input:focus-visible, .editorial-scope .field select:focus-visible, .editorial-scope .field textarea:focus-visible {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
.editorial-scope input[type="checkbox"], .editorial-scope input[type="radio"] { accent-color: var(--accent); width: 1.15em; height: 1.15em; }

/* Cards */
.editorial-scope .card { padding: var(--space-l); background: var(--bg);
        border: 1px solid var(--rule); border-radius: var(--radius-md); }
.editorial-scope .card--surface { background: var(--surface); }
.editorial-scope .card.is-link { cursor: pointer; transition: border-color var(--dur-1) var(--ease); }
.editorial-scope .card.is-link:hover { border-color: var(--ink); }

/* Badges / tags / chips */
.editorial-scope .badge { display: inline-block; font-size: var(--step--1); font-weight: 500;
         color: var(--muted); border: 1px solid var(--rule);
         border-radius: var(--radius-xs); padding: 2px var(--space-2xs); white-space: nowrap; }
.editorial-scope .badge-positive { color: var(--positive); border-color: color-mix(in srgb, var(--positive) 40%, var(--rule)); }
.editorial-scope .badge-caution  { color: var(--caution);  border-color: color-mix(in srgb, var(--caution) 40%, var(--rule)); }
.editorial-scope .badge-critical { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, var(--rule)); }
.editorial-scope .chip { display: inline-flex; align-items: center; gap: var(--space-2xs);
        font-size: var(--step--1); padding: var(--space-2xs) var(--space-xs);
        background: var(--surface); border-radius: var(--radius-sm); }

/* Callouts */
.editorial-scope .callout { padding: var(--space-m) var(--space-l); border-radius: var(--radius-sm);
        background: var(--surface); border-left: 3px solid var(--rule);
        max-width: var(--measure); }
.editorial-scope .callout p { margin: 0; max-width: none; }
.editorial-scope .callout-caution  { border-left-color: var(--caution); }
.editorial-scope .callout-critical { border-left-color: var(--critical); }
.editorial-scope .callout-positive { border-left-color: var(--positive); }

/* Navigation */
.editorial-scope .nav { position: sticky; top: 0; z-index: 10;
       display: flex; align-items: center; gap: var(--space-l);
       min-height: 56px; padding: var(--space-s) var(--gutter);
       background: var(--bg); border-bottom: 1px solid var(--rule); }
.editorial-scope .nav-brand { font-family: var(--font-display); font-size: var(--step-1);
             font-weight: 600; color: var(--ink); text-decoration: none; }
.editorial-scope .nav-brand:hover { color: var(--ink); }
.editorial-scope .nav-links { display: flex; gap: var(--space-l); margin-inline-start: auto; }
.editorial-scope .nav-links a { color: var(--ink); text-decoration: none; font-size: var(--step--1);
               padding: var(--space-xs) 0; position: relative;
               transition: color var(--dur-1) var(--ease); }
.editorial-scope .nav-links a:hover { color: var(--accent-ink); }
.editorial-scope .nav-links a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 2px;
  height: 1.5px; background: var(--accent);
}

/* Tables */
.editorial-scope .table-wrap { overflow-x: auto; }
.editorial-scope .table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.editorial-scope .table th, .editorial-scope .table td { text-align: left; padding: var(--space-s) var(--space-m);
                       border-bottom: 1px solid var(--rule); }
.editorial-scope .table th { font-weight: 500; color: var(--muted); background: var(--surface);
            white-space: nowrap; }
.editorial-scope .table td { color: var(--ink); font-variant-numeric: tabular-nums; }
.editorial-scope .table tbody tr { transition: background-color var(--dur-1) var(--ease); }
.editorial-scope .table tbody tr:hover { background: var(--surface); }

/* --------------------------------------------------------------------------
   5. Utilities
   -------------------------------------------------------------------------- */
.editorial-scope .container { width: 100%; max-width: var(--container);
             margin-inline: auto; padding-inline: var(--gutter); }
.editorial-scope .measure { max-width: var(--measure); }
.editorial-scope .section { padding-block: var(--space-4xl); }
.editorial-scope .section-sm { padding-block: var(--space-2xl); }
.editorial-scope .stack > * + * { margin-top: var(--space-m); }
.editorial-scope .stack-lg > * + * { margin-top: var(--space-l); }
.editorial-scope .cluster { display: flex; flex-wrap: wrap; gap: var(--space-s); align-items: center; }
.editorial-scope .cluster-between { justify-content: space-between; }
.editorial-scope .grid { display: grid; gap: var(--space-xl); }
.editorial-scope .grid-2 { grid-template-columns: repeat(2, 1fr); }
.editorial-scope .grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .editorial-scope .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .editorial-scope .grid-2 { grid-template-columns: 1fr; } }
.editorial-scope .eyebrow { font-size: var(--step--1); letter-spacing: .08em; text-transform: uppercase;
           color: var(--muted); font-weight: 500; }
.editorial-scope .muted { color: var(--muted); }
.editorial-scope .text-center { text-align: center; }
.editorial-scope .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; }

/* 等级徽章通用底（替代原全色谱渐变分级） */
.editorial-scope .level-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--step--1); font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-xs);
  color: var(--muted); border: 1px solid var(--rule);
  background: var(--bg); white-space: nowrap;
}
.editorial-scope .level-pill.is-accent { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); }
.editorial-scope .level-pill.is-max { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* 进度条（替代原多色渐变） */
.editorial-scope .bar { height: 6px; border-radius: var(--radius-xs); background: var(--surface);
       border: 1px solid var(--rule); overflow: hidden; }
.editorial-scope .bar-fill { height: 100%; background: var(--accent);
       transition: width var(--dur-3) var(--ease); }

/* --------------------------------------------------------------------------
   6. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .editorial-scope *, .editorial-scope *::before, .editorial-scope *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
