/* ============================================================
   Navigator — css/style.css
   苹果风格多端自适应导航网站
   ============================================================ */

/* ── CSS 变量（浅色主题） ── */
:root {
  --bg-primary:    #f5f5f7;
  --bg-secondary:  #ffffff;
  --bg-card:       rgba(255, 255, 255, 0.82);
  --bg-nav:        rgba(245, 245, 247, 0.88);

  --text-primary:   #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary:  #aeaeb2;

  --border:      rgba(0, 0, 0, 0.08);
  --border-card: rgba(0, 0, 0, 0.06);

  --shadow-sm:    0 2px 8px  rgba(0, 0, 0, 0.06);
  --shadow-md:    0 4px 24px rgba(0, 0, 0, 0.09);
  --shadow-hover: 0 10px 40px rgba(0, 0, 0, 0.13);

  --accent:       #0071e3;
  --radius-sm:    10px;
  --radius-md:    16px;

  --font: -apple-system, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", Arial, sans-serif;
  --ease:     cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --t-fast:   0.18s;
  --t-med:    0.30s;

  --nav-h:      60px;
  --sidebar-w:  220px;
}

/* ── 深色主题 ── */
[data-theme="dark"] {
  --bg-primary:    #000000;
  --bg-secondary:  #1c1c1e;
  --bg-card:       rgba(28, 28, 30, 0.82);
  --bg-nav:        rgba(0, 0, 0, 0.88);

  --text-primary:   #f5f5f7;
  --text-secondary: #98989d;
  --text-tertiary:  #636366;

  --border:      rgba(255, 255, 255, 0.10);
  --border-card: rgba(255, 255, 255, 0.07);

  --shadow-sm:    0 2px 8px  rgba(0, 0, 0, 0.40);
  --shadow-md:    0 4px 24px rgba(0, 0, 0, 0.50);
  --shadow-hover: 0 10px 40px rgba(0, 0, 0, 0.60);
}

/* 跟随系统深色模式 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary:    #000000;
    --bg-secondary:  #1c1c1e;
    --bg-card:       rgba(28, 28, 30, 0.82);
    --bg-nav:        rgba(0, 0, 0, 0.88);
    --text-primary:   #f5f5f7;
    --text-secondary: #98989d;
    --text-tertiary:  #636366;
    --border:      rgba(255, 255, 255, 0.10);
    --border-card: rgba(255, 255, 255, 0.07);
    --shadow-sm:    0 2px 8px  rgba(0, 0, 0, 0.40);
    --shadow-md:    0 4px 24px rgba(0, 0, 0, 0.50);
    --shadow-hover: 0 10px 40px rgba(0, 0, 0, 0.60);
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease);
}
a { text-decoration: none; color: inherit; }

/* ══════════════════════════════════════════
   顶部导航栏
══════════════════════════════════════════ */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex; align-items: center;
  padding: 0 20px; gap: 14px;
  transition: background var(--t-med) var(--ease);
}

.navbar-logo {
  display: flex; align-items: center; gap: 9px;
  font-size: 18px; font-weight: 700; letter-spacing: -.4px;
  color: var(--text-primary); flex-shrink: 0;
}
.logo-icon {
  width: 30px; height: 30px; background: var(--accent);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 14px; color: #fff; font-weight: 800;
}

/* 搜索框 */
.navbar-search { flex: 1; max-width: 460px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ico {
  position: absolute; left: 11px;
  color: var(--text-tertiary); pointer-events: none; z-index: 1;
  display: flex; align-items: center;
}
#searchInput {
  width: 100%; height: 34px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 0 32px 0 34px;
  font-family: var(--font); font-size: 13.5px;
  color: var(--text-primary); outline: none;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow   var(--t-fast) var(--ease),
              background   var(--t-med)  var(--ease);
}
#searchInput::placeholder { color: var(--text-tertiary); }
#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, .14);
}
.search-clear {
  position: absolute; right: 9px;
  background: var(--text-tertiary); border: none; border-radius: 50%;
  width: 15px; height: 15px; cursor: pointer;
  color: var(--bg-secondary); font-size: 9px;
  display: none; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.search-clear:hover { background: var(--text-secondary); }
.search-clear.on { display: flex; }

/* 右侧控件 */
.navbar-right { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-secondary);
  transition: background var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--border); color: var(--text-primary); transform: scale(1.08); }
.icon-btn:active { transform: scale(.93); }

/* 汉堡菜单（仅移动端显示） */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  cursor: pointer; padding: 6px; border-radius: 8px;
  background: transparent; border: none;
  transition: background var(--t-fast);
}
.hamburger:hover { background: var(--border); }
.hamburger span {
  display: block; width: 19px; height: 2px;
  background: var(--text-primary); border-radius: 2px;
  transition: all var(--t-med) var(--ease);
}
.hamburger.on span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.on span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.on span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ══════════════════════════════════════════
   布局
