/* 重設、字體、版面寬度、共用的標題與「捲到才浮上」。顏色和字級一律用 tokens.css 的變數。 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.7;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
/* 背景光暈：固定在視窗上的三處，讓毛玻璃底下有東西可以透 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(70vw 46vw at 88% 30%, var(--glow-cool), var(--scrim-0) 70%),
    radial-gradient(60vw 44vw at 6% 72%, var(--glow-mark), var(--scrim-0) 70%),
    radial-gradient(60vw 40vw at 70% 100%, var(--glow-cool-2), var(--scrim-0) 70%);
}
h1, h2, h3, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: transparent; border: 0; padding: 0; cursor: pointer; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

a, button, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}
[id] { scroll-margin-top: calc(var(--nav-h) + 30px); }

/* 跳到主要內容：平常在畫面外，按 Tab 才出現 */
.skip {
  position: absolute;
  left: 16px;
  top: 0;
  z-index: 60;
  transform: translateY(-120%);
  background: var(--mark);
  color: var(--markink);
  font-size: var(--fs-btn);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--r-pill);
}
.skip:focus { transform: translateY(12px); }

.wrap { width: min(1240px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.sec { padding-top: var(--sec-gap); }
.sec-head { display: grid; gap: 10px; margin-bottom: clamp(20px, 3.4vw, 40px); }
.sec-head p { max-width: 30em; text-wrap: balance; }
.ph { display: inline-block; }

h1, h2, h3, .h2, .h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
.h2 { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: var(--fs-h2); line-height: 1.18; }
.h3 { font-family: var(--serif); font-weight: 700; color: var(--ink); font-size: var(--fs-h3); line-height: 1.25; }
.lab { font-size: var(--fs-label); letter-spacing: .14em; color: var(--ink2); }
.measure { max-width: 30em; }
.num { font-family: var(--latin); font-variant-numeric: tabular-nums; }

/* 捲到才浮上：只有腳本跑起來才會先藏，沒跑就直接看得到 */
.js .reveal { opacity: 0; transform: translateY(18px); }
.js .reveal.in { opacity: 1; transform: none; transition: opacity .8s var(--ease), transform .8s var(--ease); }

@keyframes up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes sweep { from { transform: scaleX(0); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }

/* 換頁時淡接（選配，支援的瀏覽器才有） */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media (max-width: 760px) {
  :root { --gutter: 16px; }
  [id] { scroll-margin-top: 16px; }
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
