/* ===========================================================================
   base.css — reset、排版、可及性基礎。
   這裡不放任何元件樣式，元件一律在 components.css。
   =========================================================================== */

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

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

body {
  margin: 0;
  /* 規格第八節：body 必須明確指定底色，不可繼承宿主背景。 */
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

h1, h2, h3, h4 {
  line-height: var(--lh-tight);
  font-weight: 600;
  text-wrap: balance;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }

img, svg { display: block; max-width: 100%; height: auto; }

a {
  color: inherit;
  text-decoration-color: var(--line-2);
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* --- 可及性 --------------------------------------------------------------
   規格第九節：鍵盤可完整操作，focus ring 明顯可見，不可 outline:none。
   用 :focus-visible 讓滑鼠點擊不出現外框，鍵盤操作一定出現。 */

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

/* 舊瀏覽器沒有 :focus-visible 時的保底，仍然看得見 focus。 */
@supports not selector(:focus-visible) {
  :focus { outline: 2px solid var(--focus); outline-offset: 2px; }
}

.skip-link {
  position: absolute;
  left: var(--s3);
  top: calc(-1 * var(--s8));
  z-index: 100;
  padding: var(--s2) var(--s4);
  background: var(--surface);
  border: var(--hair) solid var(--line-2);
  border-radius: var(--r-md);
  transition: top 120ms ease;
}
.skip-link:focus { top: var(--s3); }

/* 螢幕閱讀器可讀、視覺上隱藏。 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- 數字 ----------------------------------------------------------------
   規格第八節：所有數字欄位加 tabular-nums，讓欄位對得齊。 */

.num, table, .meter-value, .stat-value, .badge-term {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --- 版面骨架 ------------------------------------------------------------ */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--s4);
}

/* 內容是 JS 畫出來的，畫出來之前 #main 只有一行「載入中」。
   高度不夠時頁尾一開始就在視窗裡，內容一出現就把它往下推 ——
   Lighthouse 實測這一跳讓 CLS 到 0.18–0.24，桌機效能掉到 88。
   撐滿一個視窗高，頁尾一開始就在視窗外，被推下去也不算版面位移。 */
#main { min-height: 100vh; }

/* 髮絲線是這個站的分隔語彙，不是卡片。 */
.hair { border: 0; border-top: var(--hair) solid var(--line); margin: 0; }
