/*
Theme Name: katatemablog
Theme URI:
Author:
Author URI:
Description: レベルアップの「かたてま」に寄り添うブログ
Requires at least: 6.9
Tested up to: 6.9
Requires PHP: 5.7
Version: 0.2
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: katatemablog
Tags: blog
*/

/* =========================================================
   ヘッダー：スクロール追従
   ========================================================= */
.wp-site-blocks > header,
body > header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--wp--preset--color--base);
	transition: box-shadow 0.25s ease;
}
/* スクロール時：ヘッダーを縮める（内側グループのpaddingとロゴを縮小） */
.wp-site-blocks > header.is-scrolled,
body > header.is-scrolled {
	box-shadow: 0 2px 10px rgba(44,52,48,0.06);
}
.wp-site-blocks > header > .wp-block-group,
body > header > .wp-block-group {
	transition: padding 0.25s ease;
}
.wp-site-blocks > header.is-scrolled > .wp-block-group,
body > header.is-scrolled > .wp-block-group {
	padding-top: 0.35rem !important;
	padding-bottom: 0.35rem !important;
}
/* ロゴも少し小さく */
.wp-site-blocks > header .wp-block-site-logo img,
body > header .wp-block-site-logo img {
	transition: max-width 0.25s ease, width 0.25s ease;
}
.wp-site-blocks > header.is-scrolled .wp-block-site-logo img,
body > header.is-scrolled .wp-block-site-logo img {
	max-width: 140px;
	width: 140px;
}
/* スクロール中も下線を維持 */
.wp-site-blocks > header::after,
body > header::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 1px;
	background: var(--wp--preset--color--border);
	pointer-events: none;
}
/* sticky を効かせるため、先祖に overflow や transform を付けない */
html, body, .wp-site-blocks {
	overflow: visible;
}

/* =========================================================
   記事本文の見出しスタイル
   ========================================================= */

/* H2: ストライプアンダーライン（文字幅に追従） */
.wp-block-post-content h2,
.entry-content h2 {
	position: relative;
	width: fit-content;
	max-width: 100%;
	padding-bottom: 0.5em;
	margin-top: 2.5em;
	margin-bottom: 1em;
}
.wp-block-post-content h2::after,
.entry-content h2::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 7px;
	background: repeating-linear-gradient(
		-45deg,
		var(--wp--preset--color--primary),
		var(--wp--preset--color--primary) 2px,
		transparent 2px,
		transparent 5px
	);
}

/* H3: 左縦バー */
.wp-block-post-content h3,
.entry-content h3 {
	position: relative;
	padding-left: 0.75em;
	margin-top: 2em;
	margin-bottom: 0.8em;
	border-left: 4px solid var(--wp--preset--color--primary);
	line-height: 1.4;
}

/* H4: 下線のみ */
.wp-block-post-content h4,
.entry-content h4 {
	border-bottom: 1px solid var(--wp--preset--color--border);
	padding-bottom: 0.3em;
	margin-top: 1.8em;
	margin-bottom: 0.6em;
}

/* カテゴリ別の見出しアクセント色（body に class をつけて切替） */
.cat-learn .wp-block-post-content h2::after,
.cat-learn .entry-content h2::after {
	background: repeating-linear-gradient(-45deg, var(--wp--preset--color--cat-learn-ink), var(--wp--preset--color--cat-learn-ink) 2px, transparent 2px, transparent 5px);
}
.cat-learn .wp-block-post-content h3,
.cat-learn .entry-content h3 { border-left-color: var(--wp--preset--color--cat-learn-ink); }

.cat-read .wp-block-post-content h2::after,
.cat-read .entry-content h2::after {
	background: repeating-linear-gradient(-45deg, var(--wp--preset--color--cat-read-ink), var(--wp--preset--color--cat-read-ink) 2px, transparent 2px, transparent 5px);
}
.cat-read .wp-block-post-content h3,
.cat-read .entry-content h3 { border-left-color: var(--wp--preset--color--cat-read-ink); }

.cat-try .wp-block-post-content h2::after,
.cat-try .entry-content h2::after {
	background: repeating-linear-gradient(-45deg, var(--wp--preset--color--cat-try-ink), var(--wp--preset--color--cat-try-ink) 2px, transparent 2px, transparent 5px);
}
.cat-try .wp-block-post-content h3,
.cat-try .entry-content h3 { border-left-color: var(--wp--preset--color--cat-try-ink); }

