/*
 * jra-gateway.css — JRA（中央競馬）窓口ページ（ショートコード [jra_index_gateway]）の見た目（teaser のみ）
 * 設計: 00_指数計算処理_opt/jra_index_plugin/docs/06_いま進められるタスク整理.md／C:/Temp/wf_twotier/plan.md（§3.2/§3.4）。
 *
 * 流用元: 地方競馬/31_Wordpress実装_NAR/.../nar-gateway.css（和モダン緑・日付下線タブ／場カード／
 *   横スクロールRストリップ／CSSミニバー TOP3）を jra- 接頭辞へ移植。teaser のみ＝詳細UI（タブ/サマリ/
 *   マトリクス/追切/Chart.js/データ表）は各場CPT [jra_index_view]（jra-index-report.css）の責務ゆえ持たない。
 *   ★色だけは流用元から離れる＝ブランド使い分け（NAR:緑／JRA:青）ゆえ、移植時の緑系ブランド色と
 *     ウォームベージュ系ニュートラルは同明度のクール青灰へ移行済み（意味を持つデータ色は不変）。
 *
 * 方針:
 *   - !important を一切使わない（特異度で勝つ）。生成ノードは全て jra-gateway- 接頭辞・CSS変数は --jra-。
 *   - 中央/NAR 資産（dual-index-／ability-／nar-／nar-gateway-）を一切参照しない（構造分離）。
 *   - 色/寸法は CSS変数へ集約。背景画像は CSS の url() 相対参照（../assets/race.png）＝PHP非依存。
 *     ★assets/race.png が無い場合は background-color のみで縮退（画像は任意・帯は表示される）。
 *   - JS-UI（#jra-index-venues 配下の描画）は server レンダ後 JS が差し替え、no-JS 時は
 *     .jra-index-fallback（サーバレンダ表）を表示。成功時は .jra-js-ready で .jra-index-fallback を隠す。
 *   - 単一インスタンス前提（固定 id は container/datestrip/venues/data/fallback。配下は keibajo_code 一意）。
 */

.jra-index-gateway-container {
  /* 色テーマ（JRA基調＝青系パレットを CSS変数に集約。★NAR:緑／JRA:青のブランド使い分け） */
  --jra-blue: #1d4e89;           /* ブランド濃青（見出し/現在R/バー/リンク）＝assets/race.png の紺 #002b64 と同系 */
  --jra-ink: #1f2227;            /* 主テキスト（濃墨＝わずかに青寄り） */
  --jra-ink-soft: #232a33;       /* 馬名 */
  --jra-muted: #626872;          /* 副次テキスト */
  --jra-muted-2: #8796aa;        /* 既走Rの文字 */
  --jra-faint: #97a5bb;          /* 最も淡い注記 */
  --jra-bar-track: #d5deee;      /* ミニバー軌道 */
  --jra-rpill-future-bg: #f9fbfe;
  --jra-rpill-future-fg: #34383f;
  --jra-rpill-future-bd: #c6d0e1;
  --jra-rpill-done-bg: #d9e2f1;
  --jra-rpill-done-fg: #8796aa;
  --jra-rnav-bg: #e2ebf9;
  --jra-rnav-fg: #616874;
  --jra-allhorses-bg: #e6effc;
  --jra-allhorses-bd: #d0d6e0;
  --jra-rule-soft: #ced8ea;
  --jra-hairline: #d5deeb;
  --jra-foot-link-bd: #b8c2d4;
  --jra-focus: #ffd166;          /* キーボードフォーカスリング（濃青/淡背景双方で視認可・青系移行後も琥珀のまま維持＝地色と衝突しない） */

  /* 基底 typography（コンテナで一括指定＝テーマ font-size/line-height に左右されない） */
  /* レスポンシブ＝スマホは全幅(単一カラム)・PC等の広幅では各場カードを2カラム化（下記 .jra-index-venues）。 */
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  background: #ffffff;
  color: var(--jra-ink);
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', 'Yu Gothic', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.jra-index-gateway-container *,
.jra-index-gateway-container *::before,
.jra-index-gateway-container *::after { box-sizing: border-box; }
.jra-index-gateway-container a { -webkit-tap-highlight-color: transparent; }

/* ============================================================
   ヘッダ（サブタイトル：日付ラベル＋前日公開の注記）
   ============================================================ */
.jra-index-gateway-head { padding: 18px 22px 10px; }
.jra-index-gateway-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--jra-muted);
  letter-spacing: 0.5px;
}

/* ============================================================
   日付セレクタ（直近開催日タブ＋◀▶・クライアントJSのみ＝URL不変）
   ★no-JS（.jra-js-ready 未付与）では非表示＝「selected_date(canonical)」表示に縮退。
   ============================================================ */
