/* ================================================
   css/style.css — 简航导航站样式
   ================================================ */

/* ---------- CSS 自定义属性（亮色主题） ---------- */
:root {
  /* 主色 / 强调色 */
  --accent:          #4f6ef7;
  --accent-hover:    #3a57e8;
  --accent-light:    #eef1fe;
  --accent-text:     #fff;

  /* 页面背景 */
  --bg-page:         #f4f5f9;
  --bg-card:         #ffffff;
  --bg-card-hover:   #fafbff;

  /* 导航条 */
  --nav-bg:          rgba(255, 255, 255, 0.82);
  --nav-border:      rgba(0, 0, 0, 0.07);

  /* 文字色 */
  --text-primary:    #1a1d2e;
  --text-secondary:  #5a6075;
  --text-muted:      #9499ae;

  /* 边框 / 分割线 */
  --border:          #e8eaf0;

  /* 阴影 */
  --shadow-sm:       0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.09);
  --shadow-lg:       0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-card-hover: 0 8px 28px rgba(79, 110, 247, 0.18);

  /* 英雄区遮罩（底部更不透明） */
  --hero-overlay:    linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.40) 0%,
    rgba(255, 255, 255, 0.72) 55%,
    rgba(255, 255, 255, 0.92) 100%
  );

  /* 搜索建议 */
  --suggestion-bg:   #ffffff;
  --suggestion-hover:#f0f3ff;

  /* 页脚 */
  --footer-bg:       #f0f2f8;
  --footer-text:     #9499ae;

  /* 圆角 */
  --radius-card:     14px;
  --radius-pill:     999px;
  --radius-sm:       8px;
}

/* ---------- CSS 自定义属性（深色主题） ---------- */
[data-theme="dark"] {
  --bg-page:         #12131a;
  --bg-card:         #1c1e2b;
  --bg-card-hover:   #22253a;

  --nav-bg:          rgba(18, 19, 26, 0.85);
  --nav-border:      rgba(255, 255, 255, 0.07);

  --text-primary:    #e8eaf6;
  --text-secondary:  #9499c0;
  --text-muted:      #5a5f80;

  --border:          #2a2d42;

  --shadow-sm:       0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg:       0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 8px 28px rgba(79, 110, 247, 0.28);

  --hero-overlay:    linear-gradient(
    to bottom,
    rgba(18, 19, 26, 0.42) 0%,
    rgba(18, 19, 26, 0.72) 55%,
    rgba(18, 19, 26, 0.94) 100%
  );

  --suggestion-bg:   #1c1e2b;
  --suggestion-hover:#272a3e;

  --footer-bg:       #0e0f17;
  --footer-text:     #5a5f80;

  --accent-light:    #1e2245;
}