.cat-make .wp-block-post-content h2::after,
.cat-make .entry-content h2::after {
	background: repeating-linear-gradient(-45deg, var(--wp--preset--color--cat-make-ink), var(--wp--preset--color--cat-make-ink) 2px, transparent 2px, transparent 5px);
}
.cat-make .wp-block-post-content h3,
.cat-make .entry-content h3 { border-left-color: var(--wp--preset--color--cat-make-ink); }

/* =========================================================
   投稿ページ 2カラムレイアウト
   ========================================================= */

/* 2カラムレイアウト: 本文 / 右ウィジェット */
.single-post-layout {
	display: grid;
	grid-template-columns: minmax(0, 760px) 300px;
	gap: var(--wp--preset--spacing--70);
	max-width: 1200px;
	margin: 0 auto;
	align-items: start;
}

/* 右サイドバーはスクロール追従しない（staticのまま） */
.single-post-layout > aside {
	align-self: start;
}

/* タブレット（1023px以下）: 1カラム */
@media (max-width: 1023px) {
	.single-post-layout {
		grid-template-columns: minmax(0, 1fr);
		max-width: 720px;
	}
}

/* =========================================================
   サイドバー内のブロック装飾
   ========================================================= */

.post-sidebar .sidebar-widget {
	margin-bottom: var(--wp--preset--spacing--60);
}
.post-sidebar .sidebar-widget h3 {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--base);
	font-weight: 600;
	margin: 0 0 0.8em;
	padding-bottom: 0.4em;
	border-bottom: 2px solid var(--wp--preset--color--primary);
	border-left: none !important;
	padding-left: 0 !important;
}
.post-sidebar ul { list-style: none; padding: 0; margin: 0; }
.post-sidebar ul li { margin-bottom: 0.5em; font-size: var(--wp--preset--font-size--sm); }

/* =========================================================
   目次（TOC）スタイル
   ========================================================= */

/* ============ 基本スタイル（狭い画面：記事上部にインラインの折りたたみ式） ============ */
.katatema-toc-accordion {
	margin: 0 0 var(--wp--preset--spacing--60);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 10px;
	background: var(--wp--preset--color--white);
	overflow: hidden;
	transition: box-shadow 0.2s ease;
}
.katatema-toc-accordion[open] {
	box-shadow: var(--wp--preset--shadow--soft);
}
.katatema-toc-accordion > summary {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.9em 1.2em;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	color: var(--wp--preset--color--ink);
	user-select: none;
	transition: background 0.15s ease;
}
.katatema-toc-accordion > summary::-webkit-details-marker { display: none; }
.katatema-toc-accordion > summary:hover {
	background: var(--wp--preset--color--surface);
}
.katatema-toc-accordion__label::before {
	content: "";
	display: inline-block;
	width: 4px;
	height: 1em;
	margin-right: 0.6em;
	vertical-align: -0.15em;
	background: var(--wp--preset--color--primary);
	border-radius: 2px;
}
.katatema-toc-accordion__icon {
	width: 10px;
	height: 10px;
	border-right: 2px solid var(--wp--preset--color--muted);
	border-bottom: 2px solid var(--wp--preset--color--muted);
	transform: rotate(45deg); /* 下向き（閉） */
	transition: transform 0.25s ease;
	margin-top: -4px;
}
.katatema-toc-accordion[open] .katatema-toc-accordion__icon {
	transform: rotate(-135deg); /* 上向き（開） */
	margin-top: 4px;
}
.katatema-toc-accordion > nav {
	padding: 0.4em 1.2em 1em;
	border-top: 1px solid var(--wp--preset--color--border);
}

