/* ============================================================
   我的个人空间 · 共享主题与导航样式
   单一样式源：所有页面统一引用本文件，实现三主题（简约白/暗夜/赛博朋克）
   与竖列侧边栏导航（移动端折叠为底部标签栏）。
   ============================================================ */

/* ---------- 结构令牌（主题无关） ---------- */
:root {
  /* 字号标尺 */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.375rem;
  --text-display: clamp(1.875rem, 4.5vw, 2.875rem);
  /* 间距标尺（4pt） */
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  /* 圆角 */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-full: 999px;
  /* 布局尺寸 */
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --tabbar-h: 66px;
}

/* ---------- 主题令牌 ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-decor:
    radial-gradient(circle at top left, rgba(79, 107, 255, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(84, 197, 255, 0.14), transparent 26%);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --text: #162033;
  --muted: #5a6678;
  --line: #e7edf5;
  --line-strong: #c9d6ff;
  --brand: #4459e6;
  --brand-strong: #3952d8;
  --brand-soft: #eef2ff;
  --on-brand: #ffffff;
  --success: #159957;
  --danger: #d64545;
  --nav-bg: rgba(255, 255, 255, 0.82);
  --card-border: rgba(255, 255, 255, 0.65);
  --tag-bg: #ffffff;
  /* 内容区补充令牌（替代各页遗留的硬编码色） */
  --surface: #ffffff;
  --surface-2: #fbfcff;
  --focus-ring: rgba(68, 89, 230, 0.14);
  --danger-soft: #fff5f5;
  --danger-line: #f1c4c4;
  --shadow-sm: 0 6px 24px rgba(27, 39, 94, 0.05);
  --shadow-md: 0 8px 24px rgba(27, 39, 94, 0.07);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1420;
  --bg-decor:
    radial-gradient(circle at top left, rgba(108, 134, 255, 0.16), transparent 36%),
    radial-gradient(circle at top right, rgba(56, 199, 255, 0.08), transparent 28%);
  --panel: rgba(23, 30, 48, 0.9);
  --panel-strong: #1d2540;
  --text: #e8edf7;
  --muted: #98a4bd;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(140, 157, 255, 0.45);
  --brand: #6c86ff;
  --brand-strong: #8a9dff;
  --brand-soft: rgba(108, 134, 255, 0.16);
  --on-brand: #0f1420;
  --success: #34d399;
  --danger: #f87171;
  --nav-bg: rgba(15, 20, 32, 0.85);
  --card-border: rgba(255, 255, 255, 0.1);
  --tag-bg: rgba(255, 255, 255, 0.05);
  --surface: #1d2540;
  --surface-2: #181f36;
  --focus-ring: rgba(108, 134, 255, 0.26);
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-line: rgba(248, 113, 113, 0.4);
  --shadow-sm: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="cyberpunk"] {
  color-scheme: dark;
  --bg: #0a0a12;
  --bg-decor:
    radial-gradient(circle at top left, rgba(0, 240, 255, 0.12), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 46, 166, 0.1), transparent 30%);
  --panel: rgba(16, 18, 32, 0.88);
  --panel-strong: #141830;
  --text: #e8f6ff;
  --muted: #a8b8d8;
  --line: rgba(0, 240, 255, 0.16);
  --line-strong: rgba(0, 240, 255, 0.5);
  --brand: #00f0ff;
  --brand-strong: #ff2ea6;
  --brand-soft: rgba(0, 240, 255, 0.1);
  --on-brand: #051018;
  --success: #00ffa3;
  --danger: #ff5c7a;
  --nav-bg: rgba(10, 10, 18, 0.85);
  --card-border: rgba(0, 240, 255, 0.1);
  --tag-bg: rgba(0, 240, 255, 0.06);
  --surface: #141830;
  --surface-2: #12142a;
  --focus-ring: rgba(0, 240, 255, 0.22);
  --danger-soft: rgba(255, 92, 122, 0.14);
  --danger-line: rgba(255, 92, 122, 0.45);
  --shadow-sm: 0 6px 24px rgba(0, 240, 255, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 240, 255, 0.1);
}

