/* Genyas — 記事内テーブル専用（Gutenberg / 经典）
   読み込み: functions.php（pages.css の後・最終レイヤー）
   WP core の thead 3px 罫線は PHP dequeue + 下記 reset で無効化
*/

/* ============================================================
   1. WP / Gutenberg リセット
   ============================================================ */
.entry-content :is(.wp-block-table, figure.wp-block-table) {
	margin: 2em 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	max-width: 100%;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	background: transparent;
}

/* core: .wp-block-table thead { border-bottom: 3px solid } */
.entry-content :is(.wp-block-table, figure.wp-block-table) table :is(thead, tfoot),
.entry-content table :is(thead, tfoot) {
	border: 0;
}

.entry-content :is(.wp-block-table, figure.wp-block-table) :is(thead, tbody, tfoot, tr, th, td),
.entry-content table :is(thead, tbody, tfoot, tr, th, td) {
	border-radius: 0;
	box-shadow: none;
}

.entry-content :is(.wp-block-table.is-style-stripes, figure.wp-block-table.is-style-stripes) tbody tr:nth-child(odd) {
	background: transparent;
}

/* core: .wp-block-table td, .wp-block-table th { border: 1px solid } を一度解除 */
.entry-content :is(.wp-block-table, figure.wp-block-table) table :is(th, td),
.entry-content table :is(th, td) {
	border-style: solid;
	border-width: 0;
	border-color: var(--line);
}

/* ============================================================
   2. グリッド（1px 統一 — table 上左 + セル右下）
   ============================================================ */
.entry-content table {
	--table-line: #C5B69E;
	--table-line-head-in: rgba(255, 255, 255, 0.34);
	--table-line-head-out: #B89A78;

	width: 100%;
	border-collapse: collapse;
	border-top: 1px solid var(--table-line);
	border-left: 1px solid var(--table-line);
	background: var(--paper);
	font-size: 0.92rem;
	line-height: 1.75;
}

.entry-content :is(.wp-block-table, figure.wp-block-table) table :is(th, td),
.entry-content table :is(th, td) {
	border-color: var(--table-line);
}

.entry-content table :is(th, td) {
	padding: 12px 16px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	vertical-align: top;
	text-align: left;
}

/* ============================================================
   3. テーマ装飾
   ============================================================ */

/* 列ヘッダー */
.entry-content table thead th {
	font-family: var(--mincho);
	font-weight: 700;
	font-size: 0.88rem;
	letter-spacing: 0.04em;
	color: #fff;
	background-color: var(--cha-deep2);
	border-right-color: var(--table-line-head-in);
	border-bottom-color: var(--table-line-head-out);
}

.entry-content table thead th:last-child {
	border-right-color: var(--table-line);
}

/* 本文セル */
.entry-content table tbody td {
	color: var(--sumi);
	background-color: var(--paper);
}

.entry-content table tbody tr:nth-child(even) td {
	background-color: var(--washi-2);
}

/* 行見出し（左列 th） */
.entry-content table tbody th {
	font-family: var(--mincho);
	font-weight: 700;
	color: var(--sumi);
	background-color: var(--washi-2);
}

.entry-content table tbody tr:nth-child(even) th {
	background-color: var(--washi-deep);
}

/* thead 無し — 先頭行をヘッダー扱い */
.entry-content table:not(:has(thead)) tbody tr:first-child :is(th, td) {
	font-family: var(--mincho);
	font-weight: 700;
	font-size: 0.88rem;
	letter-spacing: 0.04em;
	color: #fff;
	background-color: var(--cha-deep2);
	border-right-color: var(--table-line-head-in);
	border-bottom-color: var(--table-line-head-out);
}

.entry-content table:not(:has(thead)) tbody tr:first-child :is(th, td):last-child {
	border-right-color: var(--table-line);
}

.entry-content table:not(:has(thead)) tbody tr:first-child ~ tr:nth-child(even) td {
	background-color: var(--paper);
}

.entry-content table:not(:has(thead)) tbody tr:first-child ~ tr:nth-child(odd) td {
	background-color: var(--washi-2);
}

.entry-content table caption {
	caption-side: bottom;
	margin-top: 0.75em;
	font-size: 0.82rem;
	color: var(--sumi-soft);
	text-align: center;
	line-height: 1.7;
}

@media (max-width: 760px) {
	.entry-content table :is(th, td) {
		padding: 10px 12px;
		font-size: 0.85rem;
	}
}
