/* ============================================================
   base.css —— 设计 token（全站唯一的颜色 / 圆角 / 描边来源）
   风格 B「Playful Brutalism」：纸面底 + 近黑硬描边 + 硬偏移阴影（无模糊）+ 饱和强调色。
   组件层（front.css / admin.css / lightbox.css）一律 var(...)，禁止出现颜色字面量。
   变量名全部保留（只改值）；暗色分支只换值（纸与墨互换），不新增组件规则。
   固化测试：tests/css.test.js。约定：docs/CONVENTIONS.md §14。
   ============================================================ */

:root {
  /* 饱和强调色（紫 / 橙 / 绿）：彩色硬阴影用 */
  --accent-purple: #7c3aed;
  --accent-orange: #ff6a2f;
  --accent-green: #16a34a;
  --accent-red: #d5362a;              /* 错误/危险态专用（历史糖果名指向它） */

  /* 主题色：由 settings.theme_accent 驱动（public/js 把它写成 --accent），默认饱和紫 */
  --accent: var(--accent-purple);
  --accent-soft: var(--wash-purple);  /* 名字保留：历史引用（值收敛为浅色底 token） */

  /* 浅色主题（纸面） */
  --bg: #f4f4f0;
  --bg-card: #ffffff;
  --bg-sticky: #f0efe9;               /* 硬底，不再用渐变 */
  --ink: #15130f;                     /* 近黑 */
  --ink-soft: #5c5850;
  --line: #15130f;                    /* 硬描边色（同时也是硬阴影色） */
  --on-accent: #ffffff;               /* 强调色底上的文字色，暗色主题下仍是浅色 */

  /* 硬偏移阴影（无模糊，4-5px，可用彩色） */
  --shadow: 5px 5px 0 var(--line);
  --shadow-soft: 3px 3px 0 var(--line);
  --shadow-accent: 5px 5px 0 var(--accent-purple);

  /* 形状：卡片圆角 4-8px、胶囊 999px、描边 ≥3px（硬约定） */
  --radius: 6px;
  --radius-sm: 4px;
  --pill: 999px;
  --stroke: 3px;
  --stroke-thick: 4px;

  /* 遮罩与浅色底（灯箱遮罩、flash、空状态） */
  --overlay: rgba(21, 19, 15, 0.88);
  --overlay-soft: rgba(244, 244, 240, 0.66);
  --wash-purple: rgba(124, 58, 237, 0.14);
  --wash-orange: rgba(255, 106, 47, 0.16);
  --wash-green: rgba(22, 163, 74, 0.14);

  /* 历史糖果名：名字保留（组件层引用不改），值统一到新强调色 */
  --candy-red: var(--accent-red);
  --candy-orange: var(--accent-orange);
  --candy-yellow: var(--accent-orange);
  --candy-mint: var(--accent-green);
  --candy-blue: var(--accent-green);
  --candy-purple: var(--accent-purple);
  --candy-pink: var(--accent-orange);
  --candy-grape: var(--accent-purple);

  /* 字体：系统字体栈（不引 CDN、不入库字体文件 —— CSP style-src 'self'）
     拉丁与数字靠 Space Grotesk 类，中文回落系统 CJK 字形 */
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Space Grotesk", ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;

  /* 字号阶梯（名字保留） */
  --fs-xs: 0.8rem;
  --fs-sm: 0.92rem;
  --fs-base: 1.05rem;
  --fs-lg: 1.3rem;
  --fs-xl: 1.7rem;
  --fs-hero: 2.3rem;

  /* 动效（名字保留） */
  --pop: 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --slide: 320ms cubic-bezier(0.22, 1, 0.36, 1);

  /* 布局（名字保留） */
  --maxw: 1000px;
  --gap: 18px;
}

/* 暗色主题（同 token 换皮：纸与墨互换，硬阴影靠 --line 自动成立；不引 JS） */
@media (prefers-color-scheme: dark) {
  :root {
    --accent-soft: var(--wash-purple);
    --bg: #15130f;
    --bg-card: #1d1b17;
    --bg-sticky: #221f1a;
    --ink: #f4f4f0;
    --ink-soft: #a9a49a;
    --line: #f4f4f0;                  /* 硬描边与硬阴影变浅色 */
    --shadow-accent: 5px 5px 0 var(--accent-purple);
    --wash-purple: rgba(167, 120, 245, 0.18);
    --wash-orange: rgba(255, 138, 79, 0.18);
    --wash-green: rgba(45, 190, 110, 0.16);
    --overlay: rgba(12, 11, 9, 0.9);
    --overlay-soft: rgba(244, 244, 240, 0.62);
  }
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.3;
  margin: 0 0 0.5em;
}
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 0.9em; }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }

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

code {
  background: var(--bg-sticky);
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  font-size: var(--fs-sm);
}

strong { color: var(--accent); }

/* ---------- 通用卡片（硬描边 + 硬偏移阴影） ---------- */
.card {
  background: var(--bg-card);
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.tag {
  display: inline-block;
  background: var(--bg-sticky);
  border: var(--stroke) solid var(--line);
  border-radius: var(--pill);
  padding: 2px 10px;
  font-size: var(--fs-xs);
  margin: 0 6px 6px 0;
}

.badge {
  display: inline-block;
  border: var(--stroke) solid var(--line);
  border-radius: var(--pill);
  padding: 2px 10px;
  font-size: var(--fs-xs);
  background: var(--accent-soft);
  font-weight: 700;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  border: var(--stroke) solid var(--line);
  border-radius: var(--pill);
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform var(--pop), box-shadow var(--pop);
}

.btn:hover { transform: translateY(-2px); color: var(--on-accent); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); box-shadow: 1px 1px 0 var(--line); color: var(--on-accent); }

.btn-ghost { background: var(--bg-sticky); color: var(--ink); }
.btn-danger { background: var(--accent-orange); }
.btn-mint { background: var(--accent-green); color: var(--on-accent); }

/* ---------- 表单 ---------- */
input[type="text"], input[type="password"], input[type="number"], input[type="email"], textarea, select {
  width: 100%;
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sticky);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

textarea { min-height: 160px; resize: vertical; }

label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  margin-bottom: 6px;
  font-weight: 700;
}

.field { margin-bottom: 14px; }

/* ---------- flash ---------- */
.flash {
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-soft);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.flash-ok { background: var(--accent-soft); }
.flash-warn { background: var(--wash-orange); }
.flash-oops { background: var(--wash-green); }

/* ---------- 空状态 ---------- */
.empty-state {
  border: var(--stroke) dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 26px;
  text-align: center;
}

.empty-emoji { font-size: 2rem; display: block; margin-bottom: 8px; }
.empty-text { margin: 0 0 12px; color: var(--ink-soft); }

/* ---------- 入场动画（增强项，无 JS 时不影响阅读） ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--slide), transform var(--slide);
}

.reveal.is-in { opacity: 1; transform: none; }

/* 降级：尊重系统"减少动态效果" */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 焦点可见（键盘友好） ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: var(--stroke) solid var(--accent);
  outline-offset: 2px;
}
