/*
 * WordPressコアブロックの共通表示。
 * 静的HTMLとfunboxブロックは既存の専用スタイルを使うため対象外にする。
 */
:root {
	--funbox-core-content-width: 70rem;
	--funbox-core-content-gutter: 1.25rem;
	--funbox-core-block-space: clamp(1.25rem, 3vw, 2.5rem);
}

/* テキストエリア由来の本文・リード文だけ、入力した改行を公開側・SSRプレビュー側とも保持する。
   ブロック全体には指定せず、ギャラリー・ボタン・ナビゲーションなどのレイアウトへ継承させない。 */
:where(
	.site-text,
	.site-s-lead,
	.site-sublead,
	.site-lead,
	.site-b-lead,
	.factory-lead,
	.section-intro__text,
	.factory-staff__description,
	.feature-media__text,
	.numbered-detail__text,
	.product-item-specs__value,
	.flow-card__text,
	.process-overview__description,
	.about-history__text,
	.about-philosophy__item-text,
	.product-item-summary__lead
) {
	white-space: pre-line;
}

:where(.page-content, .product-item-page, .works-detail-page) > .wp-block:not(.wp-block-html):not([class*="wp-block-funbox-"]) {
	box-sizing: border-box;
	width: min(calc(100% - (var(--funbox-core-content-gutter) * 2)), var(--funbox-core-content-width));
	margin-right: auto;
	margin-left: auto;
	margin-block: var(--funbox-core-block-space);
}

:where(.page-content, .product-item-page, .works-detail-page) > .wp-block-heading {
	font-size: clamp(1.5rem, 3vw, 2.25rem);
	line-height: 1.45;
}

:where(.page-content, .product-item-page, .works-detail-page) > .wp-block-paragraph,
:where(.page-content, .product-item-page, .works-detail-page) .wp-block-list,
:where(.page-content, .product-item-page, .works-detail-page) .wp-block-quote {
	line-height: 2;
}

:where(.page-content, .product-item-page, .works-detail-page) .wp-block-image img,
:where(.page-content, .product-item-page, .works-detail-page) .wp-block-cover,
:where(.page-content, .product-item-page, .works-detail-page) .wp-block-media-text {
	max-width: 100%;
}

:where(.page-content, .product-item-page, .works-detail-page) .wp-block-table {
	overflow-x: auto;
}

:where(.page-content, .product-item-page, .works-detail-page) .wp-block-table table {
	width: 100%;
	border-collapse: collapse;
}

:where(.page-content, .product-item-page, .works-detail-page) .wp-block-table th,
:where(.page-content, .product-item-page, .works-detail-page) .wp-block-table td {
	padding: .75rem;
	border: 1px solid #d9d9d9;
}

/* 製品テンプレートの末尾に配置する、追加ブロック用の領域。 */
.funbox-product-additional-blocks:empty {
	min-height: 0;
	margin: 0;
}

/*
 * 詳細ページはブロックを直接出力するため、静的ページで親要素が担っていた
 * レイアウトをここで補う。編集画面には影響させない。
 */
.product-item-page {
	display: block;
}

.product-item-page > .wp-block-funbox-section-title {
	margin: 0;
}

.product-item-page > .wp-block-funbox-gallery {
	grid-column: 1;
	grid-row: 2 / span 2;
}

.product-item-page > .wp-block-funbox-text-section,
.product-item-page > .wp-block-funbox-file-download {
	grid-column: 2;
}

.product-item-page > .wp-block-funbox-text-section {
	margin-top: .4rem;
}

.product-item-page > .wp-block-funbox-file-download {
	margin-top: 3rem;
}

.product-item-template .product-item-inquiry {
	color: inherit;
	text-decoration: none;
}

.product-item-template .product-item-inquiry + .product-item-template__title {
	margin-top: 3rem;
}

.product-item-page > .wp-block-funbox-spec-table,
.product-item-page > .wp-block-funbox-numbered-feature,
.product-item-page > .funbox-product-additional-blocks,
.product-item-page > .wp-block:not(.wp-block-funbox-section-title):not(.wp-block-funbox-gallery):not(.wp-block-funbox-text-section):not(.wp-block-funbox-file-download) {
	grid-column: 1 / -1;
}

.product-item-page > .wp-block-funbox-spec-table {
	margin-top: 11.5rem;
}

.product-item-page > .wp-block-funbox-numbered-feature + .wp-block-funbox-numbered-feature {
	margin-top: 0;
}

.product-item-page > .product-item-related {
	grid-column: 1 / -1;
	margin-top: 10rem;
}

.product-item-related .project-list {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 2rem;
	margin-top: 3rem;
}

.product-item-related .project-card__img img {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
}


.works-detail-page {
	width: min(calc(100% - 4rem), 113rem);
	margin-inline: auto;
	padding-bottom: 13rem;
}

.works-detail-page > .wp-block-funbox-section-title {
	width: 100vw;
	margin: 0 calc(50% - 50vw) 5rem;
}

.works-detail-page > .wp-block:not(.wp-block-funbox-section-title) {
	width: min(100%, 74rem);
}

.works-detail-page > .wp-block-funbox-text-section {
	margin-top: 5rem;
}

@media screen and (max-width: 599px) {
	.product-item-page {
		width: calc(100% - 4rem);
		padding: 2rem 0 7rem;
		display: block;
	}

	.product-item-page > .wp-block-funbox-section-title {
		margin-top: -2rem;
		margin-bottom: 2rem;
	}

	.product-item-page > .wp-block-funbox-text-section,
	.product-item-page > .wp-block-funbox-file-download,
	.product-item-page > .wp-block-funbox-spec-table {
		margin-top: 5rem;
	}

	.product-item-related .project-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.works-detail-page {
		width: calc(100% - 4rem);
		padding-bottom: 7rem;
	}

	.works-detail-page > .wp-block-funbox-section-title {
		margin-bottom: 3rem;
	}
}
