/* style.css — 引力剧场 · 设计系统「天文馆之夜」
 * 风格: 深蓝黑底 + 星图暗纹 + 金色天球仪, 衬线大标题, 天文馆官网质感
 * 动效: 教学仪式感 (动效只服务信息层级, 无音效, 课堂可用)
 * 完整规范见 ../DESIGN.md */

/* ═══════════ 设计令牌 ═══════════ */
:root {
  /* 色板 */
  --bg: #0b1220;          /* 夜幕底 */
  --bg-deep: #060a14;     /* 穹顶深黑 (模拟器画布) */
  --panel: #101a2e;       /* 面板 */
  --card: #12203a;        /* 题卡 */
  --line: #24365a;        /* 结构线 */
  --text: #e8edf6;        /* 正文 */
  --muted: #93a5c4;       /* 次要文字 */
  --gold: #d9c08a;        /* 金色: 主强调 (按钮/高轨/徽章) */
  --gold-bright: #f0d9a8; /* 金色亮态 (悬停/点火) */
  --blue: #7ea6e8;        /* 星蓝: 低轨/信息强调 */
  --green: #6fbf8f;       /* 攻克绿 */
  --pink: #d98a9e;        /* 道之玫红 (认知升华标注) */
  /* 字体 */
  --serif: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  /* 动效 (仪式感节奏表) */
  --ease-out: cubic-bezier(.22, .9, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --radius: 14px;
}

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

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1200px 500px at 70% -10%, #152244 0%, transparent 60%),
    radial-gradient(900px 420px at 8% 32%, #0f1a33 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* 星图暗纹: 三层星点叠加, 覆盖全页 (不参与交互) */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(217, 225, 240, .20), transparent 70%),
    radial-gradient(1px 1px at 140px 90px, rgba(217, 225, 240, .14), transparent 70%),
    radial-gradient(1.6px 1.6px at 80px 160px, rgba(240, 217, 168, .22), transparent 70%),
    radial-gradient(1px 1px at 180px 210px, rgba(217, 225, 240, .10), transparent 70%);
  background-size: 220px 240px;
}
.topbar, section, footer { position: relative; z-index: 1; }

/* ═══════════ 顶栏 ═══════════ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: rgba(11, 18, 32, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-weight: 700; letter-spacing: .12em; color: var(--gold); }
.brand-sub { font-size: .62em; color: var(--muted); letter-spacing: .28em; margin-left: 8px; font-family: var(--sans); }
.topbar nav { display: flex; gap: 14px; font-size: .85em; }
.topbar nav a { color: var(--muted); text-decoration: none; transition: color .25s; }
.topbar nav a:hover { color: var(--gold); }

/* ═══════════ Hero: 金圈天球仪 ═══════════ */
.hero { text-align: center; padding: 70px 20px 44px; position: relative; overflow: hidden; }
.celestial {
  position: absolute; left: 50%; top: 148px; transform: translateX(-50%);
  width: min(430px, 92vw); aspect-ratio: 1; pointer-events: none;
}
.ring { position: absolute; left: 50%; top: 50%; border-radius: 50%; }
.ring-outer {
  width: 100%; height: 100%; margin: -50% 0 0 -50%;
  border: 1px dashed rgba(217, 192, 138, .38);
  animation: spin 140s linear infinite;           /* 天球仪缓转: 慢到像静止, 但余光里活着 */
}
.ring-inner {
  width: 62%; height: 62%; margin: -31% 0 0 -31%;
  border: 1px solid rgba(217, 192, 138, .20);
}
@keyframes spin { to { transform: rotate(360deg); } }

.hero h1 {
  position: relative;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7vw, 3.8rem);
  font-weight: 700;
  letter-spacing: .18em; text-indent: .18em;      /* 中文居中对齐补偿 */
  background: linear-gradient(160deg, #f5e7c8 20%, var(--gold) 60%, #a8895a);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.tagline { color: var(--muted); letter-spacing: .34em; text-indent: .34em; margin-top: 8px; font-size: .92em; }
.lead { color: var(--muted); margin-top: 20px; font-size: 1.02em; }
.kpi { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 32px; }
.kpi > div {
  min-width: 122px; padding: 14px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .3s, transform .3s;
}
.kpi > div:hover { border-color: rgba(217, 192, 138, .4); transform: translateY(-2px); }
.kpi b { display: block; font-family: var(--serif); font-size: 1.7em; color: var(--gold); }
.kpi span { font-size: .82em; color: var(--muted); }

/* ═══════════ 通用区块 ═══════════ */
section { max-width: 1080px; margin: 0 auto; padding: 44px 20px; }
section > h2 {
  font-family: var(--serif); font-size: 1.45em; letter-spacing: .12em;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
section > h2::before { content: "✦"; color: var(--gold); font-size: .8em; }
.section-intro { color: var(--muted); margin: 12px 0 24px; font-size: .95em; }
.section-intro strong { color: var(--gold); }

/* ═══════════ ① 天体实验室 ═══════════ */
.lab-tabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.lab-tab {
  padding: 9px 18px; font-size: .92em; min-height: 40px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0; cursor: pointer;
  transition: color .25s, border-color .25s;
}
.lab-tab:hover { color: var(--text); }
.lab-tab.active {
  color: var(--gold);
  border-color: var(--line) var(--line) var(--gold);
  border-bottom: 2px solid var(--gold);
}
.hidden { display: none !important; }

.sim-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.sim-stage {
  position: relative;
  background: var(--bg-deep);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(10, 18, 36, .8);
}
#orbit, #binaryCanvas, #tbCanvas { display: block; width: 100%; height: 460px; touch-action: manipulation; }
.sim-status {
  position: absolute; left: 12px; bottom: 12px;
  padding: 6px 14px; font-size: .88em;
  background: rgba(10, 16, 30, .9); border: 1px solid var(--line); border-radius: 999px;
  color: var(--blue);                                   /* 默认 = 低轨蓝 */
  transition: color .4s, border-color .4s, transform .3s;
}
.sim-status.st-transfer { color: var(--text); }         /* 转移 = 星白 */
.sim-status.st-high { color: var(--gold); }             /* 高轨 = 金 */
.sim-status.st-earthmoon { color: var(--gold); }        /* 地月模式 = 金 */
.sim-status.fired { color: var(--gold-bright); border-color: var(--gold); transform: scale(1.06); }

.sim-panel {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.panel-block label { display: block; font-size: .92em; margin-bottom: 8px; }
.out { color: var(--gold); font-weight: 700; font-size: 1.15em; font-variant-numeric: tabular-nums; }
.r2km { color: var(--muted); font-size: .82em; margin-left: 6px; }
input[type="range"] { width: 100%; accent-color: var(--gold); cursor: pointer; }
.slider-ticks { display: flex; justify-content: space-between; font-size: .72em; color: var(--muted); }

.burns { display: flex; flex-direction: column; gap: 8px; }
.burn {
  padding: 10px 14px; text-align: left; font-size: .95em;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color .25s, transform .12s, box-shadow .25s;
}
.burn:hover:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(217, 192, 138, .18);       /* 点火按钮悬停: 微光预告 */
}
.burn:active:not(:disabled) { transform: scale(.98); }
.burn:disabled { opacity: .4; cursor: not-allowed; }
.burn.up em { color: var(--green); font-style: normal; font-size: .82em; }
.burn.down em { color: var(--pink); font-style: normal; font-size: .82em; }
.burn.active { border-color: var(--gold); color: var(--gold); }

.row { display: flex; gap: 8px; }
.row button {
  flex: 1; padding: 9px 6px; font-size: .88em;
  background: var(--gold); color: #0b1220; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  transition: filter .2s, transform .12s;
}
.row button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.row button:hover { filter: brightness(1.12); }
.row button:active { transform: scale(.97); }

.readout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  font-size: .88em;
  background: var(--bg-deep); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
}
.readout .k { color: var(--muted); }
.readout .v { text-align: right; font-variant-numeric: tabular-nums; }
.readout .v.hl { color: var(--gold); font-weight: 700; }

.energy { font-size: .85em; }
.energy-label { color: var(--muted); margin-bottom: 6px; }
.energy-label strong { color: var(--text); }
.energy-bar { height: 8px; background: var(--bg-deep); border-radius: 999px; overflow: hidden; }
#eBar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width .5s var(--ease-out);               /* 点火后能级条缓慢归位 = 仪式感 */
}
.energy-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: .75em; margin-top: 4px; }

