/* ==========================================================================
   My Garage — 樣式
   色票:dataviz 參考色票(已通過 CVD/對比驗證;亮/暗各自選定,非自動反轉)
   ========================================================================== */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.06);

  /* 圖表系列色(亮) */
  --s1: #2a78d6;
  --s2: #1baf7a;
  --s3: #eda100;
  --deemph: #898781;

  /* 狀態色(固定,不隨主題) */
  --st-good: #0ca30c;
  --st-warn: #fab219;
  --st-serious: #ec835a;
  --st-crit: #d03b3b;

  --radius: 14px;
  --radius-s: 8px;
  color-scheme: light;
}

[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --s1: #3987e5;
  --s2: #199e70;
  --s3: #c98500;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --s1: #3987e5;
    --s2: #199e70;
    --s3: #c98500;
    color-scheme: dark;
  }
}

/* --- 基礎 --- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--s1); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: color-mix(in srgb, var(--ink) 6%, transparent); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; border-radius: 4px; }

.container { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { color: var(--muted); padding: 48px 0; text-align: center; }

/* --- 頁首 / 頁尾 --- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1060px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { color: var(--ink); font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 20px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-btn:hover { border-color: var(--baseline); }

.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 24px 0 40px; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 4px 0; }

/* --- 車庫首頁 --- */
.garage-hero { padding: 28px 0 4px; }
.garage-hero h1 { margin: 0 0 6px; font-size: clamp(26px, 4.5vw, 38px); line-height: 1.2; }
.garage-hero p { margin: 0; color: var(--ink-2); }

.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 28px 0; }
.car-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: var(--ink); box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.car-card:hover { transform: translateY(-2px); text-decoration: none; }
.car-cover { aspect-ratio: 16 / 9; position: relative; display: flex; align-items: flex-end; overflow: hidden; }
.car-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.car-cover-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(34px, 6vw, 52px); font-weight: 800; letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.82); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.car-card-body { padding: 16px 18px 18px; }
.car-card-body h2 { margin: 0; font-size: 20px; }
.car-card-body .trim { color: var(--ink-2); font-size: 13.5px; margin: 2px 0 10px; }

/* --- 通用元件 --- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px;
  font-size: 12.5px; color: var(--ink-2); background: color-mix(in srgb, var(--ink) 3%, transparent);
  white-space: nowrap;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--border); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  padding: 2px 10px; border-radius: 999px;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.badge.ok { background: color-mix(in srgb, var(--st-good) 14%, transparent); }
.badge.ok::before { background: var(--st-good); }
.badge.warn { background: color-mix(in srgb, var(--st-warn) 18%, transparent); }
.badge.warn::before { background: var(--st-warn); }
.badge.serious { background: color-mix(in srgb, var(--st-serious) 18%, transparent); }
.badge.serious::before { background: var(--st-serious); }
.badge.crit { background: color-mix(in srgb, var(--st-crit) 15%, transparent); }
.badge.crit::before { background: var(--st-crit); }
.badge.neutral { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.badge.neutral::before { background: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.card-title { margin: 0 0 10px; font-size: 15.5px; }
[id] { scroll-margin-top: 96px; }
.section { margin: 22px 0; }
.section > h2 { font-size: 18px; margin: 0 0 10px; }
.section-sub { color: var(--muted); font-size: 13px; margin: -6px 0 10px; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* --- 車輛頁 hero --- */
.car-hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); margin-top: 18px; background: var(--surface); }
.car-hero-band { height: 110px; position: relative; }
.car-hero-band.has-photo { height: 240px; }
@media (max-width: 640px) { .car-hero-band.has-photo { height: 160px; } }
.car-hero-band .plate {
  position: absolute; right: 16px; bottom: 12px;
  background: rgba(252, 252, 251, 0.9); color: #0b0b0b; border-radius: 6px;
  padding: 2px 12px; font-weight: 700; letter-spacing: 0.08em; font-family: ui-monospace, Consolas, monospace;
}
.car-hero-body { padding: 16px 20px 18px; }
.car-hero-body h1 { margin: 0; font-size: clamp(24px, 4vw, 32px); line-height: 1.25; }
.car-hero-body .trim { color: var(--ink-2); margin: 4px 0 14px; }
.breadcrumb { font-size: 13.5px; color: var(--muted); margin: 20px 0 0; }
.breadcrumb a { color: var(--muted); }