══════════════════════════════════════════ */
.layout {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* ══════════════════════════════════════════
   侧边栏
══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: var(--nav-h); left: 0; bottom: 0;
  overflow-y: auto; padding: 16px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: 900; scrollbar-width: none;
  transition: transform var(--t-med) var(--ease),
              background var(--t-med) var(--ease);
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-tertiary);
  padding: 6px 12px 4px; margin-top: 6px;
}
.sidebar-nav { list-style: none; }
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sidebar-item:hover  { background: var(--border); color: var(--text-primary); }
.sidebar-item.active { background: rgba(0, 113, 227, .10); color: var(--accent); }
.sidebar-item-icon   { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-item-count  {
  margin-left: auto; background: var(--border);
  color: var(--text-tertiary); font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 20px;
}
.sidebar-item.active .sidebar-item-count {
  background: rgba(0, 113, 227, .15); color: var(--accent);
}

/* ══════════════════════════════════════════
   主内容区
══════════════════════════════════════════ */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 28px 64px;
  transition: margin var(--t-med) var(--ease);
}

/* ── Hero ── */
.hero { text-align: center; padding: 40px 20px 32px; }
.hero-title {
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 700; letter-spacing: -1.2px; line-height: 1.1;
  margin-bottom: 10px; color: var(--text-primary);
}
.hero-title span {
  background: linear-gradient(135deg, var(--accent) 0%, #bf5af2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { font-size: 16px; color: var(--text-secondary); }

/* ── 分类区块 ── */
.cat-section {
  margin-bottom: 44px;
  animation: fadeUp .4s var(--ease) both;
}
.cat-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.cat-icon-wrap {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cat-name  { font-size: 19px; font-weight: 700; letter-spacing: -.4px; }
.cat-count { margin-left: auto; font-size: 12.5px; color: var(--text-tertiary); font-weight: 500; }

/* ── 卡片网格 ── */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 13px;
}

/* ── 链接卡片 ── */
.link-card {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 18px 15px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  /* iOS 点击修复 */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform    var(--t-fast) var(--ease),
              box-shadow   var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background   var(--t-med)  var(--ease);
  animation: cardIn .35s var(--ease) both;
}
.link-card:hover {
  transform: translateY(-3px) scale(1.015);
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
}
.link-card:active { transform: translateY(-1px) scale(.985); box-shadow: var(--shadow-md); }

.card-emoji { font-size: 22px; margin-bottom: 9px; display: block; line-height: 1; }
.card-name  { font-size: 14.5px; font-weight: 600; letter-spacing: -.2px; margin-bottom: 4px; }
.card-desc  { font-size: 11.5px; color: var(--text-secondary); line-height: 1.4; flex: 1; }
.card-arrow {
  font-size: 11.5px; color: var(--text-tertiary);
  margin-top: 9px; font-weight: 500;
  transition: color var(--t-fast), letter-spacing var(--t-fast);
}
.link-card:hover .card-arrow { color: var(--accent); letter-spacing: .2px; }

/* ── 搜索结果 ── */
#searchResults { display: none; }
#searchResults.on { display: block; }
.result-count {
  font-size: 12.5px; color: var(--text-secondary);
  padding: 2px 0 18px; font-weight: 500;
}
.search-empty { text-align: center; padding: 56px 20px; color: var(--text-secondary); }
.search-empty-icon { font-size: 44px; margin-bottom: 14px; opacity: .45; }
.search-empty h3 { font-size: 17px; font-weight: 600; margin-bottom: 7px; color: var(--text-primary); }
mark { background: rgba(0, 113, 227, .15); color: var(--accent); border-radius: 3px; padding: 0 1px; }

/* ── Footer ── */
.footer {
  text-align: center; padding: 20px;
  font-size: 11.5px; color: var(--text-tertiary);
  border-top: 1px solid var(--border); margin-top: 12px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px;
}
.footer-info { flex: 1; min-width: auto; }
.footer code {
  font-size: 11px; background: var(--border);
  padding: 1px 5px; border-radius: 4px;
}

/* ── 加载速度显示 ── */
.load-time {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  padding: 4px 8px; border-radius: 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: all var(--t-fast) var(--ease);
  opacity: 0;
  animation: fadeInScale .5s var(--ease) .2s both;
}

.load-time.super-fast {
  background: rgba(52, 211, 153, 0.10);
  color: #10b981;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.20);
}
.load-time.fast {
  background: rgba(59, 130, 246, 0.10);
  color: #3b82f6;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.20);
}
.load-time.normal {
  background: rgba(168, 85, 247, 0.10);
  color: #a855f7;
  box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.20);
}
.load-time.slow {
  background: rgba(249, 115, 22, 0.10);
  color: #f97316;
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.20);
}
.load-time.very-slow {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.20);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── 遮罩层 ── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 850;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;   /* 关闭状态完全穿透，不拦截点击 */
  transition: opacity var(--t-med) var(--ease);
}
.overlay.on { opacity: 1; pointer-events: auto; }

