/**
 * Base — Reset + 基礎排版
 * ============================================
 * 【2026-08-04 Apple 風改版】
 * 字體策略：英數走系統字（Mac=SF Pro / Win=Segoe UI Variable），中文 fallback 到
 * Noto Sans TC。標題用 --font-display 並套負字距，做出 Apple 大標那種收斂的視覺。
 */

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

html {
  /* iOS 安全區 + 避免橡皮筋捲動露出白邊 */
  background: var(--color-canvas);
  -webkit-text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "palt" 1;   /* 中文標點半形對齊 */
  font-variant-numeric: tabular-nums; /* 數字等寬，表格與金額不跳動 */
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* 點擊高亮拿掉，改由各元件自己做 active 回饋（iOS 質感） */
  -webkit-tap-highlight-color: transparent;
}

/* 標題：Display 字體 + 負字距（Apple 大標的關鍵） */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-title);
  color: var(--color-primary);
}

h1 { font-size: var(--fs-xxl); font-weight: var(--fw-bold); letter-spacing: var(--ls-display); }
h2 { font-size: var(--fs-xl);  font-weight: var(--fw-semibold); }
h3 { font-size: var(--fs-lg);  font-weight: var(--fw-semibold); }

p { margin: 0; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}
a:hover { color: var(--color-primary-dk); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select {
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--color-text);
}

/* ============= 捲軸：macOS 風細捲軸（懸停才明顯） ============= */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(53, 65, 74, 0.22) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(53, 65, 74, 0.18);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(53, 65, 74, 0.34); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ============= 選取色跟著品牌 ============= */
::selection {
  background: var(--color-primary-tint-4);
  color: var(--color-primary-dk);
}

/* ============= 全域 focus ring（鍵盤操作才出現） ============= */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--color-primary-tint-3);
  border-radius: var(--radius-sm);
}

/* Utility — 字體切換 */
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }
.font-num     { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* Utility — 文字色 */
.text-mute    { color: var(--color-text-mute); }
.text-dim     { color: var(--color-text-dim); }
.text-on-dark { color: var(--color-text-on-dark); }

/* Utility — 隱藏 */
[hidden] { display: none !important; }

/* ============= 尊重系統的「減少動態效果」設定 ============= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
