/* =========================================================
   回測計算機 — stock-compare.html 專用樣式
   色彩與字型全部沿用 style.css 的 :root，這裡只新增圖表用的色票。
   ========================================================= */

:root{
  /* ---------- 圖表資料線配色 ----------
     來源：dataviz 規範的六項可計算檢查，用 validate_palette.js 實跑通過
     （淺色模式、底色 #FAF8F6、--pairs all）：
       明度帶 PASS ／ 彩度下限 PASS ／ 一般視覺下限 15.6 PASS ／ 對比 PASS
       色盲分辨 WARN 6.8（梅紫↔綠，deutan）
     那個 WARN 的條件是「必須有次要編碼」，所以四條線以內一律直接標籤，
     不可以只靠顏色區分。改配色請重跑驗證器，不要憑眼睛判斷。

     為什麼不用品牌紅 #E21A22：checkup.css 第 14 行的既有決定——
     品牌紅專門給「行動」。資料線若用紅色，使用者分不出「按我」和「這是資料」。
     狀態三色（--ck-good/warn/danger）也不可借用，那是「健康／注意／危險」的語意。 */
  --sc-series-1: #B5751A;   /* 金　最接近源利品牌金 gold-500，給第一檔（通常是基準） */
  --sc-series-2: #2A6FB0;   /* 藍 */
  --sc-series-3: #1F7F5C;   /* 綠 */
  --sc-series-4: #8E3A6E;   /* 梅紫 */

  /* 圖表骨架。格線與軸線要退到背景，不能跟資料線搶 */
  --sc-grid:     rgba(34,26,22,.08);
  --sc-axis:     rgba(34,26,22,.22);
  --sc-zero:     rgba(34,26,22,.38);   /* 零線比一般格線重，但仍比資料線輕 */
}

/* ---------- 頁面節奏 ----------
   style.css 的 .section 是 96px，那是給行銷頁的呼吸感。
   工具頁區塊多且需要連續閱讀，縮到 56px，手機 40px。 */
.sc-page .section{ padding-block:56px; }
.sc-page .sc-intro{ padding-bottom:32px; }
.sc-page .sc-setup-section{ padding-top:0; }

/* ---------- 標題 ---------- */
.sc-title{
  font-family:var(--serif);
  font-size:clamp(32px,4.4vw,52px);
  line-height:1.15; letter-spacing:-.01em;
  color:var(--ink); margin:0 0 14px;
}
.sc-lede{
  font-family:var(--sans); font-size:17px; line-height:1.75;
  color:var(--slate); margin:0; max-width:46em;
}
.sc-h2{
  font-family:var(--serif); font-size:clamp(22px,2.4vw,28px);
  color:var(--ink); margin:0 0 6px;
}
.sc-charts .sc-h2{ margin-top:48px; }
.sc-charts .sc-h2:first-of-type{ margin-top:0; }

/* ---------- 設定面板 ---------- */
.sc-panel{
  background:var(--cream);
  border:1px solid var(--sand);
  border-radius:var(--r-lg);
  padding:32px;
  display:grid; gap:30px;
}
.sc-field{ border:0; padding:0; margin:0; min-width:0; }
.sc-field-label{
  display:flex; align-items:center; gap:10px;
  font-family:var(--sans); font-size:15px; font-weight:700;
  color:var(--ink); padding:0; margin-bottom:14px;
}
.sc-step{
  display:inline-grid; place-items:center;
  width:24px; height:24px; border-radius:999px;
  background:var(--ink); color:var(--white);
  font-size:12px; font-weight:700; font-variant-numeric:tabular-nums;
}
.sc-hint{
  font-family:var(--sans); font-size:13px; line-height:1.6;
  color:var(--slate-l); margin:10px 0 0;
}

/* 標的選鈕。選中時用該標的的資料線顏色，讓選單和圖表對得起來 */
.sc-picker{ display:flex; flex-wrap:wrap; gap:10px; }
.sc-pick{
  display:inline-flex; align-items:center; gap:8px;
  padding:10px 16px; border-radius:999px;
  background:var(--white); border:1.5px solid var(--sand);
  font-family:var(--sans); font-size:14px; font-weight:600;
  color:var(--slate); cursor:pointer;
  transition:border-color .18s ease,color .18s ease,background .18s ease;
}
.sc-pick:hover{ border-color:var(--slate-l); color:var(--ink); }
.sc-pick .sc-dot{
  width:10px; height:10px; border-radius:999px;
  background:var(--sand); flex:0 0 auto;
  transition:background .18s ease;
}
.sc-pick.is-on{ background:var(--white); border-color:currentColor; color:var(--ink); }
.sc-pick.is-on .sc-dot{ background:var(--sc-pick-color,var(--ink)); }
.sc-pick[disabled]{ opacity:.42; cursor:not-allowed; }

