/* ── 设计 Token ── */
:root {
  --primary: #0066cc;
  --primary-focus: #0071e3;
  --primary-on-dark: #2997ff;
  --accent-soft: rgba(0, 102, 204, 0.08);
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --muted-dark: #cccccc;
  --ink-muted-80: #333333;
  --ink-muted-48: #7a7a7a;
  --divider: #ececf0;
  --hairline: #dedee4;
  --canvas: #ffffff;
  --parchment: #f7f8fa;
  --pearl: #fafafc;
  --tile-dark: #272729;
  --tile-dark-2: #2a2a2c;
  --black: #000000;
  --top-nav-height: 49px;
  --category-nav-height: 62px;
  --font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", var(--font);
}

[data-accent="0"] {
  --category-accent: #1f6feb;
  --category-accent-soft: rgba(31, 111, 235, 0.08);
  --category-accent-line: rgba(31, 111, 235, 0.28);
}

[data-accent="1"] {
  --category-accent: #0f766e;
  --category-accent-soft: rgba(15, 118, 110, 0.08);
  --category-accent-line: rgba(15, 118, 110, 0.28);
}

[data-accent="2"] {
  --category-accent: #7c3aed;
  --category-accent-soft: rgba(124, 58, 237, 0.08);
  --category-accent-line: rgba(124, 58, 237, 0.28);
}

[data-accent="3"] {
  --category-accent: #b45309;
  --category-accent-soft: rgba(180, 83, 9, 0.08);
  --category-accent-line: rgba(180, 83, 9, 0.28);
}

[data-accent="4"] {
  --category-accent: #475569;
  --category-accent-soft: rgba(71, 85, 105, 0.08);
  --category-accent-line: rgba(71, 85, 105, 0.28);
}

[data-accent="5"] {
  --category-accent: #be123c;
  --category-accent-soft: rgba(190, 18, 60, 0.08);
  --category-accent-line: rgba(190, 18, 60, 0.28);
}

* { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: opacity 0.15s;
}

a:active { opacity: 0.7; }

button, input { font: inherit; }

.container {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
}

main {
  padding-top: var(--category-nav-height);
}

/* ── 导航栏 ── */
.sub-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--divider);
  height: var(--top-nav-height);
  display: flex;
  align-items: center;
}

.sub-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
}

.sub-nav .nav-brand {
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ── Hero 区 ── */
.hero {
  background: var(--canvas);
  border-bottom: 1px solid var(--divider);
  padding: 54px 0 45px;
  text-align: center;
}

.hero h1 {
  font-family: var(--display);
  font-size: clamp(35px, 5vw, 54px);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.1;
  color: var(--ink);
  margin: 0 0 12px;
}

.hero-kicker {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.hero-subtitle {
  color: var(--muted);
  font-size: clamp(16px, 2vw, 21px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.45;
}

.category-nav-shell {
  position: fixed;
  top: var(--top-nav-height);
  left: 0;
  right: 0;
  z-index: 90;
  overflow: hidden;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.18) 42%, rgba(245, 245, 247, 0.34)),
    rgba(245, 245, 247, 0.42);
  border-top: 1px solid rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 0 rgba(255, 255, 255, 0.28),
    0 1px 0 rgba(0, 0, 0, 0.04);
  backdrop-filter: saturate(190%) contrast(106%) blur(28px);
  -webkit-backdrop-filter: saturate(190%) contrast(106%) blur(28px);
}

.category-nav-shell::before {
  content: "";
  position: absolute;
  inset: -55% -10% auto -10%;
  height: 120%;
  pointer-events: none;
  background:
    radial-gradient(70% 90% at 16% 10%, rgba(255, 255, 255, 0.72), transparent 58%),
    radial-gradient(65% 85% at 86% 0%, rgba(255, 255, 255, 0.46), transparent 62%);
  opacity: 0.72;
  transform: translateY(-16%);
}

.category-nav-shell::after {
  content: "";
  position: absolute;
  inset: 1px 0 auto;
  height: 1px;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.76);
}

.category-nav {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 auto;
  max-width: 1120px;
  padding: 10px 0;
}

.category-nav-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--ink);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 400;
  letter-spacing: 0;
  padding: 8px 13px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset 0 -1px 0 rgba(255, 255, 255, 0.16);
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s;
}

.category-nav-chip::after {
  content: "";
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 4px;
  height: 2px;
  border-radius: 999px;
  background: var(--category-accent, var(--primary));
  opacity: 0;
  transform: scaleX(0.35);
  transform-origin: center;
  transition: opacity 0.18s ease, transform 0.24s ease;
}

.category-nav-chip:hover {
  background: rgba(255, 255, 255, 0.38);
  border-color: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

.category-nav-chip.is-active {
  background: var(--category-accent-soft);
  border-color: var(--category-accent-line);
  color: var(--category-accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 5px 14px rgba(0, 0, 0, 0.05);
}

.category-nav-chip.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.category-nav-chip:focus-visible {
  outline: 2px solid var(--category-accent, var(--primary-focus));
  outline-offset: 2px;
}

.category-nav-chip:active {
  transform: translateY(1px);
}

/* ── 通用 Section ── */
.section { padding: 41px 0 50px; }
.section-parchment { background: var(--parchment); }

/* ── 分类网格 ── */
.category-grid { display: flex; flex-direction: column; }

.category {
  scroll-margin-top: calc(var(--top-nav-height) + var(--category-nav-height) + 38px);
  padding: 33px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.category:last-child { border-bottom: none; }

.category h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  margin-bottom: 19px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--divider);
}

.category-title {
  min-width: 0;
}

.category-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.category-icon {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  color: var(--category-accent, var(--primary));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.category-count {
  flex: 0 0 auto;
  border: 1px solid var(--category-accent-line);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--category-accent);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 5px 9px;
}

.category-description {
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0;
  line-height: 1.5;
  margin: -6px 0 19px;
  max-width: 780px;
}

/* ── 网站列表（卡片网格） ── */
.site-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 15px;
}

