/* ============================
   CSS Variables & Theme
   ============================ */
:root {
  --bg: #0c0b0f;
  --bg-surface: #141218;
  --bg-elevated: #1b1820;
  --bg-hover: #24202b;
  --border: #302a38;
  --border-light: #211d27;
  --text: #eeeaf0;
  --text-secondary: #aaa2ae;
  --text-muted: #746d79;
  --brand-purple-deep: #59307f;
  --brand-purple: #b361b9;
  --brand-purple-light: #d684dc;
  --brand-purple-soft: #ecb1f0;
  --accent: #a45bac;
  --accent-hover: #c174c7;
  --accent-green: #759786;
  --accent-orange: #ad9878;
  --accent-red: #b6787d;
  --accent-purple: #b361b9;
  --shadow: 0 1px 3px rgba(0,0,0,.34), 0 0 0 1px rgba(0,0,0,.26);
  --shadow-lg: 0 12px 38px rgba(0,0,0,.44);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: .2s ease;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;

  /* ---- 布局标尺（唯一来源）----
     内容列宽度以前散落在 packs.css / doc.css / pack.css / resources.css，
     又被 site-theme.css 覆盖、terms 还写在内联样式里 —— 5 页 5 个值。
     现在统一在这里定义，各容器只引用变量。 */
  --page-max:        1280px;  /* 常规内容列（与导航内层一致） */
  --page-max-wide:   1500px;  /* 卡片列表 / 曲包详情等宽内容 */
  --page-max-narrow:  860px;  /* 法律文本（阅读宽度） */
  --page-pad-top:      30px;  /* 内容列顶部内边距（导航栏到内容） */
  --navbar-height: 56px;
  --icon-size: 20px;
}

/* 图标样式（内联 SVG，见 js/icons-sprite.js） */
/* 页面里静态写死的 <i data-lucide="..."> 在 App.refreshIcons() 替换成 <svg> 之前
   先按这个规则占位，减少布局抖动（CLS） */
[data-lucide] {
  width: var(--icon-size);
  height: var(--icon-size);
}
.lucide-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  stroke-width: 2;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-filled {
  fill: currentColor;
}
/* 旋转的加载图标（现在命中的是替换后的 <svg data-lucide="loader-2">，
   所以选择器不能再限定 i 标签） */
[data-lucide="loader-2"] {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f2f5;
  --bg-hover: #e8ecf0;
  --border: #d0d7de;
  --border-light: #e3e8ed;
  --text: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8c959f;
  --brand-purple-deep: #59307f;
  --brand-purple: #a754ae;
  --brand-purple-light: #c66dcd;
  --brand-purple-soft: #df9ce4;
  --accent: #8c4594;
  --accent-hover: #703778;
  --accent-green: #1a7f37;
  --accent-orange: #9a6700;
  --accent-red: #cf222e;
  --accent-purple: #a754ae;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
}

/* ============================
   Reset & Base
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  /* 纵向 flex + 下面内容容器的 flex:1：内容不足一屏时页脚沉到视口底部，
     而不是紧贴内容悬在屏幕中间（wiki 短章节、空页签这类页面最明显） */
  display: flex;
  flex-direction: column;
  transition: background var(--transition), color var(--transition);
}

/* 内容区吃掉剩余高度（7 个页面各只有一个内容容器，见各页 body 结构）
   注：index 的 <main> 有意通栏（hero 设计），不加 max-width。
   ⚠️ 必须显式 width: 100%：这些容器是「max-width + margin:0 auto」居中的，
   而 flex 规范里交叉轴的 auto 边距会**阻止 stretch** —— 不写 width 的话
   容器会缩成内容宽度（实测 wiki 内容挤在屏幕中间就是这个原因）。 */
