/*!
 * gg-table-filter v2.0 — 比較表の絞り込み（ジムガイド用）
 * 色は記事の比較表（.gg-cmp）と見出しに合わせています。
 * 変えたいときは .gg-filter の変数だけを書き換えてください。
 *
 * v2.0 の変更
 *   - スマホ（600px以下）は「項目名を左・チップは折り返し」にして高さを抑えた
 *   - 予算などの数値を、下限・上限の2つのつまみで選べる範囲スライダーを追加
 *   - .gg-filter--scroll を付けると、スマホでチップを1行の横スクロールにできる
 */
.gg-filter {
  --gg-accent: #6b46c1;       /* 選択中のチップ・スライダー（h2の左線と同じ紫） */
  --gg-accent-dark: #4c1d95;  /* 件数・タイトル・予算の金額（表の見出しの文字色） */
  --gg-heading: #3d2d6b;      /* 項目名（h2の文字色） */
  --gg-soft: #f3effe;         /* 注記の背景（表の見出しの背景） */
  --gg-border: #e5e7eb;       /* 枠線（表の罫線） */
  --gg-divider: #f0edf7;
  --gg-chip-border: #d9d3ea;
  --gg-track: #e5e0f0;        /* スライダーの溝 */
  --gg-link: #1176d4;         /* リセット（記事のリンク色） */
  --gg-muted: #5b5670;        /* 目盛りの文字 */

  box-sizing: border-box;
  margin: 16px 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--gg-border);
  border-radius: 8px;
  background: #ffffff;
  color: #333333;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* JSが動くまでは出さない（JSが止まっても表はそのまま読める） */
.gg-filter:not(.is-ready) { display: none !important; }

.gg-filter *, .gg-filter *::before, .gg-filter *::after { box-sizing: border-box; }
.gg-filter p { margin: 0 !important; padding: 0; }

/* 見出し行：タイトル ……… リセット　9 / 9件 */
.gg-filter__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gg-divider);
}
.gg-filter__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--gg-accent-dark);
}
.gg-filter__count {
  flex: none;
  font-size: 13px;
  white-space: nowrap;
}
.gg-filter__count strong {
  display: inline-block;
  min-width: 1.5em;            /* 件数が 9 → 10 や 1 になっても横にずれない（ジムガイド 2026-10-22。1.3em だと「10」より約1px狭く、10商品の記事で1px揺れた） */
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  line-height: 1;
  color: var(--gg-accent-dark);
}
.gg-filter__reset {
  flex: none;
  font: inherit;
  font-size: 13px;
  height: 32px;                /* 見出し行の高さを固定（出たときに欄が 5px 伸びて下が揺れていた） */
  line-height: 32px;
  margin: 0;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--gg-link);
  text-decoration: underline;
  cursor: pointer;
}
/* 隠すときも場所は取っておく（出し入れで件数の位置が動かないように） */
.gg-filter__reset[hidden] { display: inline-block !important; visibility: hidden; }

/* チップの項目：項目名を左、チップを右に並べる */
.gg-filter__group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.gg-filter__label {
  flex: 0 0 52px;
  padding-top: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gg-heading);
}
.gg-filter__chips {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gg-filter .gg-chip {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  margin: 0;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--gg-chip-border);
  border-radius: 999px;
  background: #ffffff;
  color: #333333;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .15s;
}
/* 選ぶと太字になって幅が変わり、となりのチップが横に揺れていた → 太字の幅を見えない文字で先に取っておく（data-label が要る） */
.gg-filter .gg-chip::after {
  content: attr(data-label);
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 700;
}
.gg-filter .gg-chip:hover { border-color: var(--gg-accent); }
.gg-filter .gg-chip:focus-visible { outline: 2px solid var(--gg-accent); outline-offset: 2px; }
.gg-filter .gg-chip[aria-pressed="true"] {
  background: var(--gg-accent);
  border-color: var(--gg-accent);
  color: #ffffff;
  font-weight: 700;
}

/* 範囲スライダーの項目（予算など）：項目名と金額の行 → スライダー → 目盛り */
.gg-filter__range {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}
.gg-filter__range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.gg-filter__range-head .gg-filter__label { flex: none; padding-top: 0; }
.gg-filter__range-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--gg-accent-dark);
  white-space: nowrap;
}
.gg-range {
  --gg-lo: 0;
  --gg-hi: 1;
  position: relative;
  height: 36px;
  touch-action: pan-y;
}
.gg-range__track {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 16px;
  height: 4px;
  border-radius: 2px;
  background: var(--gg-track);
}
.gg-range__fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--gg-accent);
  left: calc(100% * var(--gg-lo));
  width: calc(100% * (var(--gg-hi) - var(--gg-lo)));
}
/* つまみ2つ：同じ場所に重ねた input[type=range]。押せるのはつまみだけ */
.gg-filter .gg-range__input {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}
.gg-filter .gg-range__input.is-top { z-index: 3; }
.gg-filter .gg-range__input:focus { outline: none; }
.gg-filter .gg-range__input::-webkit-slider-runnable-track { height: 36px; background: transparent; border: none; }
.gg-filter .gg-range__input::-moz-range-track { background: transparent; border: none; }
.gg-filter .gg-range__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  pointer-events: auto;
  width: 24px;
  height: 24px;
  margin-top: 6px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--gg-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  cursor: grab;
}
.gg-filter .gg-range__input::-moz-range-thumb {
  box-sizing: border-box;
  pointer-events: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--gg-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  cursor: grab;
}
.gg-filter .gg-range__input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--gg-accent); outline-offset: 2px; }
.gg-filter .gg-range__input:focus-visible::-moz-range-thumb { outline: 2px solid var(--gg-accent); outline-offset: 2px; }
.gg-range__ticks {
  position: relative;
  height: 18px;
  font-size: 11.5px;
  line-height: 18px;
  color: var(--gg-muted);
  white-space: nowrap;
}
.gg-range__ticks > span { position: absolute; top: 0; transform: translateX(-50%); }
.gg-range__ticks > span[data-at="min"] { left: 0; transform: none; }
.gg-range__ticks > span[data-at="max"] { right: 0; transform: none; }

/* 表の側 */
tr.gg-is-hidden { display: none !important; }
.gg-cmp-note {
  display: block;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f3effe;
  color: #4c1d95;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
}
.gg-cmp-note[hidden] { display: none !important; }
tr.gg-cmp-empty[hidden] { display: none !important; }
tr.gg-cmp-empty td {
  padding: 16px !important;
  background: #ffffff;
  color: #666666;
  font-size: 13px;
  text-align: left;
}

/* スマホ：項目名を細くして、チップを1行に収まりやすくする */
@media (max-width: 600px) {
  .gg-filter { padding: 12px 14px 14px; }
  .gg-filter__group { gap: 6px; }
  .gg-filter__label { flex-basis: 26px; }
  .gg-filter .gg-chip { padding: 0 10px; }

  /* .gg-filter--scroll：チップを1行の横スクロールにする（D案） */
  .gg-filter--scroll .gg-filter__group { align-items: center; gap: 8px; }
  .gg-filter--scroll .gg-filter__label { flex-basis: 34px; padding-top: 0; }
  .gg-filter--scroll .gg-filter__chips {
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    margin-right: -14px;
    padding-right: 28px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .gg-filter--scroll .gg-filter__chips::-webkit-scrollbar { display: none; }
  .gg-filter--scroll .gg-chip { flex: 0 0 auto; height: 40px; padding: 0 15px; font-size: 13.5px; }
}
