/* ========================================
   POE2 国服攻略站 - 导航站样式 v3
   参照 poe2.baozangdh.com 风格
   浅色默认 + 夜间模式切换
   ======================================== */

/* ===== 变量已在 HTML 内联 ===== */

/* ===== 基础 ===== */
html { scroll-behavior: smooth; }
body { overflow-y: scroll; }

/* ===== 站点导航栏 ===== */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--nav-bg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--nav-border);
  height: 48px;
  transition: background .3s ease, border-color .3s ease;
}
.site-nav-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 1.5rem;
  height: 100%; display: flex; align-items: center; gap: 0;
}
.site-nav-logo {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
  text-decoration: none; margin-right: 24px; flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  transition: color .2s;
  letter-spacing: -0.3px;
}
.site-nav-logo:hover { color: var(--link-hover); }
.logo-icon {
  font-size: 1.15rem; line-height: 1;
  background: linear-gradient(135deg, #c9a227, #8b6914);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 2px rgba(201,162,39,0.3));
}
.site-nav-links {
  display: flex; align-items: center; gap: 0; flex: 1;
}
.site-nav-link {
  padding: 0 14px; height: 48px; line-height: 48px;
  font-size: 0.88rem; font-weight: 500; color: var(--nav-link);
  text-decoration: none; transition: color .2s, background .2s;
  white-space: nowrap;
}
.site-nav-link:hover { color: var(--nav-link-hover); background: rgba(128,128,128,0.06); }
.site-nav-link.active { color: var(--nav-active); font-weight: 600; }
.site-nav-toggle {
  display: none; flex-direction: column; gap: 5px; padding: 8px;
  background: none; border: none; cursor: pointer;
}
.site-nav-toggle span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: .3s; }
.site-nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.site-nav-toggle.active span:nth-child(2) { opacity: 0; }
.site-nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }

/* ===== 紧凑搜索栏（无标题） ===== */
.search-container.compact {
  max-width: 1400px; margin: 64px auto 0; padding: 0 1.5rem;
  position: relative; display: flex; flex-direction: column;
}
.search-container.compact .search-box {
  max-width: 480px; margin: 0 auto;
}

/* ===== 主题切换 / 返回顶部 ===== */
#theme-toggle, #back-to-top {
  position: fixed; z-index: 100; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; line-height: 1; border: none; border-radius: 50%;
  color: var(--btn-icon); background: var(--btn-bg); cursor: pointer;
  box-shadow: var(--btn-shadow); transition: background-color .2s, box-shadow .2s;
  font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;
}
#theme-toggle { right: 1.5rem; top: 6px; width: 34px; height: 34px; border-radius: 17px; z-index: 1100; }
#theme-toggle svg { transition: opacity .25s, transform .25s; }
#theme-toggle .theme-sun { display: block; }
#theme-toggle .theme-moon { display: none; }
[data-theme="dark"] #theme-toggle .theme-sun { display: none; }
[data-theme="dark"] #theme-toggle .theme-moon { display: block; }
#back-to-top { right: 1.5rem; bottom: 1.5rem; opacity: 0; visibility: hidden; }
#back-to-top.visible { opacity: 1; visibility: visible; }
#theme-toggle:hover, #back-to-top:hover { background: var(--btn-bg-hover); box-shadow: var(--btn-shadow-hover); }

/* ===== 搜索容器 ===== */
.search-container {
  max-width: 600px; margin: 0 auto 1rem;
  position: relative; display: flex; flex-direction: column;
}
.search-box {
  display: grid; grid-template-columns: 40px 1fr;
  max-width: 480px; margin: 0 auto 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); border-radius: 8px;
  overflow: hidden; background: #fff; border: 1px solid var(--card-border);
  height: 44px; align-items: center;
}
[data-theme="dark"] .search-box { background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); }
.search-box:hover { border-color: var(--subtext); }
.search-box:focus-within { border-color: var(--text); }
.search-icon {
  display: flex; align-items: center; justify-content: center;
  color: var(--subtext); padding-left: 10px;
}
.search-input-area {
  position: relative; display: flex; align-items: center;
  height: 44px; min-width: 0; width: 100%;
}
.search-input {
  width: 100%; padding: 0 16px; padding-right: 36px;
  border: none; background: transparent; color: var(--text);
  font-size: 15px; font-weight: 400; outline: none;
  height: 44px; line-height: 44px;
}
.search-input::placeholder { color: rgba(154,160,166,0.7); font-weight: 400; font-size: 13px; }
[data-theme="dark"] .search-input { color: var(--text); }
[data-theme="dark"] .search-input::placeholder { color: rgba(148,163,184,0.6); }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--subtext); cursor: pointer;
  padding: 0; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; transition: color .2s, opacity .2s, visibility .2s;
  width: 24px; height: 24px; z-index: 10; outline: none;
  opacity: 0; visibility: hidden;
}
.search-clear.visible { opacity: 1; visibility: visible; }
.search-clear:hover { color: var(--text); }
.search-results-count {
  margin-top: 0.5rem; font-size: 0.85rem; color: var(--subtext);
  text-align: right; padding: 0 0.5rem; display: none;
}
.search-results-count.visible { display: block; }