.hint { font-size: .82em; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }

/* ═══════════ ② 情景题卡 ═══════════ */
.progress { margin-bottom: 22px; display: flex; align-items: center; gap: 14px; }
.progress span { font-size: .88em; color: var(--muted); white-space: nowrap; }
.progress-bar { flex: 1; height: 6px; background: var(--bg-deep); border-radius: 999px; overflow: hidden; position: relative; }
#progressBar { height: 100%; width: 0; background: var(--green); transition: width .5s var(--ease-out); }
.progress-bar::after {                                   /* 光点扫过: 攻克一件, 星轨亮一次 */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: translateX(-100%);
  animation: shine 2.4s ease-in-out infinite;
}
@keyframes shine { to { transform: translateX(100%); } }

.qcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px;
  transition: border-color .3s;
}
.qcard:hover { border-color: rgba(217, 192, 138, .3); }
.qhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qnum {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 1.05em;
  background: var(--gold); color: #0b1220;
  transition: transform .6s var(--ease-spring), background .4s, color .4s;
}
.qcard.solved .qnum { transform: rotate(360deg); background: var(--green); }  /* 打卡: 徽章翻面变绿 */
.qtag { font-size: .75em; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--gold); color: var(--gold); }
.qtag.mech { border-color: var(--muted); color: var(--muted); }
.qsrc { font-size: .78em; color: var(--muted); margin-left: auto; }
.qtitle { font-family: var(--serif); font-size: 1.18em; font-weight: 700; margin: 12px 0 6px; letter-spacing: .04em; }
.qstem { font-size: .97em; }
.qstem p { margin: 6px 0; }
.qopts { margin-top: 8px; }
.qopts span { display: inline-block; margin: 3px 14px 3px 0; }

