/* ============================================================
   YuuToolbox · base.css
   主题变量 / 重置 / 布局骨架
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --font-sans: "Inter", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --sidebar-w: 264px;
  --topbar-h: 58px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
  --bg: #0e1117;
  --bg-soft: #141922;
  --bg-elev: #1a2130;
  --bg-input: #10151e;
  --bg-hover: #202a3b;

  --border: #232c3d;
  --border-strong: #33405a;

  --text: #e6ebf4;
  --text-dim: #9aa7bd;
  --text-mute: #64708a;

  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, .14);
  --accent-text: #ffffff;

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .14);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .14);

  --code-key: #7dd3fc;
  --code-str: #a5e075;
  --code-num: #f0a868;
  --code-bool: #c792ea;
  --code-null: #8b98ad;

  --shadow: 0 10px 30px rgba(0, 0, 0, .38);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .28);
}

html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --bg-elev: #ffffff;
  --bg-input: #f7f9fc;
  --bg-hover: #eef2f9;

  --border: #e2e7f0;
  --border-strong: #c9d2e3;

  --text: #1a2233;
  --text-dim: #5a6883;
  --text-mute: #8c97ac;

  --accent: #3b6ef5;
  --accent-soft: rgba(59, 110, 245, .1);
  --accent-text: #ffffff;

  --ok: #0f9d68;
  --ok-soft: rgba(15, 157, 104, .12);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, .12);
  --err: #d93b3b;
  --err-soft: rgba(217, 59, 59, .1);

  --code-key: #0b6bcb;
  --code-str: #2f8a3b;
  --code-num: #b5560a;
  --code-bool: #8b3ec4;
  --code-null: #8592a8;

  --shadow: 0 10px 28px rgba(28, 44, 82, .1);
  --shadow-sm: 0 2px 8px rgba(28, 44, 82, .07);
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--font-mono); }

::selection { background: var(--accent); color: var(--accent-text); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-mute); background-clip: content-box; }

/* ---------- 布局 ---------- */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -.5px;
  box-shadow: var(--shadow-sm);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14px; letter-spacing: .2px; }
.brand-text small { color: var(--text-mute); font-size: 11px; }

.sidebar-search { padding: 6px 16px 12px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
}

.nav-group-title {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .nav-ico { width: 20px; text-align: center; font-size: 15px; flex: 0 0 20px; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-empty { padding: 20px 12px; color: var(--text-mute); font-size: 13px; text-align: center; }

.sidebar-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-foot .muted { margin-top: 8px; }

.sidebar-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s var(--ease);
  z-index: 39;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
}
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--text-mute); }

.content {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  padding: 26px 22px 56px;
  animation: fade-in .28s var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px 22px 30px;
  color: var(--text-mute);
  font-size: 12px;
}
.foot .dot { opacity: .5; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .24s var(--ease);
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-mask { opacity: 1; visibility: visible; }
  .main { margin-left: 0; }
  .content { padding: 18px 14px 48px; }
  .topbar { padding: 0 14px; }
  /* 这些覆盖需要压过 components.css 中的同名规则，因此加 !important */
  .topbar .menu-btn { display: inline-flex !important; }
  .sidebar-head .sidebar-close { display: inline-flex !important; }

  /* 移动端更紧凑 */
  .page-head h1 { font-size: 20px !important; }
  .page-head .desc { font-size: 13px; }
  .hero { padding: 18px !important; }
  .hero h1 { font-size: 22px !important; }
  .card { padding: 14px !important; }
}

@media (min-width: 901px) {
  .menu-btn, .sidebar-close { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
