/* ══════════════════════════════════════════════════════════════════
   设计系统 · 外壳层
   token 定义 + 全局重置 + 导航 + 双主题覆盖
   组件样式见 components.css
   主题意象：暖白纸感 · 墨青点缀 / 石墨墨黑 · 薄荷青点缀
   低饱和暖中性打底，全局只用一个墨青作为交互强调色
   ══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  color-scheme: light;
  /* 品牌衬线：仅用于标题/品牌/大数字，正文保持无衬线保证可读 */
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Georgia", "STZhongsong", "SimSun", serif;
  --font-body: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;

  /* 色板 · 日间（暖白纸感 + 墨青强调） */
  --bg-base:      #faf9f6;
  --bg-surface:   #ffffff;
  --bg-hover:     #f3f1ec;
  --bg-sunken:    #e7e3da;
  --border:       #e3dfd6;
  --border-strong:#cfc9bc;
  --accent:       #0f766e;         /* 墨青，唯一交互强调色 */
  --accent-hover: #115e59;
  --accent-soft:  #e6f4f1;
  --on-accent:    #ffffff;         /* 强调色上的文字 */
  --on-danger:    #ffffff;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --danger-solid: #dc2626;         /* 危险实底按钮，保证白字可读 */
  /* 旧变量统一收敛到墨青，保持单强调色 */
  --honey:        var(--accent);
  --honey-soft:   var(--accent-soft);
  --sage:         var(--accent);
  --sage-soft:    var(--accent-soft);
  --text-primary: #1c1917;
  --text-muted:   #57534e;
  --text-faint:   #78716c;
  /* 顶栏：近黑底 + 暖白字，明暗两套都稳定成一条品牌横条 */
  --bg-nav:       #1c1917;
  --nav-text:     #faf9f6;
  --nav-muted:    #a8a29a;
  --nav-accent:   #5eead4;
  --nav-hover-bg: rgba(255,255,255,.08);
  --nav-border:   rgba(255,255,255,.14);
  --bg-input:     #f3f1ec;
  --placeholder:  #78716c;
  --shadow-sm:    0 1px 2px rgba(28,25,23,.05), 0 1px 6px rgba(28,25,23,.04);
  --shadow-md:    0 2px 6px rgba(28,25,23,.06), 0 10px 28px rgba(28,25,23,.09);
  --shadow-lg:    0 6px 16px rgba(28,25,23,.10), 0 22px 48px rgba(28,25,23,.13);
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    16px;

  /* 间距刻度 */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;

  /* 字号刻度 */
  --fs-xs:   .75rem;
  --fs-sm:   .84rem;
  --fs-base: .95rem;
  --fs-lg:   1.08rem;
  --fs-xl:   1.3rem;
  --fs-2xl:  1.75rem;

  /* 动效 */
  --ease:      cubic-bezier(.4,0,.2,1);
  --ease-out:  cubic-bezier(.16,.84,.44,1);
  --dur-fast:  .15s;
  --dur:       .25s;

  /* 层级 */
  --z-nav:    100;
  --z-modal:  1050;
  --z-toast:  1100;

  /* 旅行途经点语义色（地图底图始终为浅色，两套主题共用） */
  --spot-start: #0f766e;
  --spot-food:  #b45309;
  --spot-hotel: #475569;
  --spot-sight: #4d7c0f;
  --spot-way:   #78716c;
  --spot-end:   #b91c1c;
}

*, *::before, *::after { box-sizing: border-box; }

/* 预留滚动条空间，避免页面在“可滚动 / 不可滚动”之间切换时整体左右跳动 */
html { scrollbar-gutter: stable; }

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* SVG 图标（配合 icons.svg sprite） */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Navbar（近黑实底、暖白字、衬线品牌字） ── */
.app-nav {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--nav-border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  gap: 0.5rem;
}
.app-nav .brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--nav-text);
  text-decoration: none;
  margin-right: 1.75rem;
  white-space: nowrap;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.app-nav .brand .icon { font-size: 1.25rem; color: var(--nav-accent); }
