/* ============================================================
 * styles.css  ——  全局样式系统（基于主题 token，零颜色字面量）
 *   - 所有颜色必须用 var(--color-*)、box-shadow 用 var(--shadow-*)
 *   - 2 列网格（PC 也 2 列，唯一断点 max-width:539px）
 * ============================================================ */

/* ---------- 1. 基础重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
/* [hidden] 始终胜出 class 的 display 规则（修复搜索弹窗/移动菜单的初始可见 bug） */
[hidden] { display: none !important; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video, canvas { max-width: 100%; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
ul, ol { padding-left: 1.2em; margin: 0.5em 0; }
h1, h2, h3, h4 { font-family: 'Fredoka One', system-ui, sans-serif; font-weight: 400; line-height: 1.2; margin: 0.5em 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0.6em 0; }

/* ---------- 2. Layout ---------- */
.nav { position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height); z-index: 100;
  background: var(--nav-gradient); border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  transition: transform .25s ease; backdrop-filter: saturate(160%) blur(6px);
}
.nav--hidden { transform: translateY(-100%); }
.nav__logo { font-family: 'Fredoka One', system-ui, sans-serif; font-size: 1.3rem;
  color: var(--color-primary); display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.nav__logo img { width: 28px; height: 28px; }
.nav__logo:hover { text-decoration: none; transform: scale(1.03); transition: transform .15s; }

/* 顶导航: 只有 logo + 搜索 + 汉堡。横向菜单 / popup 都已删除(§2.4.1 抽屉模式) */
.nav__actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.nav__search-btn, .nav__hamburger {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  display: grid; place-items: center; color: var(--color-text); font-size: 1.2rem;
}
.nav__search-btn:hover, .nav__hamburger:hover { background: var(--color-border); }
.nav__hamburger { display: grid; }

/* ===== 抽屉(Drawer) — §2.4.1 唯一导航模式 ===== */
.nav-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 500;
  width: min(85vw, 320px);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow-y: auto; overscroll-behavior: contain;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-drawer--open { transform: translateX(0); }
.nav-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--color-border);
  background: var(--hero-gradient); color: var(--color-surface);
}
.nav-drawer__title { font-family: 'Fredoka One', system-ui, sans-serif; font-size: 1.2rem; }
.nav-drawer__close {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  display: grid; place-items: center; color: var(--color-surface); font-size: 1.4rem;
  background: rgba(255,255,255,.18);
}
.nav-drawer__close:hover { background: rgba(255,255,255,.32); }
.nav-drawer__body { flex: 1; padding: 8px 0; }
.nav-drawer__group { padding: 8px 0 4px; border-bottom: 1px solid var(--color-border); }
.nav-drawer__group:last-child { border-bottom: 0; }
.nav-drawer__heading {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  color: var(--color-text-soft); padding: 8px 20px 4px;
}
.nav-drawer__item {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 10px 20px;
  color: var(--color-text); font-weight: 600; font-size: .98rem;
  border-left: 3px solid transparent;
}
.nav-drawer__item:hover { background: var(--color-bg); border-left-color: var(--color-primary); text-decoration: none; }
.nav-drawer__item[aria-current="page"] { background: var(--color-bg); border-left-color: var(--color-primary); color: var(--color-primary); }
.nav-drawer__item--sub { padding-left: 32px; font-size: .92rem; }
.nav-drawer__foot {
  padding: 14px 20px; border-top: 1px solid var(--color-border);
  color: var(--color-text-soft); font-size: .8rem; text-align: center;
}
/* 遮罩 */
.nav-drawer__scrim {
  position: fixed; inset: 0; background: var(--color-overlay); z-index: 400;
  opacity: 0; transition: opacity 280ms ease;
}
.nav-drawer__scrim--show { opacity: 1; }
/* 抽屉打开时锁滚动 */
body.nav-drawer-open { overflow: hidden; }