/* ============ 広い画面：左端に固定した縦タブ＋横方向にスライド開閉 ============ */
@media (min-width: 1280px) {
	.katatema-toc-accordion {
		position: fixed;
		top: 140px;
		left: 0;
		margin: 0;
		z-index: 30;
		display: flex;
		flex-direction: row;
		align-items: stretch;
		background: transparent;
		border: none;
		border-radius: 0;
		overflow: visible;
		box-shadow: none;
		max-height: calc(100vh - 180px);
	}
	.katatema-toc-accordion[open] { box-shadow: none; }

	/* 縦タブ（常時表示） */
	.katatema-toc-accordion > summary {
		writing-mode: vertical-rl;
		text-orientation: mixed;
		padding: 1.4em 0.55em;
		background: var(--wp--preset--color--white);
		border: 1px solid var(--wp--preset--color--border);
		border-left: none;
		border-radius: 0 8px 8px 0;
		box-shadow: 2px 2px 10px rgba(44,52,48,0.06);
		letter-spacing: 0.08em;
		gap: 0.8em;
	}
	.katatema-toc-accordion[open] > summary {
		border-radius: 0;
		border-right: none;
		box-shadow: none;
	}
	/* 縦書き時：アクセントバーを横線に、矢印は左右方向に */
	.katatema-toc-accordion__label::before {
		width: 1em;
		height: 4px;
		margin: 0 0 0.6em 0;
		vertical-align: baseline;
	}
	.katatema-toc-accordion__icon {
		transform: rotate(-45deg); /* 右向き（閉→クリックで右に開く） */
		margin: 0 auto;
	}
	.katatema-toc-accordion[open] .katatema-toc-accordion__icon {
		transform: rotate(135deg); /* 左向き（開→クリックで左に閉じる） */
		margin: 0 auto;
	}

	/* 展開するパネル：1カラム目にかからないよう、ガター余白に収まるサイズに制限 */
	.katatema-toc-accordion > nav {
		width: min(220px, calc((100vw - 1200px) / 2 - 60px));
		max-height: calc(100vh - 180px);
		overflow-y: auto;
		padding: 1em 1.2em;
		background: var(--wp--preset--color--white);
		border: 1px solid var(--wp--preset--color--border);
		border-radius: 0 8px 8px 0;
		box-shadow: 4px 4px 16px rgba(44,52,48,0.08);
	}
}

/* パネルを展開してもガターが狭すぎる画面では、固定タブ自体をやめてインライン表示に戻す */
@media (min-width: 1280px) and (max-width: 1499px) {
	.katatema-toc-accordion {
		position: static;
		margin: 0 0 var(--wp--preset--spacing--60);
		display: block;
		max-height: none;
		border: 1px solid var(--wp--preset--color--border);
		border-radius: 10px;
		background: var(--wp--preset--color--white);
		overflow: hidden;
	}
	.katatema-toc-accordion > summary {
		writing-mode: horizontal-tb;
		padding: 0.9em 1.2em;
		border: none;
		border-radius: 0;
		box-shadow: none;
	}
	.katatema-toc-accordion[open] > summary {
		border-bottom: 1px solid var(--wp--preset--color--border);
	}
	.katatema-toc-accordion__label::before {
		width: 4px;
		height: 1em;
		margin: 0 0.6em 0 0;
		vertical-align: -0.15em;
	}
	.katatema-toc-accordion__icon {
		transform: rotate(45deg);
		margin-top: -4px;
	}
	.katatema-toc-accordion[open] .katatema-toc-accordion__icon {
		transform: rotate(-135deg);
		margin-top: 4px;
	}
	.katatema-toc-accordion > nav {
		width: auto;
		max-height: none;
		padding: 0.4em 1.2em 1em;
		border: none;
		border-radius: 0;
		box-shadow: none;
	}
}

/* カテゴリ別: 左のバーとアイコン色 */
.cat-learn .katatema-toc-accordion__label::before { background: var(--wp--preset--color--cat-learn-ink); }
.cat-read  .katatema-toc-accordion__label::before { background: var(--wp--preset--color--cat-read-ink); }
.cat-try   .katatema-toc-accordion__label::before { background: var(--wp--preset--color--cat-try-ink); }
.cat-make  .katatema-toc-accordion__label::before { background: var(--wp--preset--color--cat-make-ink); }

.katatema-toc {
	font-size: var(--wp--preset--font-size--sm);
	line-height: 1.6;
}
.katatema-toc ol {
	list-style: none;
	padding-left: 0;
	margin: 0;
	border-left: 1px solid var(--wp--preset--color--border);
}
.katatema-toc ol ol {
	padding-left: 0.75em;
	margin-top: 0;
	border-left: none;
}
.katatema-toc li {
	margin: 0;
	position: relative;
}
.katatema-toc li a {
	color: var(--wp--preset--color--muted);
	text-decoration: none;
	display: block;
	padding: 0.4em 0.8em;
	margin-left: -1px;
	border-left: 2px solid transparent;
	transition: all 0.15s ease;
	line-height: 1.4;
}
.katatema-toc li a:hover {
	color: var(--wp--preset--color--ink);
	background: var(--wp--preset--color--surface);
}

