/**
 * 成績テーブル。カードで囲わず、0.5pxのヘアラインのみで区切る。
 * ゼブラ縞は使わない。赤は打率1位のみ（design-policy.md 3章: 赤は1画面に2〜3箇所まで）。
 *
 * @package goonies
 */

/* 21列（打撃）・20列（投手）はモバイル幅に収まらないため横スクロールさせる
   （design-policy.md 10章）。position: relative は右端グラデーションの土台。
   tabindex="0" はマークアップ側（矢印キーでのスクロールに必要）。
   width: 100% + min-width: 0 + max-width: 100% はいずれも、中の幅広い table に
   引きずられてこの要素自体、ひいては .stats-page 等の祖先・ページ全体まで
   横スクロールしてしまわないための保険（本来の原因は .site-main 側の flex
   アイテムの自動最小幅と、祖先の block要素は width だけでは中身のはみ出しを
   止められない点。base.css / assets/css/stats-page.css 参照） */
.stats-table-scroll {
	position: relative;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	overflow-x: auto;
	/* overflow-xだけを指定するとブラウザはoverflow-yを暗黙にautoへ変換し、
	   この要素自体が縦方向のスクロールコンテナになる（CSS Overflow仕様の既定挙動）。
	   すると中のsticky theadの基準がviewportではなくこの要素になり、
	   top: var(--header-sticky-offset) の意味がズレる。overflow-y: clip を
	   明示してその昇格を防ぐ（縦方向は元々はみ出さないため見た目への影響は無い） */
	overflow-y: clip;
}

/* スクロール領域の右端。まだ続きがあることを示す薄いグラデーション（幅24px）。
   JS（assets/js/stats-table.js）が右端到達時・そもそも収まる場合に非表示にする */
.stats-table-scroll::after {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 24px;
	background: linear-gradient(90deg, transparent, var(--c-paper));
	pointer-events: none;
	opacity: 1;
	transition: opacity var(--duration-standard) var(--ease-standard);
}

.stats-table-scroll.is-scroll-end::after,
.stats-table-scroll.is-not-scrollable::after {
	opacity: 0;
}

/* table-layout: fixed + min-width（列幅の合計をtableタグ側でカスタムプロパティとして
   指定。打撃1204px・投手1148px）で「列幅の合計 = テーブル幅」を厳密にする。
   width: max-content はキーワードによる内在サイズ計算のため、深くネストした
   overflow-x: auto 内で正しくクリップされないことがあったため、確定した
   px 値の min-width に置き換えた。width: 100% + auto layout だと内容に対して
   テーブルが必要以上に広がるため使わない。
   .stats-table-scroll に包まれる打撃・投手テーブルにだけ適用する
   （CAREER STATS・ランキング表は列幅を指定していないtable-layout: autoのまま） */
.stats-table-scroll .stats-table {
	width: 100%;
	min-width: var(--goonies-stats-table-min-width);
	table-layout: fixed;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0;
}

/* colgroupで列幅を確定する。背番号・選手名はsticky列の左オフセット計算のため
   固定幅が必須。375px幅で固定列を除き最低6列見えるよう詰めている */
.stats-table__col--number {
	width: 32px;
}

.stats-table__col--name {
	width: 80px;
}

.stats-table__col--data {
	width: 34px;
}

/* ランキング表・CAREER STATS（.stats-table-scrollで包まない小さい表）の既定幅。
   打撃・投手テーブルは上の .stats-table-scroll .stats-table が
   詳細度で上書きする（table-layout: fixed + 列幅合計のmin-width） */
.stats-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
}

/* table-layout: fixed で横スクロールするテーブル（page-stats.php の打撃・投手、
   選手個別ページ CAREER STATS の打撃成績）は <caption> をテーブルの外
   （.stats-table-scroll の手前）に出しているため、<p> として組む。
   スクロールしても見出しが流れないようにするため（テーブル内のcaptionは
   スクロール領域と一緒に流れてしまう）。テーブルとは aria-labelledby で紐づける。
   ランキング表・CAREER STATSの投手成績（横スクロールしない）は
   従来どおり <caption> のまま */
.stats-table__caption {
	text-align: left;
	font-family: var(--f-display);
	font-weight: var(--fw-display-regular);
	font-size: var(--fs-section-label);
	letter-spacing: var(--ls-label);
	text-transform: uppercase;
	color: var(--c-gray-50);
	margin: 0 0 16px;
}

