/*--------------------------------------------------------------
# Shared Article Content
--------------------------------------------------------------*/
.post-article__content,
.editor-styles-wrapper .is-root-container,
.editor-styles-wrapper .wp-block-post-content {
	font-family: var(
		--wp--preset--font-family--body-sans,
		"Noto Sans TC",
		"PingFang TC",
		"Microsoft JhengHei",
		sans-serif
	);
}

.post-article__content :is(p, li, blockquote, q, cite, h2, h3, h4, h5, h6),
.editor-styles-wrapper .is-root-container :is(p, li, blockquote, q, cite, h2, h3, h4, h5, h6),
.editor-styles-wrapper .wp-block-post-content :is(p, li, blockquote, q, cite, h2, h3, h4, h5, h6) {
	font-family: inherit;
}

.post-article__content :is(code, pre, pre code, kbd, samp, .wp-block-code, .wp-block-code code),
.editor-styles-wrapper .is-root-container :is(code, pre, pre code, kbd, samp, .wp-block-code, .wp-block-code code),
.editor-styles-wrapper .wp-block-post-content :is(code, pre, pre code, kbd, samp, .wp-block-code, .wp-block-code code) {
	font-family: var(
		--wp--preset--font-family--code-mono,
		"JetBrains Mono",
		ui-monospace,
		"SFMono-Regular",
		Menlo,
		Monaco,
		Consolas,
		"Liberation Mono",
		monospace
	);
}

:where(.post-article__content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper .wp-block-post-content) {
	/* Headings */
	:is(h2, h3, h4, h5, h6) {
		padding-bottom: 12px;
	}

	:is(h2, h3) {
		margin-block-start: calc(var(--space-l, var(--flow-spacing, initial)) * 1);
	}

	:is(h4, h5, h6) {
		margin-block-start: calc(var(--space-m, var(--flow-spacing, initial)) * 0.9);
	}

	h2 {
		font-size: calc(var(--h2) * 0.86);
	}

	h3 {
		font-size: calc(var(--h3) * 0.9);
	}

	h4 {
		font-size: calc(var(--h4) * 0.96);
	}

	h5 {
		font-size: calc(var(--h5) * 0.96);
	}

	h6 {
		font-size: calc(var(--h6) * 0.96);
	}

	/* General */
	p {
		margin: 1rem 0;
		line-height: 1.5;
	}

	cite {
		font-style: italic;
	}

	sup {
		font-size: 0.7em;
		line-height: 0;
		position: relative;
		vertical-align: baseline;
		top: -0.5em;
	}

	/* List */
	:is(ul, ol) {
		padding: 0;
	}

	:is(ul, ol) li {
		margin: 0 0 12px 24px;
	}

	/* Blockquote */
	:is(blockquote, q, cite) {
		quotes: none;
		font-size: calc(var(--text-m) * 0.92);
	}

	blockquote {
		display: block;
		background-color: #f4f5f7;
		border: 1px dashed #ccc;
		padding: 8px 10px;
		margin: 16px 20px;
	}

	q {
		display: inline;
	}

	q::before {
		content: open-quote;
	}

	q::after {
		content: close-quote;
	}

	/* Image */
	img {
		object-fit: cover;
		object-position: center;
	}

	.img-border img {
		border: 1px solid var(--accent-light);
		border-radius: 4px;
		padding: 2px;
		box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
		transition: all 0.3s ease;
	}

	.img-border img:hover {
		transform: scale(1.02);
		box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
	}

	.img-comparison {
		display: flex;
		justify-content: center;
		gap: 10px;
		flex-wrap: wrap;
		margin: 12px 0;
	}

	.img-comparison img {
		max-height: 320px;
		max-width: 320px;
		object-fit: contain;
		padding: 4px;
		box-sizing: border-box;
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
	}

	figure,
	figcaption,
	.wp-block-image,
	.wp-block-video {
		margin: 8px 0;
		width: 100%;
	}

	/* Table Style */
	table {
		border: 1px solid var(--accent);
		border-collapse: collapse;

		th {
			border: 1px solid var(--accent);
			font-weight: bold;
			padding: 4px 10px;
			text-align: center;
		}

		thead th {
			background-color: #d2e8ff;
		}

		thead tbody {
			background-color: #f5f1f5;
		}

		td {
			height: 50px;
			border: 1px solid var(--accent);
			text-align: left;
			padding: 4px;
		}
	}

	/* Code */
	code,
	kbd,
	samp {
		font-size: 0.95em;
	}

	pre code {
		font-size: 1.5rem;
	}

	/* Post Content Footnote */
	.wp-block-footnotes {
		margin-top: var(--space-xl);
		padding-top: var(--space-l);
		margin-bottom: var(--space-xl);
		border-top: 2px solid #e5e7eb;
		font-size: calc(var(--text-m) * 0.88);
		line-height: 1.6;
		color: #6b7280;

		li {
			margin-bottom: 0.8rem;
			padding-left: 0.5rem;
		}

		li::marker {
			color: #3b82f6;
			font-weight: 600;
		}

		a {
			color: #3b82f6;
			text-decoration: none;
			border-bottom: 1px dotted #3b82f6;
			transition: all 0.2s ease;
		}

		a:hover {
			color: #1d4ed8;
			border-bottom-color: #1d4ed8;
		}

		a[href^="#"]:last-child {
			font-size: calc(var(--text-m) * 0.88);
			margin-left: 0.5rem;
			padding: 0.2rem 0.4rem;
			background-color: #f3f4f6;
			border-radius: 0.25rem;
			border: none;
		}

		a[href^="#"]:last-child:hover {
			background-color: #e5e7eb;
		}
	}

	/* External references */
	.wp-block-group.ext-reference {
		display: flex;
		background: var(--accent-ultra-light);
		margin-top: var(--space-xl);
		border-radius: 4px;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
	}

	.ext-reference ul {
		padding: 0 !important;
	}

	.ext-reference ul li {
		font-size: calc(var(--text-m) * 0.9);
	}

	.ext-reference h3 {
		margin-top: 0;
		font-size: calc(var(--h3) * 0.96);
		border-bottom: 1px solid #ddd;
		padding-bottom: 10px;
	}

	.ext-reference h3::before {
		content: "※";
		left: 0;
		color: var(--accent-dark);
		letter-spacing: 0.4em;
	}
}

@media (max-width: 768px) {
	:where(.post-article__content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper .wp-block-post-content) {
		.img-comparison img {
			max-height: 260px;
			max-width: 260px;
		}

		.wp-block-footnotes {
			margin-top: 2rem;
			padding: 1.5rem 1rem;
			font-size: calc(var(--text-m) * 0.7);
		}

		.wp-block-footnotes::before {
			font-size: calc(var(--text-m) * 0.8);
			margin-bottom: 1rem;
		}

		.wp-block-footnotes li {
			padding: 0.5rem;
			margin-bottom: 0.75rem;
		}
	}
}

@media (max-width: 480px) {
	:where(.post-article__content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper .wp-block-post-content) {
		.img-comparison {
			flex-direction: column;
		}

		.img-comparison img {
			max-height: 240px;
			max-width: 240px;
		}
	}
}