/* 現在地ハイライト */
.katatema-toc li.is-active > a {
	color: var(--wp--preset--color--primary);
	font-weight: 600;
	border-left-color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--surface);
}

/* カテゴリ別の現在地色 */
.cat-learn .katatema-toc li.is-active > a {
	color: var(--wp--preset--color--cat-learn-ink);
	border-left-color: var(--wp--preset--color--cat-learn-ink);
	background: var(--wp--preset--color--cat-learn-bg);
}
.cat-read .katatema-toc li.is-active > a {
	color: var(--wp--preset--color--cat-read-ink);
	border-left-color: var(--wp--preset--color--cat-read-ink);
	background: var(--wp--preset--color--cat-read-bg);
}
.cat-try .katatema-toc li.is-active > a {
	color: var(--wp--preset--color--cat-try-ink);
	border-left-color: var(--wp--preset--color--cat-try-ink);
	background: var(--wp--preset--color--cat-try-bg);
}
.cat-make .katatema-toc li.is-active > a {
	color: var(--wp--preset--color--cat-make-ink);
	border-left-color: var(--wp--preset--color--cat-make-ink);
	background: var(--wp--preset--color--cat-make-bg);
}

/* サブ項目（h3）は少し小さく */
.katatema-toc ol ol li a {
	font-size: 0.85em;
	padding-left: 1.5em;
}

/* =========================================================
   タグクラウド
   ========================================================= */

.post-sidebar .wp-block-tag-cloud a {
	display: inline-block;
	padding: 0.3em 0.7em;
	margin: 0 0.3em 0.3em 0;
	background: var(--wp--preset--color--surface);
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--xs) !important;
	color: var(--wp--preset--color--muted);
	text-decoration: none;
}
.post-sidebar .wp-block-tag-cloud a:hover {
	background: var(--wp--preset--color--primary);
	color: #fff;
}

/* =========================================================
   記事本文リンクのホバー
   ========================================================= */

.wp-block-post-content a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

/* =========================================================
   画像プレースホルダ（【要差し替え】alt）
   src="" の img を点線枠＋alt表示のプレースホルダとして見せる
   ========================================================= */

.wp-block-image img[alt^="【要差し替え】"],
.wp-block-image img[src=""] {
	display: block;
	width: 100%;
	min-height: 220px;
	max-width: 100%;
	background:
		repeating-linear-gradient(
			45deg,
			#f5efe4,
			#f5efe4 12px,
			#ece4d3 12px,
			#ece4d3 24px
		);
	border: 2px dashed #c4b89f;
	border-radius: 8px;
	box-sizing: border-box;
	padding: 32px 24px;
	color: #6b5d3f;
	font-size: 0.95rem;
	line-height: 1.7;
	text-align: center;
	/* alt テキストは破損画像として自動表示される */
}

/* NotebookLM 要約画像は少し大きめ＋ラベル */
.wp-block-image.notebooklm-summary {
	position: relative;
}
.wp-block-image.notebooklm-summary::before {
	content: "🧠 NotebookLM 要約";
	display: inline-block;
	position: absolute;
	top: 12px;
	left: 16px;
	background: var(--wp--preset--color--primary, #c66a3d);
	color: #fff;
	font-size: 0.75rem;
	padding: 4px 10px;
	border-radius: 999px;
	z-index: 1;
	font-weight: 600;
}
.wp-block-image.notebooklm-summary img[alt^="【要差し替え】"],
.wp-block-image.notebooklm-summary img[src=""] {
	min-height: 280px;
	background:
		repeating-linear-gradient(
			45deg,
			#fdf6ec,
			#fdf6ec 12px,
			#f4e8d2 12px,
			#f4e8d2 24px
		);
	border-color: var(--wp--preset--color--primary, #c66a3d);
}

/* figcaption をプレースホルダらしく */
.wp-block-image:has(img[alt^="【要差し替え】"]) figcaption {
	font-size: 0.85rem;
	color: #8a7a5c;
	font-style: italic;
	margin-top: 0.75em;
}