.stats-table__cell {
	padding: 10px 6px;
	border-bottom: 0.5px solid var(--c-gray-15);
	text-align: left;
	font-size: var(--fs-table-number);
	font-weight: var(--fw-body-regular);
	color: var(--c-ink);
	font-variant-numeric: tabular-nums;
	transition: background var(--duration-standard) var(--ease-standard);
}

/* リスト行ホバー：背景をごく淡く（design-policy.md 9章）。固定列（sticky）にも
   同じ背景を効かせるため、行ではなく行内の td/th 全体に対して指定する
   （.stats-table__cell--sticky が個別に background: var(--c-paper) を持つため、
   詳細度で上書きできるようセレクタをその分だけ具体的にする） */
.stats-table__row:hover .stats-table__cell {
	background: var(--c-hover);
}

/* 打撃・投手テーブルは列幅32〜80pxに詰めるため、通常の表より余白を絞る。
   数値列は折り返さない（5桁の値まで想定）。見出しは折り返してよい
   （design-policy.md 4章のテーブル数値12pxを基準に、収まらないため11pxまで下げる） */
.stats-table-scroll .stats-table__cell {
	padding: 8px 2px;
}

/* td だけを指定する（th は --num クラスを右寄せ目的で共有しているため、
   ここで font-size を変えると列見出しの文字サイズまで変わってしまう） */
.stats-table-scroll td.stats-table__cell--num {
	font-size: 11px;
	white-space: nowrap;
}

.stats-table-scroll .stats-table__cell--head {
	white-space: normal;
	line-height: 1.3;
	/* 2行に折り返す見出し（与四死球率等）が混ざっても、1行の見出しと下端が揃うように
	   明示する（テーブルセルの既定の垂直配置はブラウザ間で解釈が割れやすいため、
	   baseline依存にせず bottom を明示する） */
	vertical-align: bottom;
}

.stats-table__cell:first-child {
	padding-left: 0;
}

.stats-table__cell:last-child {
	padding-right: 0;
}

.stats-table__cell--head {
	font-family: var(--f-body);
	font-size: var(--fs-annotation);
	font-weight: var(--fw-body-regular);
	color: var(--c-gray-50);
}

.stats-table__cell--num {
	text-align: right;
}

.stats-table__cell--number {
	font-family: var(--f-display);
	font-weight: var(--fw-display-regular);
	color: var(--c-gray-25);
}

.stats-table__cell--name {
	font-family: var(--f-display);
	font-weight: var(--fw-display-regular);
	font-size: var(--fs-list-heading);
	color: var(--c-ink);
	/* 96px幅に収まらない選手名は省略せず折り返す（T.MIZUKO / K.AKASAKA 等で確認済み。
	   ハイフンの無いローマ字表記のため overflow-wrap を anywhere にする） */
	white-space: normal;
	overflow-wrap: anywhere;
}

.stats-table__cell--leader {
	color: var(--c-accent);
	font-weight: var(--fw-display-medium);
}

/* 背番号・選手名列を左端に固定する（design-policy.md 10章）。
   ヘッダ行（thead）は別途 top: var(--header-sticky-offset) も加わり、左上の2セルは
   上下左右どちらのスクロールでも画面内に留まる（z-indexを最も高くする） */
.stats-table__cell--sticky {
	position: sticky;
	background: var(--c-paper);
	z-index: 1;
}

/* top はサイトヘッダー（position: sticky）の現在の高さぶん下げる。0のままだと
   スクロール時にサイトヘッダーの裏に潜り込んでしまう（assets/css/base.css の
   --header-sticky-offset 参照。ヘッダーの縮小・管理バー表示にも追従する）。
   この位置指定はviewport基準が前提。祖先要素（.stats-page 等）に none 以外の
   transform を付けると基準がすり替わり沈み込むため付けないこと
   （assets/css/base.css の .reveal.js-reveal-init.is-visible 参照） */
.stats-table-scroll thead .stats-table__cell {
	position: sticky;
	top: var(--header-sticky-offset);
	background: var(--c-paper);
	z-index: 2;
}

.stats-table-scroll thead .stats-table__cell--sticky {
	z-index: 3;
}

