/* Boris Cherny:靛藍底、琥珀標記。整頁用 diff 的語彙:= 沒變、− 先前、+ 最近。 */

:root {
  color-scheme: light dark;
  --bg: #eceefb;        /* 淡靛白:頁面底色 */
  --panel: #f8f9ff;     /* 區塊底 */
  --ink: #15184a;       /* 深靛:內文 */
  --ink2: #3b4089;      /* 次要文字、先前的說法 */
  --dim: #5d63ad;       /* 標籤、刻度 */
  --rule: #c6caee;      /* 分隔線 */
  --amber: #ffb02e;     /* 琥珀:色塊 */
  --amber-ink: #8f4700; /* 琥珀:淺底上的字 */
  --hot: rgba(255, 176, 46, 0.26);
  --edge: #b46a00;      /* 淺底上替琥珀色塊描邊 */
  --link: #2a2faf;
  --focus: #2a2faf;

  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans TC", monospace;
  --text: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111335;
    --panel: #181b47;
    --ink: #e9ebff;
    --ink2: #c5c9f6;
    --dim: #9197d8;
    --rule: #2c3072;
    --amber-ink: #ffb02e;
    --hot: rgba(255, 176, 46, 0.14);
    --edge: transparent;
    --link: #b4b9ff;
    --focus: #ffb02e;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

::selection { background: var(--amber); color: #15184a; }

a { color: var(--link); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:hover { color: var(--amber-ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

code {
  font-family: var(--mono);
  font-size: 0.8em;
  padding: 0.1em 0.35em;
  border: 1px solid var(--rule);
  border-radius: 3px;
}

q { quotes: "“" "”"; }
q[lang="en"] { font-family: var(--mono); font-size: 0.82em; letter-spacing: -0.02em; }

.vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 10;
  padding: 0.5rem 0.9rem; background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 0.8rem;
}
.skip:focus { top: 0.75rem; color: var(--bg); }

.wrap {
  max-width: 70rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
}

/* ── 頂列 ── */

.top { border-bottom: 1px solid var(--rule); }
.top-in {
  display: flex; align-items: baseline; gap: 0.1rem;
  padding-block: 0.8rem;
  font-family: var(--mono); font-size: 0.78rem;
}
.home { color: var(--ink); font-family: var(--text); font-weight: 700; font-size: 0.95rem; }
.path { color: var(--dim); }

/* ── 指令列:每一節開頭的提示字元 ── */

.cmd {
  margin: 0 0 1rem;
  font-family: var(--mono); font-size: 0.74rem; line-height: 1.6;
  color: var(--dim);
}
.ps1 { color: var(--amber-ink); font-weight: 700; margin-right: 0.4em; }

.mk { font-family: var(--mono); font-weight: 700; }

/* ── Hero ── */

.hero { padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(2.5rem, 6vw, 4.5rem); }

h1 { margin: 0 0 1.75rem; font-weight: 900; }
h1 > span { display: block; }
.h1-name {
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(2.2rem, 10.4vw, 7rem);
  line-height: 1;
  letter-spacing: -0.06em;
  margin-bottom: 0.3em;
  margin-left: -0.04em;
}
.h1-line {
  display: flex; align-items: baseline; gap: 0.45em;
  font-size: clamp(1.55rem, 5.2vw, 3.3rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
}
.h1-line .mk { flex: none; width: 1ch; text-align: center; color: var(--dim); font-size: 0.8em; }
.h1-chg .mk { color: var(--amber-ink); }

.lede { max-width: 40rem; margin: 0 0 2.25rem; font-size: 1.125rem; color: var(--ink2); }

.jump {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  margin-top: 2rem;
  font-family: var(--mono); font-size: 0.78rem;
}
.jump a { font-family: var(--text); font-size: 0.95rem; font-weight: 500; }

/* ── Diff 區塊:這一頁的主角 ── */

.diff {
  margin: 0 0 1.5rem;
  max-width: 54rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.diff figcaption {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule);
  font-weight: 700;
  line-height: 1.5;
}
.at { font-family: var(--mono); font-size: 0.78em; font-weight: 400; color: var(--dim); }

.lines { list-style: none; margin: 0; padding: 0; }
.ln {
  display: grid;
  grid-template-columns: 2.4rem 4.6rem minmax(0, 1fr) auto;
  column-gap: 0.75rem;
  align-items: baseline;
  padding: 0.8rem 1rem 0.8rem 0;
}
.ln + .ln { border-top: 1px solid var(--rule); }
.ln .mk { text-align: center; }
.ln time { font-family: var(--mono); font-size: 0.74rem; }
.ln p { margin: 0; }
.ln .src { justify-self: end; }
.ln .srcs { justify-self: end; flex-direction: column; align-items: flex-end; gap: 0; }
.ln.old { color: var(--ink2); }
.ln.old .mk, .ln.old time { color: var(--dim); }
.ln.new { background: var(--hot); box-shadow: inset 4px 0 0 var(--amber); font-weight: 500; }
.ln.new .mk, .ln.new time { color: var(--amber-ink); }

.src {
  font-family: var(--mono); font-size: 0.68rem; line-height: 1.6;
  color: var(--dim);
  text-decoration-style: dotted;
  white-space: nowrap;
}
.srcs { display: flex; flex-wrap: wrap; gap: 0.1rem 1rem; }

.hero-diff { max-width: 44rem; margin-bottom: 0; }
.hero-diff q[lang="en"] { font-size: 0.9em; font-weight: 500; }

@media (prefers-reduced-motion: no-preference) {
  .hero-diff .ln { animation: line-in 0.5s ease-out both; }
  .hero-diff .ln.old { animation-delay: 0.25s; }
  .hero-diff .ln.new { animation-delay: 0.95s; }
  @keyframes line-in {
    from { opacity: 0; transform: translateX(-0.6rem); }
    to { opacity: 1; transform: none; }
  }
}

/* ── 一般段落 ── */

main > section:not(.hero), .themes { padding-block: clamp(2.75rem, 6vw, 4.5rem); }
main > section:not(.hero) { border-top: 1px solid var(--rule); }
.themes { padding-top: 0; }

h2 {
  display: flex; align-items: baseline; gap: 0.45em;
  margin: 0 0 0.75rem;
  font-size: clamp(1.6rem, 4.4vw, 2.5rem);
  font-weight: 900; line-height: 1.3;
}
h2 .mk { font-size: 0.8em; color: var(--dim); }
#changed-h .mk { color: var(--amber-ink); }

.sec-lede { max-width: 40rem; margin: 0 0 2rem; color: var(--ink2); }

/* ── 他是誰 ── */

.who { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.5rem 4rem; }
.who h2 { grid-column: 1 / -1; }
.facts { margin: 0; }
.facts > div { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--rule); }
.facts dt { font-family: var(--text); font-weight: 700; color: var(--dim); font-size: 0.9rem; line-height: 2; }
.facts dd { margin: 0; }
.howto { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 1.1rem 1.25rem 1.2rem; align-self: start; }
.howto h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.howto ul { margin: 0; padding-left: 1.2rem; font-size: 0.95rem; color: var(--ink2); }
.howto li + li { margin-top: 0.35rem; }

/* ── 時間軸 ── */

.tl { padding: 3.6rem 0.5rem 2.2rem; }
.tl-track { position: relative; height: 0; border-top: 2px solid var(--ink); }
.tick { position: absolute; top: 0; width: 1px; height: 7px; background: var(--dim); }
.tick b {
  position: absolute; top: 11px; left: 0; transform: translateX(-50%);
  font: 400 0.62rem/1 var(--mono); color: var(--dim); white-space: nowrap;
}
.tick:first-child b { transform: none; }
.dot {
  position: absolute; top: -1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1.5px var(--ink);
  transform: translate(-50%, -50%);
  transition: transform 0.15s;
}
.dot::before {
  content: ""; position: absolute; left: 50%; bottom: 100%;
  width: 1px; height: 10px; margin-bottom: 2px; background: var(--dim);
}
.dot.hi::before { height: 28px; }
.dot em {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 15px;
  transform: translateX(-50%);
  font: 700 0.66rem/1 var(--mono); font-style: normal; color: var(--ink);
  white-space: nowrap;
}
.dot.hi em { margin-bottom: 33px; }
.dot.end em { left: auto; right: -5px; transform: none; }
.dot.is-on { transform: translate(-50%, -50%) scale(1.5); z-index: 1; }
.dot.is-on em { color: var(--amber-ink); }

.log { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule); }
.log li {
  display: grid; grid-template-columns: 6.6rem 3.2rem minmax(0, 1fr);
  column-gap: 0.75rem; align-items: baseline;
  padding: 0.65rem 0.5rem;
  border-top: 1px solid var(--rule);
}
.log time { font-family: var(--mono); font-size: 0.74rem; color: var(--dim); }
.code { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; color: var(--amber-ink); }
.log a { font-weight: 700; }
.kind { display: block; font-size: 0.9rem; color: var(--ink2); line-height: 1.6; }
.log li.is-on { background: var(--hot); }

/* ── 主題 × 來源 ── */

.mx { width: 100%; border-collapse: collapse; }
.mx thead th { padding: 0 0 0.5rem; vertical-align: bottom; font: 700 0.68rem/1.3 var(--mono); color: var(--ink); }
.mx thead th small { display: block; font-size: 0.56rem; font-weight: 400; color: var(--dim); }
.mx abbr { text-decoration: none; cursor: help; }
.mx thead td.n { font-size: 0.7rem; color: var(--dim); text-align: right; vertical-align: bottom; padding-bottom: 0.5rem; }
.mx tbody th[scope="row"] { width: 17rem; padding: 0.3rem 1rem 0.3rem 0; text-align: left; font-weight: 500; line-height: 1.5; }
.mx tbody th[scope="row"] a { color: var(--ink); text-decoration: none; }
.mx tbody th[scope="row"] a:hover { color: var(--amber-ink); text-decoration: underline; }
.mx td { padding: 3px; }
.mx td.n { width: 3rem; padding-left: 0.75rem; text-align: right; font: 700 0.85rem/1 var(--mono); color: var(--amber-ink); }
.mx .grp th {
  padding: 1.4rem 0 0.4rem; text-align: left;
  font-size: 0.8rem; font-weight: 700; color: var(--dim);
  border-bottom: 1px solid var(--rule);
}
.mx .on, .mx .off {
  display: block; height: 1.9rem; border-radius: 3px;
  overflow: hidden; text-indent: -999em; white-space: nowrap;
}
.mx .on { background: var(--amber); box-shadow: inset 0 0 0 1.5px var(--edge); transition: transform 0.12s; }
.mx .on:hover, .mx .on:focus-visible { transform: scale(1.12); }
.mx .on:focus-visible { outline-color: var(--ink); }
.mx .off { background: radial-gradient(circle, var(--rule) 0 2px, transparent 2.6px); }
.mx.has-col .on:not(.is-col) { opacity: 0.35; }
.mx.has-col thead th.is-col { color: var(--amber-ink); }

.status {
  display: none;
  margin: 1.25rem 0 0; padding: 0.7rem 1rem; min-height: 3.4rem;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 6px;
  font-size: 0.92rem; line-height: 1.7;
}
.js .status { display: block; }
@media (hover: none) { .js .status { display: none; } }

/* ── 九個想法 ── */

.grp-h {
  margin: 0; padding: 3rem 0 0.9rem;
  font-size: 0.95rem; font-weight: 700; color: var(--dim);
}
.grp-h:first-child { padding-top: 0; }

.theme {
  display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
  gap: 1.5rem clamp(2rem, 5vw, 4.5rem);
  padding-block: 2.25rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}
.theme > header { align-self: start; position: sticky; top: 1.5rem; }
.theme h4 { margin: 0 0 0.6rem; font-size: 1.5rem; font-weight: 900; line-height: 1.35; }
.gist { margin: 0 0 0.9rem; color: var(--ink2); }
.count { margin: 0; font-size: 0.82rem; color: var(--dim); }
.count b { font: 800 1.25rem/1 var(--mono); color: var(--amber-ink); }

.rm-h { margin: 1.4rem 0 0.4rem; font-size: 0.82rem; font-weight: 700; color: var(--dim); }
.rm { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; line-height: 1.5; }
.rm li { padding: 0.35rem 0; border-top: 1px dashed var(--rule); }
.rm s { text-decoration-color: var(--amber-ink); text-decoration-thickness: 2px; }
.rm span { display: block; font-size: 0.78rem; color: var(--dim); }
.rm .todo { font-weight: 700; }

.pts { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule); }
.pts li { padding: 0.85rem 0.75rem 0.85rem 1.25rem; }
.pts li + li { border-top: 1px dashed var(--rule); }
.pts p { margin: 0 0 0.3rem; }
.pts li.hit { background: var(--hot); box-shadow: inset 4px 0 0 var(--amber); margin-left: -2px; padding-left: calc(1.25rem + 2px); }

/* ── 變了的說法 ── */

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.75rem; margin: 0 0 1.5rem; font-size: 0.88rem; color: var(--ink2); }
.legend .mk { margin-right: 0.5em; }
.legend .old .mk { color: var(--dim); }
.legend .new .mk { color: var(--amber-ink); }

#changed .diff { margin-bottom: 2rem; scroll-margin-top: 1rem; }

/* ── 比例圖 ── */

.pct { margin: 3.5rem 0 0; max-width: 54rem; }
.pct h3 { margin: 0 0 0.3rem; font-size: 1.3rem; font-weight: 900; }
.pct figcaption p { margin: 0 0 1.25rem; color: var(--ink2); max-width: 40rem; }
.pct-rows { list-style: none; margin: 0; padding: 0; }
.pct-rows li {
  display: grid; grid-template-columns: 15rem minmax(0, 1fr) 4.8rem;
  column-gap: 1.25rem; align-items: center;
  padding: 0.6rem 0; border-top: 1px solid var(--rule);
}
.lab { display: grid; grid-template-columns: 4.4rem minmax(0, 1fr); column-gap: 0.5rem; align-items: baseline; line-height: 1.45; }
.lab time, .lab .when { font: 400 0.74rem/1.6 var(--mono); color: var(--dim); }
.lab .when { font-family: var(--text); font-size: 0.85rem; }
.lab b { font-weight: 700; font-size: 0.95rem; }
.lab .by { grid-column: 2; font-size: 0.78rem; color: var(--dim); }
.lab a.by { font: 400 0.68rem/1.6 var(--mono); text-decoration-style: dotted; }
.track {
  position: relative; height: 1.5rem; margin-right: 0.5rem;
  background: linear-gradient(to right, var(--rule) 1px, transparent 1px) 0 0 / 25% 100%;
  border-right: 1px solid var(--rule);
}
.bar {
  position: absolute; top: 22%; height: 56%;
  left: calc(var(--a) * 1%); width: calc((var(--b) - var(--a)) * 1%);
  background: var(--amber); border-radius: 2px;
  box-shadow: inset 0 0 0 1.5px var(--edge);
}
.pt {
  position: absolute; top: 50%; left: calc(var(--a) * 1%);
  width: 0.95rem; height: 0.95rem; border-radius: 50%;
  background: var(--amber);
  box-shadow: inset 0 0 0 1.5px var(--edge);
  transform: translate(-50%, -50%);
}
.full .pt { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--amber-ink); }
.memo .pt { background: var(--bg); border: 2.5px solid var(--amber-ink); }
.val { font: 700 0.85rem/1 var(--mono); text-align: right; white-space: nowrap; }
.memo .val { font-weight: 400; }
.axis {
  display: flex; justify-content: space-between;
  margin: 0.2rem 6.55rem 0 16.25rem;
  font: 400 0.62rem/1.4 var(--mono); color: var(--dim);
}
.axis span { width: 0; display: flex; justify-content: center; white-space: nowrap; }

