@charset "UTF-8";
/* depth/ode-companion.css — 伴讀層樣式。
   只有在 ode-companion.js 成功執行（body.has-dock）時才改變版面；
   沒有 JS 的頁面維持原本的直排閱讀，不受影響。 */

/* ——— 釘住的圖 ——————————————————————————————————————— */
/* The dock resizes and collapses on purpose and compensates the scroll itself,
   so the browser must not also anchor the scroll position. */
/* Base pages reserve 24px on the root. With a pinned toolbar that also scrolls
   the document when a toolbar control receives focus; targets own clearance. */
html:has(body.has-dock) { scroll-padding-top: 0; }
body.has-dock { overflow-anchor: none; }
body.has-dock .instrument {
  position: sticky;
  top: 0;
  z-index: 6;
  margin-bottom: 0;
  box-shadow: 0 18px 30px -24px #000c;
}
/* 手機把控制項移到釘住區之外，仍然接在圖的下面。 */
.dock-extras {
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--panel);
  margin-bottom: 40px;
}
.dock-extras:empty { display: none; }
body:not(.has-dock) .dock-extras { display: none; }
body.has-dock .instrument + .dock-extras:empty + .reading-layout { margin-top: 40px; }
body.has-dock .instrument-head { padding: 12px 22px 8px; }
body.has-dock .instrument-head h2 { font-size: 16px; line-height: 1.5; margin: 0; }
body.has-dock .instrument-head .legend { margin-top: 8px; }
body.has-dock .instrument canvas { height: 190px; }
body.has-dock .controls { padding: 12px 22px; gap: 10px; }
body.has-dock .control-row button { min-height: 40px; padding: 4px 13px; font-size: 14px; }
body.has-dock input[type="range"] { height: 36px; }
body.has-dock .readout { padding: 10px 22px; gap: 10px; }
body.has-dock .readout output { font-size: 18px; line-height: 1.5; }
/* 固定高度：換段落時說明文字長短不同，釘住的高度不能跟著抖。 */
body.has-dock .observation {
  padding: 9px 22px 11px;
  font-size: 13px;
  line-height: 1.65;
  height: 5.9em;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.has-dock .fallback { padding: 14px 22px; }
body.has-dock .instrument-plots h3 { margin: 10px 20px 4px; font-size: 14px; }
/* 整式比對是圖的一部分，壓緊排版才放得進釘住區。 */
body.has-dock .factor-identity { padding: 10px 20px 12px; }
body.has-dock .factor-identity > p { margin-bottom: 8px; font-size: 12px; }
body.has-dock .identity-pair { gap: 16px; }
body.has-dock .identity-pair > div { padding-top: 8px; }
body.has-dock .identity-pair .math { font-size: 19px; line-height: 1.6; }
body.has-dock .factor-identity .identity-gap { margin-top: 8px; font-size: 13.5px; }
body.has-dock .instrument-plots .legend { padding-bottom: 8px; }

/* 收起後只留工具列，圖與控制項整組隱藏。 */
.instrument[data-dock-open="false"] > *:not(.dock-bar) { display: none; }

/* 桌機把圖與控制項並排，釘住的高度才壓得下來。 */
@media (min-width: 1000px) {
  body.has-dock .dock-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(290px, 1fr);
    align-items: start;
  }
  /* 右欄有上限：控制項多的頁面也不會把釘住的高度撐爆。 */
  body.has-dock .dock-side {
    border-left: 1px solid var(--line);
    max-height: min(300px, 33vh);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  body.has-dock .dock-side > :first-child { border-top: 0; }
  /* Keep the main figure at the shared dock height. */
  body.has-dock .dock-figure { display: flex; flex-direction: column; }
  body.has-dock .dock-figure > .plot { flex: 1; display: flex; flex-direction: column; min-height: 190px; }
  /* Keep CSS geometry independent of the bitmap's intrinsic aspect ratio.
     An auto height feeds rounded canvas.width/height writes back into layout
     during ResizeObserver delivery, shifting the dock and triggering a loop. */
  body.has-dock .dock-figure > .plot canvas { flex: none; height: 190px; min-height: 190px; }
  body.has-dock .dock-figure > .factor-identity { border-top: 1px solid var(--line); }
  body.has-dock .dock-figure:has(.factor-identity) > .plot { flex: none; min-height: 0; }
  body.has-dock .dock-figure:has(.factor-identity) > .plot canvas { flex: none; min-height: 0; height: 150px; }
}
@media (max-width: 999px) {
  body.has-dock .dock-cols,
  body.has-dock .dock-figure,
  body.has-dock .dock-side { display: contents; }
}

/* ——— 工具列 ——————————————————————————————————————— */
.dock-bar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 6px 12px;
  padding: 4px 14px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}