.jra-index-datestrip {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--jra-rule-soft); /* 下線タブの土台罫 */
}
.jra-index-gateway-container:not(.jra-js-ready) .jra-index-datestrip { display: none; }
/* 単日（静的モード）や JS 未構築時は空 ＝畳む（余白を出さない）。JS が日付タブを入れると表示される。 */
.jra-index-datestrip:empty { display: none; }
.jra-gateway-datenav {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  border: 0;
  background: none;
  color: var(--jra-muted);
  font-family: 'Roboto Mono', monospace;
  font-weight: 400;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.jra-gateway-datenav[disabled] { opacity: 0.3; cursor: default; }
.jra-gateway-datepills {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
}
.jra-gateway-datepill {
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 9px 4px;
  border: 0;
  border-bottom: 2px solid transparent; /* 既定は透明＝下のベースライン罫が透ける。アクティブで青下線に */
  margin-bottom: -1px;
  background: none;
  color: var(--jra-muted);               /* 非アクティブ＝灰文字 */
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.jra-gateway-datepill.jra-gateway-dateactive {
  color: var(--jra-blue);                /* アクティブ＝ブランド濃青の文字＋下線（色統一） */
  border-bottom-color: var(--jra-blue);
}

/* キーボードフォーカスリング（WCAG 2.4.7/2.4.11・日付ストリップ＋Rストリップに付与）。 */
.jra-gateway-datepill:focus-visible,
.jra-gateway-datenav:focus-visible,
.jra-gateway-rpill:focus-visible,
.jra-gateway-rnav:focus-visible {
  outline: 2px solid var(--jra-focus);
  outline-offset: 2px;
}

/* スクリーンリーダー専用（日付切替の live region 用・視覚的に隠す＝レイアウトに影響しない）。 */
.jra-gateway-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   各場カード（JS 構築・#jra-index-venues 配下）
   ============================================================ */
/* 各場カードのラッパ＝レスポンシブ・グリッド（メディアクエリ不要の自動段組）。
   auto-fill + minmax(min(340px,100%),1fr)＝狭幅(スマホ)は1カラム、コンテナ約700px超で2カラムへ自動切替
   （max-width:960px ＜ 3×340+gap ゆえ最大2カラム＝3カラムにはならない）。 */
.jra-index-venues {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  column-gap: 22px;
}
.jra-gateway-venue { padding: 16px 0 2px; }

/* 広告（窓口下部＝グリッド末尾セル・PHP サーバレンダで JS は温存＝<ins> 非接触・2026-08-17）。
   奇数位置（＝偶数場開催で新しい行の先頭に落ちる）は全幅、偶数位置（＝3場開催の右下空きセル等）は
   セル内に収まる。スマホ1列では常に全幅相当。min-height は CLS 抑制。 */
.jra-index-gateway-ad { margin-top: 16px; }
.jra-index-gateway-ad:nth-child(odd) { grid-column: 1 / -1; }
.jra-index-gateway-ad-label {
  font-family: 'Roboto Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: #999999;
  margin-bottom: 8px;
}
.jra-index-gateway-ad-slot { min-height: 80px; }

/* 場ヘッダ帯（高さ44px・一体型バナー。場名は馬の右に重ね白縁取り）。
   ★assets/race.png 同梱時は左詰めバナー。無い場合は背景色のみで縮退（帯自体は表示）。 */
.jra-gateway-venue-header {
  display: flex;
  align-items: center;
  height: 44px;
  overflow: hidden;
  background-color: #ebf2fc; /* race.png 欠落時の縮退地色＝波と調和する淡青 */
  background-image: url(../assets/race.png);
  background-repeat: no-repeat;
  background-position: left center;
  background-size: cover;
}
.jra-index-gateway-container .jra-gateway-venue-name {
  margin: 0; /* h3 既定マージンを打ち消し 44px バナー帯の整列を保持 */
  padding: 0;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--jra-ink);
  letter-spacing: 1px;
  padding-left: 96px; /* 馬シルエットの右に場名（帯高44pxに連動・NAR nar-gateway-venue-name と同値。JRA側は race.png（馬シルエット左寄せの同構図）ゆえ被らない） */
  position: relative;
  top: -3px;
  text-shadow: 1px 1px 0 #fff, -1px 1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff,
               0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff;
}

/* Rストリップ（◀ R… ▶・横スクロール帯） */
.jra-gateway-rstrip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 0;
}
.jra-gateway-rnav {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--jra-rnav-bg);
  color: var(--jra-rnav-fg);
  font-family: 'Roboto Mono', monospace;
  font-weight: 400;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.jra-gateway-rnav[disabled] { opacity: 0.4; cursor: default; }
