/* ── 全站尺寸单一来源 ──
   --nav-w：左侧通用导航宽度（220 → 200）
   --content-w：右侧主体内容统一宽度（所有页面正文容器按此宽度自适应）
   主体内容不包含「悬浮导航」「返回顶部」等 fixed/overlay 元素（本就不占内容流）。 */
:root {
  --nav-w: 200px;
  --content-w: 1000px;
  /* 品牌色单一来源（与全站 --primary 一致，消除导航侧栏 #ff5e62/#ff7e5f 漂移） */
  --primary: #FF6B6B;
  --orange: #FF9F1C;
  /* 品牌四色渐变（竖向，用于左侧导航侧栏） */
  --brand-grad-v: linear-gradient(to bottom, #FF6B6B 0%, #FF9F1C 45%, #FFE66D 75%, #6BCB77 100%);
}

/* 全站通用左侧导航（抽离自通用主题页，作为单一来源，供主题详情页复用） */
.site-nav {
  box-sizing: border-box;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  position: fixed; left: 0; top: 0;
  width: var(--nav-w); height: 100vh;
  background: linear-gradient(to bottom, #ff9a9e 0%, #fecfef 50%, #a8edea 100%);
  display: flex; flex-direction: column;
  z-index: 50;
  border-right: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}
.site-nav .nav-logo { padding: 32px; margin-bottom: 16px; }
.site-nav .nav-logo h1 {
  margin: 0.67em 0;
  line-height: 1.2;
  font-size: 1.3rem; font-weight: 900; letter-spacing: 0.1em;
  color: white; filter: drop-shadow(0 4px 3px rgba(0,0,0,0.07)) drop-shadow(0 1px 2px rgba(0,0,0,0.06));
}
.site-nav .nav-links {
  flex: 1; padding: 0 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.site-nav .nav-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: #334155;
  text-decoration: none;
  font-size: 16px; font-weight: 500; line-height: 1.45;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  transition: all 0.15s;
}
/* 导航中文 label + 英文副标签：纵向堆叠，英文淡色小号 */
.site-nav .nav-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.site-nav .nav-label { font-size: 16px; font-weight: 500; line-height: 1.3; }
.site-nav .nav-en {
  font-size: 12.5px; font-weight: 500; line-height: 1.2;
  color: #64748b; letter-spacing: 0.03em;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}
.site-nav .nav-link:hover { background: rgba(255,255,255,0.3); color: #0f172a; }
.site-nav .nav-link.active { color: var(--primary); background: rgba(255,255,255,0.4); font-weight: 700; }
.site-nav .nav-link.active .nav-en { color: rgba(255,94,98,0.85); }
.site-nav .nav-link.active .nav-indicator { opacity: 1; }
.site-nav .nav-indicator {
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 24px;
  border-radius: 0 4px 4px 0;
  background: var(--brand-grad-v);
  opacity: 0; transition: opacity 0.15s;
}
.site-nav .nav-icon { font-size: 20px; line-height: 1; display: inline-flex; }
.site-nav .nav-foot {
  padding: 24px;
  border-top: 1px solid rgba(0,0,0,0.05);
  display: flex; align-items: center; gap: 12px;
  color: #475569; font-size: 12px; line-height: 1.4;
  text-decoration: none; cursor: pointer;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  transition: all 0.15s;
}
.site-nav .nav-foot:hover { background: rgba(255,255,255,0.25); color: var(--primary); }
.site-nav .nav-foot.active { background: rgba(255,255,255,0.4); color: var(--primary); font-weight: 700; }
.site-nav .nav-foot.active .nav-foot-icon { color: var(--primary); }
.site-nav .nav-foot-icon { font-size: 18px; color: #ec4899; transition: color 0.15s; }
.page-main { margin-left: var(--nav-w); }

/* ── 悬浮侧栏：不挤压主体、不重叠固定导航 ──
   主题详情页「活动分组」(.act-nav) 与通用主题页「年龄段」(.term-nav)
   用 float+负外边距推到内容左外悬浮，不计入 1000px 主体宽度。
   固定站点导航占 0–200px。.td-main / .themes-outer 用 margin:0 auto 居中后，
   左右两侧自然形成留白 gutter = (视口−200−1000)/2。
   • 当 gutter ≥ 150px（即视口 ≥1500px）时，浮动栏刚好落入左侧 gutter，
     与固定导航（≤200）和内容（≥350）都不打架 —— 此时【不给 .page-main 加任何 padding】，
     主体内容始终精确居中、顶部 banner 也保持满宽（不会被 padding 推偏）。
   • 视口 <1500px 时空间不足，下方 @media(max-width:1499px) 把两导航自动降级为顶部横条，
     既不挤压内容（内容 = min(1000, 视口−200)），也不与固定导航重叠。
   :has() 为渐进增强——不支持的浏览器自动回退到原有（略微外推）行为，不会破损。 */

/* 视口 <1500px：左侧浮栏无足够空间，两类悬浮导航统一降级为顶部横向滚动条
   （不浮动、不挤压主体、不与固定导航重叠） */
@media (max-width: 1499px) {
  .page-main:has(.act-nav) .act-nav,
  .page-main:has(.term-nav) .term-nav {
    float: none; position: static; width: 100%; margin: 0 0 18px;
    display: flex; flex-direction: row; flex-wrap: nowrap; gap: 8px;
    overflow-x: auto; padding: 10px 12px; scrollbar-width: none;
  }
  .page-main:has(.act-nav) .act-nav::-webkit-scrollbar,
  .page-main:has(.term-nav) .term-nav::-webkit-scrollbar { display: none; }
  .page-main:has(.act-nav) .act-nav .an-title,
  .page-main:has(.term-nav) .term-nav .tn-title,
  .page-main:has(.term-nav) .term-nav .tn-group { display: none; }
  .page-main:has(.act-nav) .act-nav a,
  .page-main:has(.term-nav) .term-nav a {
    white-space: nowrap; flex: 0 0 auto; padding: 7px 12px;
    border-radius: 999px; border: 1px solid var(--td-border);
  }
}

/* ── 移动端：顶部栏 + 抽屉式导航 ── */
.mobile-topbar { display: none; }
.nav-overlay { display: none; }
@media (max-width: 860px) {
  .site-nav {
    transform: translateX(-100%);
    transition: transform .3s ease;
    z-index: 300;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .site-nav.open { transform: translateX(0); }
  .page-main { margin-left: 0; }
  /* 移动端悬浮侧栏降级为顶部横条/隐藏，撤销桌面端预留的左侧槽位，避免空白左边距 */
  .page-main:has(.act-nav),
  .page-main:has(.term-nav) { padding-left: 0; }

  /* 顶部栏：汉堡菜单（左）+ 页面名称（居中） */
  .mobile-topbar {
    display: flex; align-items: center; justify-content: center;
    position: sticky; top: 0; z-index: 280;
    height: 48px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  }
  .mobile-topbar .mt-toggle {
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px;
    background: transparent; border: none; cursor: pointer; color: #475569;
    padding: 0;
  }
  .mobile-topbar .mt-toggle svg { width: 22px; height: 22px; }
  .mobile-topbar .mt-title {
    font-size: 15px; font-weight: 600; color: #1e293b;
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 60vw;
  }

  /* 锚点跳转避开吸顶的顶部栏(48px)与二级导航.toc */
  html { scroll-padding-top: 100px; }

  .nav-overlay {
    display: none; position: fixed; inset: 0; z-index: 290;
    background: rgba(15,23,42,0.45);
  }
  .nav-overlay.show { display: block; }
}

/* ── 尊重「减少动态效果」系统偏好 ── */
@media (prefers-reduced-motion: reduce) {
  .site-nav { transition: none; }
  .to-top { transition: none; }
  .to-top.show { transform: none; }
}

/* ── 返回顶部按钮（由 nav.js 全局注入 .to-top）── */
.to-top {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 210;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--primary); color: #fff; cursor: pointer;
  box-shadow: 0 6px 16px rgba(255,107,107,.35);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(12px) scale(.9);
  transition: opacity .25s ease, transform .25s ease, background .2s ease, box-shadow .2s ease;
}
.to-top svg { display: block; width: 22px; height: 22px; }
.to-top.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
.to-top.show:hover {
  background: #ff474b;
  box-shadow: 0 10px 22px rgba(255,94,98,.45);
  transform: translateY(-2px);
}
.to-top:focus-visible { outline: 3px solid rgba(255,94,98,.45); outline-offset: 2px; }
/* 移动端：贴近内容区右缘、按钮略小 */
@media (max-width: 860px) {
  .to-top { right: 16px; bottom: 16px; width: 42px; height: 42px; }
  .to-top svg { width: 20px; height: 20px; }
}
