/* ============================================================
   E-計算！ Math — 選択肢を条件と重みで比べる（weighted-comparison.html）だけで使う形
   共通CSS（../assets/css/ek.css の v2 層）と css/math.css の上に重ねる。色は既存の変数だけを使う。
   ============================================================ */

/* 入力の比較表が横に広いので、入力を少し広くする（狭い画面では1列） */
@media (min-width: 981px) {
  .tool-layout.wc-layout { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .tool-layout.wc-layout { grid-template-columns: 1fr; }
}

/* ---- 入力の比較表（列＝条件、行＝設定と候補） ---- */
.wc-scroll { margin-top: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
html[data-ui="v2"] .table-scroll.wc-scroll { background: transparent; }
.wc-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
.wc-table th, .wc-table td { padding: 3px; vertical-align: middle; }
.wc-table td { width: 92px; min-width: 92px; }
.wc-table th[scope="row"], .wc-table .wc-corner {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  width: 104px; min-width: 104px; max-width: 104px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--ink-2); line-height: 1.35; padding-right: 6px;
}
.wc-table th[scope="row"] small, .wc-table .wc-corner small { display: block; font-size: 10.5px; font-weight: 400; color: var(--muted); }
.wc-table thead th { padding-bottom: 6px; }
.wc-table thead th.wc-ch { font-weight: 600; }
.wc-table input, .wc-table select {
  display: block; width: 100%; min-width: 0; height: 40px; padding: 0 8px; font: inherit; font-size: 14px;
  font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r);
}
/* 共通CSSの .field select（v2）より強く指定する（余白・字の大きさ） */
html[data-ui="v2"] .field .wc-table select { height: 40px; padding: 0 4px; font-size: 13.5px; }
.wc-table input.wc-num { text-align: right; }
.wc-table input:focus, .wc-table select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.wc-table input.bad, .wc-table select.bad { border-color: var(--tint-warn-ink); border-width: 2px; background: var(--tint-warn); }
.wc-table input:disabled { background: var(--page); color: var(--muted); border-style: dashed; }
/* 条件の名前（見出し）と候補の名前は太字 */
.wc-table input.wc-cname, .wc-table input.wc-name { font-weight: 600; }
.wc-headcell { display: flex; gap: 3px; align-items: center; }
.wc-headcell input { flex: 1 1 auto; }
/* 条件の削除ボタンは名前の上に置いて、名前の欄を広く使う */
.wc-ch .wc-headcell { flex-direction: column-reverse; align-items: stretch; gap: 2px; }
.wc-ch .wc-del { align-self: flex-end; flex: 0 0 auto; height: 20px; width: 26px; font-size: 14px; }
.wc-del {
  flex: 0 0 26px; width: 26px; height: 32px; padding: 0; border: 0; border-radius: var(--r);
  background: var(--page); color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
}
.wc-del:hover { background: var(--accent-soft); color: var(--accent); }
.wc-del:disabled { opacity: .35; cursor: default; }
.wc-del:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* 重みの割合・足切りの向き（入力欄の下の小さな字） */
.wc-sub { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 候補の行の始まりに区切り線 */
.wc-table tbody.wc-cands tr:first-child > * { border-top: 1px solid var(--grid); padding-top: 8px; }
.wc-table tr.wc-off { display: none; }

.wc-scroll-hint { display: none; }
/* スマホ：iOS は 16px 未満の入力欄で拡大するので 16px。表は横にスクロールし、左の列は固定 */
@media (max-width: 560px) {
  .wc-table td { width: 88px; min-width: 88px; }
  .wc-table th[scope="row"], .wc-table .wc-corner { width: 92px; min-width: 92px; max-width: 92px; font-size: 11.5px; }
  .wc-table input { height: 40px; padding: 0 6px; font-size: 16px; }
  html[data-ui="v2"] .field .wc-table select {
    -webkit-appearance: none; appearance: none; padding: 0 16px 0 5px; font-size: 16px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 10px) 52%, calc(100% - 6px) 52%; background-size: 4px 4px; background-repeat: no-repeat;
  }
  .wc-delr { flex-basis: 22px; width: 22px; }
  .wc-scroll-hint { display: block; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
}

/* ---- 結果 ---- */
.wc-top { display: block; margin-top: 2px; font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: 0; overflow-wrap: anywhere; line-height: 1.35; }
table.data td.wc-name-cell { text-align: left; white-space: normal; min-width: 6em; overflow-wrap: anywhere; font-weight: 600; }
table.data td.wc-t { text-align: left; white-space: normal; min-width: 9em; line-height: 1.6; }
table.data td .sub { white-space: nowrap; }
table.data td.wc-rank { white-space: nowrap; }
.wc-excl { margin: 14px 0 0; padding: 12px 14px; border-radius: var(--r); background: var(--page); font-size: 13px; line-height: 1.8; color: var(--ink-2); }
.wc-excl b { color: var(--ink); }
.wc-excl ul { margin: 4px 0 0; padding-left: 1.3em; }

/* 合計点の内訳（横に積んだ棒。棒は SVG、文字は HTML） */
.wc-chart { margin: 18px 0 0; padding: 16px; border: 1px solid var(--grid); border-radius: var(--r); background: var(--surface); }
.wc-chart figcaption { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 8px; line-height: 1.6; }
.wc-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 0 0 12px; font-size: 12px; color: var(--ink-2); }
.wc-legend li { display: flex; align-items: center; gap: 6px; }
.wc-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.wc-bars { list-style: none; padding: 0; margin: 0; }
.wc-bars > li { margin: 0 0 12px; }
.wc-bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 3px; }
.wc-bar-label span { font-weight: 600; overflow-wrap: anywhere; color: var(--ink); }
.wc-bar-label b { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; color: var(--ink); }
.wc-bar-label b small { font-size: 10.5px; font-weight: 400; color: var(--muted); }
.wc-bars svg { display: block; width: 100%; height: 16px; }
.wc-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: -4px; font-variant-numeric: tabular-nums; }
.wc-chart-note { font-size: 11.5px; color: var(--ink-2); line-height: 1.8; padding-top: 10px; margin: 8px 0 0; border-top: 1px solid var(--grid); }
/* 系列の色（条件の順番で固定。5番目以降はまとめて灰色） */
.wc-c0 { fill: var(--s1); background: var(--s1); }
.wc-c1 { fill: var(--s2); background: var(--s2); }
.wc-c2 { fill: var(--s3); background: var(--s3); }
.wc-c3 { fill: var(--s4); background: var(--s4); }
.wc-c4 { fill: color-mix(in srgb, var(--ink) 38%, var(--surface)); background: color-mix(in srgb, var(--ink) 38%, var(--surface)); }
.wc-track { fill: var(--page); }

