/*
Theme Name: bhags
Template: twentytwentyfive
Description: bhags.org 用の Twenty Twenty-Five 子テーマ。方眼紙のノートに見立てたデザインと、旧記事（クラシック）の補正。
Version: 2.2.0
Text Domain: bhags
*/

:root {
	--bh-ink: #1e2a44;        /* ブルーブラックのインク */
	--bh-red: #d64541;        /* 赤鉛筆 */
	--bh-blue: #2b5c9e;       /* 本文中のリンク */
	--bh-paper: #f3f6f9;      /* 方眼紙の地 */
	--bh-grid: rgba(43, 92, 158, 0.08);
	--bh-grid-strong: rgba(43, 92, 158, 0.15);
	--bh-line: #d9e1ea;
	--bh-muted: #5f6b7a;
	--bh-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 方眼紙 ---------- */
html body {
	background-color: var(--bh-paper);
	background-image:
		linear-gradient(var(--bh-grid-strong) 1px, transparent 1px),
		linear-gradient(90deg, var(--bh-grid-strong) 1px, transparent 1px),
		linear-gradient(var(--bh-grid) 1px, transparent 1px),
		linear-gradient(90deg, var(--bh-grid) 1px, transparent 1px);
	background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
	background-position: -1px -1px;
	color: var(--bh-ink);
}

a:where(:not(.wp-element-button)):focus-visible {
	outline: 3px solid var(--bh-red);
	outline-offset: 2px;
}

/* ---------- ヘッダー ---------- */
.bh-header {
	padding: 18px clamp(16px, 4vw, 40px);
	background: rgba(255, 255, 255, 0.72);
	border-bottom: 1px solid var(--bh-line);
	backdrop-filter: blur(4px);
}

.bh-header__inner {
	gap: 12px 32px;
}

.bh-header__title {
	margin: 0;
	font-size: 1.125rem;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.bh-header__title a,
.bh-footer__title a {
	color: var(--bh-ink);
	text-decoration: none;
}

.bh-nav {
	font-size: 0.9375rem;
	font-weight: 500;
}

.bh-nav a {
	text-decoration: none;
}

.bh-nav .wp-block-navigation-item__content:hover {
	color: var(--bh-red);
}

/* ---------- トップの見出し ---------- */
.bh-masthead {
	padding: clamp(48px, 8vw, 104px) clamp(16px, 4vw, 40px) clamp(36px, 5vw, 60px);
}

.bh-masthead__title {
	position: relative;
	display: inline-block;
	margin: 0;
	font-size: clamp(3rem, 1.4rem + 6.4vw, 6.5rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.03em;
	color: var(--bh-ink);
}

/* 赤鉛筆で引いた線 */
.bh-masthead__title::after {
	content: "";
	position: absolute;
	left: 1%;
	right: -3%;
	bottom: -0.16em;
	height: 0.12em;
	background: var(--bh-red);
	border-radius: 2px;
	transform: rotate(-1.4deg);
	transform-origin: left center;
}

@media (prefers-reduced-motion: no-preference) {
	.bh-masthead__title::after {
		animation: bh-draw 0.7s cubic-bezier(0.5, 0, 0.2, 1) 0.2s both;
	}
}

@keyframes bh-draw {
	from { transform: rotate(-1.4deg) scaleX(0); }
	to { transform: rotate(-1.4deg) scaleX(1); }
}

.bh-masthead__tagline {
	margin: 1.6em 0 0;
	color: var(--bh-muted);
	font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.375rem);
	letter-spacing: 0.01em;
}

/* bhags = Big Hairy Audacious Goals の頭文字 */
.bh-initial {
	color: var(--bh-red);
	font-weight: 700;
}

/* ---------- 一覧・アーカイブの見出し ---------- */
.bh-pagehead {
	padding: clamp(40px, 6vw, 72px) clamp(16px, 4vw, 40px) clamp(24px, 3vw, 36px);
}

.bh-pagehead__title {
	margin: 0;
	font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.75rem);
	font-weight: 700;
	letter-spacing: -0.01em;
}

.bh-pagehead__desc {
	margin-top: 0.6em;
	color: var(--bh-muted);
}

/* ---------- 白い紙面 ---------- */
.bh-sheet {
	box-sizing: border-box;
	padding: clamp(22px, 5vw, 56px) !important;
	margin-bottom: clamp(48px, 7vw, 88px) !important;
	background: #fff;
	border: 1px solid var(--bh-line);
	border-radius: 4px;
	box-shadow: 0 1px 0 rgba(30, 42, 68, 0.04), 0 28px 56px -36px rgba(30, 42, 68, 0.4);
}

.bh-main {
	padding-inline: clamp(12px, 3vw, 32px);
}

/* ---------- 記事の一覧 ---------- */
.bh-entries {
	margin: 0;
	padding: 0;
	list-style: none;
}

.bh-entries > li + li {
	border-top: 1px dashed var(--bh-line);
}

.bh-entry {
	display: grid !important;
	grid-template-columns: 6.25rem minmax(0, 1fr);
	gap: 0 1.75rem;
	padding: 1.75rem 0;
}

.bh-entries > li:first-child .bh-entry {
	padding-top: 0;
}

.bh-entries > li:last-child .bh-entry {
	padding-bottom: 0;
}

.bh-entry__date {
	padding-top: 0.3em;
	color: var(--bh-red);
	font-size: 0.9375rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
}

.bh-entry__body > * {
	margin-block: 0;
}

.bh-entry__cats {
	margin-bottom: 0.3em !important;
	font-size: 0.8125rem;
	color: var(--bh-muted);
}

.bh-entry__cats a {
	color: var(--bh-muted);
	text-decoration: none;
}

.bh-entry__cats a:hover {
	color: var(--bh-red);
}

.bh-entry__title {
	margin-bottom: 0.45em !important;
	font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem);
	font-weight: 700;
	line-height: 1.45;
}

