/* ===== 概念尺度實驗室 · 全站統一設計（沿用富豪頁風格：深色底＋金色強調＋襯線標題） ===== */
:root {
  --bg: #0e1420;
  --bg-soft: #141c2c;
  --panel: #1a2436;
  --panel-2: #202c42;
  --ink: #f2f5fa;
  --ink-dim: #a8b4c8;
  --ink-faint: #6c7a92;
  --gold: #f5c451;
  --gold-deep: #d9a227;
  --teal: #43d3c9;
  --rose: #f27896;
  --line: rgba(242, 245, 250, 0.12);
  --radius: 18px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --font-serif: "Noto Serif TC", serif;
  --font-sans: "Noto Sans TC", -apple-system, "PingFang TC", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 統一 Header（logo · menu · 深淺色切換） ===== */
.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(14, 20, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-logo { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.site-logo:hover { text-decoration: none; }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: #241a05;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 1.05rem;
}

.logo-text { font-family: var(--font-serif); font-weight: 900; letter-spacing: 0.05em; }

.site-menu { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.site-menu a {
  color: var(--ink-dim);
  font-size: 0.92rem;
  font-weight: 700;
  border-bottom: 2px solid transparent;
}
.site-menu a:hover, .site-menu a.current {
  color: var(--ink);
  text-decoration: none;
  border-bottom-color: var(--gold);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.theme-toggle:hover { border-color: var(--gold); transform: translateY(-1px); }

/* ===== Hero（首頁） ===== */
.hero {
  padding: 90px 6vw 70px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(245, 196, 81, 0.16), transparent 62%),
    radial-gradient(820px 460px at 8% 110%, rgba(67, 211, 201, 0.10), transparent 60%),
    var(--bg);
}

.kicker {
  color: var(--gold);
  font-size: 0.86rem;
  letter-spacing: 0.22em;
  font-weight: 700;
  margin-bottom: 18px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6.5vw, 4.6rem);
  line-height: 1.18;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.accent { color: var(--gold); }

.lede { max-width: 640px; margin-top: 22px; color: var(--ink-dim); font-size: 1.06rem; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }

/* ===== Chips ===== */
.chip {
  display: inline-block;
  padding: 10px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover { border-color: var(--gold); color: var(--ink); transform: translateY(-2px); text-decoration: none; }
.chip.active { background: var(--gold); border-color: var(--gold); color: #241a05; }

/* ===== 題目帶（module band） ===== */
.band-inner {
  display: grid;
  grid-template-columns: minmax(300px, 500px) 1fr;
  gap: 56px;
  padding: 88px 6vw;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.band--flip .band-inner > .band-head { order: 2; }
.band--flip .band-inner > .band-body { order: 1; }

.band-no {
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  font-weight: 700;
}

.band h2 {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5.6vw, 4.2rem);
  font-weight: 900;
  line-height: 1.25;
  margin: 8px 0 4px;
  text-wrap: balance;
}

.band-kicker { color: var(--ink-dim); font-weight: 700; font-size: 1.1rem; margin-bottom: 20px; }

.band-big {
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 5.4vw, 4.2rem);
  font-weight: 900;
  color: var(--gold);
  line-height: 1.1;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin: 14px 0;
  font-variant-numeric: tabular-nums;
}

.band-big .unit { font-size: 0.42em; margin-left: 8px; color: var(--ink-dim); letter-spacing: 0.06em; }
.band-note { color: var(--ink-dim); font-size: 1.1rem; line-height: 1.9; }
.body-title { font-weight: 700; font-size: 1.32rem; margin-bottom: 18px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 22px; }
.controls-label { font-weight: 700; color: var(--ink-faint); font-size: 1.02rem; }

/* ===== M1 標尺與行星表 ===== */
.ruler-strip {
  position: relative;
  height: 64px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 24px);
}

.strip-line { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--gold-deep); }
.strip-sun { position: absolute; left: 2%; bottom: -6px; font-size: 1.15rem; line-height: 1; }

.strip-dot {
  position: absolute;
  bottom: 8px;
  transform: translateX(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  padding: 0;
}

.strip-dot:hover { transform: translateX(-50%) scale(1.12); border-color: var(--gold); }
.strip-dot.sel { background: var(--gold); color: #241a05; border-color: var(--gold); }

.planet-table { display: grid; gap: 6px; }

.planet-head, .planet-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 8px;
  align-items: baseline;
}

.planet-head {
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.planet-row {
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--line);
  padding: 13px 10px;
  font-family: var(--font-sans);
  font-size: 1.04rem;
  cursor: pointer;
  color: var(--ink-dim);
  transition: background 0.15s;
}

.planet-row:hover { background: rgba(245, 196, 81, 0.08); }
.planet-row.sel { background: rgba(245, 196, 81, 0.16); }
.planet-row .p-name { color: var(--ink); font-weight: 700; }
.planet-row .p-name i { font-style: normal; font-size: 0.8rem; color: var(--ink-faint); margin-left: 4px; }

.detail-card {
  margin-top: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 20px 24px;
  font-size: 1.06rem;
  line-height: 1.9;
  color: var(--ink-dim);
}

.detail-card strong { color: var(--ink); }

/* ===== M1b：行星落點於香港 ===== */
.hk-map-block {
  margin-top: 36px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.map-note {
  color: var(--ink-faint);
  font-size: 1.02rem;
  line-height: 1.85;
  margin-bottom: 20px;
  max-width: 720px;
}

.polar-wrap { overflow-x: auto; }
.polar-wrap svg { display: block; width: 100%; min-width: 560px; max-width: 720px; }

.land { fill: var(--panel-2); stroke: var(--ink-faint); stroke-width: 0.8; }
.park { fill: rgba(245, 196, 81, 0.35); stroke: var(--gold); stroke-width: 1; }
.park-label { font-size: 11px; fill: var(--gold); font-weight: 700; }
.scale-bar line { stroke: var(--ink-dim); stroke-width: 1.5; }
.scale-bar text { font-size: 11px; fill: var(--ink-dim); }

.inset-row { display: flex; gap: 22px; align-items: flex-start; margin-top: 18px; flex-wrap: wrap; }
.inset-wrap { flex: 0 0 auto; }
.inset-wrap svg {
  width: 320px;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.inset-note { flex: 1; min-width: 260px; }

/* ===== 互動地圖（Leaflet） ===== */
.map-canvas {
  height: 620px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-2);
}
.leaflet-container { font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
.lm-tag {
  color: var(--ink);
  font: 600 10px "Noto Sans TC", "PingFang TC", sans-serif;
  white-space: nowrap;
  text-shadow: 0 0 3px var(--panel), 0 0 3px var(--panel), 0 0 2px var(--panel);
}
.leaflet-tooltip.lm-core {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 3px var(--panel), 0 0 3px var(--panel);
}
.leaflet-control-scale-line { border-color: var(--ink-dim) !important; color: var(--ink-dim) !important; }

.ring { fill: none; stroke: rgba(245, 196, 81, 0.26); stroke-width: 1; }
.ring.sel { stroke: var(--gold); stroke-width: 2; }
.ring-label { font-size: 10px; fill: var(--ink-faint); }
.ring-label.sel { fill: var(--gold); font-weight: 700; }
.lm-dot { fill: var(--teal); }
.lm-label { font-size: 10px; fill: var(--ink-dim); }
.map-core { fill: var(--gold); }
.map-core-label { font-size: 11px; fill: var(--gold); font-weight: 700; }
.map-dir { font-size: 11px; fill: var(--ink-faint); }

/* ===== M2 時間軸 ===== */
.stat-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }

.stat-chip {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-dim);
  font-size: 0.98rem;
}

.timeline {
  position: relative;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  margin-bottom: 22px;
  overflow: hidden;
}

.timeline-months {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.timeline-months span { border-left: 1px solid var(--line); padding: 4px 6px; white-space: nowrap; }

.tl-dot {
  position: absolute;
  bottom: 26px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--teal);
  transform: translateX(-50%);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  padding: 0;
}

.tl-dot:hover { transform: translateX(-50%) scale(1.35); }
.tl-dot.sel { background: var(--gold); transform: translateX(-50%) scale(1.35); }

.tl-base { position: absolute; left: 0; right: 0; bottom: 25px; height: 2px; background: var(--gold-deep); }

.tl-today {
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 0.84rem;
  color: var(--gold);
  font-weight: 700;
}

.event-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.event-chip {
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.98rem;
  cursor: pointer;
  color: var(--ink-dim);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.event-chip:hover { border-color: var(--gold); color: var(--ink); }
.event-chip.sel { background: var(--gold); border-color: var(--gold); color: #241a05; }

/* ===== M3 密度階梯 ===== */
.dens-chart { display: grid; gap: 10px; margin-bottom: 30px; }
.dens-row { display: grid; grid-template-columns: 110px 1fr 170px; gap: 14px; align-items: center; }
.dens-name { font-weight: 700; font-size: 1.06rem; }
.dens-track { height: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dens-fill { height: 100%; background: linear-gradient(90deg, #2c7a75, var(--teal)); transition: width 0.4s ease; }
.dens-row:last-child .dens-fill { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
.dens-val { font-size: 0.95rem; text-align: right; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

/* ===== 翻卡 ===== */
.flip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

.flip-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s;
}

.flip-card:hover { transform: translateY(-2px); border-color: rgba(245, 196, 81, 0.45); }
.flip-card:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.flip-main { font-size: 1.16rem; line-height: 1.8; color: var(--ink-dim); }
.flip-main strong { color: var(--gold); font-family: var(--font-serif); font-size: 1.12em; }

.flip-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.flip-card.open .flip-hint { display: none; }

.flip-math {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink-faint);
}

.flip-card.open .flip-math { display: block; }

/* ===== M5 100 人村 ===== */
.village-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }

.village-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 10px;
  max-width: 620px;
  margin-bottom: 22px;
}

.v-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--teal);
  transition: background 0.25s ease, transform 0.25s ease;
}

.village-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 1.04rem; color: var(--ink-dim); }

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex: none;
}

.legend-item b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ===== 刻度分隔線 ===== */
.tick-divider {
  height: 26px;
  border-top: 1px solid var(--line);
  background: repeating-linear-gradient(90deg, var(--gold-deep) 0 1.5px, transparent 1.5px 28px);
  background-size: 100% 12px;
  background-repeat: no-repeat;
  opacity: 0.7;
}

/* ===== 首頁：題目卡與說明 ===== */
.topics-inner, .howto-inner { padding: 80px 6vw; max-width: 1280px; margin: 0 auto; }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 30px;
}

.topic-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}

