/* 基礎：reset、排版、焦點、減少動態（D01 第 2、6、7 節）
   字體：正文用系統字型堆疊（不載入網路字型）；標題粉圓見 /assets/fonts/fonts.css */

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + var(--sp-4));
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  text-align: start;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
main { flex: 1; display: block; }
img, svg, video, picture { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
/* 內文連結用 --brand-dark：--brand 在 --paper 上只有 3.2:1，未達 AA */
a { color: var(--brand-dark); text-underline-offset: .2em; }
a:hover, a:active { color: var(--ink); }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
[hidden] { display: none !important; }

/* ── 排版 ── */
h1, h2, h3, .h1, .h2, .h3 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: var(--lh-heading);
  color: var(--ink);
  text-wrap: balance;
}
h1, .h1 { font-size: var(--fs-h1); }
h2, .h2 { font-size: var(--fs-h2); }
h3, .h3 { font-size: var(--fs-h3); }
h4, h5, h6 { font-size: var(--fs-body); font-weight: 700; line-height: var(--lh-heading); }
p { text-wrap: pretty; }
p + p { margin-top: 1em; }
small, .small { font-size: var(--fs-small); }
.muted { color: var(--ink-soft); }
strong, b { font-weight: 700; }

/* ── 版面工具 ── */
.container {
  width: 100%;
  max-width: calc(var(--max-w) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section { padding-block: var(--sp-8); }
.section--alt { background: var(--paper-2); }
@media (min-width: 768px) { .section { padding-block: var(--sp-9); } }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 200;
  padding: var(--sp-2) var(--sp-4);
  background: var(--ink);
  color: var(--white);
  border-radius: var(--r-sm);
}
.skip-link:focus { top: var(--sp-2); color: var(--white); }

/* ── 焦點 ── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ── 進場（motion.js 加 .is-in） ── */
[data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--t-enter) var(--ease), transform var(--t-enter) var(--ease);
}
[data-reveal].is-in { opacity: 1; transform: none; }
/* 沒有 JS 時不要藏內容 */
html:not(.js) [data-reveal] { opacity: 1; transform: none; }

/* ── 頁面轉場 ── */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--t-page);
  animation-timing-function: var(--ease);
}

/* ── 減少動態：關閉移動，只保留透明度 ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-property: opacity !important;
  }
  [data-reveal] { transform: none; }
}
