/* ==========================================================================
   十萬個為什麼 · Apple 風格樣式
   ========================================================================== */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --border: rgba(0, 0, 0, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 14px 34px rgba(0, 0, 0, 0.11);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "PingFang TC", "PingFang HK", "Noto Sans TC", "Microsoft JhengHei",
          "Heiti TC", "Helvetica Neue", sans-serif;
}

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: 0.01em;
}

a { -webkit-tap-highlight-color: transparent; }

/* --------------------------------------------------------------------------
   導航列（毛玻璃效果）
   -------------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 19px;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.brand-emoji { font-size: 24px; }
.brand-accent { color: var(--accent); }

.nav-search {
  flex: 1;
  max-width: 360px;
  margin-left: auto;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 980px;
  overflow: hidden;
}

.nav-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: 9px 16px;
  font-size: 15px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}

.nav-search button {
  border: none;
  background: transparent;
  padding: 0 14px;
  font-size: 15px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   首頁 Hero
   -------------------------------------------------------------------------- */
.hero {
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  padding: 84px 22px 68px;
  text-align: center;
}

.hero-inner { max-width: 720px; margin: 0 auto; }

.hero-kicker {
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.gradient-text {
  background: linear-gradient(90deg, #0071e3, #00c6fb, #34c759);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-sub {
  color: var(--text-secondary);
  font-size: 19px;
  margin-top: 18px;
}

.hero-search {
  max-width: 540px;
  margin: 34px auto 0;
  display: flex;
  background: var(--surface);
  border-radius: 980px;
  padding: 5px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: 12px 20px;
  font-size: 17px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}

.hero-search button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  border-radius: 980px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease;
}

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

.hero-random {
  display: inline-block;
  margin-top: 22px;
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}

.hero-random:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   區塊
   -------------------------------------------------------------------------- */
.section { padding: 64px 22px; }

.section-alt {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-inner { max-width: 980px; margin: 0 auto; }

.section-head { text-align: center; margin-bottom: 40px; }

.section-head h2 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head p { color: var(--text-secondary); margin-top: 8px; font-size: 17px; }

/* --------------------------------------------------------------------------
   分類卡片
   -------------------------------------------------------------------------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.cat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid transparent;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.6s ease;
}

.cat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.cat-emoji { font-size: 40px; line-height: 1; }
.cat-name { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.cat-desc { color: var(--text-secondary); font-size: 15px; }

.cat-count {
  display: inline-block;
  align-self: flex-start;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  background: rgba(0, 113, 227, 0.08);
  padding: 3px 12px;
  border-radius: 980px;
}

/* --------------------------------------------------------------------------
   問題清單
   -------------------------------------------------------------------------- */
.q-list { display: flex; flex-direction: column; gap: 14px; }

.q-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid transparent;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.6s ease;
}

.q-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.q-emoji { font-size: 30px; line-height: 1; }

.q-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.q-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }

.q-meta { color: var(--text-secondary); font-size: 14px; }

.q-arrow {
  color: var(--text-secondary);
  font-size: 20px;
  transition: transform 0.25s ease, color 0.25s ease;
}

.q-card:hover .q-arrow { transform: translateX(4px); color: var(--accent); }

/* --------------------------------------------------------------------------
   頁首（分類 / 搜尋）
   -------------------------------------------------------------------------- */
.page-head { padding: 64px 22px 0; text-align: center; }

.page-emoji { font-size: 64px; display: block; margin-bottom: 8px; line-height: 1; }

.page-head h1 {
  font-size: clamp(34px, 6vw, 48px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-head p { color: var(--text-secondary); font-size: 18px; margin-top: 10px; }

.result-count { color: var(--text-secondary); margin-bottom: 20px; }

.empty { text-align: center; color: var(--text-secondary); }

.empty-box { text-align: center; padding: 40px 20px; }

.empty-emoji { font-size: 56px; display: block; margin-bottom: 12px; }

.empty-sub { color: var(--text-secondary); margin-top: 6px; }

.back-link {
  display: inline-block;
  margin-top: 28px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   問題詳情
   -------------------------------------------------------------------------- */
.article { padding: 56px 22px 0; }

.article-inner { max-width: 720px; margin: 0 auto; }

.crumb-nav { font-size: 15px; margin-bottom: 24px; }

.crumb { color: var(--text-secondary); text-decoration: none; }

.crumb:hover { color: var(--accent); }

.crumb-sep { color: var(--text-secondary); margin: 0 6px; }

.article-hero { text-align: center; margin: 24px 0 36px; }

.article-emoji { font-size: 72px; display: block; margin-bottom: 12px; line-height: 1; }

.article-title {
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.article-meta {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

.badge {
  background: rgba(0, 0, 0, 0.05);
  padding: 6px 14px;
  border-radius: 980px;
  font-size: 14px;
  color: var(--text-secondary);
}

.answer-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 38px;
  box-shadow: var(--shadow);
}

.answer-card p {
  font-size: 20px;
  line-height: 1.95;
  color: #333336;
}

.answer-card p + p { margin-top: 20px; }

.funfact {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 20px;
}

.funfact-label {
  font-weight: 700;
  color: #b7791f;
  display: block;
  margin-bottom: 8px;
}

.funfact p { font-size: 17px; line-height: 1.85; }

.article-actions { display: flex; gap: 14px; margin-top: 30px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   按鈕
   -------------------------------------------------------------------------- */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 13px 28px;
  border-radius: 980px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-family: inherit;
  display: inline-block;
}

.btn-primary:hover { background: var(--accent-hover); transform: scale(1.02); }

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 12px 26px;
  border-radius: 980px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease;
  display: inline-block;
}

.btn-secondary:hover { background: rgba(0, 113, 227, 0.06); }

/* --------------------------------------------------------------------------
   頁尾
   -------------------------------------------------------------------------- */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 22px;
  text-align: center;
}

.footer-inner { max-width: 980px; margin: 0 auto; }

.footer p { font-size: 15px; }

.footer-sub { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }

/* --------------------------------------------------------------------------
   入場動畫
   重要：卡片預設必須可見（opacity 預設 1）。
   動畫只做「加分」，一旦 JS/CSS 失效也絕不會令內容隱形。
   -------------------------------------------------------------------------- */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cat-card,
.q-card {
  animation: cardIn 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.cat-grid > :nth-child(1), .q-list > :nth-child(1) { animation-delay: 0.02s; }
.cat-grid > :nth-child(2), .q-list > :nth-child(2) { animation-delay: 0.06s; }
.cat-grid > :nth-child(3), .q-list > :nth-child(3) { animation-delay: 0.10s; }
.cat-grid > :nth-child(4), .q-list > :nth-child(4) { animation-delay: 0.14s; }
.cat-grid > :nth-child(5), .q-list > :nth-child(5) { animation-delay: 0.18s; }
.cat-grid > :nth-child(6), .q-list > :nth-child(6) { animation-delay: 0.22s; }
.q-list > :nth-child(n+7) { animation-delay: 0.26s; }

@media (prefers-reduced-motion: reduce) {
  .cat-card, .q-card { animation: none; }
}

/* --------------------------------------------------------------------------
   響應式
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .nav-inner { flex-wrap: wrap; gap: 10px; }
  .nav-search { max-width: 100%; order: 3; width: 100%; }

  .hero { padding: 56px 20px 48px; }

  .hero-search {
    flex-direction: column;
    gap: 8px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .hero-search input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 980px;
  }
  .hero-search button { width: 100%; }

  .cat-grid { grid-template-columns: 1fr; }
  .answer-card { padding: 24px; }
  .answer-card p { font-size: 18px; }
}