/* 分段鈕 */
.sc-segment{ display:inline-flex; flex-wrap:wrap; gap:6px; }
.sc-seg{
  padding:9px 18px; border-radius:999px;
  background:var(--white); border:1.5px solid var(--sand);
  font-family:var(--sans); font-size:14px; font-weight:600;
  color:var(--slate); cursor:pointer;
  transition:background .18s ease,color .18s ease,border-color .18s ease;
}
.sc-seg:hover{ border-color:var(--slate-l); color:var(--ink); }
.sc-seg.is-on{ background:var(--ink); border-color:var(--ink); color:var(--white); }

/* 日期欄 */
/* 期間超過某一檔標的的資料長度時，那顆按鈕要按不動。
   讓它按下去再回報「其實只算得到 16 年」會更糟——
   使用者會以為兩檔比的是同一段期間。 */
.sc-seg:disabled{
  color:var(--slate-l); border-color:var(--sand);
  cursor:not-allowed; opacity:.55;
}
.sc-seg:disabled:hover{ border-color:var(--sand); color:var(--slate-l); }

/* 為什麼某個期間不能選 */
.sc-hint--warn{ color:var(--gold-text); }

/* 投入方式 */
.sc-radios{ display:flex; gap:10px; flex-wrap:wrap; }
.sc-radio,.sc-check{
  display:inline-flex; align-items:center; gap:9px;
  font-family:var(--sans); font-size:14px; font-weight:600;
  color:var(--ink); cursor:pointer;
}
.sc-radio{
  padding:10px 18px; border-radius:999px;
  background:var(--white); border:1.5px solid var(--sand);
  transition:border-color .18s ease;
}
.sc-radio:has(input:checked){ border-color:var(--ink); }
.sc-radio input,.sc-check input{ accent-color:var(--ink); width:16px; height:16px; }
.sc-check{ margin-top:20px; }

/* 金額。數字要等寬，不然改動時會跳動 */
.sc-amount{ margin-top:18px; }
.sc-amount-label{
  display:block; font-family:var(--sans); font-size:13px; font-weight:600;
  color:var(--slate); margin-bottom:8px;
}
.sc-amount-input{
  display:inline-flex; align-items:baseline; gap:8px;
  background:var(--white); border:1.5px solid var(--sand);
  border-radius:var(--r-sm); padding:10px 16px;
}
.sc-amount-input:focus-within{ border-color:var(--ink); }
.sc-amount-input input{
  font-family:var(--sans); font-size:22px; font-weight:700;
  font-variant-numeric:tabular-nums;
  color:var(--ink); border:0; background:transparent;
  width:9ch; text-align:right; padding:0;
}
.sc-amount-input input:focus{ outline:0; }
.sc-amount-unit{ font-family:var(--sans); font-size:14px; color:var(--slate); }

/* ---------- 最終金額 ----------
   深色底是刻意的：這是整頁的結論，要跟上方的設定區分開。
   數字用襯線體，跟 .sc-title 同一個家族，讓它讀起來像「答案」而不是儀表板。 */
.sc-result-section{ padding:0 var(--sec-pad) 56px; }
.sc-result{
  background:var(--ink); color:var(--white);
  border-radius:var(--r-lg); padding:36px 40px;
}
.sc-result-head{
  font-family:var(--sans); font-size:14px; color:var(--gold-400);
  margin:0 0 24px; letter-spacing:.01em;
}
.sc-result-grid{ display:grid; gap:28px; }
.sc-result-row{ display:grid; gap:6px; }
.sc-result-name{
  display:flex; align-items:center; gap:9px;
  font-family:var(--sans); font-size:14px; font-weight:600;
  color:rgba(255,255,255,.72);
}
.sc-result-name .sc-dot{ width:10px; height:10px; border-radius:999px; flex:0 0 auto; }
.sc-result-value{
  font-family:var(--serif); font-size:clamp(30px,4.2vw,46px);
  line-height:1.1;
  /* Playfair 預設是舊體數字，8、5、7、0 會掉到基線以下。
     金額要讀得精確，所以強制等高數字；tabular 讓位數變動時不跳動。 */
  font-variant-numeric:lining-nums tabular-nums;
  color:var(--white);
}
.sc-result-value .sc-unit{ font-size:.46em; margin-left:.3em; color:rgba(255,255,255,.66); }
.sc-result-sub{
  font-family:var(--sans); font-size:14px;
  color:rgba(255,255,255,.72); font-variant-numeric:tabular-nums;
}
.sc-result-sub strong{ color:var(--gold-400); font-weight:700; }
.sc-result-empty{
  font-family:var(--sans); font-size:15px; color:rgba(255,255,255,.72); margin:0;
}

@media (min-width:860px){
  .sc-result-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); gap:32px 40px; }
}