body > main,
body > .packs-layout,
body > .pack-detail,
body > .doc-layout {
  flex: 1 0 auto;
  width: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================
   Navbar (shared across all pages)
   ============================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

.nav-logo {
  height: 28px;
  width: auto;
  vertical-align: middle;
}

/* 网站 logo（data/logo/eocn_logo.svg）是单色白 #F9F9F9，深色导航栏下正好；
   但浅色主题的导航栏是 rgba(255,255,255,.86)，白 logo 会完全看不见，所以反色。
   注意：用 <img> 引入 SVG 时，SVG 里的 currentColor **不会**继承页面颜色
   （它是一份独立文档，currentColor 会解析成黑色），所以只能在 <img> 上用 filter，
   不能像内联 SVG 那样靠 color 跟着主题变。 */
[data-theme="light"] .nav-logo {
  filter: invert(1);
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-link.active {
  color: var(--accent);
  background: var(--bg-elevated);
}

.nav-spacer { flex: 1; }

.nav-stats {
  font-size: .85rem;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
}

.nav-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: var(--navbar-height);
}

.nav-actions {
  display: flex;
  gap: 4px;
}

/* ============================
   Buttons
   ============================ */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.search-box:focus-within .btn-clear,
.btn-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================
   Modal
   ============================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal-overlay.open {
  display: flex;
}

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

.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}

.modal-body {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
}

.modal-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* Modal Content */
.modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.modal-banner {
  width: 300px;
  min-width: 200px;
  height: 94px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.modal-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-banner .banner-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2rem;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-hover));
}

.modal-title-area {
  flex: 1;
  min-width: 0;
}

.modal-title-area h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
  line-height: 1.4;
}

.modal-title-area .modal-maker {
  color: var(--text-secondary);
  font-size: .9rem;
}

.modal-title-area .modal-eval {
  color: var(--text-muted);
  font-size: .88rem;
  margin-top: 6px;
  line-height: 1.6;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h3 {
  font-size: .85rem;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.modal-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.modal-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-info-item .label {
  font-size: .72rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}

.modal-info-item .value {
  font-size: .95rem;
  font-weight: 500;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-tag {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.modal-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-link-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
}

.modal-link-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.modal-link-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.modal-link-btn.primary:hover {
  background: var(--accent-hover);
}

.modal-link-btn.copy-btn {
  font-size: .78rem;
  padding: 6px 12px;
}

.modal-link-btn.copy-btn.copied {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.modal-text-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: .88rem;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-secondary);
}

/* Radar chart */
.radar-wrap {
  max-width: 400px;
  margin: 0 auto;
}

/* unranked badge (shared) */
.unranked-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-orange);
  color: #000;
  margin-right: 4px;
  vertical-align: middle;
}

/* ============================
   Toast
   ============================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: .88rem;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================
   Empty state
   ============================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 1rem;
}

/* ============================
   Loading shimmer
   ============================ */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

.shimmer {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-xs);
}

/* ============================
   Back to Top
   ============================ */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: var(--shadow);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* ============================
   Responsive (shared)
   ============================ */
@media (max-width: 768px) {
  .nav-stats {
    display: none;
  }
  .modal-container {
    max-height: 95vh;
    border-radius: var(--radius-sm);
  }
  .modal-body {
    padding: 20px;
  }
  .modal-header {
    flex-direction: column;
  }
  .modal-banner {
    width: 100%;
    height: 80px;
  }
  .modal-info-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .nav-inner {
    padding: 0 12px;
  }
  .modal-info-grid {
    grid-template-columns: 1fr;
  }
}

/* Focus visible for keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible) {
  outline: none;
}

/* Placeholder page (resources / wiki) */
.placeholder-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  flex-direction: column;
  gap: 16px;
}
.placeholder-icon {
  font-size: 3rem;
  opacity: .3;
}
.placeholder-text {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Pack detail song list count */
#songListCount {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Mobile sidebar toggle spacing */
.mobile-sidebar-toggle {
  margin-bottom: 12px;
}

/* ============================
   Site Footer (备案/条款)
   ============================ */
.site-footer {
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
  margin-top: 48px;
  padding: 20px 16px;
}
.site-footer-inner {
  max-width: var(--page-max);   /* 与 .nav-inner 一致：logo 与页脚左右边缘对齐 */
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 24px;
  font-size: .85rem;
  color: var(--text-muted);
}
.footer-left { display: flex; align-items: center; gap: 8px; }
.footer-links { display: flex; align-items: center; gap: 8px; }
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--accent); }
.footer-sep { opacity: .5; }
@media (max-width: 640px) {
  .site-footer-inner { justify-content: center; text-align: center; }
}