.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
.nav-links .nav-link {
  color: var(--nav-muted);
  text-decoration: none;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  position: relative;
  transition: color 0.2s, background 0.2s;
}
.nav-links .nav-link:hover {
  color: var(--nav-accent);
  background: var(--nav-hover-bg);
}
.nav-links .nav-link.active {
  color: var(--nav-accent);
  font-weight: 600;
}
.nav-links .nav-link.active::after {
  content: '';
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--nav-accent);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}
.nav-username {
  color: var(--nav-muted);
  font-size: 0.85rem;
}
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--nav-border);
  color: var(--nav-muted);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.05rem;
}
/* 顶栏内的按钮改为深底配色 */
.app-nav .theme-toggle {
  color: var(--nav-muted);
  border-color: var(--nav-border);
}
.app-nav .theme-toggle:hover {
  color: var(--nav-accent);
  background: var(--nav-hover-bg);
  border-color: var(--nav-accent);
}
.app-nav .btn-ghost {
  color: var(--nav-muted);
  border-color: var(--nav-border);
}
.app-nav .btn-ghost:hover {
  color: var(--nav-accent);
  border-color: var(--nav-accent);
  background: var(--nav-hover-bg);
}
@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .app-nav { padding: 0 1rem; }
  .app-nav .brand { margin-right: .75rem; }
  .nav-username { display: none; }
  .nav-right .btn-ghost { white-space: nowrap; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    z-index: calc(var(--z-nav) - 1);
    box-shadow: var(--shadow-md);
  }
  /* 抽屉落在浅色卡面上，链接改回浅底配色 */
  .nav-links .nav-link { color: var(--text-muted); }
  .nav-links .nav-link:hover { color: var(--accent); background: var(--accent-soft); }
  .nav-links .nav-link.active { color: var(--accent); }
  .nav-links .nav-link.active::after { background: var(--accent); }
  .app-nav.open .nav-links { display: flex; }
}

/* ── Theme Toggle Button ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
  color: var(--text-muted);
  transition: color var(--dur), border-color var(--dur), background var(--dur);
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}
/* 浅色模式显示月亮（点击切到夜），黑夜模式显示太阳 */
.theme-toggle .theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-dark { display: inline-block; }

/* ── 进场动效工具（js 添加 .reveal 后逐段浮现） ── */
html.js-ready .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
html.js-ready .reveal.revealed {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html.js-ready .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ══════════════════════════════════════════════════════════════════
   Dark Theme Overrides（石墨墨黑 + 薄荷青点缀）
   ══════════════════════════════════════════════════════════════════ */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-base:      #141311;
  --bg-surface:   #1c1a17;
  --bg-hover:     #23211d;
  --bg-sunken:    #2e2b26;
  --border:       #34312b;
  --border-strong:#4a463e;
  --accent:       #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft:  rgba(45,212,191,.16);
  --on-accent:    #141311;
  --on-danger:    #1c1917;
  --success:      #34d399;
  --warning:      #fbbf24;
  --danger:       #f87171;
  --danger-solid: #f87171;
  --text-primary: #f5f1e8;
  --text-muted:   #a8a29a;
  --text-faint:   #8a857c;
  --bg-nav:       #0b0a08;
  --nav-text:     #f5f1e8;
  --nav-muted:    #a8a29a;
  --nav-accent:   #5eead4;
  --nav-hover-bg: rgba(255,255,255,.06);
  --nav-border:   rgba(255,255,255,.10);
  --bg-input:     #23211d;
  --placeholder:  #8a857c;         /* 5:1 on input background */
  --shadow-sm:    0 1px 2px rgba(0,0,0,.2), 0 1px 6px rgba(0,0,0,.12);
  --shadow-md:    0 2px 6px rgba(0,0,0,.22), 0 10px 28px rgba(0,0,0,.28);
  --shadow-lg:    0 6px 16px rgba(0,0,0,.3), 0 22px 48px rgba(0,0,0,.36);
}

html[data-theme="dark"] body {
  background-color: var(--bg-base);
  color: var(--text-primary);
}
