/*
 * OT TagPages — frontend (managed term archives only).
 * Inherits theme typography and colours; borders and tints derive from currentColor so contrast
 * follows the theme (light or dark).
 */

.ot-tagpages-header {
	margin-block: 0 var( --wp--style--block-gap, 1.5rem );
}

.ot-tagpages-title {
	margin-block: 0 0.5em;
}

.ot-tagpages-intro {
	max-width: var( --wp--style--global--content-size, 72ch );
}

.ot-tagpages-intro > :first-child {
	margin-top: 0;
}

.ot-tagpages-intro > :last-child {
	margin-bottom: 0;
}

/* Sections: "Start here" and "Related topics" */
.ot-tagpages-section {
	clear: both;
	margin-block: 2rem;
}

.ot-tagpages-section__title {
	margin-block: 0 0.35em;
	font-size: clamp( 1.15rem, 1rem + 0.6vw, 1.45rem );
}

.ot-tagpages-section__note {
	margin-block: 0 1rem;
	font-size: 0.92em;
	opacity: 0.8;
}

/* Related items live in a tinted, bordered box — visibly not part of the tag's own list. */
.ot-tagpages-related {
	padding: clamp( 1rem, 0.75rem + 1vw, 1.5rem );
	border: 1px solid color-mix( in srgb, currentColor 18%, transparent );
	border-radius: 12px;
	background: color-mix( in srgb, currentColor 4%, transparent );
}

.ot-tagpages-cards {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( min( 100%, 220px ), 1fr ) );
	gap: 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ot-tagpages-card-item {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	min-width: 0;
	margin: 0;
}

.ot-tagpages-section a.ot-tagpages-card__link {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	border: 0;
	box-shadow: none;
	color: inherit;
	text-decoration: none;
}

.ot-tagpages-card__link:hover .ot-tagpages-card__title,
.ot-tagpages-card__link:focus-visible .ot-tagpages-card__title {
	text-decoration: underline;
}

.ot-tagpages-card__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
	border-radius: 4px;
}

.ot-tagpages-card__media {
	display: block;
	overflow: hidden;
	aspect-ratio: 16 / 10;
	border-radius: 8px;
	background: color-mix( in srgb, currentColor 8%, transparent );
}

.ot-tagpages-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
}

.ot-tagpages-card__title {
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.ot-tagpages-card__meta {
	font-size: 0.85em;
	opacity: 0.75;
}

@media ( prefers-reduced-motion: no-preference ) {
	.ot-tagpages-card__media img {
		transition: transform 200ms ease;
	}

	.ot-tagpages-card__link:hover .ot-tagpages-card__media img {
		transform: scale( 1.03 );
	}
}

/* Related tags (chips) — indexable tags of the same taxonomy only. */
.ot-tagpages-section .ot-tagpages-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 0.6rem;
}

.ot-tagpages-section a.ot-tagpages-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.55em;
	min-height: 2.25rem;
	padding: 0.3em 0.45em 0.3em 0.9em;
	border: 1px solid color-mix( in srgb, currentColor 20%, transparent );
	border-radius: 999px;
	background: color-mix( in srgb, currentColor 3%, transparent );
	box-shadow: none;
	color: inherit;
	font-size: 0.95em;
	font-weight: 500;
	line-height: 1.25;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 150ms ease, border-color 150ms ease;
}

.ot-tagpages-section a.ot-tagpages-chip:hover {
	border-color: color-mix( in srgb, currentColor 40%, transparent );
	background: color-mix( in srgb, currentColor 8%, transparent );
	text-decoration: none;
}

.ot-tagpages-section a.ot-tagpages-chip:hover .ot-tagpages-chip__name {
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ot-tagpages-section a.ot-tagpages-chip:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.ot-tagpages-chip__count {
	min-width: 1.6em;
	padding: 0.15em 0.55em;
	border-radius: 999px;
	background: color-mix( in srgb, currentColor 9%, transparent );
	font-size: 0.78em;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	opacity: 0.85;
}

/* Theme-proofing: content styles (`.entry-content ul li`, `nav ul li`, custom ::before bullets, link
 * underlines) must not leak into the plugin's lists. Scoped to the plugin's own markup only. */
.ot-tagpages-section ul.ot-tagpages-chips,
.ot-tagpages-section ul.ot-tagpages-cards {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
}

.ot-tagpages-section ul.ot-tagpages-chips > li,
.ot-tagpages-section ul.ot-tagpages-cards > li {
	margin: 0 !important;
	padding: 0 !important;
	border: 0;
	background: none;
	list-style: none !important;
}

.ot-tagpages-section ul.ot-tagpages-chips > li::before,
.ot-tagpages-section ul.ot-tagpages-chips > li::after,
.ot-tagpages-section ul.ot-tagpages-cards > li::before,
.ot-tagpages-section ul.ot-tagpages-cards > li::after {
	content: none !important;
	display: none !important;
}

.ot-tagpages-section ul.ot-tagpages-chips > li::marker,
.ot-tagpages-section ul.ot-tagpages-cards > li::marker {
	content: "";
}

.ot-tagpages-section a.ot-tagpages-chip::before,
.ot-tagpages-section a.ot-tagpages-chip::after,
.ot-tagpages-section a.ot-tagpages-card__link::before,
.ot-tagpages-section a.ot-tagpages-card__link::after {
	content: none !important;
}

.ot-tagpages-section .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	clip-path: inset( 50% );
	white-space: nowrap;
}

/* Blocks: the wrapper carries alignment / margin; the section keeps its own spacing. */
.ot-tagpages-block > .ot-tagpages-section {
	margin-block: 0;
}

/* Template intro: plain, slightly muted — not an editorial intro. */
.ot-tagpages-template-intro {
	opacity: 0.85;
}

/* FAQ (native <details>, keyboard accessible without JavaScript). */
.ot-tagpages-faq__item {
	border-bottom: 1px solid color-mix( in srgb, currentColor 15%, transparent );
	padding-block: 0.75rem;
}

.ot-tagpages-faq__item summary {
	cursor: pointer;
	font-weight: 600;
	list-style-position: outside;
}

.ot-tagpages-faq__item summary:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.ot-tagpages-faq__answer {
	margin-top: 0.5rem;
}

.ot-tagpages-faq__answer > :last-child {
	margin-bottom: 0;
}