/* ---------- 全局重置 ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

img {
  display: block;
}

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }

/* ---------- 英雄区 ---------- */
.hero {
  position: relative;
  width: 100%;
  min-height: 340px;
  background-image: url('../images/bg.jpg');
  background-size: cover;
  background-position: center;
  background-color: #c8d4f8; /* 图片未加载时的后备色 */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 渐变遮罩 */
.hero-overlay {
  position: absolute;
  inset: 0;
  background: var(--hero-overlay);
  pointer-events: none;
  transition: background 0.3s;
}

/* 英雄内容层（居中布局） */
.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 720px;
  padding: 40px 20px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Logo 行 */
.hero-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.logo-name {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.logo-sep {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.logo-slogan {
  font-size: 0.95rem;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}

/* 日期与时钟 */
.hero-datetime {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.datetime-sep {
  color: var(--text-muted);
}

/* ---------- 搜索引擎选项卡 ---------- */
.engine-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 640px;
}

.engine-tab {
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  transition: all 0.18s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  white-space: nowrap;
}

[data-theme="dark"] .engine-tab {
  background: rgba(28, 30, 43, 0.6);
}

.engine-tab:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

.engine-tab.active {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- 搜索框 ---------- */
.search-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;
}

.search-box {
  display: flex;
  align-items: center;
  height: 48px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.search-box:focus-within {
  box-shadow: 0 4px 20px rgba(79, 110, 247, 0.22);
  border-color: var(--accent);
}

.search-icon {
  width: 18px;
  height: 18px;
  margin: 0 12px 0 18px;
  color: var(--text-muted);
  flex-shrink: 0;
  pointer-events: none;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: inherit;
  min-width: 0;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  height: 100%;
  padding: 0 22px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: background 0.18s;
  flex-shrink: 0;
}

.search-btn:hover {
  background: var(--accent-hover);
}

/* ---------- 搜索建议下拉 ---------- */
.suggestion-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--suggestion-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 200;
  transition: background 0.3s;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.focused {
  background: var(--suggestion-hover);
}

.suggestion-item svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- 深色模式切换按钮 ---------- */
.theme-toggle {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 10;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s, transform 0.2s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
}

[data-theme="dark"] .theme-toggle {
  background: rgba(28, 30, 43, 0.75);
}

.theme-toggle:hover {
  transform: scale(1.1);
  color: var(--accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* 根据主题显示对应图标 */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: none; }

/* ---------- 吸顶分类导航条 ---------- */
.cat-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--nav-border);
  transition: background 0.3s;
}

.cat-nav-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 1280px;
  margin: 0 auto;
}

.cat-nav-inner::-webkit-scrollbar { display: none; }

.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.cat-pill:hover {
  color: var(--accent);
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.cat-pill.active {
  color: var(--accent);
  background: var(--accent-light);
  border-color: rgba(79, 110, 247, 0.25);
  font-weight: 600;
}

/* ---------- 主内容区 ---------- */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

/* ---------- 分类节 ---------- */
.cat-section {
  scroll-margin-top: 60px; /* 吸顶导航高度补偿 */
}

/* 分类标题 */
.cat-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  flex-shrink: 0;
}

.cat-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.cat-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

/* ---------- 网站卡片网格 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

/* ---------- 单个网站卡片 ---------- */
.site-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 14px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease;
  cursor: pointer;
  overflow: hidden;
}

.site-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  background: var(--bg-card-hover);
}

.site-card:hover .site-icon img,
.site-card:hover .icon-fallback {
  transform: scale(1.08);
}

/* 站点图标区 */
.site-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.site-icon img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  transition: transform 0.22s ease;
}

/* 文字 fallback 图标 */
.icon-fallback {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.22s ease;
  user-select: none;
}

/* 站名 */
.site-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 站点描述 */
.site-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 页脚 ---------- */
.footer {
  background: var(--footer-bg);
  text-align: center;
  padding: 28px 20px;
  color: var(--footer-text);
  font-size: 0.82rem;
  line-height: 2;
  border-top: 1px solid var(--border);
  transition: background 0.3s, color 0.3s;
}

/* ---------- 回到顶部按钮 ---------- */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 300;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.4);
  transition: opacity 0.25s, transform 0.25s, background 0.2s;
  opacity: 1;
}

.back-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-3px);
}

.back-to-top.hidden {
  opacity: 0 !important;
  pointer-events: none;
  display: flex !important; /* 覆盖 .hidden 的 display:none，改用 opacity 隐藏 */
  transform: translateY(10px);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* ---------- 响应式 ---------- */

/* 平板 */
@media (max-width: 768px) {
  .hero-content {
    padding: 32px 16px 28px;
    gap: 12px;
  }

  .logo-name { font-size: 1.45rem; }
  .logo-slogan { font-size: 0.85rem; }

  .main-content {
    padding: 24px 14px 36px;
    gap: 32px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
}

/* 手机 */
@media (max-width: 480px) {
  .hero {
    min-height: 300px;
  }

  .hero-datetime {
    font-size: 0.8rem;
  }

  /* 小屏上时钟部分隐藏（只保留日期） */
  .datetime-sep,
  #clockDisplay {
    display: none;
  }

  .logo-sep,
  .logo-slogan {
    display: none;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .site-card {
    padding: 12px 10px 10px;
  }

  .cat-nav-inner {
    padding: 8px 12px;
  }

  .main-content {
    padding: 18px 12px 28px;
    gap: 28px;
  }
}

/* 超宽屏卡片列数上限 */
@media (min-width: 1400px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  }
}