/* --- 子導覽 --- */
.subnav {
  position: sticky; top: 55px; z-index: 40;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin: 24px -20px 0; padding: 8px 20px;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  color: var(--ink-2); font-size: 14px; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.subnav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); text-decoration: none; }

/* --- 統計磚 --- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; margin: 14px 0 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.tile .label { font-size: 12.5px; color: var(--muted); }
.tile .value { font-size: 22px; font-weight: 650; line-height: 1.25; margin: 2px 0; }
.tile .value .unit { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.tile .sub { font-size: 12px; color: var(--muted); }

/* --- 表格 --- */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }
table.data tfoot td { color: var(--ink-2); font-size: 13px; border-top: 1px solid var(--baseline); border-bottom: none; }

.kv { display: grid; grid-template-columns: minmax(96px, max-content) 1fr; gap: 6px 18px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* --- 優缺點 --- */
.pn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.pn-list li { padding-left: 26px; position: relative; font-size: 14.5px; }
.pn-list li::before { position: absolute; left: 0; top: 1px; font-weight: 700; }
.pn-list.pros li::before { content: "+"; color: var(--st-good); }
.pn-list.cons li::before { content: "−"; color: var(--st-crit); }

/* --- 相簿 --- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.photo-grid figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 8px; box-shadow: var(--shadow); }
.photo-grid img { width: 100%; border-radius: 5px; display: block; }
.photo-grid figcaption { font-size: 11.5px; margin-top: 5px; }

/* --- 圖表 --- */
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: var(--shadow); }
.chart-card h3 { margin: 0; font-size: 15.5px; }
.chart-card .chart-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 4px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 2px; font-size: 12.5px; color: var(--ink-2); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.chart-host { position: relative; }
.chart-host svg { display: block; width: 100%; height: auto; }
.chart-host svg text { font-family: inherit; }

.viz-tooltip {
  position: absolute; z-index: 30; pointer-events: none; visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s);
  box-shadow: var(--shadow); padding: 8px 12px; font-size: 12.5px; min-width: 120px; max-width: 260px;
}
.viz-tooltip .t-title { color: var(--muted); font-size: 11.5px; margin-bottom: 3px; white-space: nowrap; }
.viz-tooltip .t-row { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.viz-tooltip .t-row .k { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.viz-tooltip .t-row .k .line { width: 10px; height: 3px; border-radius: 2px; }
.viz-tooltip .t-row .v { font-weight: 650; font-variant-numeric: tabular-nums; }

details.chart-table { margin: 6px 0 8px; }
details.chart-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; user-select: none; }
details.chart-table[open] summary { margin-bottom: 8px; }

/* --- 提示卡(下次保養) --- */
.callout {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--border); border-left: 4px solid var(--s1);
  background: color-mix(in srgb, var(--s1) 7%, var(--surface));
  border-radius: var(--radius-s); padding: 14px 18px; font-size: 14.5px;
}
.callout .icon { font-size: 20px; line-height: 1.3; }
.callout b { font-variant-numeric: tabular-nums; }

blockquote.story {
  margin: 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--baseline);
  color: var(--ink-2); font-size: 15px;
}

.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.link-list li { font-size: 14.5px; }
.link-list .ext { color: var(--muted); font-size: 12px; margin-left: 6px; }

@media (max-width: 640px) {
  body { font-size: 15px; }
  .card { padding: 14px 14px; }
  .section { margin: 18px 0; }
  .tile .value { font-size: 22px; }
}