.site {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 18px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}

.site::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--category-accent-line);
  transition: background 0.18s ease;
}

.site:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 102, 204, 0.24);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.07);
}

.site:hover::before {
  background: var(--category-accent);
}

.site-name {
  display: block;
  min-width: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.24;
  color: var(--ink);
  margin-bottom: 6px;
  transition: color 0.15s;
}

.site-name:hover { color: var(--primary); }

.site-description {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 11px;
  min-height: 45px;
}

.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
}

.site-links a {
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--pearl);
  color: var(--primary);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 8px 12px;
  line-height: 1.05;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.site-links a:hover {
  background: var(--category-accent-soft);
  border-color: var(--category-accent-line);
  color: var(--category-accent);
  opacity: 1;
}

/* ── 空状态 ── */
.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  padding: 50px 0;
}

/* ── 页脚 ── */
.site-footer {
  background: var(--canvas);
  border-top: 1px solid var(--divider);
  padding: 25px 0;
}

.footer-legal {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 19px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ink-muted-48);
}

.footer-legal a {
  color: var(--primary);
  font-size: 13px;
}

/* ── 响应式 ── */
@media (max-width: 1068px) {
  .site-list { grid-template-columns: repeat(2, 1fr); }

  .sub-nav {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .category-nav-shell {
    background: rgba(245, 245, 247, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .category-nav-shell::before { display: none; }
}

@media (max-width: 834px) {
  .nav-links { display: none; }
  .hero, .section { padding: 32px 0; }
  .category { padding: 32px 0; }
  .site-list { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════
   响应式适配 - 平板与手机端
   ══════════════════════════════════════════════════════ */

/* ── 通用适配：防止水平溢出、文字溢出、触摸友好 ── */
html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  word-break: break-word;
  -webkit-text-size-adjust: 100%;
}

img, svg {
  max-width: 100%;
  height: auto;
}

.site-links a {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
}

/* ── 平板端适配（768px - 1024px） ── */
@media (min-width: 768px) and (max-width: 1024px) {
  :root {
    --category-nav-height: 110px;
  }

  main {
    padding-top: var(--category-nav-height);
  }

  /* 卡片网格改为 2 列 */
  .site-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 13px;
  }

  /* 容器左右内边距适当缩小 */
  .container {
    width: min(1440px, calc(100% - 36px));
  }

  /* 导航栏保持单行 */
  .sub-nav .container {
    flex-wrap: nowrap;
  }

  .sub-nav .nav-brand {
    font-size: 18px;
  }

  /* 分类标题适当缩小 */
  .category h2 {
    font-size: 27px;
  }

  /* 区域间距适当减小 */
  .hero {
    padding: 41px 0 35px;
  }

  .category {
    scroll-margin-top: calc(var(--top-nav-height) + var(--category-nav-height) + 26px);
    padding: 29px 0;
  }
}

/* ── 手机端适配（< 768px） ── */
@media (max-width: 767px) {
  :root {
    --top-nav-height: 46px;
    --category-nav-height: 58px;
  }

  main {
    padding-top: var(--category-nav-height);
  }

  /* 整体左右内边距减小到 16px */
  .container {
    width: calc(100% - 32px);
  }

  /* 顶部导航栏字体缩小 */
  .sub-nav {
    height: var(--top-nav-height);
  }

  .sub-nav .nav-brand {
    font-size: 16px;
  }

  /* Hero 区间距缩小 */
  .hero {
    padding: 33px 0 29px;
  }

  .hero h1 {
    font-size: 33px;
    margin-bottom: 11px;
  }

  .hero-subtitle {
    font-size: 16px;
  }

  .category-nav-shell {
    top: var(--top-nav-height);
  }

  .category-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 9px 0;
    scrollbar-width: none;
  }

  .category-nav::-webkit-scrollbar {
    display: none;
  }

  .category-nav-chip {
    flex: 0 0 auto;
  }

  /* 卡片网格改为单列 */
  .site-list {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  /* 分类区域间距调整 */
  .section {
    padding: 25px 0;
  }

  .category {
    scroll-margin-top: calc(var(--top-nav-height) + var(--category-nav-height) + 24px);
    padding: 25px 0;
  }

  .category h2 {
    align-items: flex-start;
    flex-direction: column;
    font-size: 25px;
    gap: 8px;
    margin-bottom: 14px;
  }

  /* 卡片内的链接列表调整间距 */
  .site-links {
    gap: 8px;
  }

  .site-links a {
    padding: 8px 12px;
    font-size: 14.5px;
  }

  /* 卡片内边距适当调整 */
  .site {
    padding: 15px;
  }

  /* 页脚适配 */
  .footer-legal {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  /* 空状态间距 */
  .empty-state {
    padding: 32px 0;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .sub-nav,
  .category-nav-shell {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .category-nav-shell::before { display: none; }
}