.bh-entry__title a {
	color: var(--bh-ink);
	text-decoration: none;
	background-image: linear-gradient(var(--bh-red), var(--bh-red));
	background-repeat: no-repeat;
	background-position: 0 100%;
	background-size: 0 2px;
	transition: background-size 0.2s ease;
}

.bh-entry__title a:hover {
	background-size: 100% 2px;
}

.bh-entry__excerpt {
	color: #3b4759;
	font-size: 0.9375rem;
	line-height: 1.85;
}

.bh-entry__excerpt .wp-block-post-excerpt__excerpt {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
}

.bh-entry__excerpt .wp-block-post-excerpt__more-text {
	margin: 0.5em 0 0;
}

.bh-entry__excerpt .wp-block-post-excerpt__more-link {
	color: var(--bh-red);
	font-size: 0.875rem;
	font-weight: 500;
}

.bh-pager {
	margin-top: 2.25rem !important;
	padding-top: 1.5rem;
	border-top: 1px dashed var(--bh-line);
	font-size: 0.9375rem;
}

.bh-pager a {
	color: var(--bh-ink);
}

.bh-pager .current {
	color: var(--bh-red);
	font-weight: 700;
}

/* ---------- 記事・固定ページ ---------- */
.bh-meta {
	gap: 0.4rem 1rem;
	font-size: 0.875rem;
}

.bh-meta .wp-block-post-date {
	color: var(--bh-red);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.bh-meta .wp-block-post-terms a {
	color: var(--bh-muted);
	text-decoration: none;
}

.bh-title {
	position: relative;
	margin: 0.3em 0 1.4em !important;
	font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
	font-weight: 700;
	line-height: 1.35;
}

.bh-title::after {
	content: "";
	display: block;
	width: 3rem;
	height: 4px;
	margin-top: 0.55em;
	background: var(--bh-red);
	border-radius: 2px;
}

.bh-sheet .wp-block-post-content {
	line-height: 1.95;
}

.bh-sheet .wp-block-post-content a {
	color: var(--bh-blue);
	text-underline-offset: 0.2em;
}

.bh-sheet .wp-block-post-content h1,
.bh-sheet .wp-block-post-content h2 {
	margin-top: 2.2em;
	padding-bottom: 0.35em;
	border-bottom: 1px solid var(--bh-line);
	font-size: clamp(1.3rem, 1.1rem + 0.7vw, 1.6rem);
}

.bh-sheet .wp-block-post-content h3,
.bh-sheet .wp-block-post-content h4 {
	margin-top: 1.8em;
	font-size: 1.15rem;
}

.bh-sheet .wp-block-post-content blockquote {
	margin-inline: 0;
	padding-left: 1em;
	border-left: 3px solid var(--bh-red);
	color: var(--bh-muted);
}

.bh-sheet .wp-block-post-content code,
.bh-sheet .wp-block-post-content kbd {
	padding: 0.1em 0.35em;
	background: #eef2f7;
	border-radius: 3px;
	font-family: var(--bh-mono);
	font-size: 0.875em;
}

.bh-sheet .wp-block-post-content pre {
	padding: 1em 1.2em;
	background: #f6f8fb;
	border: 1px solid var(--bh-line);
	border-radius: 4px;
	font-family: var(--bh-mono);
	font-size: 0.875rem;
	line-height: 1.7;
}

.bh-sheet .wp-block-post-content pre code {
	padding: 0;
	background: none;
}

.bh-tags {
	margin-top: 2.5em !important;
	font-size: 0.875rem;
}

.bh-tags a {
	color: var(--bh-muted);
}

.bh-postnav {
	gap: 1rem 2rem;
	margin-bottom: clamp(48px, 7vw, 88px) !important;
	font-size: 0.9375rem;
}

.bh-postnav a {
	color: var(--bh-ink);
}

/* ---------- フッター ---------- */
.bh-footer {
	padding: 28px clamp(16px, 4vw, 40px) 40px;
	background: rgba(255, 255, 255, 0.72);
	border-top: 1px solid var(--bh-line);
}

.bh-footer__inner {
	gap: 8px 32px;
	align-items: baseline;
}

.bh-footer__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
}

