/* ============================================================
   趣味互动小课堂 · 全站共享样式 v2
   适用于：入口首页 index.html 与 topics/ 下所有主题页
   ============================================================ */

:root {
  --paper: #faf6ee;
  --ink: #2b2620;
  --ink-soft: #6b6152;
  --card: #ffffff;
  --line: #e8e0d0;
  --bronze: #b8863a;
  --bronze-dark: #8a6a35;
  --green: #2e7d32;
  --red: #c0392b;
  --shadow-sm: 0 2px 10px rgba(90, 70, 40, 0.07);
  --shadow: 0 12px 32px rgba(90, 70, 40, 0.11);
  --shadow-lg: 0 22px 48px rgba(90, 70, 40, 0.17);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 50% -220px, #f3ead7 0%, rgba(243, 234, 215, 0) 70%),
    radial-gradient(700px 380px at 88% 6%, rgba(240, 180, 41, 0.10) 0%, rgba(240, 180, 41, 0) 70%),
    var(--paper);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(184, 134, 58, 0.25); }

/* ---------------- 顶部导航（所有页面共用） ---------------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(250, 246, 238, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-nav .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
}
.site-nav .brand .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f0b429, #e8890c);
  font-size: 17px;
  box-shadow: 0 3px 8px rgba(232, 137, 12, 0.35);
}
.site-nav .badge {
  font-size: 12px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: #fff;
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.site-nav .back {
  font-size: 14px;
  font-weight: 700;
  color: var(--bronze-dark);
  text-decoration: none;
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.site-nav .back:hover {
  border-color: var(--bronze);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ---------------- 内容页通用容器 ---------------- */
.page-wrap { max-width: 900px; margin: 0 auto; padding: 28px 22px 70px; }

.topic-header { text-align: center; padding: 34px 0 8px; }
.topic-header h1 { font-size: clamp(24px, 4vw, 34px); margin: 12px 0 8px; }
.topic-header .sub { color: var(--ink-soft); margin: 0; }

.kicker {
  display: inline-block;
  font-size: 12.5px;
  letter-spacing: 2px;
  color: var(--bronze-dark);
  background: #f3ead7;
  border: 1px solid var(--line);
  padding: 4px 14px;
  border-radius: 999px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  margin: 24px 0;
}
.card h2 { font-size: 22px; margin: 0 0 10px; }
.card .lead { color: var(--ink-soft); margin: 0 0 16px; }