.stats-table__cell--number.stats-table__cell--sticky {
	left: 0;
}

.stats-table__cell--name.stats-table__cell--sticky {
	left: 32px;
	border-right: 0.5px solid var(--c-gray-15);
}

/* 固定列の右端、右方向への薄い影（スクロールでその下に本文が隠れることを示す） */
.stats-table__cell--name.stats-table__cell--sticky::after {
	content: '';
	position: absolute;
	top: 0;
	right: -8px;
	bottom: 0;
	width: 8px;
	background: linear-gradient(90deg, rgba(20, 20, 20, 0.08), transparent);
	pointer-events: none;
}

/* ソート可能な列見出し。<button>は使わず<th>自体をクリック領域にする。
   枠線・背景・パディングは付けず、見た目は通常の見出しテキストのまま
   （design-policy.md 1章: カードで要素を囲わない）。並べ替え中の列だけ、
   見出し自体に控えめな三角の矢印を付けて示す。
   矢印はposition: absoluteでインラインの流れから完全に外す。
   inline-blockのままだと、非表示時(height:0)→表示時(height:4px)で
   矢印自身のボックスサイズが変わり、その見出しだけ縦位置がずれる。
   さらに矢印が右寄せテキストの直後（インライン内の最後の要素）にあると、
   見えない状態でも矢印の余白ぶん（枠線6px+margin3px=9px）がtdの右端との
   ズレになる。absolute化すればどちらの問題も起きない */
.stats-table__cell--sortable {
	position: relative;
	cursor: pointer;
}

.stats-table__cell--sortable::after {
	content: '';
	position: absolute;
	right: 2px;
	bottom: 2px;
	width: 0;
	height: 0;
	border-left: 3px solid transparent;
	border-right: 3px solid transparent;
	opacity: 0;
	pointer-events: none;
}

.stats-table__cell--sortable[aria-sort='ascending']::after {
	opacity: 1;
	border-bottom: 4px solid currentColor;
}

.stats-table__cell--sortable[aria-sort='descending']::after {
	opacity: 1;
	border-top: 4px solid currentColor;
}

/* 選手名リンク。常時下線は付けず、ホバー時のみ下線が左から伸びる
   （design-policy.md 9章: ナビ・リンクホバー、180ms）。タップ領域44px以上を確保する */
.stats-table__player-link {
	position: relative;
	display: inline-flex;
	align-items: center;
	min-height: var(--tap-min);
	color: inherit;
	text-decoration: none;
}

.stats-table__player-link::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	bottom: 6px;
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform var(--duration-underline) var(--ease-standard);
}

.stats-table__player-link:hover::after {
	transform: scaleX(1);
}

.stats-table__row--muted .stats-table__cell {
	color: var(--c-gray-35);
}

.stats-table__row--muted .stats-table__cell--number {
	color: var(--c-gray-25);
}

.stats-table__empty {
	color: var(--c-gray-70);
	font-size: var(--fs-body);
	line-height: var(--lh-body);
	margin: 0;
}

/* 注釈（design-policy.md 4章: 9-10px / グレー25） */
.stats-table__note {
	font-size: var(--fs-annotation);
	color: var(--c-gray-25);
	margin: 8px 0 0;
}

/**
 * 年度・タブの切替UI共通コンポーネント。page-stats.php の年度セレクタ/タブと
 * 選手個別ページ（[goonies_player]）の詳細成績セレクタで共有する。
 * アクティブ状態は色と下線のみで示す（design-policy.md 3章: 赤は使わない）。
 */
.stats-selector,
.stats-tabs {
	margin: 0 0 var(--space-section);
	border-bottom: 0.5px solid var(--c-gray-15);
}

.stats-selector__list,
.stats-tabs__list {
	position: relative;
	display: flex;
	gap: 20px;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
}

/* .stats-selector__button は年度切替（案A）でJS無効時のフォールバックのため
   <a href="?year=..."> にしている。text-decoration: none はそのブラウザ既定の
   下線を消すためのもの（<button>である.stats-tabs__buttonには影響しない） */