.topic-card:hover {
  transform: translateY(-3px);
  border-color: rgba(245, 196, 81, 0.5);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.topic-no { font-size: 0.76rem; letter-spacing: 0.18em; color: var(--gold); font-weight: 700; }
.topic-card h3 { font-family: var(--font-serif); font-size: 1.22rem; margin: 10px 0 8px; line-height: 1.4; }
.topic-card p { color: var(--ink-dim); font-size: 1.02rem; }

.topic-card .go {
  display: inline-block;
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--gold);
  border-bottom: 1px solid var(--gold);
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
  margin-top: 26px;
}

.howto-item { border-top: 1px solid var(--line); padding-top: 16px; }
.howto-no { color: var(--gold); font-weight: 700; letter-spacing: 0.18em; }
.howto-item h3 { font-family: var(--font-serif); font-size: 1.1rem; margin: 8px 0 6px; }
.howto-item p { color: var(--ink-dim); font-size: 0.93rem; }

/* ===== 頁尾 ===== */
footer {
  border-top: 1px solid var(--line);
  padding: 56px 6vw 72px;
  background: var(--bg-soft);
}

footer h3 { font-family: var(--font-serif); font-size: 1.1rem; margin-bottom: 14px; color: var(--gold); }
footer ul { list-style: none; display: grid; gap: 8px; margin-bottom: 22px; }
footer li { color: var(--ink-dim); font-size: 1.02rem; padding-left: 18px; position: relative; }
footer li::before { content: "—"; position: absolute; left: 0; color: var(--gold); }