/* 移动端底部 Tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-height);
  background: var(--color-surface); border-top: 1px solid var(--color-border);
  display: flex; z-index: 90; padding-bottom: env(safe-area-inset-bottom, 0); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--color-text-soft); font-size: .72rem; font-weight: 700; }
.tabbar a:hover, .tabbar a[aria-current="page"] { color: var(--color-primary); text-decoration: none; }
.tabbar a span:first-child { font-size: 1.3rem; }

/* 主内容容器 */
main { padding: calc(var(--nav-height) + 16px) 16px 90px; max-width: 100%; }
main.no-tabbar { padding-bottom: 24px; }

/* ---------- 3. Hero ---------- */
.hero { background: var(--hero-gradient); border-radius: var(--radius-lg);
  padding: 28px 22px; color: var(--color-surface); margin-bottom: 24px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-pop); }
.hero h1 { color: var(--color-surface); font-size: 1.8rem; margin: 0 0 6px; }
.hero p { margin: 0; opacity: .95; }
.hero__decor { position: absolute; right: -16px; top: -16px; font-size: 5rem; opacity: .35;
  animation: floaty 4s ease-in-out infinite; }
@keyframes floaty { 0%,100%{ transform: translateY(0) rotate(0); } 50%{ transform: translateY(-12px) rotate(8deg); } }
.hero__decor2 { position: absolute; left: -10px; bottom: -10px; font-size: 3rem; opacity: .35;
  animation: floaty 4s ease-in-out infinite reverse; }
.hero__cta { display: inline-block; margin-top: 14px; padding: 10px 22px;
  background: var(--color-surface); color: var(--color-primary); border-radius: var(--radius-pill);
  font-weight: 800; box-shadow: var(--shadow-card); }
.hero__cta:hover { transform: translateY(-2px); text-decoration: none; transition: transform .15s; }

/* ---------- 4. Grid & Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  gap: var(--grid-gap); }
.card { display: block; background: var(--color-surface); border-radius: var(--radius-md);
  overflow: hidden; border: 1px solid var(--color-border); box-shadow: var(--shadow-card);
  transition: transform .2s, box-shadow .2s; color: var(--color-text); }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-pop); text-decoration: none; }
.card__thumb { position: relative; aspect-ratio: 1/1; background: var(--color-bg); overflow: hidden; }
.card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.card__cat { position: absolute; top: 8px; left: 8px; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--color-primary); color: var(--color-surface); font-size: .7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px; }
.card__body { padding: 10px 12px 12px; }
.card__title { font-family: 'Fredoka One', system-ui, sans-serif; font-size: 1rem; margin: 0 0 4px;
  color: var(--color-text); }
.card__meta { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--color-text-soft); }
.card__stars { color: var(--color-accent); letter-spacing: -1px; }
.card__star--empty { color: var(--color-border); }
.card__rating { font-weight: 800; color: var(--color-text); }
.card__stats { display: flex; justify-content: space-between; margin-top: 4px;
  font-size: .75rem; color: var(--color-text-soft); }
.card--sm .card__title { font-size: .92rem; }

/* 评分 */
.star { color: var(--color-accent); }
.star--empty { color: var(--color-border); }
.star--half  { background: linear-gradient(90deg, var(--color-accent) 50%, var(--color-border) 50%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }

/* 分类胶囊 */
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px;
  scrollbar-width: none; -ms-overflow-style: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { padding: 8px 16px; border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); font-weight: 700; font-size: .9rem; white-space: nowrap; }
.pill:hover { background: var(--color-bg); text-decoration: none; }
.pill--active { background: var(--color-primary); color: var(--color-surface); border-color: var(--color-primary); }