/* ◀▶ は JS でのみ機能ゆえ no-JS では隠す（死んだボタンを出さない）。no-JS は fallback 表で各場へ到達。 */
.jra-index-gateway-container:not(.jra-js-ready) .jra-gateway-rnav { display: none; }
.jra-gateway-rpills {
  flex: 1;
  min-width: 0;                      /* flex 子が内容幅未満に縮める＝overflow-x スクロールを有効化 */
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;                  /* 全Rを1列・横スクロール（スマホ=指で慣性ドラッグ／PC=◀▶/ホイール） */
  scroll-snap-type: x proximity;     /* ピルが緩くスナップ */
  -webkit-overflow-scrolling: touch; /* iOS の慣性スクロール */
  scrollbar-width: none;             /* Firefox: スクロールバー非表示 */
}
.jra-gateway-rpills::-webkit-scrollbar { display: none; } /* WebKit/Chrome/Safari: スクロールバー非表示 */
.jra-gateway-rpill {
  flex: 0 0 auto;                    /* 内容幅で並べて溢れさせる */
  min-width: 54px;
  scroll-snap-align: center;         /* スナップ基準＝各ピル中央 */
  text-align: center;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 18px;
  font-family: 'Roboto Mono', monospace;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  border: 1px solid var(--jra-rpill-future-bd);
  background: var(--jra-rpill-future-bg);
  color: var(--jra-rpill-future-fg);
}
.jra-gateway-rpill.jra-gateway-current {
  background: var(--jra-blue);
  color: #ffffff;
  border-color: var(--jra-blue);
}
.jra-gateway-rpill.jra-gateway-done {
  background: var(--jra-rpill-done-bg);
  color: var(--jra-rpill-done-fg);
  border-color: var(--jra-rpill-done-bg);
}

/* TOP3（CSSミニバー） */
.jra-gateway-top3 { padding: 11px 22px 4px; }

/* TOP3 見出し行（馬番 / 馬名 / 予想勝率・bar-row と同じ列幅 16/116/flex/40＋gap11 で整列） */
.jra-gateway-bar-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
}
.jra-gateway-th {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  font-size: 10px;
  line-height: 1;
  color: var(--jra-muted);
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.jra-gateway-th-umaban { flex: none; width: 24px; } /* 二桁馬番が折り返さない幅（2026-08-16・cell と同幅） */
.jra-gateway-th-umamei { flex: none; width: 116px; text-align: center; }
.jra-gateway-th-bar { flex: 1; min-width: 0; }
.jra-gateway-th-val { flex: none; width: 40px; text-align: right; }
.jra-gateway-bar-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 9px;
}
.jra-gateway-umaban {
  flex: none;
  width: 24px; /* 二桁馬番（"11"等）が折り返さない幅（2026-08-16。テーマの word-break にも耐えるよう nowrap 併用） */
  white-space: nowrap;
  text-align: right;
  font-family: 'Roboto Mono', monospace;
  font-weight: 400;
  font-size: 12px;
  line-height: 1;
  color: var(--jra-muted-2);
  font-variant-numeric: tabular-nums;
}
.jra-gateway-umamei {
  flex: none;
  width: 116px;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.2;
  color: var(--jra-ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.jra-gateway-bar {
  flex: 1;
  min-width: 0;
  display: block;
  height: 5px;
  background: var(--jra-bar-track);
  overflow: hidden;
}
.jra-gateway-bar-fill {
  display: block;
  height: 100%;
  /* 単勝指数バー＝実指数ページ(jra-index-report の Chart.js tansho)と同じ「青→紫」グラデをスケール基準で再現
     （青 rgba(59,89,214,.7) → 紫 rgba(153,102,255,.7)）。gradient をトラック全幅(0..SCALE_MAX)に張り、
     fill(width=指数%) が 0..値 をクリップ表示。--barpct(=fill幅%) で background-size をトラック幅へ正規化。 */
  background-image: linear-gradient(to right,
    rgba(59, 89, 214, 0.7) 0%, rgba(59, 89, 214, 0.7) 30%,
    rgba(153, 102, 255, 0.7) 70%, rgba(153, 102, 255, 0.7) 100%);
  background-repeat: no-repeat;
  background-position: left center;
  background-size: calc(10000% / max(var(--barpct, 100), 1)) 100%;
}
.jra-gateway-bar-val {
  flex: none;
  width: 40px;
  text-align: right;
  font-family: 'Roboto Mono', monospace;
  font-weight: 400;
  font-size: 14px;
  line-height: 1;
  color: var(--jra-ink);
  font-variant-numeric: tabular-nums;
}

/* 「{N}Rの全頭の指数を見る」 */
.jra-gateway-allhorses {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  margin: 3px 0 0;
  padding: 9px 0;
  border: 1px solid var(--jra-allhorses-bd);
  border-radius: 9px;
  background: var(--jra-allhorses-bg);
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: var(--jra-blue);
}
.jra-gateway-allhorses-arrow { font-family: 'Roboto Mono', monospace; font-weight: 400; font-size: 13px; line-height: 1; }

/* 「{場名}の全レースを見る →」 */
.jra-gateway-venue-foot {
  display: flex;
  align-items: center;
  padding: 10px 0 12px;
}
.jra-gateway-venue-link {
  margin-left: auto;
  text-decoration: none;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--jra-blue);
  letter-spacing: 1px;
}
.jra-gateway-venue-arrow { font-family: 'Roboto Mono', monospace; font-weight: 400; font-size: 13px; line-height: 1; margin-left: 5px; }

/* 「{場名}競馬場のコース傾向 →」（32_集客記事の解説記事へ・「全レースを見る →」の下へ右揃えで並べる）。
   ★罫線は引かない＝各場カードは grid の多段配置ゆえ、カード下端の横罫が段またぎで隣カードの区切りに見える。 */
.jra-gateway-venue-course {
  display: flex;
  align-items: center;
  padding: 0 0 6px;
}
.jra-gateway-course-link {
  margin-left: auto;
  text-decoration: none;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--jra-blue);
  letter-spacing: 1px;
}
.jra-gateway-course-link:focus-visible { outline: 2px solid var(--jra-focus); outline-offset: 2px; }
.jra-gateway-course-arrow { font-family: 'Roboto Mono', monospace; font-weight: 400; font-size: 13px; line-height: 1; margin-left: 5px; }

