/*
 * devhub design tokens — 管理介面（index.html）與介紹首頁（site/index.html）共用。
 * 規則與取捨見 design-system/devhub/MASTER.md。
 * 只放變數，不放元件樣式；不引用任何外部字體或 CDN。
 */
:root {
  color-scheme: light;

  /* ── 色彩：語意化（淺色） ── */
  --bg: #f3f4f7;            /* 頁面底 */
  --surface: #ffffff;       /* 卡片、面板 */
  --surface-2: #eaecf1;     /* 凹陷區、表頭、行內 code */
  --ink: #12151b;           /* 主要文字 */
  --ink-2: #434a58;         /* 次要文字 */
  --ink-3: #596171;         /* 輔助文字（在 --surface-2 上仍 ≥ 4.5:1） */
  --line: #d7dbe3;          /* 分隔線、邊框 */
  --line-strong: #b9bfcc;
  --accent: #3347d6;        /* 主要動作、連結、焦點 */
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --ok: #0b7a4d;
  --warn: #8f5200;
  --danger: #c2261f;
  --code-bg: #10131a;       /* 終端機區塊：兩種主題都用深色 */
  --code-ink: #e6e9f0;
  --code-mute: #8f98ab;
  --focus: var(--accent);

  /* ── 材質 ── */
  --glass: color-mix(in srgb, var(--bg) 72%, transparent);
  --glass-blur: saturate(180%) blur(18px);
  --edge-top: inset 0 1px 0 rgb(255 255 255 / .7);   /* 光線落在材質上緣 */
  --shadow-1: 0 1px 2px rgb(18 21 27 / .06), 0 1px 1px rgb(18 21 27 / .04);
  --shadow-2: 0 2px 4px rgb(18 21 27 / .05), 0 12px 28px -8px rgb(18 21 27 / .16);
  --shadow-3: 0 4px 8px rgb(18 21 27 / .06), 0 28px 60px -16px rgb(18 21 27 / .30);

  /* ── 字體：只用系統字體堆疊 ── */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui,
    "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui,
    "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 字級（rem，跟隨使用者字級設定） */
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem);
  --text-hero: clamp(1.75rem, 1rem + 2.4vw, 3rem);
  /* 字距與行高：隨字級反向調整 */
  --track-display: -.03em;
  --track-title: -.018em;
  --track-body: 0;
  --track-small: .01em;
  --lead-display: 1.1;
  --lead-title: 1.25;
  --lead-body: 1.7;
  --lead-dense: 1.5;

  /* ── 間距（4px 基底） ── */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 7rem;
  --gutter: clamp(1rem, 4vw, 1.5rem);
  --measure: 36em;

  /* ── 圓角：大面積大、小元件小 ── */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* ── 動態 ── */
  --dur-instant: 90ms;      /* 按下回饋 */
  --dur-fast: 160ms;
  --dur-base: 260ms;
  --dur-slow: 420ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);          /* 臨界阻尼感，不回彈 */
  --ease-spring: linear(0, .42 8%, .82 18%, 1.03 30%, 1.05 38%, 1 52%, .99 68%, 1);  /* 只用在帶有動量的互動 */
  --ease-inout: cubic-bezier(.65, 0, .35, 1);
  --press-scale: .97;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* 深色：同一組語意名稱，換值 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f13;
    --surface: #161a21;
    --surface-2: #1d222b;
    --ink: #eef0f4;
    --ink-2: #b6bcc8;
    --ink-3: #98a0af;
    --line: #272d38;
    --line-strong: #3a4250;
    --accent: #9aa8ff;
    --accent-ink: #0b0f2a;
    --ok: #54d89a;
    --warn: #f2b45a;
    --danger: #ff8a82;
    --code-bg: #0a0c10;
    --edge-top: inset 0 1px 0 rgb(255 255 255 / .06);
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-2: 0 2px 4px rgb(0 0 0 / .3), 0 12px 28px -8px rgb(0 0 0 / .6);
    --shadow-3: 0 4px 8px rgb(0 0 0 / .35), 0 28px 60px -16px rgb(0 0 0 / .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f13;
  --surface: #161a21;
  --surface-2: #1d222b;
  --ink: #eef0f4;
  --ink-2: #b6bcc8;
  --ink-3: #98a0af;
  --line: #272d38;
  --line-strong: #3a4250;
  --accent: #9aa8ff;
  --accent-ink: #0b0f2a;
  --ok: #54d89a;
  --warn: #f2b45a;
  --danger: #ff8a82;
  --code-bg: #0a0c10;
  --edge-top: inset 0 1px 0 rgb(255 255 255 / .06);
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 2px 4px rgb(0 0 0 / .3), 0 12px 28px -8px rgb(0 0 0 / .6);
  --shadow-3: 0 4px 8px rgb(0 0 0 / .35), 0 28px 60px -16px rgb(0 0 0 / .8);
}

/* 動態與材質的無障礙降級：token 層一次處理，元件不必各自判斷 */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant: 0ms;
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
    --press-scale: 1;
  }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--bg); --glass-blur: none; }
}
@media (prefers-contrast: more) {
  :root { --line: var(--line-strong); --ink-3: var(--ink-2); }
}
