/**
 * Scorebook gallery slider / rotator — front-end styles.
 * Loaded only on pages that contain a Gallery block with the
 * "Slider" or "Rotator" style.
 */

/* ---------- Set width and alignment (Slider settings panel) ---------- */

/* The frame takes the page's normal column (or wider, if the slider is
   wider than the text), and the slider sits inside it. */
.scorebook-slider-frame:not(.alignwide):not(.alignfull) {
	max-width: max(var(--wp--style--global--content-size, 760px), var(--scorebook-slider-width)) !important;
}

.scorebook-slider-frame > * {
	max-width: var(--scorebook-slider-width);
	margin-left: auto !important;
	margin-right: auto !important;
}

.scorebook-slider-frame.is-align-left > * {
	margin-left: 0 !important;
}

.scorebook-slider-frame.is-align-right > * {
	margin-right: 0 !important;
}

/* ---------- The gallery as a scroll-snapping track ---------- */

.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) {
	--scorebook-slide-ratio: 16 / 9;
	display: flex;
	flex-wrap: nowrap !important;
	gap: 0 !important;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--wp--preset--color--navy);
	border-bottom: 4px solid var(--wp--preset--color--red);
	margin-block: 0;
}

.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) figure.wp-block-image:not(#individual-image) {
	flex: 0 0 100%;
	width: 100%;
	max-width: 100%;
	margin: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	position: relative;
	aspect-ratio: var(--scorebook-slide-ratio);
	display: flex;
	align-items: center;
	justify-content: center;
}

.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) figure.wp-block-image:not(#individual-image) > a,
.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) figure.wp-block-image:not(#individual-image) > div {
	display: block;
	width: 100%;
	height: 100%;
}

.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) figure.wp-block-image:not(#individual-image) img {
	display: block;
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: contain;
}

/* "Crop images to fit" (on by default) fills the frame; turn it off in the
   Gallery settings to letterbox photos on navy instead. */
.wp-block-gallery.has-nested-images.is-cropped:is(.is-style-slider, .is-style-rotator) figure.wp-block-image:not(#individual-image) img {
	object-fit: cover;
}

/* Slide shape: set in the Slider settings panel (inline --scorebook-slide-ratio),
   or with one of these classes under Advanced → Additional CSS class(es). */
.wp-block-gallery.has-nested-images.scorebook-ratio-4-3 { --scorebook-slide-ratio: 4 / 3; }
.wp-block-gallery.has-nested-images.scorebook-ratio-3-2 { --scorebook-slide-ratio: 3 / 2; }
.wp-block-gallery.has-nested-images.scorebook-ratio-1-1 { --scorebook-slide-ratio: 1 / 1; }
.wp-block-gallery.has-nested-images.scorebook-ratio-21-9 { --scorebook-slide-ratio: 21 / 9; }

/* Per-photo captions sit on a navy fade across the bottom. */
.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) figure.wp-block-image figcaption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	max-height: 40%;
	overflow: auto;
	padding: 2.5rem 4.5rem 0.9rem;
	background: linear-gradient(0deg, rgba(0, 5, 58, 0.88) 0%, rgba(0, 5, 58, 0.55) 60%, rgba(0, 5, 58, 0) 100%);
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--small);
	text-align: left;
	text-shadow: none;
	backdrop-filter: none;
}

/* ---------- Enhanced slider (JavaScript running) ---------- */

.scorebook-slider {
	position: relative;
}

.scorebook-slider .wp-block-gallery {
	scrollbar-width: none;
}

.scorebook-slider .wp-block-gallery::-webkit-scrollbar {
	display: none;
}

.scorebook-slider .wp-block-gallery:focus-visible {
	outline: 3px solid var(--wp--preset--color--red);
	outline-offset: 3px;
}

.scorebook-slider__stage {
	position: relative;
}

.scorebook-slider__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 3px;
	background: var(--wp--preset--color--navy);
	color: var(--wp--preset--color--white);
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.scorebook-slider__btn svg {
	width: 1.5rem;
	height: 1.5rem;
	fill: currentColor;
}

.scorebook-slider__btn:hover,
.scorebook-slider__btn:focus-visible {
	background: var(--wp--preset--color--red);
}

.scorebook-slider__btn:focus-visible {
	outline: 3px solid var(--wp--preset--color--white);
	outline-offset: -5px;
}

.scorebook-slider__prev,
.scorebook-slider__next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	background: rgba(0, 5, 58, 0.78);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.scorebook-slider__prev {
	left: 0.75rem;
}

.scorebook-slider__next {
	right: 0.75rem;
}

.scorebook-slider.is-single .scorebook-slider__prev,
.scorebook-slider.is-single .scorebook-slider__next,
.scorebook-slider.is-single .scorebook-slider__bar {
	display: none;
}

/* Counter and pause/play bar */
.scorebook-slider__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.6rem 0;
}

.scorebook-slider__count {
	margin: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.08em;
	color: var(--wp--preset--color--heading);
}

.scorebook-slider__now {
	color: var(--wp--preset--color--accent);
}

.scorebook-slider__toggle {
	width: 2.25rem;
	height: 2.25rem;
}

.scorebook-slider__toggle svg {
	width: 1.15rem;
	height: 1.15rem;
}

/* Thumbnail strip: scrolls sideways, so any number of photos fits. */
.scorebook-slider__thumbs {
	display: flex;
	gap: 0.4rem;
	overflow-x: auto;
	padding: 0.25rem 0.1rem 0.6rem;
	scroll-snap-type: x proximity;
	scrollbar-width: thin;
	scrollbar-color: var(--wp--preset--color--line) transparent;
}

.scorebook-slider__thumb {
	flex: 0 0 auto;
	width: 5.5rem;
	aspect-ratio: 4 / 3;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 2px;
	background: var(--wp--preset--color--tint);
	cursor: pointer;
	opacity: 0.6;
	scroll-snap-align: center;
	transition: opacity 0.15s ease, border-color 0.15s ease;
}

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

.scorebook-slider__thumb:hover,
.scorebook-slider__thumb:focus-visible {
	opacity: 1;
}

.scorebook-slider__thumb[aria-current="true"] {
	opacity: 1;
	border-color: var(--wp--preset--color--red);
}

.scorebook-slider__thumb:focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 1px;
}

/* Gallery caption moves below the slider. */
.scorebook-slider__caption.blocks-gallery-caption,
.scorebook-slider .scorebook-slider__caption {
	margin: 0.25rem 0 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	text-align: left;
}

.scorebook-slider .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 600px) {
	.scorebook-slider__prev,
	.scorebook-slider__next {
		width: 2.25rem;
		height: 2.25rem;
	}
	.scorebook-slider__prev { left: 0.4rem; }
	.scorebook-slider__next { right: 0.4rem; }
	.wp-block-gallery.has-nested-images:is(.is-style-slider, .is-style-rotator) figure.wp-block-image figcaption {
		padding: 2rem 3rem 0.7rem;
	}
	.scorebook-slider__thumb {
		width: 4.25rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-gallery:is(.is-style-slider, .is-style-rotator),
	.scorebook-slider__thumbs {
		scroll-behavior: auto;
	}
}
