/**
 * Homepage featured animated SVG — carousel and grid.
 *
 * The SVG is inlined so the parent document can control its internal CSS
 * animations: idle holds frame 0, hover/focus plays once through to 100%
 * and holds while hovered, and leaving reverses to frame 0. Grid rows follow a
 * configurable rhythm (default 3 -> 2 -> 1 -> 2 -> 3) on a 12-column track.
 */

/* Horizontal alignment comes from the front-page shell
 * (main#main-content.domi-home-page in style.css): same 1600px max-width
 * and 25px side inset as .domi-site-header, so no side padding here —
 * adding any would double up and break navbar alignment. */
.domi-homepage-featured {
	--domi-grid-gap: 24px;
	--domi-media-ratio: 16 / 9;
	--domi-grid-hover-scale: 0.95;
	--domi-grid-hover-duration: 260ms;
	--domi-grid-hover-easing: ease;
	--domi-carousel-max-height: none;
	display: block;
	margin-block: var(--wp--preset--spacing--50, 3rem);
}

.domi-homepage-featured .domi-featured-media {
	display: block;
	position: relative;
	width: 100%;
	background: var(--wp--preset--color--surface, #f2f2f2);
	overflow: hidden;
}

/* Inline SVG fills the container and keeps its own viewBox ratio. Lazy posters
 * use a frozen static SVG image (zero animations) until upgraded on interaction. */
.domi-homepage-featured .domi-svg-inline,
.domi-homepage-featured .domi-svg-inline svg,
.domi-homepage-featured .domi-svg-lazy,
.domi-homepage-featured .domi-svg-lazy svg {
	display: block;
	width: 100%;
	height: 100%;
}

.domi-homepage-featured .domi-svg-inline svg {
	object-fit: contain;
}

.domi-homepage-featured .domi-featured-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* The custom JS player swaps idle/live SVG markup; `is-paused` is only a
 * marker class for the idle (frame-0) copy. No animation forcing here. */

/* Carousel ---------------------------------------------------------------- */

.domi-featured-carousel {
	position: relative;
}

.domi-featured-slide {
	display: none;
}

.domi-featured-slide.is-active {
	display: block;
}

.domi-featured-slide-link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.domi-featured-carousel .domi-featured-media {
	aspect-ratio: var(--domi-media-ratio);
	max-height: var(--domi-carousel-max-height);
	margin-inline: auto;
}

.domi-featured-title {
	display: block;
	margin-top: var(--wp--preset--spacing--20, 1rem);
	font-family: var(--wp--preset--font-family--inter, sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.domi-featured-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: var(--wp--preset--color--base, #fff);
	color: inherit;
	cursor: pointer;
	line-height: 1;
}

.domi-featured-arrow-prev { left: 0.5rem; }
.domi-featured-arrow-next { right: 0.5rem; }

.domi-featured-arrow:focus-visible,
.domi-featured-dot:focus-visible,
.domi-featured-card:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.domi-featured-dots {
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	margin-top: var(--wp--preset--spacing--20, 1rem);
}

.domi-featured-dot {
	width: 0.55rem;
	height: 0.55rem;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	cursor: pointer;
}

.domi-featured-dot[aria-selected="true"] {
	background: currentColor;
}

/* Grid -------------------------------------------------------------------- */

.domi-featured-grid {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	gap: var(--domi-grid-gap);
	margin-top: var(--wp--preset--spacing--50, 3rem);
}

/* Flush grids: at fractional cell positions the SVG layer can round its paint
 * inward, exposing a 1px page-background hairline between rows or columns.
 * Overlap each cell by 1px and reclaim that pixel on the container edge so the
 * outer grid stays aligned when there is no configured gap. */
.domi-featured-grid.is-flush {
	padding-right: 1px;
}

.domi-featured-grid.is-flush .domi-featured-card {
	margin-right: -1px;
	margin-bottom: -1px;
}

.domi-featured-card {
	display: block;
	grid-column: span 12;
	color: inherit;
	text-decoration: none;
	background: var(--domi-card-bg, transparent);
	/* The outer grid cell never scales — only .domi-featured-card-inner does. */
	transform: none;
}

/* Inner SVG + title block scales on hover/focus. The outer card (grid cell
 * + background) never transforms, so a custom background fills the full
 * cell with no gap flash. Using transform keeps this off the layout path,
 * so neighbouring cards never jump. */
.domi-featured-card-inner {
	display: block;
	transform-origin: center;
	transition: transform var(--domi-grid-hover-duration, 260ms) var(--domi-grid-hover-easing, ease);
	/* Keep the zoom on the compositor layer so it stays as sharp as a
	 * fractional scale allows; at rest (scale 1) it is pixel-crisp. */
	will-change: transform;
}

.domi-featured-card:hover .domi-featured-card-inner,
.domi-featured-card:focus-visible .domi-featured-card-inner {
	transform: scale(var(--domi-grid-hover-scale, 0.95));
}

.domi-featured-card .domi-featured-media {
	aspect-ratio: var(--domi-media-ratio);
	/* Same background as the card, so subpixel rounding can never show a
	 * contrasting hairline between the SVG and the title area. */
	background: var(--domi-card-bg, transparent);
}

.domi-featured-card-title {
	display: block;
	margin-top: var(--wp--preset--spacing--20, 0.75rem);
	font-family: var(--wp--preset--font-family--inter, sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--domi-card-title-color, inherit);
	text-align: var(--domi-card-title-align, left);
	padding-top: var(--domi-card-title-pad-top, 0px);
	padding-bottom: var(--domi-card-title-pad-bottom, 0px);
}

/* Wide screens: honour the configured row rhythm. */
@media (min-width: 60rem) {
	.domi-featured-grid .domi-featured-card[data-cols="3"] { grid-column: span 4; }
	.domi-featured-grid .domi-featured-card[data-cols="2"] { grid-column: span 6; }
	.domi-featured-grid .domi-featured-card[data-cols="1"] { grid-column: span 12; }
}

/* Mid screens: collapse 3 -> 2, keep single rows full width. */
@media (min-width: 40rem) and (max-width: 59.999rem) {
	.domi-featured-grid .domi-featured-card[data-cols="3"] { grid-column: span 6; }
	.domi-featured-grid .domi-featured-card[data-cols="2"] { grid-column: span 6; }
	.domi-featured-grid .domi-featured-card[data-cols="1"] { grid-column: span 12; }
}

/* Reduced motion: no animation, no scaling, controls still work. */
@media (prefers-reduced-motion: reduce) {
	.domi-homepage-featured .domi-featured-card-inner {
		transition: none;
	}

	.domi-homepage-featured .domi-featured-card:hover .domi-featured-card-inner,
	.domi-homepage-featured .domi-featured-card:focus-visible .domi-featured-card-inner {
		transform: none;
	}
}