.stats-selector__button,
.stats-tabs__button {
	appearance: none;
	background: none;
	border: 0;
	margin: 0;
	padding: 0;
	min-height: var(--tap-min);
	display: inline-flex;
	align-items: center;
	font-family: var(--f-display);
	font-weight: var(--fw-display-regular);
	font-size: var(--fs-list-heading);
	color: var(--c-gray-50);
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
}

.stats-selector__button.is-active,
.stats-tabs__button.is-active {
	color: var(--c-ink);
	font-weight: var(--fw-display-medium);
}

/* アクティブ下線。インク1px、赤は使わない。横スライドは transform で移動する */
.stats-selector__indicator,
.stats-tabs__indicator {
	position: absolute;
	left: 0;
	bottom: -0.5px;
	width: 0;
	height: 1px;
	background: var(--c-ink);
	transform: translateX(0);
	transition:
		transform var(--duration-standard) var(--ease-standard),
		width var(--duration-standard) var(--ease-standard);
}

/**
 * THIS SEASON サマリー（[goonies_stats type="summary"]）。
 * design-policy.md 4章「階層は大きさと明度の差で作る」の実例（15勝=66px インク / 2敗2分=32px グレー35）に基づき、
 * 勝のみ主要数値、他は副次数値として並べる。カードや罫線では囲わない。
 * 見出し（THIS SEASON / 今季成績）は .section-heading（base.css）を使う。
 */
.stats-summary__grid {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 20px;
	row-gap: 12px;
}

.stats-summary__stat {
	display: inline-flex;
	align-items: baseline;
	gap: 4px;
}

.stats-summary__value {
	font-family: var(--f-display);
	font-weight: var(--fw-display-medium);
	letter-spacing: var(--ls-number);
	font-variant-numeric: tabular-nums;
}

.stats-summary__value--primary {
	font-size: var(--fs-number-primary);
	color: var(--c-ink);
}

.stats-summary__value--secondary {
	font-size: var(--fs-number-secondary);
	color: var(--c-gray-35);
}

.stats-summary__unit {
	font-family: var(--f-body);
	font-size: var(--fs-body);
	color: var(--c-gray-50);
}

.stats-summary__unit--primary {
	color: var(--c-ink);
}

/**
 * 選手個別ページ（[goonies_player]）。docs/sitemap.md 4-3準拠。
 * 背番号は本人のページなので --c-ink で大きく組む。成績表内の背番号（.stats-table__cell--number）は
 * 従来どおり --c-gray-25 のまま、ここでは一切変更しない。
 */
.player-photo {
	margin: 0 0 var(--space-section);
}

/* 縦横比は元画像のまま。object-fitによる切り抜きはしない */
.player-photo__img {
	display: block;
	width: 100%;
	height: auto;
}

.player-header {
	display: flex;
	align-items: baseline;
	gap: 16px;
	margin: 0;
}

.player-header__number {
	font-family: var(--f-display);
	font-weight: var(--fw-display-medium);
	font-size: var(--fs-number-primary);
	letter-spacing: var(--ls-number);
	font-variant-numeric: tabular-nums;
	color: var(--c-ink);
}

.player-header__identity {
	display: flex;
	flex-direction: column;
}

.player-header__name {
	font-family: var(--f-display);
	font-weight: var(--fw-display-medium);
	font-size: var(--fs-hero);
	color: var(--c-ink);
	margin: 0;
}

.player-header__role {
	font-family: var(--f-body);
	font-size: var(--fs-body);
	color: var(--c-gray-70);
	margin: 4px 0 0;
}

/* ヘッダー（背番号+選手名）／PROFILE／CAREER STATS／DETAILED STATSの間
   （第1階層）。見出しを24-28pxの2段構成に拡大したことで罫線が無くても
   階層が読み取れるため、罫線は引かない（design-policy.md 2章、2026-08-14改訂）。
   .player-photo・.player-header が常に手前にあり、.player-section が
   DOM上の:first-childになることは無いため、除外ルールは不要
   （front-page.php の .home-section と同じ考え方） */
.player-section {
	margin-top: var(--space-tier-1);
}

.player-personal {
	margin: 0;
}

/* 項目間（第3階層）。UPCOMING（front-page.php）・試合結果詳細（game-result.php）・
   PERSONAL DATA/DETAILED STATS（player.php）で共通 */
.player-personal__row {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: calc(var(--space-tier-3) / 2) 0;
	border-bottom: var(--rule-3);
}