/* ---------------- 入口首页 ---------------- */
.hero {
  position: relative;
  text-align: center;
  padding: 66px 0 14px;
  overflow: hidden;
}
.hero h1 {
  font-size: clamp(28px, 5.5vw, 46px);
  line-height: 1.25;
  margin: 18px 0 14px;
  background: linear-gradient(120deg, #8a5a00, #c0392b 45%, #1d6f8f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .sub { color: var(--ink-soft); font-size: 17px; max-width: 560px; margin: 0 auto 28px; }
.hero .cta {
  display: inline-block;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  padding: 12px 28px;
  border-radius: 999px;
  background: linear-gradient(120deg, #f0b429, #e8890c);
  box-shadow: 0 10px 24px rgba(232, 137, 12, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero .cta:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(232, 137, 12, 0.45); }
.floating {
  position: absolute;
  font-size: 34px;
  opacity: 0.5;
  user-select: none;
  pointer-events: none;
  animation: float 7s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin: 30px 0;
}
.topic-card {
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: fadeUp 0.6s ease both;
}
.topic-card:nth-child(1) { animation-delay: 0.05s; }
.topic-card:nth-child(2) { animation-delay: 0.12s; }
.topic-card:nth-child(3) { animation-delay: 0.19s; }
.topic-card:nth-child(4) { animation-delay: 0.26s; }
.topic-card:nth-child(5) { animation-delay: 0.33s; }
.topic-card:nth-child(6) { animation-delay: 0.40s; }

.topic-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--bronze);
}
.topic-card .icon-tile {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  background: var(--tile, #f0b429);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
}
.topic-card h3 { margin: 16px 0 6px; font-size: 19px; }
.topic-card p { margin: 0; font-size: 14px; color: var(--ink-soft); flex: 1 1 auto; }
.topic-card .tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bronze-dark);
  background: #f3ead7;
  border: 1px solid var(--line);
  padding: 2px 11px;
  border-radius: 999px;
}
.topic-card .go {
  margin-top: 16px;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--bronze-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topic-card .go .arrow { transition: transform 0.18s ease; }
.topic-card:hover .go .arrow { transform: translateX(6px); }

/* ---------------- 年龄标识（卡片右上角徽章 + 主题页适龄药丸） ---------------- */
.age-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
  user-select: none;
}
.age-badge.age-under6  { background: linear-gradient(135deg, #7bc96f, #4e9e52); }
.age-badge.age-6to8    { background: linear-gradient(135deg, #4aa3c8, #2e7fa3); }
.age-badge.age-8to12   { background: linear-gradient(135deg, #f0b429, #e07b1c); }
.age-badge.age-12plus  { background: linear-gradient(135deg, #8e7cc3, #6a56a8); }

.age-pill {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  padding: 3px 11px;
  border-radius: 999px;
  vertical-align: middle;
}
.age-pill.age-under6   { background: linear-gradient(135deg, #7bc96f, #4e9e52); }
.age-pill.age-6to8     { background: linear-gradient(135deg, #4aa3c8, #2e7fa3); }
.age-pill.age-8to12    { background: linear-gradient(135deg, #f0b429, #e07b1c); }
.age-pill.age-12plus   { background: linear-gradient(135deg, #8e7cc3, #6a56a8); }

/* ---------------- 首页筛选导航（学科 + 年龄） ---------------- */
.filter-area { margin: 34px 0 2px; }
.filter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 12px;
}
.filter-row + .filter-row { margin-top: 12px; }
.filter-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--bronze-dark);
  background: #efe7d6;
  padding: 5px 11px;
  border-radius: 8px;
  white-space: nowrap;
}
.topic-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.filter-hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 12.5px;
  margin: 14px 0 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.filter-chip:hover {
  border-color: var(--bronze);
  color: var(--bronze-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.filter-chip.is-active {
  color: #fff;
  background: linear-gradient(120deg, #f0b429, #e8890c);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(232, 137, 12, 0.35);
}
.filter-chip .count {
  font-size: 11px;
  font-weight: 800;
  color: var(--bronze-dark);
  background: #f3ead7;
  border-radius: 999px;
  padding: 1px 8px;
  line-height: 1.7;
}
.filter-chip.is-active .count { background: rgba(255, 255, 255, 0.28); color: #fff; }

.topic-card.is-hidden { display: none; }

.topic-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  background: #f6f1e7;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 34px 20px;
  margin: 26px 0 0;
}

/* 施工中的占位卡片 */
.topic-card.coming { cursor: default; box-shadow: none; background: rgba(255, 255, 255, 0.6); border-style: dashed; }
.topic-card.coming .icon-tile { background: #c9c2b4 !important; box-shadow: none; filter: saturate(0.3); }
.topic-card.coming h3, .topic-card.coming p, .topic-card.coming .go { color: #9a9080; }
.topic-card.coming:hover { transform: none; border-color: var(--line); }

.portal-note {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  background: #f6f1e7;
  border-radius: 14px;
  padding: 14px 18px;
  margin: 10px 0 0;
}
.portal-note code { background: #efe7d6; padding: 1px 7px; border-radius: 6px; font-size: 13px; }

/* ---------------- 页脚（所有页面共用） ---------------- */
.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  padding: 34px 0 10px;
}
.site-footer a { color: var(--bronze-dark); font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 620px) {
  .site-nav { padding: 11px 16px; }
  .site-nav .badge { display: none; }
  .topic-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 46px; }
  .filter-area { margin-top: 26px; }
  .topic-filter { gap: 8px; }
  .filter-chip { padding: 7px 13px; font-size: 13px; }
}
