/* =========================================================
   云屿导航 · 糖果撞色拟态样式
   ========================================================= */

:root {
  --bg: #eef1f6;
  --bg-2: #e7ebf3;
  --card: #f0f3f9;
  --card-2: #f5f8fd;
  --text: #2a3050;
  --text-2: #6b7392;
  --text-3: #9aa2bd;
  --line: rgba(255, 255, 255, .7);
  --shadow-dark: rgba(163, 177, 198, .55);
  --shadow-light: rgba(255, 255, 255, .95);
  --out: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
  --out-sm: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  --inset: inset 4px 4px 9px var(--shadow-dark), inset -4px -4px 9px var(--shadow-light);
  --inset-sm: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light);
  --r-card: 24px;
  --r-plate: 16px;
  --accent: #6c8cff;
  --accent-2: #ff7f9c;
  --radius: 999px;
  --font: "LXGW WenKai", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #1a1d27;
  --bg-2: #171a23;
  --card: #222633;
  --card-2: #262b3a;
  --text: #e8ebf5;
  --text-2: #9aa3c0;
  --text-3: #737c99;
  --line: rgba(255, 255, 255, .06);
  --shadow-dark: rgba(0, 0, 0, .55);
  --shadow-light: rgba(96, 108, 148, .30);
  --accent: #8aa4ff;
  --accent-2: #ff92ad;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  overflow-x: clip; /* 根级兜底：任何后代都不能产生横向滚动 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
  /* hidden 兜底旧内核；clip 更强（真正裁剪、不可滚动），且不会破坏 sticky 定位 */
  overflow-x: hidden;
  overflow-x: clip;
  /* 任何超长连续字符串（长英文/URL）都换行，杜绝撑破布局 */
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
  /* iOS 聚焦时不整体缩放 */
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

.wrap {
  width: min(1180px, 92vw);
  margin-inline: auto;
}

/* ---------- 背景装饰 ---------- */
.blobs {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .55;
  will-change: transform;
}
[data-theme="dark"] .blob { opacity: .30; filter: blur(80px); }
.b1 { width: 420px; height: 420px; left: -120px; top: -80px;  background: #a7f3d0; animation: drift1 26s ease-in-out infinite; }
.b2 { width: 380px; height: 380px; right: -100px; top: 40px;  background: #fbcfe8; animation: drift2 32s ease-in-out infinite; }
.b3 { width: 340px; height: 340px; left: 15%; bottom: -140px; background: #bfdbfe; animation: drift3 29s ease-in-out infinite; }
.b4 { width: 300px; height: 300px; right: 18%; bottom: -60px; background: #fde68a; animation: drift1 35s ease-in-out infinite reverse; }
.b5 { width: 260px; height: 260px; left: 45%; top: 26%; background: #ddd6fe; animation: drift2 24s ease-in-out infinite; }

@keyframes drift1 { 50% { transform: translate(60px, 50px) scale(1.12); } }
@keyframes drift2 { 50% { transform: translate(-50px, 70px) scale(1.08); } }
@keyframes drift3 { 50% { transform: translate(70px, -40px) scale(1.15); } }

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}
[data-theme="dark"] .grain { opacity: .16; }

/* ---------- 通用拟态件 ---------- */
.neu-card {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--out);
}
.neu-inset {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--inset);
}
.neu-btn {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--out-sm);
  transition: box-shadow .2s ease, transform .15s ease;
}
.neu-btn:hover { transform: translateY(-1px); }
.neu-btn:active { box-shadow: var(--inset-sm); transform: translateY(0); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 14px 0 6px;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
/* grid/flex 子项默认 min-width:auto，字体变宽后会拒绝收缩而撑破布局，这里显式允许收缩 */
.topbar-inner > * { min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, #6c8cff, #a678ff 55%, #ff7f9c);
  box-shadow: var(--out-sm);
  flex: none;
}
.brand-logo {
  display: block;
  width: 40px; height: 40px;
  flex: none;
}
.brand-logo img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--out-sm);
  display: block;
}
.brand-logo .brand-mark { display: none; }
.brand-name {
  font-size: 19px; font-weight: 700; letter-spacing: .5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions { display: flex; gap: 10px; }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
}
.icon-btn svg { display: block; }
[data-theme="light"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 34px;
  align-items: start;
  padding: 46px 0 26px;
}
/* grid 子项默认 min-width:auto —— 字体加载后会撑破列宽，显式设 0 */
.hero > * { min-width: 0; }
.hero-title {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.18;
  letter-spacing: 1px;
  font-weight: 800;
}
.grad-text {
  background: linear-gradient(100deg, #ff7f9c, #ffb45c 30%, #3ec9a7 62%, #6c8cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 0 0 26px; color: var(--text-2); font-size: 16px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  color: var(--text-3);
  max-width: 520px;
}
.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15.5px;
  font-family: inherit;
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-3); }
.search-box input::-webkit-search-cancel-button { display: none; }
.clear-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--out-sm);
  color: var(--text-2);
  line-height: 1;
}

.notice {
  margin-top: 18px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-2);
  border-radius: 18px;
}
.notice-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ff7f9c;
  box-shadow: 0 0 0 4px rgba(255, 127, 156, .22);
  flex: none;
}