/* ── Reference ── */

.refs h3 { margin: 2.25rem 0 0.5rem; font-size: 1.05rem; }
.reflist { list-style: none; margin: 0; padding: 0; max-width: 54rem; }
.reflist li {
  display: grid; grid-template-columns: 3.2rem minmax(0, 1fr); column-gap: 0.75rem; align-items: baseline;
  padding: 0.7rem 0.5rem; border-top: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}
.reflist.plain li { grid-template-columns: minmax(0, 1fr); }
.reflist li:target { background: var(--hot); box-shadow: inset 4px 0 0 var(--amber); }
.reflist time { white-space: nowrap; }
.fine { margin: 2rem 0 0; font-size: 0.85rem; color: var(--dim); }

.foot { border-top: 1px solid var(--rule); padding-block: 1.75rem 2.5rem; }
.foot a { font-weight: 700; }

/* ── 窄螢幕 ── */

@media (max-width: 760px) {
  body { font-size: 1rem; }

  .who { grid-template-columns: minmax(0, 1fr); }

  .ln { grid-template-columns: 1.9rem auto minmax(0, 1fr); row-gap: 0.15rem; padding-right: 0.8rem; }
  .ln .mk { grid-row: 1; grid-column: 1; }
  .ln time { grid-row: 1; grid-column: 2; }
  .ln .src, .ln .srcs { grid-row: 1; grid-column: 3; }
  .ln .srcs { flex-direction: row; gap: 0 0.6rem; justify-content: flex-end; }
  .ln p { grid-row: 2; grid-column: 2 / -1; }

  .log li { grid-template-columns: auto minmax(0, 1fr); row-gap: 0.1rem; }
  .log li > div { grid-column: 1 / -1; }

  .mx, .mx thead, .mx tbody, .mx tr { display: block; }
  .mx thead { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: 0.5rem; border-bottom: 1px solid var(--rule); }
  .mx thead tr, .mx tbody tr:not(.grp) { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)) 1.6rem; gap: 3px; align-items: center; }
  .mx thead td:first-child { display: none; }
  .mx thead th { padding-bottom: 0.4rem; font-size: 0.56rem; letter-spacing: -0.04em; text-align: center; }
  .mx thead th small { display: none; }
  .mx thead td.n { font-size: 0; padding: 0; }
  .mx tbody th[scope="row"] { grid-column: 1 / -1; width: auto; padding: 0.85rem 0 0.2rem; font-weight: 700; }
  .mx td { padding: 0; }
  .mx td.n { width: auto; padding-left: 0; font-size: 0.78rem; }
  .mx .grp th { display: block; padding-top: 1.6rem; }
  .mx .on, .mx .off { height: 1.7rem; }

  .theme { grid-template-columns: minmax(0, 1fr); gap: 1.1rem; padding-block: 1.75rem; }
  .theme > header { position: static; }
  .theme h4 { font-size: 1.3rem; }

  .pct-rows li { grid-template-columns: minmax(0, 1fr) 4.4rem; row-gap: 0.35rem; column-gap: 0.75rem; }
  .pct-rows .lab { grid-column: 1 / -1; }
  .axis { margin: 0.2rem 5.65rem 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dot, .mx .on { transition: none; }
}
