/* 我們身邊的大地 — lab shell. Dark theater: a lit table in a dark room, flat chrome, one gold accent. */
@font-face { font-family: "Study Serif"; src: url("../../fonts/StudySerif-site.woff2") format("woff2"); font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: rgba(13, 16, 21, 0.9);
  --panel-solid: #0d1015;
  --rule: rgba(236, 228, 210, 0.1);
  --rule2: rgba(236, 228, 210, 0.18);
  --text: #ece6d9;
  --sub: #a8a296;
  --faint: #6f6b63;
  --gold: #d8b26a;
  --gold-dim: rgba(216, 178, 106, 0.55);
  --blue: #7cc0e0;
  --red: #e07a5f;
  --green: #8fc07a;
  --serif: "Study Serif", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --body: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #d6d8e8; color: var(--text); font: 15px/1.7 var(--body); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- stage ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px 20px rgba(60, 60, 110, 0.12); }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }

/* labels written on the objects */
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; opacity: 0; transition: opacity .35s var(--ease); will-change: transform; }
.tag.on { opacity: 1; }
.tag .t { display: inline-block; padding: 3px 9px 4px; font: 13px/1.35 var(--serif); letter-spacing: .04em; color: var(--text); background: rgba(8, 10, 13, 0.82); border: 1px solid var(--gold-dim); border-radius: 3px; }
.tag .t small { display: block; font: 11px/1.4 var(--body); color: var(--sub); letter-spacing: .02em; }
.tag .t b { color: var(--gold); font-weight: 400; }
.tag .stem { display: block; width: 1px; height: 16px; margin: 0 auto; background: var(--gold-dim); }
.tag .dot { display: block; width: 5px; height: 5px; margin: -1px auto 0; border-radius: 50%; background: var(--gold); }
.tag.blue .t { border-color: rgba(124, 192, 224, 0.6); }
.tag.blue .stem { background: rgba(124, 192, 224, 0.6); }
.tag.blue .dot { background: var(--blue); }
.tag.red .t { border-color: rgba(224, 122, 95, 0.65); }
.tag.red .stem { background: rgba(224, 122, 95, 0.65); }
.tag.red .dot { background: var(--red); }
.tag.flat .stem, .tag.flat .dot { display: none; }
.tag.flat { transform: translate(-50%, -50%); }
.tag .n { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px; border: 1px solid var(--gold); border-radius: 50%; font: 11px/1 var(--mono); color: var(--gold); vertical-align: 1px; }
.tag.hl .t { background: rgba(216, 178, 106, 0.95); color: #17130b; border-color: var(--gold); }
.tag.hl .t small { color: rgba(23, 19, 11, 0.75); }
.tag.hl .n { border-color: #17130b; color: #17130b; }
.tag.dim { opacity: .28; }

/* ---------- top bar ---------- */
.top { position: fixed; left: 0; right: 0; top: 0; z-index: 5; display: flex; align-items: flex-start; gap: 24px; padding: 18px 24px 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { min-width: 0; }
.brand .back { display: inline-block; font-size: 12px; letter-spacing: .12em; color: #4a4e63; text-decoration: none; padding: 2px 0; }
.brand .back:hover { color: var(--gold); }
.brand h1 { margin: 6px 0 0; font: 400 30px/1.15 var(--serif); letter-spacing: .14em; color: #1b1f2e; }
.brand .en { margin-top: 6px; font: 11px/1 var(--mono); letter-spacing: .32em; color: #a8741a; text-transform: uppercase; }
.brand .en::after { content: ""; display: block; width: 44px; height: 1px; margin-top: 10px; background: var(--gold-dim); }
.brand .sub { margin-top: 8px; font-size: 12px; color: #4a4e63; letter-spacing: .06em; }

.nav { margin-left: auto; display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.ticks { display: flex; align-items: flex-end; gap: 3px; height: 30px; }
.ticks button { position: relative; width: 26px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.ticks button::before { content: ""; position: absolute; left: 3px; right: 3px; bottom: 4px; height: 2px; background: rgba(27, 31, 46, 0.22); transition: background .25s, height .25s; }
.ticks button span { position: absolute; left: 0; right: 0; top: 0; font: 10px/1 var(--mono); color: #6a6e82; text-align: center; }
.ticks button:hover::before { background: var(--sub); }
.ticks button.done::before { background: rgba(168, 116, 26, 0.5); }
.ticks button.on::before { background: #a8741a; height: 3px; }
.ticks button.on span { color: #a8741a; }
.ticks .sep { width: 10px; }
.ibtn { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--rule2); border-radius: 3px; background: var(--panel); cursor: pointer; font-size: 13px; color: var(--sub); }
.ibtn:hover { color: var(--text); border-color: var(--gold-dim); }

/* ---------- chapter card (left, floating) ---------- */
.card { position: fixed; left: 24px; bottom: 24px; z-index: 4; width: 372px; max-height: 46vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; }
.card header { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px 12px; border-bottom: 1px solid var(--rule); }
.card .no { font: italic 400 40px/0.9 var(--serif); color: var(--gold); min-width: 46px; }
.card h2 { margin: 0; font: 400 21px/1.3 var(--serif); letter-spacing: .06em; }
.card .cen { margin-top: 4px; font: italic 12px/1.2 var(--serif); color: var(--sub); letter-spacing: .04em; }
.card .sec { margin-top: 6px; font: 11px/1 var(--mono); color: var(--faint); letter-spacing: .14em; }
.card .arrows { margin-left: auto; display: flex; gap: 6px; }
.card .arrows button { width: 30px; height: 30px; border: 1px solid var(--rule2); border-radius: 3px; background: none; color: var(--sub); cursor: pointer; }
.card .arrows button:hover { color: var(--gold); border-color: var(--gold-dim); }
.card .body { padding: 14px 20px 18px; overflow-y: auto; scrollbar-width: thin; }
.card .lead p { margin: 0 0 10px; color: #d9d3c6; font-size: 14px; line-height: 1.75; }
.card .lead b { color: var(--gold); font-weight: 500; }
.card .lead .flow { margin: 4px 0 12px; padding: 8px 12px; border-left: 2px solid var(--gold-dim); background: rgba(216, 178, 106, 0.06); font-size: 14px; color: var(--text); }
.card .rule { margin: 4px 0 12px; padding: 10px 12px; border: 1px solid var(--rule2); border-radius: 3px; font-size: 14px; }
.card .rule::before { content: "重點"; display: block; font: 11px/1 var(--mono); letter-spacing: .2em; color: var(--gold); margin-bottom: 6px; }
.tasks { list-style: none; margin: 4px 0 0; padding: 0; }
.tasks li { position: relative; padding: 5px 0 5px 26px; font-size: 14px; color: var(--sub); }
.tasks li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 12px; height: 12px; border: 1px solid var(--rule2); border-radius: 2px; }
.tasks li.ok { color: var(--text); }
.tasks li.ok::before { border-color: var(--gold); background: var(--gold); box-shadow: inset 0 0 0 2px var(--panel-solid); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- panel (right) ---------- */
.panel { position: fixed; right: 24px; top: 92px; bottom: 24px; z-index: 4; width: 360px; overflow-y: auto; background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; scrollbar-width: thin; }
.panel section { padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.panel section:last-child { border-bottom: 0; }
.panel h3 { margin: 0 0 10px; font: 11px/1 var(--mono); letter-spacing: .2em; color: var(--gold); text-transform: uppercase; }
.panel h3 em { font: 12px/1 var(--body); font-style: normal; letter-spacing: .08em; color: var(--sub); margin-left: 6px; text-transform: none; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--rule2); border-radius: 3px; background: none; font-size: 13px; color: var(--text); cursor: pointer; transition: border-color .2s, background .2s; }
.btn:hover { border-color: var(--gold-dim); }
.btn.gold { border-color: var(--gold); color: var(--gold); }
.btn.gold:hover { background: rgba(216, 178, 106, 0.1); }
.btn.on { background: var(--gold); border-color: var(--gold); color: #17130b; }
.btn[disabled] { opacity: .4; cursor: default; }

.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule2); border-radius: 3px; overflow: hidden; }
.seg button { flex: 1 1 auto; padding: 7px 8px; border: 0; border-right: 1px solid var(--rule2); background: none; font-size: 13px; color: var(--sub); cursor: pointer; white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); }
.seg button.on { background: rgba(216, 178, 106, 0.14); color: var(--gold); }
.seg.wrap button { flex: 1 1 30%; border-bottom: 1px solid var(--rule2); }

.sl { margin: 10px 0 4px; }
.sl .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--sub); }
.sl .row b { font: 500 13px/1 var(--mono); color: var(--gold); }
.sl input { width: 100%; margin: 8px 0 0; accent-color: var(--gold); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 18px; background: none; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--rule2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--gold); border: 0; }
input[type=range]::-moz-range-track { height: 2px; background: var(--rule2); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 0; }

/* readout card */
.rd { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.rd dt { color: var(--sub); }
.rd dd { margin: 0; text-align: right; font: 14px/1.5 var(--mono); color: var(--text); }
.rd dd.big { font: 400 22px/1.2 var(--serif); color: var(--gold); }
.rd dd.q { color: var(--faint); }
.rd dd .u { font: 12px var(--body); color: var(--sub); margin-left: 3px; }

/* guess box */
.guess p { margin: 0 0 10px; font-size: 14px; }
.guess .opts { display: grid; gap: 6px; }
.guess .opts button { text-align: left; padding: 8px 12px; border: 1px solid var(--rule2); border-radius: 3px; background: none; font-size: 14px; color: var(--text); cursor: pointer; }
.guess .opts button:hover:not([disabled]) { border-color: var(--gold-dim); }
.guess .opts button[disabled] { cursor: default; }
.guess .opts button.right { border-color: var(--green); color: var(--green); }
.guess .opts button.wrong { border-color: var(--red); color: var(--red); }
.guess .ex { display: none; margin-top: 10px; font-size: 14px; color: #d9d3c6; }
.guess.done .ex { display: block; }
.guess .ex b { color: var(--gold); font-weight: 500; }

/* textbook figure */
.fig { margin: 0; background: #f3eee2; border-radius: 2px; color: #2a2620; }
.fig svg { display: block; width: 100%; height: auto; }
.fig figcaption { padding: 6px 10px 8px; font-size: 12px; color: #6b6458; border-top: 1px solid rgba(42, 38, 32, 0.12); }
.fig .hit { cursor: pointer; }

/* exam table */
.ex-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.ex-t th, .ex-t td { padding: 7px 6px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.ex-t th { font-weight: 400; color: var(--sub); white-space: nowrap; }
.ex-t td { color: var(--text); }
.ex-t tr:last-child th, .ex-t tr:last-child td { border-bottom: 0; }
.note { font-size: 12px; color: var(--faint); margin: 8px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 9px; border: 1px solid var(--rule2); border-radius: 3px; font-size: 13px; color: var(--faint); }
.chip.on { border-color: var(--gold); color: var(--gold); }
.chip.no { text-decoration: line-through; }

.cta { display: block; padding: 12px 14px; border: 1px solid var(--gold); border-radius: 3px; color: var(--gold); text-decoration: none; font-size: 14px; }
.cta:hover { background: rgba(216, 178, 106, 0.08); }
.cta small { display: block; color: var(--sub); font-size: 12px; margin-top: 2px; }

/* bare mode: hide the card and panel to look at the model */
body.bare .card, body.bare .panel { opacity: 0; pointer-events: none; transform: translateY(8px); }
.card, .panel { transition: opacity .3s var(--ease), transform .3s var(--ease); }
.rulebox { padding: 10px 12px; border: 1px solid var(--rule2); border-radius: 3px; font-size: 14px; }

/* toast for results */
.toast { position: fixed; left: 50%; top: 96px; z-index: 6; transform: translate(-50%, -8px); padding: 8px 16px; background: rgba(8, 10, 13, 0.92); border: 1px solid var(--gold-dim); border-radius: 3px; font: 15px/1.5 var(--serif); letter-spacing: .03em; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; max-width: min(520px, 86vw); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* intro veil */
#veil { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #dfe1ee; color: #1b1f2e; transition: opacity 1.4s var(--ease); }
#veil.off { opacity: 0; pointer-events: none; }
#veil .in { text-align: center; }
#veil .in div { font: 400 34px/1.2 var(--serif); letter-spacing: .3em; opacity: 0; animation: up 1s .1s var(--ease) forwards; }
#veil .in small { display: block; margin-top: 12px; font: 11px/1 var(--mono); letter-spacing: .4em; color: #a8741a; opacity: 0; animation: up 1s .4s var(--ease) forwards; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.watermark { position: fixed; left: 24px; bottom: 6px; z-index: 3; font-size: 11px; color: rgba(236, 228, 210, 0.25); letter-spacing: .1em; pointer-events: none; display: none; }

/* ---------- phones / narrow ---------- */
@media (max-width: 899px) {
  body { overflow: auto; }
  #stage { position: sticky; top: 0; height: 52svh; z-index: 1; }
  .top { position: absolute; padding: 12px 14px 0; }
  .brand h1 { font-size: 19px; letter-spacing: .1em; margin-top: 2px; }
  .brand .en, .brand .sub { display: none; }
  .nav { display: none; }
  .mnav { position: sticky; top: 52svh; z-index: 3; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--panel-solid); border-bottom: 1px solid var(--rule); scrollbar-width: none; }
  .mnav button { flex: none; min-width: 34px; height: 30px; border: 1px solid var(--rule2); border-radius: 3px; background: none; color: var(--sub); font: 12px var(--mono); }
  .mnav button.on { border-color: var(--gold); color: var(--gold); }
  .card, .panel { position: static; width: auto; max-height: none; margin: 0; border-radius: 0; border-left: 0; border-right: 0; background: var(--panel-solid); }
  .card .body { overflow: visible; }
  .toast { top: 60px; }
  .tag .t { font-size: 11px; padding: 2px 6px 3px; }
  .tag .t small { font-size: 10px; }
  .tag .stem { height: 10px; }
}
@media (min-width: 900px) { .mnav { display: none; } }
@media (min-width: 900px) and (max-width: 1240px) {
  .card { width: 340px; }
  .panel { width: 320px; }
  .brand h1 { font-size: 24px; }
  .ticks button { width: 20px; }
}

/* 小白's speech bubble */
.tag.bubble .t { max-width: 270px; white-space: normal; padding: 8px 12px 9px; background: #fffdf7; color: #24211b; border: 1.5px solid #24211b; border-radius: 14px; font: 14px/1.5 var(--body); letter-spacing: .02em; box-shadow: 0 3px 0 rgba(36, 33, 27, 0.18); }
.tag.bubble .t b { color: #b5651d; font-weight: 600; }
.tag.bubble .stem { width: 0; height: 0; background: none; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 9px solid #24211b; margin-top: -1px; }
.tag.bubble .dot { display: none; }
.tag.bubble { transition: opacity .3s, transform .05s linear; }
#confetti { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
#gl.pointy { cursor: pointer; }

/* one experiment per page: no chapter ticks */
body.single .ticks, body.single .mnav { display: none; }