.hero-side { display: grid; gap: 16px; min-width: 0; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stats-row > * { min-width: 0; }
.stat {
  padding: 16px 10px;
  text-align: center;
  border-radius: 20px;
  overflow: hidden;
}
.stat b {
  display: block;
  font-size: 24px;
  font-family: var(--mono);
  letter-spacing: .5px;
  background: linear-gradient(120deg, #6c8cff, #a678ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat span { font-size: 12.5px; color: var(--text-3); }

.hot { padding: 18px 18px 12px; }
.hot-title {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.hot-list { list-style: none; margin: 0; padding: 0; }
.hot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  transition: background .2s ease, transform .15s ease;
}
.hot-item:hover { background: var(--card-2); transform: translateX(3px); }
.hot-name { flex: 1; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot-num { font-size: 12px; font-family: var(--mono); color: var(--text-3); }

/* ---------- 分类胶囊 ---------- */
.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 0 30px;
  position: sticky;
  top: 66px;
  z-index: 30;
  background: linear-gradient(to bottom, var(--bg) 72%, transparent);
  padding-bottom: 20px;
}
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 14px;
  color: var(--text-2);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--out-sm);
  transition: all .22s cubic-bezier(.16, 1, .3, 1);
}
.cat-pill:hover { transform: translateY(-2px); color: var(--text); }
.cat-pill.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #a678ff);
  box-shadow: 5px 5px 14px color-mix(in srgb, var(--accent) 38%, transparent), -4px -4px 12px var(--shadow-light);
}

/* ---------- 分区与卡片 ---------- */
.cat-section { margin-bottom: 42px; }
.sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
}
.sec-head h2 { margin: 0; font-size: 19px; letter-spacing: 1px; }
.sec-count {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
  padding: 2px 9px;
  border-radius: var(--radius);
  box-shadow: var(--inset-sm);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 22px;
}
.grid > * { min-width: 0; }

.link-card {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 18px;
  transition: transform .28s cubic-bezier(.16, 1, .3, 1), box-shadow .28s ease;
  will-change: transform;
}
.link-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(140deg, rgba(255, 255, 255, .55), transparent 45%);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.link-card:hover {
  transform: translateY(-6px);
  box-shadow: 12px 12px 26px var(--shadow-dark), -10px -10px 22px var(--shadow-light);
}
.link-card:hover::after { opacity: 1; }
.link-card:active { transform: translateY(-2px); }
.link-card.is-hidden { display: none; }

.card-body { flex: 1; min-width: 0; }
.card-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card-top > * { min-width: 0; }
.card-top h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-hot {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
  padding: 2px 7px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #ff7f9c, #ffb45c);
  transform: translateY(-2px);
  flex: none;
}
.card-clicks {
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--text-3);
  flex: none;
}
.card-body p {
  margin: 5px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  box-shadow: var(--inset-sm);
}

.card-arrow {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-3);
  box-shadow: var(--out-sm);
  background: var(--card);
  opacity: 0;
  transform: translate(4px, 4px);
  transition: all .25s ease;
}
.link-card:hover .card-arrow {
  opacity: 1;
  transform: translate(0, 0);
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #a678ff);
}

/* ---------- 图标底板 ---------- */
.icon-plate {
  position: relative;
  flex: none;
  width: 56px; height: 56px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--c1), var(--c2));
  box-shadow: 4px 4px 12px color-mix(in srgb, var(--c2) 34%, transparent), -3px -3px 10px var(--shadow-light);
  overflow: hidden;
}
.icon-plate img {
  width: 30px; height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .18));
}
.icon-plate.is-fallback .icon-letter { display: block; }
.icon-letter {
  display: none;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.icon-emoji { font-size: 28px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .15)); }
.icon-plate.sm { width: 38px; height: 38px; border-radius: 12px; }
.icon-plate.sm img { width: 21px; height: 21px; }
.icon-plate.sm .icon-emoji { font-size: 19px; }
.icon-plate.sm .icon-letter { font-size: 17px; }
.icon-plate.tiny { width: 22px; height: 22px; border-radius: 7px; box-shadow: none; }
.icon-plate.tiny .icon-letter { display: none; }
.icon-plate.tiny .icon-emoji { font-size: 16px; }
.icon-plate.tiny img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; filter: none; }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  margin-bottom: 40px;
  color: var(--text-2);
}
.empty-face { font-size: 44px; margin-bottom: 6px; }
.empty-state p { margin: 0 0 18px; }
.empty-state .neu-btn { padding: 10px 22px; font-size: 14px; }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 20px;
  padding: 26px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 13px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.footer-left { display: flex; gap: 14px; flex-wrap: wrap; }
.footer a:hover { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  padding: 11px 22px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--out);
  font-size: 14px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: all .3s cubic-bezier(.16, 1, .3, 1);
  z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 入场动画 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .hero-text > *, .hero-side > *, .cat-pill, .link-card {
    animation: rise .6s cubic-bezier(.16, 1, .3, 1) both;
  }
  .hero-side > * { animation-delay: .1s; }
  .grid .link-card:nth-child(2n) { animation-delay: .05s; }
  .grid .link-card:nth-child(3n) { animation-delay: .1s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 20px; padding-top: 26px; }
  .cats { top: 60px; }
}

