/**
 * Card Stack Carousel — plugin styles
 *
 * Everything is driven by CSS custom properties so the component stays generic
 * and re-themeable. Defaults are a neutral dark card; override the --cs-*
 * variables (per instance via the `accent`/`radius` attributes, or globally in
 * your theme) to match a brand.
 */

.cardstack {
	/* Theming tokens (override these) */
	--cs-radius: 20px;
	--cs-accent: #ffffff;                       /* arrows + download link */
	--cs-card-bg: #111214;                      /* shows through while media loads */
	--cs-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55), 0 4px 12px -6px rgba(0, 0, 0, .4);
	--cs-heading-color: #f2f2f2;
	--cs-sub-color: #d7d7d9;
	--cs-overlay: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .5) 26%, rgba(0, 0, 0, .12) 55%, rgba(0, 0, 0, 0) 78%);
	--cs-caption-color: #6b6b6b;
	--cs-link-color: var(--cs-accent);
	--cs-caption-font: "neue-haas-grotesk-text", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	/* Stack geometry (room for the peeking cards + shadow), as % of width */
	--cs-inset: 2%;
	--cs-peek-x: 6%;   /* extra room on the right for the stack to peek into */
	--cs-peek-y: 3%;   /* extra room at the bottom (slight downward cascade) */

	--cs-ratio: 4/5;
	--cs-ratio-mobile: var(--cs-ratio);

	display: block;
	width: 100%;
	max-width: var(--cs-max-width, none);
	margin: 0;
	box-sizing: border-box;
}

.cardstack *,
.cardstack *::before,
.cardstack *::after {
	box-sizing: border-box;
}

.cardstack--align-center { margin-inline: auto; }
.cardstack--align-left   { margin-inline: 0 auto; }
.cardstack--align-right  { margin-inline: auto 0; }

/* ---- Stage: holds the peek padding + clips (or, with bleed, doesn't) ------ */
.cardstack__stage {
	position: relative;
	width: 100%;
	padding:
		var(--cs-inset)
		calc(var(--cs-inset) + var(--cs-peek-x))
		calc(var(--cs-inset) + var(--cs-peek-y))
		var(--cs-inset);
	/* No aspect-ratio here on purpose. The card's ratio is set on the swiper
	   below so the percentage padding can't distort it — and, critically, so it
	   renders identically in WebKit/Safari, which resolves percentage padding
	   against an aspect-ratio box differently from Blink. The stage's height
	   simply follows the swiper. */
	overflow: hidden;
}

/* Bleed mode: let the peek + the swiped-away card spill past the stage edge.
   Use this inside a narrow/centered column (e.g. a 1/2-width Avada column) so
   the stack isn't clipped at the column boundary. The trade-off is that a card
   can travel sideways beyond the column while animating; if that produces a
   horizontal scrollbar on the page, add `overflow-x: clip;` to the body or a
   wrapping section. */
.cardstack--bleed .cardstack__stage {
	overflow: visible;
}

/* The stack also has to escape the theme wrappers it sits inside. Avada
   columns/rows set `overflow: hidden`, which re-clips the cards at the column
   edge. `:has()` targets ONLY the ancestors that actually contain a bleed
   carousel, so nothing else on the page is affected. Covers Avada's column,
   inner column wrapper, and row, plus the Gutenberg column block. In a browser
   without :has() support the stack simply clips as before (graceful). */
:is(
	.fusion-layout-column,
	.fusion-column-wrapper,
	.fusion-builder-row,
	.fusion-row,
	.wp-block-column,
	.wp-block-columns
):has(.cardstack--bleed) {
	overflow: visible !important;
}

/* ---- Swiper = the active card. Its aspect-ratio defines the card shape ---- */
.cardstack__swiper {
	width: 100%;
	aspect-ratio: var(--cs-ratio);   /* the card is EXACTLY this ratio, all engines */
	overflow: visible;               /* let the stack peek out of the card area */
}

@media (max-width: 767px) {
	.cardstack__swiper { aspect-ratio: var(--cs-ratio-mobile); }
}

.cardstack__swiper .swiper-slide {
	height: 100%;
	border-radius: var(--cs-radius);
	box-shadow: var(--cs-shadow);
	overflow: hidden;
	background: var(--cs-card-bg);
}

/* Inner card wrapper — holds the media + optional text overlay */
.cardstack__card {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	overflow: hidden;
}

.cardstack__media {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	user-select: none;
	-webkit-user-drag: none;
}

/* Swiper's own darkening overlay as a card leaves the top of the stack.
   Soften it so photos don't flash black. */
.cardstack__swiper .swiper-slide-shadow {
	background: rgba(0, 0, 0, .28);
	border-radius: inherit;
}

/* ---- Text overlay (only rendered when heading/subheading provided) ------- */
.cardstack__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: clamp(18px, 6%, 40px);
	background: var(--cs-overlay);
	pointer-events: none;
}

.cardstack__heading {
	margin: 0;
	color: var(--cs-heading-color);
	font-size: clamp(1.25rem, 1rem + 1.6vw, 1.9rem);
	line-height: 1.15;
	font-weight: 600;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.cardstack__subheading {
	margin: .5em 0 0;
	color: var(--cs-sub-color);
	font-size: clamp(.9rem, .82rem + .5vw, 1.05rem);
	line-height: 1.45;
}

/* ---- Navigation arrows (desktop only; swipe carries mobile) -------------- */
.cardstack__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 30;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	border-radius: 999px;
	cursor: pointer;
	color: var(--cs-accent);
	background: rgba(0, 0, 0, .42);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	box-shadow: 0 2px 10px -2px rgba(0, 0, 0, .5);
	transition: background-color .15s ease, opacity .15s ease, transform .15s ease;
	appearance: none;
}

.cardstack__nav:hover { background: rgba(0, 0, 0, .62); }
.cardstack__nav:active { transform: translateY(-50%) scale(.94); }
.cardstack__nav:focus-visible {
	outline: 2px solid var(--cs-accent);
	outline-offset: 2px;
}
.cardstack__nav svg { width: 22px; height: 22px; }
.cardstack__nav--prev { left: 10px; }
.cardstack__nav--next { right: 10px; }

/* Swiper marks the nav disabled at the ends; with loop on it never fires,
   but keep the styling for non-looped use. */
.cardstack__nav.swiper-button-disabled { opacity: 0; pointer-events: none; }

@media (max-width: 767px), (pointer: coarse) {
	.cardstack__nav { display: none; }
}

/* ---- Caption + download ------------------------------------------------- */
.cardstack__caption {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px 14px;
	margin-top: 14px;
	padding: 0 4px;
	color: var(--cs-caption-color);
	font-family: var(--cs-caption-font);
	font-size: .875rem;
	line-height: 1.5;
	text-align: center;
}

.cardstack__download {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--cs-link-color);
	text-decoration: none;
	font-weight: 600;
	border-bottom: 1px solid transparent;
	transition: border-color .15s ease, opacity .15s ease;
}
.cardstack__download:hover { border-bottom-color: currentColor; }
.cardstack__download svg { width: 16px; height: 16px; }
.cardstack__download:focus-visible {
	outline: 2px solid var(--cs-link-color);
	outline-offset: 3px;
	border-radius: 2px;
}

/* Grab cursor on the draggable stack */
.cardstack .swiper { cursor: grab; }
.cardstack .swiper:active { cursor: grabbing; }

/* Reduced motion: Swiper still works; we just avoid autoplaying video (JS). */
