/*
 * #117 記事内の表（料金表など）がスマホで画面の横にはみ出す不具合の修正（2026-12-06）
 * - スマホ幅（768px 以下）だけに効く。PC 幅の見た目は変えない。
 * - ページ全体ではなく「表の中だけ」を横スクロールさせ、最初の列（項目名）を左に固定する。
 * - style.min.css（Gulp 生成物）には触れず、追加ファイルとして functions.php で読み込む。
 * - ランキング表 .cps-table03 と既存のラッパー .scrollable-table / .scroll-table は対象外（既存の挙動を保つ）。
 */
@media only screen and (max-width: 768px) {
	/* ブロック形式の表（<figure class="wp-block-table">）: figure をスクロール箱にする */
	.single-content .wp-block-table {
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	/* ラッパーのない生の <table>: 表自身をスクロール箱にする */
	.single-content table:not(.cps-table03) {
		display: block;
		width: max-content;
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	/* ラッパーがある表は従来どおり table のまま（スクロールはラッパー側が受け持つ） */
	.single-content .wp-block-table table:not(.cps-table03),
	.single-content .scrollable-table table:not(.cps-table03),
	.single-content .scroll-table table:not(.cps-table03),
	.single-content table table {
		display: table;
		width: 100%;
		max-width: none;
		overflow: visible;
	}

	/*
	 * 最初の列（項目名）を横スクロール中も左に残す。
	 * 元のセル背景は半透明（td: 白60% / th: 黒10%）で、固定すると下の列が透けるため、
	 * 「下地の色＋同じ半透明の重ね」を不透明に描いて、止まっている時の見た目を元と同じにする。
	 * 下地: 表に背景色の指定（ブロックの has-background）があればその色、無ければ白。
	 */
	.single-content table:not(.cps-table03) tr > th:first-child,
	.single-content table:not(.cps-table03) tr > td:first-child {
		position: -webkit-sticky;
		position: sticky;
		left: 0;
		z-index: 1;
		background-color: #fff;
	}
	.single-content table:not(.cps-table03) tr > td:first-child {
		background-image: linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));
	}
	.single-content table:not(.cps-table03) tr > th:first-child {
		background-image: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1));
	}
	.single-content table.has-background > thead,
	.single-content table.has-background > tbody,
	.single-content table.has-background > tfoot,
	.single-content table.has-background > * > tr,
	.single-content table.has-background:not(.cps-table03) tr > th:first-child,
	.single-content table.has-background:not(.cps-table03) tr > td:first-child {
		background-color: inherit;
	}
}