/* ---- 平板及以下：整体收紧 ---- */
@media (max-width: 768px) {
  .wrap { width: min(100% - 28px, 1180px); }

  /* 顶栏：去掉昂贵的 backdrop-filter，改纯色半透明 */
  .topbar {
    padding: 10px 0 4px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
  }
  .brand-mark, .brand-logo { width: 36px; height: 36px; }
  .brand-logo img { border-radius: 12px; }
  .brand-name { font-size: 17px; }
  .icon-btn { width: 38px; height: 38px; }

  /* Hero：压缩，让卡片尽快进入首屏 */
  .hero { padding: 18px 0 12px; gap: 16px; }
  .hero-title { font-size: clamp(26px, 7vw, 34px); margin-bottom: 8px; }
  .hero-sub { font-size: 14px; margin-bottom: 16px; }
  .search-box { padding: 11px 16px; max-width: none; }
  .search-box input { font-size: 16px; } /* 16px 防 iOS 聚焦缩放 */
  .notice { margin-top: 12px; padding: 10px 14px; font-size: 13px; }

  /* 热门直达在手机上与下方卡片重复，直接隐藏，节省大量纵向空间 */
  .hero-side .hot { display: none; }
  .stats-row { gap: 8px; }
  .stat { padding: 10px 8px; border-radius: 16px; }
  .stat b { font-size: 18px; }
  .stat span { font-size: 11px; }

  /* 分类：横向滚动，不再换行占掉半屏 */
  .cats {
    top: 52px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 9px;
    padding: 10px 0 14px;
    margin-inline: -14px;
    padding-inline: 14px;
    scroll-snap-type: x proximity;
  }
  .cats::-webkit-scrollbar { display: none; }
  .cat-pill {
    flex: none;
    padding: 8px 15px;
    font-size: 13.5px;
    scroll-snap-align: start;
    min-height: 40px; /* 触控目标 */
  }
  .icon-btn { width: 40px; height: 40px; } /* 触控目标 */

  /* 卡片：更紧凑，一屏能多看好几个 */
  .cat-section { margin-bottom: 26px; }
  .sec-head { margin-bottom: 12px; }
  .sec-head h2 { font-size: 17px; }
  .grid { gap: 12px; }
  .link-card { padding: 13px; gap: 11px; border-radius: 20px; }
  .link-card:hover { transform: none; box-shadow: var(--out); }
  .card-top h3 { font-size: 15px; }
  .card-body p { font-size: 12.5px; min-height: 0; -webkit-line-clamp: 1; margin-top: 3px; }
  .tags { margin-top: 7px; gap: 5px; }
  .tag { font-size: 10.5px; padding: 2px 8px; }
  .card-clicks { font-size: 11px; }
  .card-arrow { display: none; } /* 触屏无 hover，箭头无意义 */
  .icon-plate { width: 50px; height: 50px; border-radius: 15px; }
  .icon-plate img { width: 27px; height: 27px; }
  .icon-emoji { font-size: 25px; }
  .icon-letter { font-size: 21px; }

  .footer { padding: 20px 0 calc(24px + env(safe-area-inset-bottom)); }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ---- 手机竖屏 ---- */
@media (max-width: 480px) {
  .wrap { width: min(100% - 20px, 1180px); }
  /* .wrap 侧边距为 10px，分类条全出血负边距需同步，否则左右各溢出 4px */
  .cats { margin-inline: -10px; padding-inline: 10px; }
  .hero-title { font-size: 25px; }
  .hero-sub { font-size: 13px; }
  .stat b { font-size: 16px; }
  .stat span { font-size: 10.5px; }
  .link-card { padding: 12px; gap: 10px; }
  .grid { gap: 10px; }
  .cat-pill { padding: 7px 13px; font-size: 13px; }
  .empty-state { padding: 40px 18px; }
  .toast { left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateY(20px); text-align: center; }
  .toast.show { transform: translateY(0); }
}

/* ---- 低端机/省电：关闭装饰性模糊与动画 ---- */
@media (max-width: 768px) {
  .blob { filter: blur(38px); opacity: .42; }
  [data-theme="dark"] .blob { filter: blur(44px); opacity: .24; }
  .b5 { display: none; } /* 少一个光斑，省一次大面积模糊合成 */
  .grain { opacity: .22; }
}

/* ---- 触屏设备：去掉依赖 hover 的反馈 ---- */
@media (hover: none) and (pointer: coarse) {
  .link-card:hover { transform: none; }
  .hot-item:hover { transform: none; }
  .neu-btn:hover, .cat-pill:hover, .tab:hover, .btn.primary:hover { transform: none; }
  .card-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .blob { animation: none !important; }
}

@media print {
  .no-print, .blobs, .grain, .cats, .card-arrow, .toast { display: none !important; }
  body { background: #fff; }
  .neu-card, .neu-inset { box-shadow: none; border: 1px solid #eee; }
}