/* ── 返回顶部 ── */
#scrollTop {
  position: fixed; bottom: 24px; right: 24px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--text-secondary);
  opacity: 0; pointer-events: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  z-index: 500;
  transition: opacity var(--t-med), transform var(--t-fast),
              background var(--t-fast), color var(--t-fast);
}
#scrollTop.on { opacity: 1; pointer-events: auto; }
#scrollTop:hover { transform: translateY(-2px); background: var(--accent); color: #fff; border-color: var(--accent); }
#scrollTop:active { transform: none; }

/* ── 骨架屏 ── */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 13px; margin-bottom: 44px;
}
.skeleton-card {
  height: 115px; border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--border) 0%, var(--bg-secondary) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

/* ── 动画 ── */
@keyframes fadeUp  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes cardIn  { from { opacity: 0; transform: scale(.96); }       to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 入场延迟 */
.cat-section:nth-child(1) { animation-delay: .04s; }
.cat-section:nth-child(2) { animation-delay: .09s; }
.cat-section:nth-child(3) { animation-delay: .14s; }
.cat-section:nth-child(4) { animation-delay: .19s; }
.cat-section:nth-child(5) { animation-delay: .24s; }
.cat-section:nth-child(6) { animation-delay: .29s; }

/* ══════════════════════════════════════════
   响应式断点
══════════════════════════════════════════ */

/* 平板 */
@media (max-width: 1024px) {
  :root { --sidebar-w: 190px; }
  .main { padding: 22px 22px 52px; }
  .links-grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
}

/* 手机 */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    width: 250px;
    box-shadow: var(--shadow-hover);
  }
  .sidebar.on { transform: translateX(0); }
  .overlay { display: block; pointer-events: none; } /* 展示但不拦截 */
  .main { margin-left: 0; padding: 18px 15px 52px; }
  .navbar-search { max-width: none; }
  .logo-text { display: none; }
  .links-grid { grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 10px; }
  #scrollTop { bottom: 18px; right: 14px; }
}

/* 小屏手机 */
@media (max-width: 480px) {
  .links-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .navbar { padding: 0 14px; gap: 10px; }
}

/* 超小屏 */
@media (max-width: 360px) {
  .links-grid { grid-template-columns: 1fr; }
}

/* 大屏 */
@media (min-width: 1400px) {
  .links-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

/* ══════════════════════════════════════════
   弹窗 (Modal)
══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1500;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease);
}
.modal-overlay.show { display: block; opacity: 1; pointer-events: auto; }

.modal {
  display: none;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  z-index: 1600;
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn .3s var(--ease);
}
.modal.show { display: block; }

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%) scale(.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px;
  background: transparent; border: none;
  cursor: pointer; font-size: 18px;
  color: var(--text-secondary);
  transition: color var(--t-fast);
  z-index: 10;
}
.modal-close:hover { color: var(--text-primary); }

.modal-content {
  padding: 28px 24px;
}

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

.modal-header h2 {
  font-size: 20px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 6px;
}

.modal-header p {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
}

.modal-body {
  margin-bottom: 20px;
  text-align: center;
}

.modal-qrcode {
  display: inline-block; margin-bottom: 16px;
  padding: 12px; border-radius: 12px;
  background: var(--border);
  min-width: 120px; min-height: 120px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-secondary);
}

.modal-qrcode img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
}

.modal-info {
  padding: 12px 16px;
  background: rgba(0, 113, 227, .08);
  border-radius: 10px;
  border: 1px solid rgba(0, 113, 227, .15);
}

.modal-info p {
  font-size: 13px; color: var(--text-primary);
  margin: 6px 0; line-height: 1.5;
}

.modal-footer {
  display: flex; gap: 10px;
}

.btn {
  flex: 1; padding: 10px 16px;
  border: none; border-radius: 9px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent); color: #ffffff;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 113, 227, .3); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--border); color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border-card); }
.btn-secondary:active { transform: scale(.98); }

/* 小屏适配 */
@media (max-width: 480px) {
  .modal {
    width: 95%;
    max-width: 360px;
  }
  .modal-content {
    padding: 20px 16px;
  }
  .modal-header h2 {
    font-size: 18px;
  }
}