/* Section 标题 */
.section { margin: 28px 0 14px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section__head h2 { font-size: 1.4rem; margin: 0; }
.section__head a { font-size: .9rem; font-weight: 700; }

/* ---------- 5. Detail page ---------- */
.detail { display: grid; grid-template-columns: 1fr; gap: 18px; }
.detail__hero { background: var(--hero-gradient); border-radius: var(--radius-lg);
  padding: 24px; color: var(--color-surface); display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center; }
.detail__hero img { width: 120px; height: 120px; border-radius: var(--radius-md); background: var(--color-surface); padding: 8px; }
.detail__hero h1 { color: var(--color-surface); font-size: 1.6rem; margin: 0 0 6px; }
.detail__hero p { margin: 0; opacity: .95; font-size: .95rem; }
.detail__hero .meta { display: flex; gap: 14px; margin-top: 8px; font-size: .85rem; }
.detail__play { display: block; text-align: center; padding: 14px; margin: 18px 0;
  background: var(--color-primary); color: var(--color-surface); border-radius: var(--radius-pill);
  font-family: 'Fredoka One', system-ui, sans-serif; font-size: 1.2rem; box-shadow: var(--shadow-pop); }
.detail__play:hover { background: var(--color-secondary); text-decoration: none; transform: translateY(-2px); transition: all .15s; }
.detail__panel { background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 18px; }
.detail__panel h2 { margin-top: 0; }
.detail__panel ol { padding-left: 1.4em; }
.detail__panel ol li { margin: 6px 0; }

/* ---------- 6. Comments ---------- */
.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { display: grid; grid-template-columns: 40px 1fr; gap: 12px; }
.comment__avatar { width: 40px; height: 40px; border-radius: var(--radius-pill);
  display: grid; place-items: center; color: var(--color-surface); font-weight: 800; }
.comment__head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.comment__name { font-weight: 800; color: var(--color-text); }
.comment__stars { color: var(--color-accent); letter-spacing: -1px; }
.comment__date { color: var(--color-text-soft); margin-left: auto; }
.comment__text { margin: 4px 0 0; color: var(--color-text); font-size: .95rem; }

/* ---------- 7. Search modal ---------- */
.search-modal { position: fixed; inset: 0; background: var(--color-overlay); z-index: 300;
  display: flex; align-items: flex-start; justify-content: center; padding: 80px 16px 16px; }
.search-modal__panel { background: var(--color-surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; box-shadow: var(--shadow-pop); padding: 16px; }
.search-modal__head { display: flex; align-items: center; gap: 8px; }
.search-modal input { flex: 1; padding: 12px 14px; border: 1px solid var(--color-border);
  border-radius: var(--radius-pill); font-size: 1rem; background: var(--color-bg); color: var(--color-text); }
.search-close { width: 40px; height: 40px; border-radius: var(--radius-pill); font-size: 1.2rem; }
.search-close:hover { background: var(--color-border); }
.search-results { margin-top: 14px; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.search-item { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: var(--radius-sm);
  color: var(--color-text); }
.search-item:hover { background: var(--color-bg); text-decoration: none; }
.search-item img { border-radius: var(--radius-sm); }
.search-item__name { font-weight: 700; }
.search-item__cat { font-size: .8rem; color: var(--color-text-soft); }
.search-empty { color: var(--color-text-soft); padding: 20px; text-align: center; }

/* ---------- 8. Ad slots ---------- */
.ad-slot { display: block; margin: 24px auto; min-height: 50px; min-width: 320px;
  background: var(--color-bg); border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
  text-align: center; color: var(--color-text-soft); font-size: .75rem; padding: 4px; }
.ad-slot::before { content: 'AD'; display: inline-block; padding: 2px 8px;
  background: var(--color-border); color: var(--color-text-soft); border-radius: var(--radius-pill);
  font-size: .65rem; font-weight: 800; margin-bottom: 4px; }

/* ---------- 9. Loader ---------- */
.loader { position: fixed; inset: 0; z-index: 500; background: var(--color-bg);
  display: flex; align-items: center; justify-content: center; transition: opacity .3s, visibility .3s; }
.loader--hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader__ball { width: 60px; height: 60px; border-radius: var(--radius-pill);
  background: var(--hero-gradient); animation: pulse 1.2s ease-in-out infinite;
  box-shadow: var(--shadow-pop); }
@keyframes pulse { 0%,100%{ transform: scale(.85); } 50%{ transform: scale(1.1); } }

/* ---------- 10. Footer ---------- */
.footer { background: var(--color-surface); border-top: 1px solid var(--color-border);
  padding: 28px 16px 80px; margin-top: 28px; }
.footer__grid { display: grid; grid-template-columns: 1fr; gap: 18px; max-width: 720px; margin: 0 auto; }
.footer h4 { font-size: 1rem; margin: 0 0 8px; color: var(--color-text); }
.footer p, .footer a { font-size: .88rem; color: var(--color-text-soft); }
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin: 4px 0; }
.footer__bottom { text-align: center; padding-top: 18px; margin-top: 18px;
  border-top: 1px solid var(--color-border); color: var(--color-text-soft); font-size: .8rem; }

/* ---------- 11. Breadcrumb ---------- */
.crumbs { font-size: .85rem; color: var(--color-text-soft); margin: 0 0 14px; }
.crumbs a { color: var(--color-text-soft); }
.crumbs a:hover { color: var(--color-primary); }

/* ---------- 12. Legal/Static content ---------- */
.legal { max-width: 760px; margin: 0 auto; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 24px; }
.legal h1 { margin-top: 0; }
.legal h2 { margin-top: 24px; }
.legal p, .legal li { color: var(--color-text); }

/* ---------- 13. Particle canvas ---------- */
.particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
main, .nav, .tabbar, .footer { position: relative; z-index: 1; }

/* ---------- 14. Responsive (single breakpoint) ---------- */
@media (min-width: 540px) {
  /* ===== §2.4.6 PC 端强制使用移动端宽度("手机框"模式) =====
     - 内容区限宽 540px 居中,左右留空
     - 顶导航 / 抽屉 / tabbar 行为与移动端完全一致(共用同一套布局 token)
     - 不为 PC 加列数 / 不写扩展断点
  */
  :root { --frame-max: 540px; }
  body  { background: #1A1A2E; }                    /* 框外深色,衬托"手机框" */
  .nav, .tabbar { max-width: var(--frame-max); margin-left: auto; margin-right: auto; left: 0; right: 0; }
  main { max-width: var(--frame-max); margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; padding-bottom: 24px; }

  /* PC 抽屉宽度仍 320px,从左滑出(行为与移动端一致) */
  .nav-drawer { width: 320px; }

  /* 汉堡永远可见 */
  .nav__hamburger { display: grid; }

  .tabbar { display: none; }
  /* 详情页保持单列布局(§2.4.6 PC = 540px 移动端宽度,2 列会导致 panel 变窄变形) */
  .footer__grid { grid-template-columns: 2fr 1fr 1fr; }
  .loader__ball { width: 80px; height: 80px; }
  .legal { padding: 36px; }
  h1 { font-size: 2.2rem; }
  .hero h1 { font-size: 2.2rem; }
}
@media (max-width: 539px) {
  .nav__item span { display: none; }
  .detail__hero { grid-template-columns: 90px 1fr; padding: 16px; }
  .detail__hero img { width: 90px; height: 90px; }
  .nav__overlay a { font-size: 1.3rem; }
  main { padding: calc(var(--nav-height) + 8px) 12px 90px; }
}

/* ---------- 15. Dark mode ---------- */
[data-theme="dark"] body { background: var(--color-bg); color: var(--color-text); }
[data-theme="dark"] .card { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .legal,
[data-theme="dark"] .detail__panel,
[data-theme="dark"] .pill,
[data-theme="dark"] .search-modal__panel { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .ad-slot { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .nav { background: var(--nav-gradient); }
[data-theme="dark"] .footer { background: var(--color-surface); border-color: var(--color-border); }