/* 公式排版: 手写 HTML 分数结构, 零依赖 */
.f { font-family: "STIX Two Text", "Times New Roman", serif; font-style: italic; font-size: 1.06em; }
.f .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; }
.f .frac span { padding: 0 4px; }
.f .frac span:first-child { border-bottom: 1px solid currentColor; }
.f sub, .f sup { font-style: normal; font-size: .72em; }

.qactions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.qactions button {
  padding: 9px 18px; font-size: .9em; min-height: 40px;
  background: var(--gold); color: #0b1220; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  transition: filter .2s, transform .12s, background .3s;
}
.qactions button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.qactions button.solved-btn { background: transparent; color: var(--green); border: 1px solid var(--green); }
.qactions button:hover { filter: brightness(1.12); }
.qactions button:active { transform: scale(.97); }

/* 揭晓 = 书页展开: 拆解步骤逐条滑入, 答案与升华缓入 */
.qreveal { display: none; margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; }
.qreveal.open { display: block; }
.qblock { margin-bottom: 16px; }
.qblock h4 { font-family: var(--serif); font-size: .88em; letter-spacing: .18em; color: var(--gold); margin-bottom: 8px; }
.qblock ol { padding-left: 1.4em; list-style: none; counter-reset: step; }
.qblock ol li {
  margin: 7px 0; font-size: .94em; position: relative; padding-left: 4px;
  opacity: 0; transform: translateY(10px);
}
.qreveal.open .qblock ol li {
  animation: stepIn .45s var(--ease-out) forwards;
}
.qreveal.open .qblock ol li:nth-child(1) { animation-delay: .08s; }
.qreveal.open .qblock ol li:nth-child(2) { animation-delay: .20s; }
.qreveal.open .qblock ol li:nth-child(3) { animation-delay: .32s; }
.qreveal.open .qblock ol li:nth-child(4) { animation-delay: .44s; }
.qreveal.open .qblock ol li:nth-child(5) { animation-delay: .56s; }
@keyframes stepIn { to { opacity: 1; transform: none; } }
.qblock li strong { color: var(--blue); }
.ansbox {
  background: #0a1424; border: 1px solid var(--green); border-radius: 10px;
  padding: 12px 16px; margin: 10px 0;
  opacity: 0;
}
.qreveal.open .ansbox { animation: fadeIn .6s ease .66s forwards; }
.ansbox b { color: var(--green); }
.qtao {
  background: linear-gradient(120deg, #152244, #101a30);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; font-size: .94em;
  opacity: 0;
}
.qreveal.open .qtao { animation: fadeIn .6s ease .8s forwards; }
@keyframes fadeIn { to { opacity: 1; } }
.qtao strong { color: var(--pink); }
.qtao em { color: var(--gold); font-style: normal; }

/* ═══════════ ③ 公式墙 ═══════════ */
.formula-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.fcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-align: center;
  transition: border-color .3s, transform .3s;
}
.fcard:hover { border-color: rgba(217, 192, 138, .4); transform: translateY(-3px); }
.fcard .f { font-family: var(--serif); font-size: 1.32em; color: var(--gold); margin-bottom: 10px; }
.fcard h3 { font-family: var(--serif); font-size: .98em; letter-spacing: .1em; }
.fcard p { font-size: .82em; color: var(--muted); margin-top: 6px; }

/* ═══════════ 页脚 ═══════════ */
footer {
  max-width: 1080px; margin: 30px auto 0; padding: 28px 20px 48px;
  border-top: 1px solid var(--line); font-size: .8em; color: var(--muted);
}
footer p { margin: 6px 0; }
footer strong { color: var(--text); }

/* ═══════════ 移动端 ═══════════ */
@media (max-width: 860px) {
  .sim-layout { grid-template-columns: 1fr; }
  #orbit, #binaryCanvas, #tbCanvas { height: 320px; }
  .formula-grid { grid-template-columns: 1fr 1fr; }
  .celestial { top: 118px; }
}
@media (max-width: 480px) {
  .formula-grid { grid-template-columns: 1fr; }
}

/* 课堂可用: 系统减弱动效时全部静默 (教师投影 / 弱动效偏好) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
