/*
 * Homepage hero photos ([oak_hero_slides]).
 * - The frame's bottom-right corner sweeps round like the oak leaf in the logo,
 *   and a gold line follows that curve, drawing itself once as the page loads.
 * - Photos cross-fade with a slow settle. The progress line under the current
 *   place is a CSS animation; hero-slides.js shows the next photo when it ends,
 *   so hovering the photos holds them.
 */

.oak-slides {
	--oak-curve: clamp(4.5rem, 13vw, 12rem);
	--oak-arc-gap: clamp(0.5rem, 1vw, 0.875rem);
	--oak-slide-time: 7s;
	position: relative;
}

.oak-slides__frame {
	aspect-ratio: 4 / 3;
	background: var(--wp--preset--color--teal-dark);
	border-bottom-right-radius: var(--oak-curve);
	isolation: isolate;
	overflow: hidden;
	position: relative;
}

.oak-slides__slide {
	inset: 0;
	margin: 0;
	opacity: 0;
	position: absolute;
	transition: opacity 1.4s ease, visibility 0s linear 1.4s;
	visibility: hidden;
}

.oak-slides__slide.is-active {
	opacity: 1;
	transition: opacity 1.4s ease;
	visibility: visible;
	z-index: 1;
}

.oak-slides__slide img {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

/* The gold line around the curved corner. */
.oak-slides::after {
	border-bottom: 3px solid var(--wp--preset--color--gold);
	border-bottom-right-radius: calc(var(--oak-curve) + var(--oak-arc-gap));
	border-right: 3px solid var(--wp--preset--color--gold);
	bottom: calc(-1 * var(--oak-arc-gap));
	content: "";
	height: 58%;
	pointer-events: none;
	position: absolute;
	right: calc(-1 * var(--oak-arc-gap));
	width: 52%;
	z-index: 2;
}

/* Dots and pause: beneath the photo's curved corner, clear of the headline box.
 * The current photo's dot stretches into a line that fills while it shows. */
.oak-slides__nav {
	display: flex;
	justify-content: flex-end;
	padding: calc(var(--oak-arc-gap) + 0.75rem) calc(var(--oak-arc-gap) + 0.25rem) 0 0;
	position: absolute;
	right: 0;
	top: 100%;
	z-index: 3;
}

.oak-slides__nav[hidden] {
	display: none;
}

.oak-slides__tabs {
	align-items: center;
	display: flex;
}

.oak-slides__tab,
.oak-slides__pause {
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	min-height: 2.75rem;
	padding: 0 0.375rem;
	position: relative;
}

.oak-slides__tab:focus-visible,
.oak-slides__pause:focus-visible {
	outline: 3px solid var(--wp--preset--color--ink);
	outline-offset: 0;
}

.oak-slides__bar {
	background: rgb(15 42 45 / 0.28);
	border-radius: 999px;
	display: block;
	height: 0.625rem;
	overflow: hidden;
	transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), background-color 0.2s ease;
	width: 0.625rem;
}

.oak-slides__tab:hover .oak-slides__bar {
	background: rgb(15 42 45 / 0.5);
}

.oak-slides__tab[aria-current="true"] .oak-slides__bar {
	background: rgb(15 42 45 / 0.16);
	width: 2.75rem;
}

.oak-slides__bar::after {
	background: var(--wp--preset--color--teal);
	border-radius: inherit;
	content: "";
	display: block;
	height: 100%;
	opacity: 0;
	transform-origin: left center;
}

.oak-slides__tab[aria-current="true"] .oak-slides__bar::after {
	opacity: 1;
}

.oak-slides.is-playing .oak-slides__tab[aria-current="true"] .oak-slides__bar::after {
	animation: oak-slide-progress var(--oak-slide-time) linear both;
}

/* Hovering the photo holds it. */
.oak-slides.is-playing:has(.oak-slides__frame:hover) .oak-slides__bar::after {
	animation-play-state: paused;
}

@keyframes oak-slide-progress {
	from {
		transform: scaleX(0);
	}

	to {
		transform: scaleX(1);
	}
}

/* Pause and play: two bars, or a triangle. */
.oak-slides__pause {
	margin-left: 0.25rem;
	padding: 0;
	width: 2.75rem;
}

.oak-slides__pause::before {
	border-color: var(--wp--preset--color--ink);
	border-style: solid;
	border-width: 0 4px;
	box-sizing: border-box;
	content: "";
	height: 0.875rem;
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 0.75rem;
}

.oak-slides:not(.is-playing) .oak-slides__pause::before {
	border-color: transparent transparent transparent var(--wp--preset--color--ink);
	border-width: 0.4375rem 0 0.4375rem 0.75rem;
	height: 0;
	transform: translate(-35%, -50%);
	width: 0;
}

.oak-slides__pause:hover {
	background: var(--wp--preset--color--white);
}

/* Phones and tablets: the headline box spans the photo's foot, so the controls
 * sit at the foot of the photo, just above it, in a small white pill. */
@media (max-width: 781px) {
	.oak-slides__nav {
		bottom: 3.75rem;
		padding: 0;
		right: 0.75rem;
		top: auto;
	}

	.oak-slides__tabs {
		background: rgb(255 255 255 / 0.92);
		border-radius: 999px;
		box-shadow: 0 2px 12px rgb(15 42 45 / 0.18);
		padding: 0 0.375rem;
	}

	.oak-slides__tab {
		min-height: 2.5rem;
	}

	.oak-slides__pause {
		min-height: 2.5rem;
		width: 2.5rem;
	}

	.oak-slides::after {
		display: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.oak-slides__slide.is-active img {
		animation: oak-slide-settle calc(var(--oak-slide-time) + 1.4s) cubic-bezier(0.2, 0.6, 0.2, 1) both;
	}

	.oak-slides::after {
		animation: oak-arc-draw 1.6s cubic-bezier(0.65, 0, 0.35, 1) 0.5s both;
		-webkit-mask-image: conic-gradient(from 90deg at 0 0, #000 var(--oak-arc), transparent 0);
		mask-image: conic-gradient(from 90deg at 0 0, #000 var(--oak-arc), transparent 0);
	}
}

@property --oak-arc {
	syntax: "<angle>";
	inherits: false;
	initial-value: 90deg;
}

@keyframes oak-slide-settle {
	from {
		transform: scale(1.07);
	}

	to {
		transform: scale(1);
	}
}

@keyframes oak-arc-draw {
	from {
		--oak-arc: 0deg;
	}

	to {
		--oak-arc: 90deg;
	}
}