/* ===== 分类区块 ===== */
main { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem 2rem; min-height: 300px; }
section { margin: 2rem 0; }
section h2 {
  font-size: 1.15rem; font-weight: 700; padding: 0.6rem 1rem;
  margin-bottom: 1rem; border-radius: 8px;
  background: linear-gradient(135deg, rgba(26,115,232,0.08), rgba(26,115,232,0.02));
  color: var(--text); display: flex; align-items: center;
  border-left: 3px solid var(--accent);
}
[data-theme="dark"] section h2 {
  background: linear-gradient(135deg, rgba(91,163,245,0.12), rgba(91,163,245,0.04));
}

/* ===== 链接网格 ===== */
ul {
  list-style: none; display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.85rem; padding: 0; margin: 0; width: 100%;
}
li {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 0.85rem 1rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow .25s, border-color .25s, transform .2s;
  position: relative; overflow: hidden; cursor: pointer;
}
li:hover {
  box-shadow: var(--card-shadow-hover); border-color: var(--accent);
  transform: translateY(-2px);
}
li a {
  color: var(--link); text-decoration: none; font-weight: 600;
  font-size: 1rem; display: flex; align-items: center;
  transition: color .2s; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
li a:hover { color: var(--link-hover); }
.favicon-container {
  width: 24px; height: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-start;
}
body.hide-favicon .favicon-container { display: none; }
.favicon {
  width: 16px; height: 16px; border-radius: 2px;
  opacity: 0; transition: opacity .3s; display: block;
}
.favicon.loaded { opacity: 1; }
.link-text { flex: 1; min-width: 0; word-break: break-word; }
li .url {
  margin-top: 0.5rem; font-size: 0.75rem; color: var(--subtext);
  word-break: break-all; line-height: 1.4; position: relative;
  z-index: 2; opacity: 0.8; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* ===== 加载/错误 ===== */
.loading, .error-message {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 3rem 0;
}
.spinner {
  width: 30px; height: 30px; border: 2px solid rgba(0,0,0,0.1);
  border-radius: 50%; border-top-color: var(--text);
  animation: spin 0.8s linear infinite; margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-message p { color: var(--subtext); font-size: 0.95rem; margin-bottom: 1rem; }
.error-message button {
  background: var(--link); color: white; border: none;
  padding: 0.5rem 1.2rem; border-radius: 6px; font-size: 0.9rem; cursor: pointer;
}
.error-message button:hover { background: var(--link-hover); }

/* ===== 页脚 ===== */
footer {
  text-align: center; padding: 2.5rem 1.5rem;
  font-size: 0.85rem; color: var(--subtext); opacity: 0.5;
}
footer a { color: inherit; text-decoration: none; transition: color .2s; }
footer a:hover { color: var(--link); text-decoration: underline; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
[data-theme="dark"] ::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
html { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.2) rgba(0,0,0,0.05); }
[data-theme="dark"] html { scrollbar-color: rgba(255,255,255,0.25) rgba(255,255,255,0.05); }

/* ===== 响应式 ===== */
@media (max-width: 1199px) { ul { grid-template-columns: repeat(5, 1fr); gap: 0.65rem; } }
@media (max-width: 899px) { ul { grid-template-columns: repeat(4, 1fr); gap: 0.6rem; } }
@media (max-width: 767px) {
  ul { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
  .site-nav-links {
    display: none; position: absolute; top: 48px; left: 0; right: 0;
    background: var(--nav-bg); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--nav-border);
    flex-direction: column; padding: 8px; gap: 0;
  }
  .site-nav-links.open { display: flex; }
  .site-nav-link { padding: 10px 14px; height: auto; line-height: 1.5; border-radius: 6px; }
  .site-nav-toggle { display: flex; }
  .search-container { max-width: 100%; margin-bottom: 1.5rem; }
  .search-box { max-width: calc(100% - 32px); margin: 0 16px 1.5rem; }
  header h1 { font-size: 1.6rem; }
  header .subtitle { font-size: 0.9rem; }
  li { padding: 1rem; }
  #theme-toggle { width: 44px; height: 44px; right: 1.2rem; top: 4.2rem; }
}
@media (max-width: 480px) {
  ul { grid-template-columns: repeat(2, 1fr); gap: 0.48rem; }
  .search-container { margin: 0 1rem 1.5rem; padding: 0; max-width: none; }
  .search-box { max-width: calc(100% - 16px); margin: 0 8px 1rem; height: 40px; }
  .search-icon { padding-left: 8px; }
  .search-input { font-size: 13px; padding: 0 10px; padding-right: 32px; height: 40px; line-height: 40px; }
  .search-input::placeholder { font-size: 12px; }
  li { padding: 0.6rem 0.7rem; }
  li a { font-size: 0.9rem; }
  li .url { font-size: 0.7rem; }
  header { padding: 4.5rem 1rem 1rem; }
  main { padding: 0 1rem 1.5rem; }
}
@media (max-width: 280px) { ul { grid-template-columns: 1fr; gap: 0.36rem; } }