.player-personal__row:first-child {
	padding-top: 0;
}

.player-personal__row:last-child {
	padding-bottom: 0;
	border-bottom: none;
}

.player-personal__label {
	font-family: var(--f-body);
	font-size: var(--fs-body);
	color: var(--c-gray-50);
	margin: 0;
}

.player-personal__value {
	font-family: var(--f-body);
	font-size: var(--fs-body);
	color: var(--c-ink);
	margin: 0;
	text-align: right;
}

/* 打撃成績と投手成績の間（第2階層）。打撃成績は .player-career-scroll
   （.stats-table-scroll）で包むため、投手成績（従来どおりラップ無し）と
   並んだときの間隔を揃えるにはラッパー側にも同じロジックが要る。
   .player-career-table クラスは打撃成績の内側のtableにも付いているため
   （セルのスタイル共有用）、.player-section の直接の子だけに限定する
   （そうしないと.player-career-scrollとその中のtableの二重で線・余白が付く） */
.player-career-scroll,
.player-section > table.player-career-table {
	margin-bottom: var(--space-tier-2);
	padding-bottom: var(--space-tier-2);
	border-bottom: var(--rule-2);
}

.player-career-scroll:last-child,
.player-section > table.player-career-table:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

/* 年度は行の識別子であり主役の数値ではない。背番号を淡くする考え方と同じ
   （design-policy.md 7章）。.player-career-table 内の年度セル（打撃・投手とも
   .stats-table__cell--name を年度ラベルに使っている）だけを対象にし、
   /stats/ の選手名セル等、他で使われる .stats-table__cell--name には
   影響しないよう .player-career-table 配下に限定する */
.player-career-table .stats-table__cell--name {
	font-weight: var(--fw-body-regular);
	color: var(--c-gray-70);
}

/* 通算行は従来どおり強調する（太字・インク）。年度セルも含め、
   上の淡色化を上書きする。ここより後に置くこと（同じ詳細度のため
   ソース順で勝つ）。上端は年度行との区切り（第2階層）にし、通算行が
   年度行に埋もれず浮いて見えるようにする */
.player-career-table__row--career .stats-table__cell {
	font-weight: var(--fw-display-medium);
	color: var(--c-ink);
	border-top: var(--rule-2);
}

/* CAREER STATS 打撃成績（9列）の固定列は年度のみ（page-stats.php の
   打撃・投手テーブルは背番号+選手名の2列固定だが、こちらは1列）。
   .stats-table__cell--sticky（position: sticky / background / z-index）は
   そのまま流用し、左オフセットと右端のヘアライン・影だけをここで追加する。
   page-stats.php 側の .stats-table__cell--name.stats-table__cell--sticky には
   影響しないよう、専用クラスとして分離する */
.player-career-table__col--year {
	width: 60px;
}

.player-career-table__cell--year.stats-table__cell--sticky {
	left: 0;
	border-right: 0.5px solid var(--c-gray-15);
}

.player-career-table__cell--year.stats-table__cell--sticky::after {
	content: '';
	position: absolute;
	top: 0;
	right: -8px;
	bottom: 0;
	width: 8px;
	background: linear-gradient(90deg, rgba(20, 20, 20, 0.08), transparent);
	pointer-events: none;
}

/* YouTube動画のfacade（サムネイル + 再生ボタン）。トップページのLATEST GAME、
   試合結果ページの<details>内で共通して使う（assets/js/youtube-facade.js）。
   16:9でトリミングして表示し、角丸は使わない（design-policy.md 5章）。 */
.youtube-facade {
	position: relative;
	aspect-ratio: 16 / 9;
	background: var(--c-plane);
	overflow: hidden;
	margin: 0 0 16px;
}

.youtube-facade__thumb {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.youtube-facade__play {
	appearance: none;
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	background: rgba(20, 20, 20, 0.15);
	border: 0;
	cursor: pointer;
}

/* 再生アイコン（三角）。左右の枠線幅を非対称にして、視覚的な重心を中央に寄せる */
.youtube-facade__play-icon {
	width: 0;
	height: 0;
	margin-left: 4px;
	border-top: 12px solid transparent;
	border-bottom: 12px solid transparent;
	border-left: 20px solid var(--c-paper);
}

.youtube-facade__iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}
