/* =========================================================
   中学生の塾えらび2026 — 比較表ショーケース
   型: compare × max × no-hero × plain。表が主役、静かな高密度。
   craft-kit v2 を土台に、reveal は最小限（罫線・余白・数字の揃えで finish を出す）。
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'Noto Sans JP', system-ui, -apple-system, 'Hiragino Sans', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;               /* body 横スクロール禁止（表内のみ横スクロール可） */
}
img { max-width: 100%; display: block; }
button { font: inherit; }
.visually-hidden, .vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-alt: #eef2ee;
  --ink: #17201b;
  --sub: #59665e;
  --sub-2: #7c877f;
  --line: #dde3dc;
  --line-strong: #c4cdc2;

  --accent: #0e6b4f;
  --accent-deep: #094c37;
  --accent-soft: #e2f1ea;
  --accent-soft-2: #eef7f1;

  --rank-good: #0e6b4f;
  --rank-good-bg: #e2f1ea;
  --rank-mid: #8a5c0d;
  --rank-mid-bg: #f6ecd9;
  --rank-bad: #8f4a42;
  --rank-bad-bg: #f3e6e3;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 10px;
  --shadow-1: 0 1px 2px rgba(23,32,27,.06);
  --shadow-2: 0 8px 24px rgba(23,32,27,.08);
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 32px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- masthead（ヒーロー無し・情報から始まる帯） ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-alt) 0%, var(--bg) 100%);
  padding: 40px 0 30px;
}
.kicker {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--accent-deep);
  text-transform: uppercase;
}
.h1 {
  margin: 0 0 14px;
  font-weight: 800;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.h1-y { color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: .62em; margin-left: 4px; }
.lead {
  margin: 0 0 22px;
  max-width: 68ch;
  color: var(--sub);
  font-size: 15.5px;
  line-height: 1.85;
}
.lead b { color: var(--ink); font-weight: 700; }

.meta { display: flex; flex-wrap: wrap; gap: 28px 40px; margin: 0; padding-top: 18px; border-top: 1px dashed var(--line-strong); }
.meta > div { display: flex; flex-direction: column; gap: 3px; }
.meta dt { font-size: 11.5px; color: var(--sub-2); letter-spacing: .04em; }
.meta dd { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.meta dd.num { font-size: 22px; color: var(--accent-deep); }
.meta dd.num span { font-size: 13px; font-weight: 500; color: var(--sub); margin-left: 2px; }

/* ---------- 絞り込み ---------- */
.filterbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244,246,243,.92);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.filterbar-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.filter-label { margin: 0; font-size: 13px; font-weight: 700; color: var(--sub); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px 7px 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13.5px;
  color: var(--sub);
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
  user-select: none;
}
.chip input { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 12px; height: 12px; accent-color: var(--accent); margin: 0; }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip:has(input:checked), .chip.is-checked { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); font-weight: 600; }

.filter-status { margin: 12px 0 0; font-size: 13px; color: var(--sub-2); display: flex; align-items: center; gap: 14px; }
.filter-status .num { color: var(--accent-deep); font-weight: 700; font-size: 14px; }
.reset-btn {
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--sub);
  border-radius: 6px; padding: 5px 11px; font-size: 12.5px; cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.reset-btn:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---------- 比較表（表が主役） ---------- */
.tablesec { padding: 30px 0 10px; }
.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-1);
}
.table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table.cmp {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1360px;              /* 意図的に横スクロールを発生させ、内部スクロールで密度を確保 */
  font-size: 14px;
}
table.cmp thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel-alt);
  border-bottom: 2px solid var(--line-strong);
  border-left: 1px solid var(--line);
  padding: 0;
  text-align: left;
  white-space: nowrap;
}
table.cmp thead th:first-child { border-left: 0; }
table.cmp thead th.c-check { width: 58px; text-align: center; font-size: 11px; color: var(--sub-2); font-weight: 700; padding: 10px 6px; }
.th-btn {
  display: flex; align-items: center; gap: 5px; width: 100%;
  background: none; border: 0; cursor: pointer;
  padding: 12px 16px; font-weight: 700; font-size: 13.5px; color: var(--ink);
  text-align: left;
}
.th-btn::after {
  content: '';
  width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 5px solid var(--line-strong);
  opacity: .55;
  transition: transform .15s ease, border-color .15s ease, opacity .15s ease;
}
th[aria-sort="ascending"] .th-btn::after { border-bottom-color: var(--accent); opacity: 1; }
th[aria-sort="descending"] .th-btn::after { border-bottom-color: var(--accent); border-bottom: none; border-top: 5px solid var(--accent); opacity: 1; }
th[aria-sort="ascending"], th[aria-sort="descending"] { background: var(--accent-soft-2); }
th:not([data-sort]) { padding: 12px 16px; font-weight: 700; font-size: 13.5px; color: var(--sub); }
.num-col .th-btn, table.cmp td.num { text-align: right; justify-content: flex-end; }

table.cmp tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  white-space: nowrap;
}
table.cmp tbody td:first-child { border-left: 0; }
table.cmp tbody tr:nth-child(even) td { background: var(--bg); }
table.cmp tbody tr:hover td { background: var(--accent-soft-2); }
table.cmp tbody tr.is-selected td { background: var(--accent-soft); }
table.cmp tbody tr.is-hidden { display: none; }

