/*
Theme Name: Affiliate Media
Description: O-N Era 用の軽量ブロックテーマ。
Version: 0.6.2
Requires at least: 6.9
Requires PHP: 8.2
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: affiliate-media
*/

/* Base */

html {
	scroll-behavior: smooth;
}

body {
	overflow-wrap: break-word;
}

h2[id],
h3[id] {
	scroll-margin-top: 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

.editor-styles-wrapper {
	padding-inline: 1rem;
}

/* Header */

.site-header {
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.site-header .wp-block-site-title {
	font-weight: 700;
	letter-spacing: 0.02em;
}

.site-header .wp-block-site-title a {
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

.site-header .wp-block-navigation a {
	align-items: center;
	display: inline-flex;
	font-weight: 700;
	min-height: 44px;
	padding-inline: 0.5rem;
	text-decoration: none;
}

.site-header .wp-block-navigation a:hover {
	color: var(--wp--preset--color--accent);
}

.category-pc .site-header a[href$="/category/pc/"],
.category-used-pc .site-header a[href$="/category/pc/"],
.category-pc-guide .site-header a[href$="/category/pc/"],
.category-peripherals .site-header a[href$="/category/pc/"],
.category-appliances .site-header a[href$="/category/appliances/"],
.category-smart-home .site-header a[href$="/category/appliances/"],
.category-home-appliances .site-header a[href$="/category/appliances/"],
.category-useful-goods .site-header a[href$="/category/appliances/"],
.category-ai .site-header a[href$="/category/ai/"],
.category-ai-tools .site-header a[href$="/category/ai/"],
.category-ai-productivity .site-header a[href$="/category/ai/"],
.category-ai-services .site-header a[href$="/category/ai/"] {
	box-shadow: inset 0 -2px 0 var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent);
}

.site-header .wp-block-search {
	max-width: 16rem;
}

.site-header .wp-block-search__input {
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px 0 0 6px;
	font-size: 1rem;
	min-height: 40px;
	padding-block: 0.25rem;
}

.site-header .wp-block-search__button {
	border-radius: 0 6px 6px 0;
	margin-left: 0;
	min-height: 40px;
	white-space: nowrap;
}

/* Front page */

.am-hero {
	background: var(--wp--preset--color--surface);
	border-radius: 6px;
	padding: 1rem 1.25rem;
}

.am-hero > * {
	margin-block: 0.25rem;
}

.am-hero .wp-block-site-tagline {
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.5;
}

.am-section {
	margin-top: 2.5rem;
}

.am-section > .wp-block-heading {
	margin-block: 0 1rem;
}

.am-card {
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px;
	margin: 0;
	padding: 0.75rem 1rem;
	position: relative;
}

.am-card > :first-child {
	margin-top: 0;
}

.am-card > :last-child {
	margin-bottom: 0;
}

.am-card .wp-block-heading {
	margin-bottom: 0.25rem;
}

.am-card .wp-block-heading a {
	text-decoration: none;
}

.am-card:is(p) a {
	text-decoration: none;
}

.am-card:is(p) a::after {
	content: "";
	inset: 0;
	position: absolute;
}

.am-card:is(p):hover {
	border-color: var(--wp--preset--color--accent);
}

/* Hide sections that would only show a heading when no posts exist. */
body:not(.editor-styles-wrapper) .am-hide-if-empty:not(:has(.wp-block-post)) {
	display: none;
}

/* Post cards: the title link stretches over the card, so links never nest. */

.wp-block-post-template:not(.am-list) > .wp-block-post {
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px;
	overflow: hidden;
	padding-bottom: 0.75rem;
	position: relative;
}

.wp-block-post-template:not(.am-list) > .wp-block-post:hover {
	border-color: var(--wp--preset--color--accent);
}

.wp-block-post-template:not(.am-list) > .wp-block-post:not(:has(.wp-block-post-featured-image)) {
	padding-top: 0.75rem;
}

.wp-block-post-template:not(.am-list) > .wp-block-post > :not(.wp-block-post-featured-image) {
	margin-inline: 0.875rem;
}

.wp-block-post-template .wp-block-post-featured-image {
	margin: 0;
}

.wp-block-post-template .wp-block-post-title,
.wp-block-post-template .wp-block-post-terms,
.wp-block-post-template .wp-block-post-excerpt,
.wp-block-post-template .wp-block-post-date {
	margin-block: 0.375rem;
}

.wp-block-post-template .wp-block-post-title a {
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

.wp-block-post-template .wp-block-post-title a:hover {
	color: var(--wp--preset--color--accent);
}

.wp-block-post-template:not(.am-list) .wp-block-post-title {
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	display: -webkit-box;
	font-weight: 700;
	line-height: 1.5;
	overflow: hidden;
}

.wp-block-post-template:not(.am-list) .wp-block-post-title a::after {
	content: "";
	inset: 0;
	position: absolute;
}

.wp-block-post-template:not(.am-list) .wp-block-post-title a:focus-visible {
	outline: none;
}

.wp-block-post-template:not(.am-list) .wp-block-post-title a:focus-visible::after {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: -2px;
}

.wp-block-post-template .wp-block-post-terms a {
	position: relative;
	text-decoration: none;
	z-index: 1;
}

.wp-block-post-template .wp-block-post-date {
	color: var(--wp--preset--color--muted);
}

.am-list > .wp-block-post {
	border-bottom: 1px solid var(--wp--preset--color--border);
	padding-block: 1rem;
}

/* Category page */

.am-subcategories {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	list-style: none;
	margin-block: 1rem 2rem;
	padding: 0;
}

.am-subcategories a {
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	display: block;
	font-size: var(--wp--preset--font-size--small);
	padding: 0.25rem 0.875rem;
	text-decoration: none;
}

.am-subcategories a:hover {
	border-color: var(--wp--preset--color--accent);
}

/* Article */

.wp-block-breadcrumbs {
	margin-bottom: 1.5rem;
}

.am-date-published::before {
	content: "公開日: ";
}

.am-date-modified::before {
	content: "更新日: ";
}

.am-post-dates,
.am-disclosure {
	color: var(--wp--preset--color--muted);
}

:is(.wp-block-post-content, .is-root-container) > h2.wp-block-heading {
	border-bottom: 2px solid var(--wp--preset--color--accent);
	font-size: 1.5rem;
	margin-block: 3rem 1.25rem;
	padding-bottom: 0.5rem;
}

:is(.wp-block-post-content, .is-root-container) > h3.wp-block-heading {
	border-left: 4px solid var(--wp--preset--color--accent);
	font-size: var(--wp--preset--font-size--large);
	margin-block: 2.25rem 1rem;
	padding-left: 0.75rem;
}

:is(.wp-block-post-content, .is-root-container) > :is(p, ul, ol) {
	margin-block: 1.25rem;
}

:is(.wp-block-post-content, .is-root-container) li + li {
	margin-top: 0.375rem;
}

/* Table of contents and boxes share one frame. */

.am-toc,
.am-box {
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px;
	margin-block: 1.75rem;
	padding: 1.25rem;
}

.am-box > :first-child {
	margin-top: 0;
}

.am-box > :last-child {
	margin-bottom: 0;
}

.am-toc,
.am-box--conclusion {
	background: var(--wp--preset--color--surface);
}

.am-box--conclusion {
	border-left: 4px solid var(--wp--preset--color--accent);
}

.am-box--note {
	border-left: 4px solid var(--wp--preset--color--muted);
}

.am-toc summary {
	cursor: pointer;
	font-weight: 700;
}

.am-toc ol {
	list-style: none;
	margin: 0.75rem 0 0;
	padding: 0;
}

.am-toc li + li {
	margin-top: 0.25rem;
}

.am-toc a {
	text-decoration: none;
}

.am-toc a:hover {
	text-decoration: underline;
}

.am-toc__h3 {
	font-size: var(--wp--preset--font-size--small);
	padding-left: 1rem;
}

.wp-block-columns.am-box .wp-block-column > p:first-child {
	border-bottom: 1px solid var(--wp--preset--color--border);
	margin-top: 0;
	padding-bottom: 0.5rem;
}

.wp-block-columns.am-box .wp-block-column:first-child > p:first-child {
	color: var(--wp--preset--color--accent);
}

.wp-block-columns.am-box .wp-block-column:last-child > p:first-child {
	color: var(--wp--preset--color--muted);
}

.am-product-card .wp-block-column:not(:has(*)) {
	display: none;
}

.am-product-card .wp-block-column:not(:has(*)) + .wp-block-column {
	flex: 1 1 100% !important;
}

/* Only links are affected: form submit buttons have no href either. */
a.wp-block-button__link:not([href]):not(.block-editor-rich-text__editable) {
	background: var(--wp--preset--color--border);
	color: var(--wp--preset--color--muted);
	cursor: default;
	pointer-events: none;
}

/* Comparison tables */

.am-compare {
	margin-block: 1.75rem;
	overflow-x: auto;
	padding-bottom: 0.75rem;
}

.am-compare table {
	border-collapse: separate;
	border-spacing: 0;
	font-size: var(--wp--preset--font-size--small);
	min-width: 36rem;
}

.am-compare :is(th, td) {
	background: var(--wp--preset--color--base);
	border: 0;
	border-bottom: 1px solid var(--wp--preset--color--border);
	padding: 0.625rem 0.75rem;
	text-align: left;
	vertical-align: top;
}

.am-compare thead th {
	background: var(--wp--preset--color--surface);
	border-bottom: 2px solid var(--wp--preset--color--accent);
}

.am-compare :is(th, td):first-child {
	background: var(--wp--preset--color--surface);
	box-sizing: border-box;
	font-weight: 700;
	width: 6rem;
}

.am-compare figcaption {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	left: 0;
	position: sticky;
}

@media (max-width: 880px) {
	.am-compare :is(th, td):first-child {
		border-right: 1px solid var(--wp--preset--color--border);
		left: 0;
		position: sticky;
		z-index: 1;
	}
}

@media (max-width: 359px) {
	.am-compare :is(th, td):first-child {
		padding-inline: 0.5rem;
		width: 4.5rem;
	}
}

@media (max-width: 640px), (min-width: 782px) and (max-width: 880px) {
	.am-compare::before {
		color: var(--wp--preset--color--muted);
		content: "横にスクロールできます →";
		display: block;
		font-size: var(--wp--preset--font-size--small);
		left: 0;
		margin-bottom: 0.375rem;
		position: sticky;
	}
}

/* Sidebar */

.am-side-box {
	margin-bottom: 2rem;
}

.am-side-box > .wp-block-heading {
	border-bottom: 1px solid var(--wp--preset--color--border);
	margin-block: 0 0.75rem;
	padding-bottom: 0.5rem;
}

.am-side-box ul {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
	list-style: none;
	margin: 0;
	padding: 0;
}

.am-side-box li {
	margin-block: 0.5rem;
}

.am-side-box ul ul {
	padding-left: 1rem;
}

.am-side-box a {
	text-decoration: none;
}

.am-side-box a:hover {
	text-decoration: underline;
}

body:not(.editor-styles-wrapper) .am-side-box:has(.cat-item-none),
body:not(.editor-styles-wrapper) .am-side-box:has(> .wp-block-latest-posts:empty) {
	display: none;
}

/* Footer */

.site-footer {
	border-top: 1px solid var(--wp--preset--color--border);
}

.site-footer a {
	text-decoration: none;
}

.site-footer a:hover {
	text-decoration: underline;
}

.site-footer p {
	margin-block: 0.25rem;
}

/* Small screens */

@media (max-width: 781px) {
	.site-header .wp-block-navigation__container {
		gap: 0.25rem;
	}

	.site-header .wp-block-navigation a {
		padding-inline: 0.375rem;
	}

	.site-header .wp-block-search {
		max-width: none;
		width: 100%;
	}

	:is(.wp-block-post-content, .is-root-container) > h2.wp-block-heading {
		font-size: 1.375rem;
	}
}