/* ============================================================
   フォールバック（.jra-index-fallback・サーバレンダ・PHP 出力）
   ★JS 成功（.jra-js-ready 付与）時に隠す＝二重描画を防ぐ。
     no-JS/JS失敗時のみ可視＝各場 先頭R TOP3 ＋ 各場CPT への実リンクで遷移可（graceful）。
   ============================================================ */
.jra-index-gateway-container.jra-js-ready .jra-index-fallback { display: none; }
.jra-index-fallback { padding: 8px 22px 18px; }
.jra-index-gateway-container .jra-venue { padding: 12px 0; border-top: 1px solid var(--jra-hairline); }
.jra-index-gateway-container .jra-venue:first-child { border-top: 0; }
.jra-index-gateway-container .jra-venue-name {
  margin: 0 0 6px;
  padding: 0;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  color: var(--jra-ink);
  border: 0;
  background: none;
}
.jra-index-gateway-container .jra-venue-cur-race {
  margin: 0 0 6px;
  padding: 0;
  font-family: 'Roboto Mono', monospace;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  color: var(--jra-blue);
  border: 0;
  background: none;
}
.jra-gateway-top-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 8px;
}
.jra-gateway-top-table th,
.jra-gateway-top-table td {
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1.3;
  border-bottom: 1px solid var(--jra-hairline);
  text-align: left;
}
.jra-gateway-top-table th {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  font-size: 10px;
  color: var(--jra-muted);
}
.jra-gateway-top-table .jra-umaban { width: 36px; text-align: right; font-family: 'Roboto Mono', monospace; color: var(--jra-muted-2); }
.jra-gateway-top-table .jra-umamei { color: var(--jra-ink-soft); }
.jra-gateway-top-table .jra-tansho { width: 64px; text-align: right; font-family: 'Roboto Mono', monospace; color: var(--jra-ink); font-variant-numeric: tabular-nums; }
.jra-venue-link-wrap { margin: 4px 0 0; }
.jra-index-gateway-container .jra-venue-link {
  text-decoration: none;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--jra-blue);
  letter-spacing: 1px;
}

/* ============================================================
   データ無し（静的モードの不正日付/データ欠落＝簡易メッセージ）
   ============================================================ */
.jra-index-no-data { padding: 28px 22px; }
.jra-index-no-data p {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--jra-muted);
}

/* ============================================================
   レスポンシブ（狭幅で馬名幅を詰める）
   ============================================================ */
@media (max-width: 380px) {
  .jra-gateway-umamei { width: 92px; }
  .jra-gateway-bar-val { width: 36px; font-size: 13px; }
  .jra-gateway-th-umamei { width: 92px; }
  .jra-gateway-th-val { width: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .jra-gateway-rnav,
  .jra-gateway-datenav { transition: none; }
}