td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
td.num small { font-family: 'Inter','Noto Sans JP',sans-serif; font-weight: 500; color: var(--sub-2); margin-left: 3px; }
td small { color: var(--sub-2); font-size: 12px; }

/* 塾名列: sticky（横スクロールしても常に見える） */
td.c-name, th[data-sort="name"] {
  position: sticky;
  left: 58px;
  z-index: 2;
  background: var(--panel);
  min-width: 168px;
  box-shadow: 1px 0 0 var(--line);
}
table.cmp tbody tr:nth-child(even) td.c-name { background: var(--bg); }
table.cmp tbody tr:hover td.c-name { background: var(--accent-soft-2); }
table.cmp tbody tr.is-selected td.c-name { background: var(--accent-soft); }
td.c-name { font-weight: 700; white-space: normal; }
.c-badge {
  display: block; margin-top: 3px;
  font-size: 11px; font-weight: 600; color: var(--accent-deep);
  background: var(--accent-soft); border-radius: 4px; padding: 1px 6px;
  width: max-content;
}
th.c-check, td.c-check {
  position: sticky; left: 0; z-index: 3;
  background: var(--panel-alt);
  text-align: center;
  box-shadow: 1px 0 0 var(--line);
}
td.c-check { background: var(--panel); z-index: 2; }
table.cmp tbody tr:nth-child(even) td.c-check { background: var(--bg); }
table.cmp tbody tr:hover td.c-check { background: var(--accent-soft-2); }
table.cmp tbody tr.is-selected td.c-check { background: var(--accent-soft); }
.cmp-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  font-weight: 800; font-size: 13px;
  cursor: help;
}
.rank-good { color: var(--rank-good); background: var(--rank-good-bg); }
.rank-mid  { color: var(--rank-mid);  background: var(--rank-mid-bg); }
.rank-bad  { color: var(--rank-bad);  background: var(--rank-bad-bg); }

.table-hint { margin: 12px 2px 0; font-size: 12.5px; color: var(--sub-2); line-height: 1.9; }
.table-hint .rank { width: 18px; height: 18px; font-size: 11px; vertical-align: -3px; margin: 0 2px; }

/* ---------- 横並び比較 ---------- */
.comparesec { padding: 54px 0 44px; }
.h2 { margin: 0 0 4px; font-size: 21px; font-weight: 800; color: var(--ink); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.h2-sub { font-size: 13px; font-weight: 600; color: var(--accent-deep); font-family: var(--mono); }
.compare-empty, .compare-limit {
  margin: 16px 0 0; padding: 14px 18px;
  border: 1px dashed var(--line-strong); border-radius: 8px;
  color: var(--sub); font-size: 13.5px; background: var(--panel-alt);
}
.compare-limit { border-color: var(--rank-mid); color: var(--rank-mid); background: var(--rank-mid-bg); border-style: solid; }

.compare-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.cc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 20px 22px;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 14px;
}
.cc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cc-name { font-size: 16.5px; font-weight: 800; color: var(--ink); line-height: 1.4; }
.cc-name span { display: block; font-size: 11.5px; font-weight: 600; color: var(--accent-deep); margin-top: 3px; }
.cc-remove {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--sub-2); font-size: 13px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, color .15s ease;
}
.cc-remove:hover { border-color: var(--rank-bad); color: var(--rank-bad); }

.cc-fee { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.cc-fee small { font-size: 13px; color: var(--sub-2); font-weight: 500; margin-left: 4px; }

.cc-dl { display: grid; grid-template-columns: 84px 1fr; row-gap: 7px; column-gap: 8px; font-size: 13px; margin: 0; }
.cc-dl dt { color: var(--sub-2); }
.cc-dl dd { margin: 0; color: var(--ink); font-weight: 600; }
.cc-dl dd .rank { width: 18px; height: 18px; font-size: 11px; margin-right: 3px; vertical-align: -3px; }

.cc-block { border-top: 1px dashed var(--line-strong); padding-top: 12px; font-size: 13px; line-height: 1.8; color: var(--sub); }
.cc-block b { display: block; color: var(--ink); font-size: 12px; margin-bottom: 3px; }

/* ---------- 選ぶ前に ---------- */
.notes { padding: 10px 0 60px; }
.cautions { margin: 16px 0 0; padding-left: 22px; display: grid; gap: 12px; max-width: 78ch; }
.cautions li { color: var(--sub); font-size: 14.5px; line-height: 1.85; }
.cautions b { color: var(--ink); }
.source { margin: 26px 0 0; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--sub-2); font-size: 12.5px; line-height: 1.9; max-width: 78ch; }
.source b { color: var(--sub); }

/* ---------- フッター ---------- */
.ft { border-top: 1px solid var(--line); padding: 26px 0 34px; }
.ft-disc { margin: 0 0 8px; font-size: 12px; color: var(--sub-2); line-height: 1.8; max-width: 78ch; }
.ft-c { margin: 0; font-size: 11.5px; color: #9aa39c; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 860px) {
  .wrap { padding: 0 20px; }
  .masthead { padding: 30px 0 24px; }
  .filterbar-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .compare-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .meta { gap: 16px 26px; }
  .h1 { font-size: 26px; }
}

/* ---------- craftkit reveal 上書き: 静かな高密度に合わせ控えめな移動量 ---------- */
[data-ck-reveal] { transform: translate3d(0, 14px, 0); }