.bh-footer__note {
	margin: 0;
	color: var(--bh-muted);
	font-size: 0.8125rem;
}

/* ---------- 旧記事（クラシック）の補正 ---------- */
.wp-block-post-content,
.wp-block-post-title,
.wp-block-post-excerpt {
	overflow-wrap: anywhere;
}

.wp-block-post-content.is-layout-constrained > .alignleft {
	margin-left: max(0px, calc((100% - var(--wp--style--global--content-size)) / 2));
	margin-right: 1.5em;
}

.wp-block-post-content.is-layout-constrained > .alignright {
	margin-right: max(0px, calc((100% - var(--wp--style--global--content-size)) / 2));
	margin-left: 1.5em;
}

.wp-block-post-content .wp-caption {
	max-width: 100%;
	margin-bottom: 1em;
}

.wp-block-post-content .wp-caption-text {
	margin-top: 0.4em;
	font-size: 0.875rem;
	color: var(--bh-muted);
}

.wp-block-post-content img,
.wp-block-post-content iframe,
.wp-block-post-content video {
	max-width: 100%;
}

.wp-block-post-content img {
	height: auto;
}

.wp-block-post-content pre,
.wp-block-post-content table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
}

.wp-block-post-content pre {
	overflow-wrap: normal;
}

/* ---------- 言語タブ（.bh-langtabs > .bh-langtabs__panel[data-label][lang]） ---------- */
.bh-langtabs__list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 0;
	border-bottom: 1px solid var(--bh-line);
}

/* ノートのインデックスタブ */
.bh-langtabs__tab {
	position: relative;
	bottom: -1px;
	padding: 0.55em 1.25em;
	border: 1px solid var(--bh-line);
	border-radius: 6px 6px 0 0;
	background: var(--bh-paper);
	color: var(--bh-muted);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 700;
	cursor: pointer;
}

.bh-langtabs__tab:hover {
	color: var(--bh-ink);
}

.bh-langtabs__tab[aria-selected="true"] {
	border-top: 3px solid var(--bh-red);
	border-bottom-color: #fff;
	background: #fff;
	color: var(--bh-ink);
}

.bh-langtabs__tab:focus-visible {
	outline: 3px solid var(--bh-red);
	outline-offset: 2px;
}

.bh-langtabs__panel {
	padding-top: 0.5em;
}

.bh-langtabs__panel:focus-visible {
	outline: none;
}

.bh-langtabs__panel > h2:first-child {
	margin-top: 1.2em;
}

/* 行頭の日付（<li><strong>2026年3月</strong> …）は途中で折り返さない */
.bh-langtabs__panel li > strong:first-child {
	white-space: nowrap;
	margin-right: 0.25em;
}

/* About Me のプロフィール写真：方眼ノートにマスキングテープで貼った写真 */
.bh-avatar {
	position: relative;
	float: right;
	width: min(40%, 220px);
	margin: 0.6em 0.4em 1.2em 1.8em;
	padding: 8px 8px 10px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(30, 42, 68, 0.14), 0 10px 22px rgba(30, 42, 68, 0.12);
	transform: rotate(1.8deg);
}

.bh-avatar::before {
	content: "";
	position: absolute;
	top: -11px;
	left: 50%;
	width: 86px;
	height: 22px;
	margin-left: -43px;
	background: rgba(214, 69, 65, 0.26);
	box-shadow: 0 1px 1px rgba(30, 42, 68, 0.08);
	transform: rotate(-4deg);
}

.bh-avatar img {
	display: block;
	width: 100%;
	height: auto;
}

.bh-langtabs__panel > h2:not(:first-child) {
	clear: both;
}

/* JavaScript が動かないときは、3言語を見出し付きで縦に並べる */
.bh-langtabs:not(.is-ready) > .bh-langtabs__panel::before {
	content: attr(data-label);
	display: block;
	margin: 2em 0 0.5em;
	padding: 0.2em 0.8em;
	border-left: 4px solid var(--bh-red);
	font-weight: 700;
}

/* ---------- スマホ ---------- */
@media (max-width: 700px) {
	.bh-entry {
		grid-template-columns: minmax(0, 1fr);
	}

	.bh-entry__date {
		padding-top: 0;
		margin-bottom: 0.2em;
		font-size: 0.875rem;
	}

	.bh-masthead__title::after {
		bottom: -0.2em;
	}

	.bh-entry__excerpt .wp-block-post-excerpt__excerpt {
		-webkit-line-clamp: 4;
		line-clamp: 4;
	}

	.bh-avatar {
		float: none;
		width: 200px;
		margin: 1.4em auto 1.4em;
	}
}