.disclaimer {
  font-size: 0.92rem;
  color: var(--ink-faint);
  border-top: 1px dashed var(--line);
  padding-top: 16px;
  letter-spacing: 0.04em;
}

/* ===== 進場動畫 ===== */
.band-head, .band-body {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.band.in .band-head, .band.in .band-body { opacity: 1; transform: none; }

/* ===== 響應式 ===== */
@media (max-width: 860px) {
  .band-inner { grid-template-columns: 1fr; gap: 32px; padding: 64px 6vw; }
  .band--flip .band-inner > .band-head { order: 0; }
  .band--flip .band-inner > .band-body { order: 0; }
  .site-menu { display: none; }
  .planet-head, .planet-row { grid-template-columns: 1.1fr 1fr 1fr; }
  .planet-head span:last-child, .planet-row .p-walk { display: none; }
  .dens-row { grid-template-columns: 72px 1fr; }
  .dens-val { grid-column: 2; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
  .band-head, .band-body { opacity: 1; transform: none; }
}

/* ===== 淺色主題（與富豪頁一致） ===== */
:root[data-theme="light"] {
  --bg: #f5f1e8;
  --bg-soft: #ece6d8;
  --panel: #ffffff;
  --panel-2: #f1ebdd;
  --ink: #222b3d;
  --ink-dim: #4b5872;
  --ink-faint: #7b859b;
  --gold: #a1741a;
  --gold-deep: #c2931f;
  --teal: #0d7f76;
  --rose: #c04a6c;
  --line: rgba(34, 43, 61, 0.14);
  --shadow: 0 18px 48px rgba(120, 100, 55, 0.16);
}

:root[data-theme="light"] .site-head { background: rgba(245, 241, 232, 0.92); }
:root[data-theme="light"] .logo-mark { color: #ffffff; }
:root[data-theme="light"] .chip.active,
:root[data-theme="light"] .event-chip.sel,
:root[data-theme="light"] .strip-dot.sel { color: #ffffff; }
:root[data-theme="light"] .flip-main strong { color: var(--gold); }
:root[data-theme="light"] .hero {
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(194, 147, 31, 0.14), transparent 62%),
    radial-gradient(820px 460px at 8% 110%, rgba(13, 127, 118, 0.08), transparent 60%),
    var(--bg);
}

/* ===== 行動版主選單（漢堡選單） ===== */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
  transition: border-color 0.2s ease;
}

.menu-toggle:hover { border-color: var(--gold); }

@media (max-width: 860px) {
  .site-head { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .menu-toggle { display: inline-flex; margin-left: auto; order: 2; }
  .theme-toggle { order: 3; padding: 8px 12px; }
  .site-menu {
    display: none;
    order: 4;
    width: 100%;
    margin: 2px 0 4px;
    flex-direction: column;
    gap: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
  }
  .site-head.nav-open .site-menu { display: flex; }
  .site-menu a {
    padding: 13px 18px;
    font-size: 1rem;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
  }
  .site-menu a:last-child { border-bottom: none; }
  .site-menu a:hover,
  .site-menu a.current {
    border-bottom-color: var(--line);
    border-left-color: var(--gold);
    background: rgba(245, 196, 81, 0.1);
    text-decoration: none;
  }
}
