/* ============================================================
   WAVE Archive — Shared Design Tokens & Base Reset
   All pages import this file; page-specific overrides stay inline.
   ============================================================ */

/* ---- Light-mode tokens ---- */
:root {
  /* Page backgrounds */
  --bg-page: #f4f0e6;
  --bg-page-soft: #f7f4ee;

  /* Surfaces */
  --surface-card: rgba(250, 248, 242, 0.72);
  --surface-card-strong: rgba(250, 248, 242, 0.88);
  --surface-input: rgba(247, 244, 238, 0.9);

  /* Borders */
  --border-soft: rgba(37, 47, 41, 0.10);
  --border-medium: rgba(37, 47, 41, 0.16);

  /* Buttons */
  --button-primary: #204f4a;
  --button-primary-hover: #173633;
  --button-primary-border: rgba(32, 79, 74, 0.18);
  --button-primary-text: #fff;

  /* Navigation */
  --nav-slogan: #94a3b8;

  /* Semantic aliases (used across pages) */
  --bg: var(--bg-page);
  --bg-2: var(--bg-page-soft);
  --panel: var(--surface-card);
  --panel-strong: var(--surface-card-strong);
  --line: var(--border-medium);
  --line-strong: #c6dbd5;
  --text: #171714;
  --ink: #171714;
  --muted: #6a675f;
  --brand: #204f4a;
  --accent: #204f4a;
  --accent-2: #173633;
  --gold: #c27c2c;
  --amber: #c27c2c;
  --danger: #b2432f;
  --shadow: 0 18px 50px rgba(33, 28, 18, 0.08);

  /* Dark-mode page background (used by JS) */
  --bg-page-dark: #121612;
}

/* ---- Dark-mode tokens ---- */
html[data-theme="dark"] {
  --theme-bg: var(--bg-page-dark);
  --theme-bg-2: #191a16;
  --theme-panel: rgba(255,253,248,.075);
  --theme-panel-strong: rgba(255,253,248,.105);
  --theme-line: rgba(174,160,128,.24);
  --theme-line-strong: rgba(209,189,137,.36);
  --theme-text: #eee9dd;
  --theme-muted: #bbb2a1;
  --theme-brand: #83b8aa;
  --theme-brand-strong: #b7d8ce;
  --theme-brand-soft: rgba(131,184,170,.13);
  --theme-gold: #d1bd89;
  --theme-gold-hover: #e6d29c;
  --theme-danger: #e88f99;
  --theme-shadow: 0 30px 80px rgba(0,0,0,.26);
}

/* ---- Base reset ---- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  letter-spacing: 0.1px;
}
a { color: inherit; }

/* ---- Dark-mode base overrides ---- */
html[data-theme="dark"] body {
  color: var(--theme-text);
  background: var(--bg-page-dark);
}

html[data-theme="dark"] .top,
html[data-theme="dark"] .appbar {
  border-bottom-color: var(--theme-line);
  background: rgba(20,22,18,.78);
  box-shadow: none;
}

html[data-theme="dark"] .brand,
html[data-theme="dark"] .brand-type,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3 {
  color: var(--theme-text);
}

html[data-theme="dark"] .brand-mark {
  background: #5d9185;
  color: #08100d;
}

html[data-theme="dark"] .brand-divider {
  border-color: rgba(174,160,128,.3);
}

html[data-theme="dark"] .brand-slogan,
html[data-theme="dark"] .lead,
html[data-theme="dark"] .section-head p,
html[data-theme="dark"] p,
html[data-theme="dark"] .hint {
  color: var(--theme-muted);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  border-color: var(--theme-line);
  background: rgba(255,253,248,.07);
  color: var(--theme-text);
}

/* ---- Shared theme toggle widget ---- */
.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid #d8d1c3;
  border-radius: 999px;
  background: var(--surface-card);
}
.theme-switch button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 6px 9px;
  background: transparent;
  color: #6a675f;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.theme-switch button.active {
  background: #204f4a;
  color: #fff;
}
.theme-switch .theme-toggle {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-card-strong) 86%, transparent);
  color: var(--brand, var(--accent, #204f4a));
}
.theme-switch .theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html[data-theme="dark"] .theme-switch {
  border-color: var(--theme-line);
  background: var(--theme-panel);
}
html[data-theme="dark"] .theme-switch button {
  color: var(--theme-muted);
}
html[data-theme="dark"] .theme-switch button.active {
  background: var(--theme-brand);
  color: #121612;
}
html[data-theme="dark"] .theme-switch .theme-toggle {
  background: var(--theme-panel-strong);
  color: var(--theme-brand);
}

/* ---- Shared navigation pills ---- */
.nav { display: flex; align-items: center; justify-content: center; gap: 10px; }
.nav a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  background: var(--surface-card);
  transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}
.nav a.active, .nav a:hover {
  color: var(--accent);
  border-color: rgba(32,79,74,.18);
  background: rgba(32,79,74,.08);
}

html[data-theme="dark"] .nav a {
  border-color: var(--theme-line);
  color: var(--theme-muted);
  background: var(--theme-panel);
}
html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .nav a:hover {
  color: var(--theme-brand);
  border-color: rgba(131,184,170,.25);
  background: var(--theme-brand-soft);
}
