/**
 * Front-page slider styling.
 *
 * Single overlapping viewport: every slide stacks in the same box; the active
 * one is shown, the rest are hidden from layout and assistive tech. An
 * aspect-ratio container reserves height so unloaded images cause no layout
 * shift. Caption "over" gets a contrast scrim (the audience skews older; high
 * contrast is a stated principle). The caption feature is provisional — see
 * tasks/homepage-slider.md — and is kept cleanly separable.
 *
 * @package just2euro
 */

.j2e-slider {
	position: relative;
	margin: 0 0 2em;
}

.j2e-slider__viewport {
	position: relative;
	overflow: hidden;
}

.j2e-slider__track {
	position: relative;
	margin: 0;
	padding: 0;
	list-style: none;
}

.j2e-slider__slide {
	position: absolute;
	inset: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	opacity: 0;
	visibility: hidden;
	/* Cross-fade: opacity animates, and visibility flips to hidden only after the
	   fade completes (0s transition, 0.4s delay) so the outgoing slide stays
	   painted while the incoming one fades in — no page-background bleed-through. */
	transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

.j2e-slider__slide.is-active {
	position: relative;
	opacity: 1;
	visibility: visible;
	transition: opacity 0.4s ease, visibility 0s;
}

/* One slide (no JS): the single slide simply fills the viewport. */
.j2e-slider__track > .j2e-slider__slide:only-child {
	position: relative;
	opacity: 1;
	visibility: visible;
}

.j2e-slider__link,
.j2e-slider__image {
	display: block;
}

.j2e-slider__image {
	width: 100%;
	height: auto;
	/* Reserve height before the image loads: 3:1 letterbox hero. The active
	   slide is position:relative, so this also gives the track its height and
	   leaves room below for a "below" caption (no clipping by the viewport). */
	aspect-ratio: 3 / 1;
	object-fit: cover;
}

/* Caption: over the image, scrimmed for contrast. */
.j2e-slider__caption {
	box-sizing: border-box;
	font-size: 1.125rem;
	line-height: 1.4;
}

.j2e-slider--caption-over .j2e-slider__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 1.25em 1.5em 1em;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0) 100%);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.j2e-slider--caption-below .j2e-slider__caption {
	padding: 0.75em 0 0;
	color: inherit;
}

/* Arrows + dots only render with >1 slide. */
.j2e-slider__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease;
}

/* GeneratePress fills every <button> background and its `:focus` state
   (specificity 0,1,1) outranks the bare `.j2e-slider__arrow` (0,1,0); a mouse
   click sets `:focus` but not `:focus-visible`, so without an explicit `:focus`
   (and `:active`) rule the theme's button background bled through after a click.
   Mirrors the burger fix in header-mobile.css. */
.j2e-slider__arrow:hover,
.j2e-slider__arrow:focus,
.j2e-slider__arrow:active,
.j2e-slider__arrow:focus-visible {
	background: rgba(0, 0, 0, 0.72);
}

.j2e-slider__arrow--prev {
	left: 0.75rem;
}

.j2e-slider__arrow--next {
	right: 0.75rem;
}

.j2e-slider__dots {
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.j2e-slider__dot {
	width: 0.85rem;
	height: 0.85rem;
	padding: 0;
	border: 2px solid currentColor;
	border-radius: 50%;
	background: transparent;
	color: #555;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.j2e-slider__dot:hover {
    color: #3f4047;
    background-color: #3f4047;
}

.j2e-slider__dot.is-active {
	background: currentColor;
	color: #111;
}

/* Dots-inside variant: overlay the dots on the bottom of the image rather than
   placing them in the flow below it. Light dots with a soft shadow stay legible
   over arbitrary artwork. */
.j2e-slider--dots-inside .j2e-slider__dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0.75rem;
	margin-top: 0;
	z-index: 2;
}

.j2e-slider--dots-inside .j2e-slider__dot {
	color: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.j2e-slider--dots-inside .j2e-slider__dot:hover {
	color: #fff;
	background-color: #fff;
}

.j2e-slider--dots-inside .j2e-slider__dot.is-active {
	background: #fff;
	color: #fff;
}

.j2e-slider__autoplay {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	cursor: pointer;
}

.j2e-slider__autoplay-icon {
	display: inline-block;
	width: 0;
	height: 0;
	/* Play triangle (paused state). */
	border-style: solid;
	border-width: 0.45rem 0 0.45rem 0.7rem;
	border-color: transparent transparent transparent currentColor;
}

/* Playing state: a pause glyph (two bars). */
.j2e-slider__autoplay[aria-pressed="false"] .j2e-slider__autoplay-icon {
	width: 0.7rem;
	height: 0.9rem;
	border: 0;
	border-left: 0.22rem solid currentColor;
	border-right: 0.22rem solid currentColor;
}

/* Visible focus on every control. */
.j2e-slider__arrow:focus-visible,
.j2e-slider__dot:focus-visible,
.j2e-slider__autoplay:focus-visible {
	outline: 3px solid #1a73e8;
	outline-offset: 2px;
}

@media (max-width: 768px) {
	.j2e-slider__image {
		aspect-ratio: 16 / 9;
	}

	.j2e-slider__caption {
		font-size: 1rem;
	}

	.j2e-slider__arrow {
		width: 2.25rem;
		height: 2.25rem;
		font-size: 1.4rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	/* Match the `.is-active` specificity (0,2,0) so the cross-fade transition is
	   fully suppressed, not just the base-slide one. */
	.j2e-slider__slide,
	.j2e-slider__slide.is-active {
		transition: none;
	}
}