/* ---------- 圖表 ---------- */
.sc-chart-note{
  font-family:var(--sans); font-size:14px; color:var(--slate); margin:0 0 18px;
}
.sc-figure{ margin:0; }
.sc-chart{ position:relative; width:100%; }
.sc-chart svg{ display:block; width:100%; height:auto; overflow:visible; }
.sc-figcaption{
  font-family:var(--sans); font-size:13px; color:var(--slate-l); margin-top:12px;
}

/* 格線與軸要退到背景 */
.sc-grid-line{ stroke:var(--sc-grid); stroke-width:1; }
.sc-zero-line{ stroke:var(--sc-zero); stroke-width:1; }
.sc-axis-line{ stroke:var(--sc-axis); stroke-width:1; }
.sc-axis-text{
  font-family:var(--sans); font-size:11px; fill:var(--slate-l);
  font-variant-numeric:tabular-nums;
}

/* 資料線 2px，端點圓角，不填色 */
.sc-line{ fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
/* 直接標籤。四條線以內一律標，因為色盲分辨是 WARN 等級，不能只靠顏色 */
.sc-line-label{
  font-family:var(--sans); font-size:12px; font-weight:700;
  font-variant-numeric:tabular-nums;
  paint-order:stroke; stroke:var(--cream); stroke-width:3px; stroke-linejoin:round;
}
/* 長條：資料端圓角，相鄰之間留 2px 底色縫 */
.sc-bar{ rx:3; }

/* 游標十字線與提示框 */
.sc-crosshair{ stroke:var(--sc-axis); stroke-width:1; stroke-dasharray:3 3; }
.sc-marker{ stroke:var(--cream); stroke-width:2; }
.sc-tip{
  position:absolute; z-index:2; pointer-events:none;
  background:var(--ink); color:var(--white);
  border-radius:var(--r-sm); padding:10px 13px;
  font-family:var(--sans); font-size:13px; line-height:1.55;
  box-shadow:0 8px 24px rgba(34,26,22,.22);
  white-space:nowrap; opacity:0;
  transition:opacity .12s ease;
}
.sc-tip.is-on{ opacity:1; }
.sc-tip-date{ color:rgba(255,255,255,.64); font-size:12px; margin-bottom:5px; }
.sc-tip-row{ display:flex; align-items:center; gap:8px; font-variant-numeric:tabular-nums; }
.sc-tip-row .sc-dot{ width:8px; height:8px; border-radius:999px; flex:0 0 auto; }
.sc-tip-row b{ margin-left:auto; padding-left:14px; font-weight:700; }

/* ---------- 表格 ---------- */
.sc-table-wrap{ overflow-x:auto; }
.sc-table{
  width:100%; border-collapse:collapse;
  font-family:var(--sans); font-size:14px;
  font-variant-numeric:tabular-nums;
}
.sc-caption{
  caption-side:bottom; text-align:left;
  font-size:13px; color:var(--slate-l); padding-top:12px;
}
.sc-table th,.sc-table td{
  padding:13px 16px; text-align:right; white-space:nowrap;
  border-bottom:1px solid var(--line);
}
.sc-table thead th{
  color:var(--ink); font-weight:700;
  border-bottom:1.5px solid var(--sand);
}
.sc-table th:first-child,.sc-table td:first-child{ text-align:left; color:var(--slate); }
.sc-table tbody tr:last-child td{ border-bottom:0; }
/* 標的名稱旁的色點，讓表格和圖表對得起來 */
.sc-table thead .sc-dot{
  display:inline-block; width:9px; height:9px; border-radius:999px;
  margin-right:7px; vertical-align:baseline;
}
.sc-table-toggle{ margin-top:22px; }
.sc-table-toggle summary{
  font-family:var(--sans); font-size:14px; font-weight:600;
  color:var(--slate); cursor:pointer; padding:6px 0;
}
.sc-table-toggle summary:hover{ color:var(--ink); }
.sc-table-toggle[open] summary{ margin-bottom:12px; }

/* ---------- 資料來源與免責 ---------- */
.sc-legal-section{ padding-top:0; }
.sc-legal{
  border-top:1px solid var(--line); padding-top:28px;
  font-family:var(--sans); font-size:13px; line-height:1.8; color:var(--slate-l);
}
.sc-legal p{ margin:0 0 10px; max-width:62em; }
.sc-legal p:last-child{ margin-bottom:0; }
.sc-legal strong{ color:var(--slate); font-weight:700; }
.sc-source{ color:var(--slate); }

/* ---------- 手機 ---------- */
@media (max-width:640px){
  .sc-page .section{ padding-block:40px; }
  .sc-panel{ padding:22px 18px; gap:26px; }
  .sc-result-section{ padding-bottom:40px; }
  .sc-result{ padding:26px 22px; }
  .sc-amount-input input{ width:8ch; font-size:20px; }
  .sc-charts .sc-h2{ margin-top:36px; }
  /* 日期欄在窄螢幕排成兩行，不要擠在一起 */
}
