/* =========================================
   static/css/base.css
   Base utility overrides and animations
   ========================================= */

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
}

.font-mono,
code,
pre {
  font-family: var(--font-mono);
}

a {
  color: var(--primary-color);
}

a:hover {
  color: var(--secondary-color);
}

.btn,
.sidebar-link,
.nav-item {
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
}

.btn-secondary {
  background-color: var(--secondary-color) !important;
  border-color: var(--secondary-color) !important;
}

.badge-accent {
  background-color: var(--accent-color) !important;
}

.text-primary {
  color: var(--primary-color) !important;
}

.text-secondary {
  color: var(--secondary-color) !important;
}

.text-accent {
  color: var(--accent-color) !important;
}

/* Global Language Toggle Logic */
html[data-lang="zh"] .lang-en {
  display: none !important;
}

html[data-lang="en"] .lang-zh {
  display: none !important;
}

html[data-lang="en"] body {
  font-family: 'Inter', 'Roboto', 'Segoe UI', sans-serif;
}


    /* === 全局搜索 Modal 样式 (Spotlight Search) === */
    .search-modal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 99999;
      background: hsl(var(--n) / 0.5);
      backdrop-filter: blur(8px);
      align-items: flex-start;
      justify-content: center;
      padding-top: 10vh;
      opacity: 0;
      transition: opacity 0.2s ease;
    }

    .search-modal.show {
      display: flex;
      opacity: 1;
    }

    .search-container {
      width: 100%;
      max-width: 600px;
      margin: 0 1rem;
      background: hsl(var(--b1));
      border: 1px solid hsl(var(--bc) / 0.1);
      border-radius: 1rem;
      box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
      transform: scale(0.95);
      transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      overflow: hidden;
      display: flex;
      flex-direction: column;
      max-height: 70vh;
    }

    .search-modal.show .search-container {
      transform: scale(1);
    }
    
    .search-input-wrapper {
      position: relative;
      display: flex;
      align-items: center;
      padding: 0 1.5rem;
      border-bottom: 1px solid hsl(var(--bc) / 0.1);
    }
    
    .search-input-wrapper i {
      color: var(--primary-color);
      font-size: 1.25rem;
    }
    
    .search-input {
      width: 100%;
      padding: 1.5rem 1rem;
      background: transparent;
      border: none;
      outline: none;
      font-size: 1.125rem;
      color: hsl(var(--bc));
    }
    
    .search-results {
      overflow-y: auto;
      padding: 0.5rem;
    }
    
    .search-item {
      display: block;
      padding: 0.75rem 1rem;
      border-radius: 0.5rem;
      margin-bottom: 0.25rem;
      color: hsl(var(--bc) / 0.8);
      transition: all 0.1s;
    }
    
    .search-item:hover, .search-item.active {
      background: hsl(var(--p) / 0.1);
      color: var(--primary-color);
    }
    
    .search-item-title {
      font-weight: 600;
      margin-bottom: 0.25rem;
    }
    
    .search-item-desc {
      font-size: 0.75rem;
      opacity: 0.7;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    .search-hint {
      padding: 1rem;
      text-align: center;
      font-size: 0.875rem;
      color: hsl(var(--bc) / 0.5);
    }
    /* === 跨页平滑过渡动画 (View Transitions) === */
    @view-transition {
      navigation: auto;
    }
    
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation-duration: 0.3s;
      animation-fill-mode: both;
      animation-timing-function: ease-in-out;
      mix-blend-mode: normal;
    }

    ::view-transition-old(root) {
      animation-name: pageFadeOut;
    }

    ::view-transition-new(root) {
      animation-name: pageFadeIn;
    }

    @keyframes pageFadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    @keyframes pageFadeOut {
      from { opacity: 1; }
      to { opacity: 0; }
    }
    /* === 跨页平滑过渡动画结束 === */
    /* 返回顶部按钮样式 (Back to top button styles) */
    #back-to-top {
      position: fixed;
      bottom: 2rem;
      right: 2rem;
      z-index: 50;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.3s, visibility 0.3s;
    }

    #back-to-top.show {
      opacity: 1;
      visibility: visible;
    }

    /* 侧边栏滚动条美化 (Sidebar scrollbar styling) */
    .sidebar-scroll {
      scrollbar-width: thin;
      scrollbar-color: hsl(var(--bc) / 0.2) transparent;
    }

    .sidebar-scroll::-webkit-scrollbar {
      width: 6px;
    }

    .sidebar-scroll::-webkit-scrollbar-track {
      background: transparent;
    }

    .sidebar-scroll::-webkit-scrollbar-thumb {
      background: hsl(var(--bc) / 0.2);
      border-radius: 3px;
    }

    .sidebar-scroll::-webkit-scrollbar-thumb:hover {
      background: hsl(var(--bc) / 0.3);
    }

    /* 侧边栏固定布局 (Fixed sidebar layout) */
    @media (min-width: 1024px) {
      .sidebar-fixed {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
      }

      .content-with-sidebar {
        margin-left: 280px;
      }
    }

    /* 移动端侧边栏样式 (Mobile sidebar styles) */
    @media (max-width: 1023px) {
      .sidebar-fixed {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
      }

      .sidebar-fixed.open {
        transform: translateX(0);
      }

      .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
      }

      .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
      }
    }

    /* Toast 通知样式 (Toast notification styles) */
    .toast-container {
      position: fixed;
      top: 1rem;
      right: 1rem;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      max-width: 400px;
    }

    .toast {
      padding: 1rem 1.5rem;
      border-radius: 0.5rem;
      box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
      display: flex;
      align-items: center;
      gap: 0.75rem;
      animation: slideIn 0.3s ease-out;
      background: hsl(var(--b2));
      color: hsl(var(--bc));
    }

    .toast.success {
      background: hsl(var(--su));
      color: hsl(var(--suc));
    }

    .toast.error {
      background: hsl(var(--er));
      color: hsl(var(--erc));
    }

    .toast.warning {
      background: hsl(var(--wa));
      color: hsl(var(--wac));
    }

    .toast.info {
      background: hsl(var(--in));
      color: hsl(var(--inc));
    }

    @keyframes slideIn {
      from {
        transform: translateX(100%);
        opacity: 0;
      }

      to {
        transform: translateX(0);
        opacity: 1;
      }
    }

    @keyframes slideOut {
      from {
        transform: translateX(0);
        opacity: 1;
      }

      to {
        transform: translateX(100%);
        opacity: 0;
      }
    }

    .toast.removing {
      animation: slideOut 0.3s ease-out forwards;
    }

    /* ==================== TOC Glow Card 样式 ==================== */
    #toc-list {
      position: relative;
      padding-left: 0;
      margin-left: 0;
    }

    #toc-list li {
      list-style: none;
    }

    #toc-list a {
      display: block;
      padding: 0.45rem 0.75rem;
      font-size: 0.8125rem;
      line-height: 1.5;
      color: var(--glass-text-dim);
      border-radius: 0.5rem;
      border-left: 3px solid transparent;
      transition: color 0.25s ease, background-color 0.25s ease,
        border-color 0.3s ease, box-shadow 0.3s ease,
        transform 0.25s ease;
    }

    #toc-list a:hover {
      color: var(--glass-text-strong) !important;
      background: hsl(var(--bc) / 0.06);
    }

    #toc-list a.toc-active {
      color: var(--primary-color) !important;
      font-weight: 600;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-left: 3px solid var(--primary-color);
      box-shadow: -4px 0 14px -2px rgba(16, 185, 129, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.2);
      transform: translateX(2px);
    }

    :root:not([data-theme="business"]) #toc-list a.toc-active {
      background: rgba(0, 0, 0, 0.04);
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-left: 3px solid var(--primary-color);
      box-shadow: -4px 0 14px -2px rgba(16, 185, 129, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.06);
      transform: translateX(2px);
    }

    /* TOC 缩进层级 */
    #toc-list a.toc-h2 {
      padding-left: 1.5rem;
    }

    #toc-list a.toc-h3 {
      padding-left: 2.25rem;
      font-size: 0.75rem;
    }

    /* 全局语言切换逻辑 (Global Language Toggle Logic) */
    html[data-lang="zh"] .lang-en {
      display: none !important;
    }

    html[data-lang="en"] .lang-zh {
      display: none !important;
    }

    /* 英文专用字体样式 (Optional typographic tweaks for English) */
    html[data-lang="en"] body {
      font-family: 'Inter', 'Roboto', 'Segoe UI', sans-serif;
    }

    /* 主题切换：快速淡入淡出（仅 opacity，GPU 合成零卡顿） */

    /* 侧边栏当前页活跃指示器 */
    .menu li>a.sidebar-link-active,
    .menu a.sidebar-link-active {
      color: hsl(var(--p)) !important;
      background: hsl(var(--p) / 0.10) !important;
      font-weight: 600;
      transform: translateX(4px);
    }
    
    /* 顶部阅读进度条 (Reading Progress Bar) */
    .reading-progress-container {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 3px;
      background: transparent;
      z-index: 9999;
      pointer-events: none;
    }
    
    .reading-progress-bar {
      height: 100%;
      background: var(--primary-color);
      box-shadow: 0 0 8px var(--primary-color);
      width: 0%;
      transition: width 0.1s ease-out;
    }
  