/* ---------- 旧令牌别名（兼容各页遗留引用） ---------- */
:root {
  --brand-dark: var(--brand-strong);
  --radius: var(--radius-lg);
  --shadow: var(--shadow-md);
}

/* ---------- 基础重置 ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-decor);
  background-attachment: fixed;
}

a {
  color: inherit;
}

:is(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- 内容容器（侧边栏布局） ---------- */
.page {
  margin-left: var(--sidebar-w);
  max-width: calc(100% - var(--sidebar-w));
  padding: var(--space-6) var(--space-8) var(--space-16);
}

/* ---------- 竖列侧边栏 ---------- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-4);
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
}

.nav-brand {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--brand-strong);
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-lg);
  line-height: 1;
  background: var(--brand-soft);
  color: var(--brand-strong);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-label {
  line-height: 1.3;
}

.nav-item:hover {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.nav-item:hover .nav-icon {
  background: var(--panel-strong);
}

.nav-item.active {
  color: var(--on-brand);
  background: var(--brand-strong);
}

.nav-item.active .nav-icon {
  background: rgba(255, 255, 255, 0.18);
  color: var(--on-brand);
}

/* ---------- 侧边栏底部（账号 / 退出 / 主题） ---------- */
.nav-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.chip {
  border: 1px solid var(--line);
  background: var(--tag-bg);
  color: var(--muted);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  background: var(--brand-strong);
  color: var(--on-brand);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  background: var(--brand);
}

.btn.secondary {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.secondary:hover {
  color: var(--brand-strong);
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.theme-switch {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
}

.theme-switch button {
  flex: 1;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: var(--radius-full);
  font-size: var(--text-md);
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.theme-switch button[aria-pressed="true"] {
  background: var(--brand-soft);
  color: var(--brand-strong);
  border-color: var(--line-strong);
}

/* ---------- 移动端：底部标签栏 + 顶部迷你栏 ---------- */
@media (max-width: 768px) {
  .site-nav {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--line);
    /* 关键：清除桌面端继承的 backdrop-filter，否则它会对 fixed 子元素建立包含块，导致顶栏/底部标签栏定位错乱 */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    filter: none;
    transform: none;
  }

  .nav-brand {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 55;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6) 0 var(--space-4);
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }

  .nav-right {
    position: fixed;
    top: 0;
    right: var(--space-4);
    z-index: 60;
    height: var(--topbar-h);
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    padding: 0;
    border-top: none;
  }

  .chip {
    display: none;
  }

  /* mobile: compact action buttons (both visible) */
  .nav-right .btn {
    padding: 5px 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  .nav-right {
    gap: 6px;
  }

  .theme-switch button {
    flex: 0 0 auto;
    width: 34px;
    min-height: 34px;
    min-width: 34px;
  }

  .nav-links {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    height: var(--tabbar-h);
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--line);
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 1 0 auto;
    min-width: 68px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: var(--space-2) var(--space-2);
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    text-align: center;
  }

  .nav-icon {
    width: 30px;
    height: 30px;
    font-size: var(--text-base);
    background: transparent;
  }

  .nav-label {
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
  }

  .nav-item:hover {
    background: transparent;
    color: var(--brand-strong);
  }

  .nav-item:hover .nav-icon {
    background: var(--brand-soft);
  }

  .nav-item.active {
    background: transparent;
    color: var(--brand-strong);
  }

  .nav-item.active .nav-icon {
    background: var(--brand-strong);
    color: var(--on-brand);
  }

  .page {
    margin-left: 0;
    max-width: none;
    padding: calc(var(--topbar-h) + var(--space-4)) var(--space-4) calc(var(--tabbar-h) + var(--space-4));
  }
}

/* ---------- 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}