/* 重みを動かしたときの合計点（折れ線） */
.wc-sens-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 12px 0 0; font-size: 13px; }
.wc-sens-ctrl[hidden] { display: none; }   /* display:flex が hidden 属性に勝たないように */
.wc-sens-ctrl select { height: 36px; padding: 0 8px; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); }
.wc-line { margin: 10px 0 0; }
.wc-line svg { display: block; width: 100%; height: auto; overflow: visible; }
.wc-line .ax { stroke: var(--grid); stroke-width: 1; }
.wc-line .ax-t { fill: var(--muted); font-size: 11px; }
.wc-line .ln { fill: none; stroke: color-mix(in srgb, var(--ink) 30%, var(--surface)); stroke-width: 2; stroke-linecap: round; }
.wc-line .ln.top { stroke: var(--accent); }
.wc-line .ln.rival { stroke: var(--s1); }
.wc-line .now { stroke: var(--ink-2); stroke-width: 1; }
.wc-line .band { fill: var(--accent-soft); }
.wc-line .lab { font-size: 11.5px; fill: var(--ink); font-weight: 600; }
.wc-line .lab-s { font-size: 11px; fill: var(--ink-2); }
.wc-line .dot { stroke: var(--surface); stroke-width: 2; }
.wc-line .dot.top { fill: var(--accent); }
.wc-line .dot.rival { fill: var(--s1); }
.wc-line .dot.other { fill: color-mix(in srgb, var(--ink) 30%, var(--surface)); }
.wc-line-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 8px 0 0; font-size: 12px; color: var(--ink-2); }
.wc-line-legend li { display: flex; align-items: center; gap: 6px; }
.wc-line-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.wc-line-legend i.top { background: var(--accent); }
.wc-line-legend i.rival { background: var(--s1); }
.wc-line-legend i.other { background: color-mix(in srgb, var(--ink) 30%, var(--surface)); }
.wc-line-legend i.band { height: 10px; background: var(--accent-soft); }
/* 図の下の表（線の数。名前の前に線の色の印） */
.wc-line-cap { margin: 12px 0 4px; font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.6; }
.wc-sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: color-mix(in srgb, var(--ink) 30%, var(--surface)); }
.wc-sw.top { background: var(--accent); }
.wc-sw.rival { background: var(--s1); }

/* 早見（本文の最初） */
.wc-steps { margin: 6px 0 0; padding-left: 1.4em; }
.wc-steps li + li { margin-top: 6px; }