.dock-bar button {
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}
.dock-bar button:hover { color: var(--ink); }
.dock-follow[aria-pressed="true"] { color: var(--gold); border-color: #4a3f28; }
.dock-follow[aria-pressed="false"] { color: var(--muted); border-style: dashed; }
.dock-cue {
  margin: 0;
  min-width: 0;
  height: 1.5em;
  color: var(--gold);
  font-size: 12.5px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dock-menu { grid-column: 1; grid-row: 1; }
.dock-cue { grid-column: 2; grid-row: 1; }
.dock-tools { grid-column: 3; grid-row: 1; }
.dock-follow { grid-column: 4; grid-row: 1; }
.dock-open { grid-column: 5; grid-row: 1; }
.dock-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: #1a2030; }
.dock-progress i { display: block; height: 100%; width: 0; background: var(--gold); }

.dock-menu { border: 0; }
.dock-menu > summary { min-height: 36px; padding: 7px 0; font-size: 13px; color: var(--muted); }
.dock-menu > summary:hover { color: var(--ink); }
.dock-menu-body {
  position: absolute;
  top: 100%;
  left: 8px;
  z-index: 3;
  width: min(430px, calc(100vw - 32px));
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding: 8px 18px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 34px #000c;
}
.dock-menu-body nav a {
  display: block;
  min-height: 42px;
  padding: 9px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  text-decoration: none;
  border-bottom: 1px solid #161b26;
}
.dock-menu-body nav a:hover { color: var(--ink); }
.dock-menu-body nav a.is-active { color: var(--gold); }
.dock-menu-body nav a.is-active::before { content: '▸ '; }
.primer > summary { font-size: 14px; color: var(--gold); padding: 14px 0 10px; min-height: 44px; }
.primer dl { margin: 0 0 10px; font-size: 14px; line-height: 1.75; }
.primer dt { color: var(--ink); font-weight: 600; margin-top: 12px; }
.primer dd { margin: 4px 0 0; color: var(--muted); }

/* ——— 圖的長說明 ——————————————————————————————————— */
.figure-note { border-bottom: 0; border-top: 1px solid var(--line); }
.figure-note > summary { padding: 10px 22px; min-height: 42px; font-size: 13px; color: var(--muted); }
.figure-note > summary:hover { color: var(--ink); }
.figure-note-body { padding: 0 22px 14px; font-size: 13.5px; line-height: 1.8; color: var(--muted); }
.figure-note-body > * { margin: 0 0 10px; padding: 0; }
.figure-note-body > :last-child { margin-bottom: 0; }
.article > section > .prediction { border-left: 2px solid var(--gold); padding: 8px 0 8px 14px; margin: 0 0 20px; color: var(--ink); font-size: 16px; }

/* ——— 側邊目錄與錨點：讓開釘住的圖 ————————————————————— */
/* Anchor targets carry their own clearance. Using scroll-padding on the root
   instead would also push the browser to scroll when focus lands on a control
   inside the pinned dock, which can never leave that band. */
body.has-dock #reading,
body.has-dock .dock-extras,
body.has-dock .article > section { scroll-margin-top: calc(var(--dock-h, 0px) + 18px); }

body.has-dock .contents {
  top: calc(var(--dock-h, 0px) + 20px);
  max-height: calc(100vh - var(--dock-h, 0px) - 40px);
  overflow-y: auto;
}
body.has-dock .contents a.is-active { color: var(--gold); }

/* ——— 白話重點句 ————————————————————————————————— */
.plain {
  display: flow-root;
  margin: 0 0 20px;
  padding: 10px 16px;
  border-left: 2px solid var(--curve);
  background: #070d12;
  font-size: 16px;
  line-height: 1.85;
}
.plain::before {
  content: '白話';
  display: inline-block;
  margin-right: 10px;
  padding: 1px 7px;
  border: 1px solid #2c4a44;
  border-radius: 2px;
  color: var(--curve);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: .08em;
  vertical-align: 2px;
}

/* ——— 名詞白話註釋 ——————————————————————————————— */
.term {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  border-bottom: 1px dotted var(--gold);
  cursor: help;
}
.term::after { content: '?'; font-size: .58em; vertical-align: super; color: var(--gold); opacity: .7; margin-left: 1px; }
.term[aria-expanded="true"] { color: var(--gold); }
.term-pop {
  position: fixed;
  z-index: 20;
  padding: 14px 16px 15px;
  border: 1px solid #39415a;
  background: #0d121c;
  box-shadow: 0 18px 38px #000d;
  font-size: 14px;
  line-height: 1.75;
}
.term-pop strong { display: block; color: var(--gold); font-size: 13px; letter-spacing: .04em; margin-bottom: 6px; }
.term-pop p { margin: 0; }
.term-pop .term-hint { margin-top: 8px; color: var(--muted); font-size: 13px; }

/* ——— 窄螢幕 ————————————————————————————————————— */
@media (max-width: 820px) {
  body.has-dock .instrument-head { padding: 8px 16px 4px; }
  body.has-dock .instrument-head h2 { font-size: 15px; }
  body.has-dock .instrument canvas { height: 192px; }
  body.has-dock .instrument-plots canvas { height: 150px; }
  body.has-dock .controls { padding: 10px 16px; }
  body.has-dock .readout { padding: 9px 16px; }
  body.has-dock .readout output { font-size: 16px; }
  body.has-dock .observation { padding: 8px 16px 10px; height: auto; font-size: 12.5px; }
  body.has-dock .component-values { padding: 12px 16px; gap: 16px; }
  body.has-dock .component-values span { min-height: 2.6em; font-size: 11.5px; }
  body.has-dock .component-values output { font-size: 17px; }
  body.has-dock .component-values > div + div::before { top: 2.3em; }
  .dock-bar { padding: 3px 12px 5px; row-gap: 0; column-gap: 8px; }
  .dock-bar button { min-height: 32px; padding: 4px 8px; font-size: 12px; }
  .dock-menu > summary { min-height: 32px; padding: 5px 0; font-size: 12px; }
  .dock-cue {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 2.9em;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  /* 釘住時空間有限：標題壓成一行，數值改成左右對齊的單欄。 */
  body.has-dock .instrument-head h2 {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.has-dock .readout { grid-template-columns: 1fr; gap: 1px; padding: 7px 16px 9px; }
  body.has-dock .readout > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
  body.has-dock .readout span { font-size: 12px; }
  body.has-dock .readout output { font-size: 15px; line-height: 1.6; }
  body.has-dock .figure-note > summary { padding-block: 7px; min-height: 34px; }
  .figure-note > summary, .figure-note-body { padding-inline: 16px; }
  .plain { font-size: 15px; padding: 9px 13px; }
}
/* 螢幕太矮時釘住反而擋路：回到原本的直排。 */
@media (max-height: 620px) {
  body.has-dock .instrument { position: static; }
  body.has-dock .contents { top: 20px; max-height: none; }
  body.has-dock #reading,
  body.has-dock .dock-extras,
  body.has-dock .article > section { scroll-margin-top: 18px; }
}
@media print {
  body.has-dock .instrument { position: static; }
  .dock-bar, .term-pop { display: none; }
  .term { border-bottom: 0; }
  .term::after { content: ''; }
}
