/*
 * Pharaon Evidence Carousel
 *
 * Every selector is namespaced under .pharaon-evidence-carousel so nothing here
 * can reach an Elementor Image widget, another carousel, or the site lightbox.
 * Depth values are driven by data-dist, which the script sets from the wrapped
 * distance between an item and the active index.
 */

.pharaon-evidence-carousel {
	/*
	 * SHARPNESS CONTRACT
	 *
	 * --pec-h is the height the ACTIVE document is drawn at, and the active tier
	 * is scale(1). That is deliberate: an <img> is decoded at its LAYOUT size,
	 * so magnifying the active slide with a transform means decoding small and
	 * then interpolating a raster upward - which is what softened the document
	 * text. Depth now comes from scaling the neighbours DOWN.
	 *
	 * These heights are mirrored in pharaon_ec_active_heights() in PHP, which
	 * derives each image's `sizes` attribute from them. Change one, change both.
	 */
	/*
	 * --pec-k is the active scale the section used BEFORE this fix. Every tier
	 * scale was divided by it, so every painted decoration - shadows, radii,
	 * caption type - shrank by the same amount. Multiplying the source values
	 * by k puts them back at exactly the size they were rendering at.
	 */
	--pec-k: 1.45;
	--pec-h: 435px;          /* height of the ACTIVE document */
	--pec-stage-h: 486px;    /* unchanged from the pre-fix layout */
	--pec-s1: .7724;         /* first neighbour  (was 1.12 against a 300px base) */
	--pec-s2: .5931;         /* second           (was .86) */
	--pec-s3: .4276;         /* third            (was .62) */
	--pec-s4: .3448;         /* parked off-stage (was .5)  */
	--pec-gap-1: 250px;      /* x offset of the first neighbour */
	--pec-gap-2: 425px;
	--pec-gap-3: 560px;
	--pec-ease: cubic-bezier(.22, .68, .32, 1);
	--pec-speed: .62s;
	--pec-accent: #F5901F;

	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	overflow: hidden;          /* nothing may push the page sideways */
	outline: none;
}

.pharaon-evidence-carousel:focus-visible {
	outline: 2px solid var(--pec-accent);
	outline-offset: 6px;
	border-radius: 4px;
}

/* ---------------------------------------------------------------- stage */
.pharaon-evidence-carousel .pec-stage {
	position: relative;
	height: var(--pec-stage-h);
	perspective: 1600px;
	transform-style: preserve-3d;
}

.pharaon-evidence-carousel .pec-item {
	position: absolute;
	top: 50%;
	left: 50%;
	margin: 0;
	width: auto;
	will-change: transform, opacity;
	transition:
		transform var(--pec-speed) var(--pec-ease),
		opacity   var(--pec-speed) var(--pec-ease),
		filter    var(--pec-speed) var(--pec-ease);
	transform: translate(-50%, -50%) scale(var(--pec-s4));
	opacity: 0;
	z-index: 1;
	pointer-events: none;
}

.pharaon-evidence-carousel .pec-open {
	display: block;
	padding: 0;
	margin: 0;
	border: 0;
	background: #fff;
	border-radius: calc(4px * var(--pec-k));
	cursor: zoom-in;
	line-height: 0;
	box-shadow: 0 calc(10px * var(--pec-k)) calc(26px * var(--pec-k)) rgba(0, 0, 0, .34);
	transition: box-shadow var(--pec-speed) var(--pec-ease);
}

.pharaon-evidence-carousel .pec-open:focus-visible {
	outline: 3px solid var(--pec-accent);
	outline-offset: 3px;
}

/* the document is never cropped */
.pharaon-evidence-carousel .pec-item img {
	display: block;
	height: var(--pec-h);
	width: auto;
	max-width: none;
	object-fit: contain;
	border-radius: calc(4px * var(--pec-k));
	user-select: none;
}

/* ------------------------------------------------- depth by distance */
/* scale(1): the active document is rasterised at its true final size */
.pharaon-evidence-carousel .pec-item[data-dist="0"] {
	transform: translate(-50%, -50%);
	opacity: 1;
	filter: none;
	z-index: 100;
	pointer-events: auto;
}
.pharaon-evidence-carousel .pec-item[data-dist="0"] .pec-open {
	box-shadow:
		0 calc(38px * var(--pec-k)) calc(84px * var(--pec-k)) rgba(0, 0, 0, .62),
		0 0 calc(78px * var(--pec-k)) calc(4px * var(--pec-k)) rgba(245, 144, 31, .26),
		0 0 0 calc(1px * var(--pec-k)) rgba(255, 255, 255, .34);
}

.pharaon-evidence-carousel .pec-item[data-dist="1"] {
	transform: translate(calc(-50% + var(--pec-x)), -50%) scale(var(--pec-s1));
	opacity: .88;
	filter: brightness(.84);
	z-index: 80;
	pointer-events: auto;
}
.pharaon-evidence-carousel .pec-item[data-dist="2"] {
	transform: translate(calc(-50% + var(--pec-x)), -50%) scale(var(--pec-s2));
	opacity: .68;
	filter: brightness(.66);
	z-index: 60;
	pointer-events: auto;
}
.pharaon-evidence-carousel .pec-item[data-dist="3"] {
	transform: translate(calc(-50% + var(--pec-x)), -50%) scale(var(--pec-s3));
	opacity: .46;
	filter: brightness(.52);
	z-index: 40;
	pointer-events: none;
}
/* parked off-stage, reused by the loop */
.pharaon-evidence-carousel .pec-item[data-dist="4"] {
	transform: translate(calc(-50% + var(--pec-x)), -50%) scale(var(--pec-s4));
	opacity: 0;
	z-index: 10;
	pointer-events: none;
}

/* ---------------------------------------------------------------- caption
 * Unused since the per-document captions were removed from the markup: nothing
 * in the carousel carries .pec-caption any more. Kept rather than deleted so the
 * captions can be turned back on by restoring the one figcaption in the
 * template. The lightbox caption is a separate, class-less figcaption built in
 * pec.js and is styled under .pec-lightbox below.
 */
.pharaon-evidence-carousel .pec-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: calc(42px * var(--pec-k)) calc(14px * var(--pec-k)) calc(13px * var(--pec-k));
	font-size: calc(13px * var(--pec-k));
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: .02em;
	color: #fff;
	text-align: center;
	border-radius: 0 0 calc(4px * var(--pec-k)) calc(4px * var(--pec-k));
	background: linear-gradient(180deg, rgba(8, 13, 36, 0) 0%, rgba(8, 13, 36, .94) 46%);
	opacity: 0;
	transition: opacity var(--pec-speed) var(--pec-ease);
	pointer-events: none;
}
.pharaon-evidence-carousel .pec-item[data-dist="0"] .pec-caption { opacity: 1; }

/* ---------------------------------------------------------------- nav */
.pharaon-evidence-carousel .pec-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 54px;
	height: 54px;
	min-width: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, .32);
	background: rgba(255, 255, 255, .08);
	color: #fff;
	cursor: pointer;
	z-index: 120;
	transition: background .25s ease, border-color .25s ease, transform .25s ease;
	-webkit-backdrop-filter: blur(5px);
	backdrop-filter: blur(5px);
}
.pharaon-evidence-carousel .pec-nav svg { width: 22px; height: 22px; }
.pharaon-evidence-carousel .pec-nav:hover,
.pharaon-evidence-carousel .pec-nav:focus-visible {
	background: var(--pec-accent);
	border-color: var(--pec-accent);
}
.pharaon-evidence-carousel .pec-nav:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.pharaon-evidence-carousel .pec-prev { left: 18px; }
.pharaon-evidence-carousel .pec-next { right: 18px; }

/* ---------------------------------------------------------------- dots */
.pharaon-evidence-carousel .pec-dots {
	display: flex;
	justify-content: center;
	gap: 9px;
	margin-top: 26px;
}
.pharaon-evidence-carousel .pec-dot {
	width: 9px;
	height: 9px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .34);
	cursor: pointer;
	transition: background .25s ease, transform .25s ease;
}
.pharaon-evidence-carousel .pec-dot[aria-selected="true"] {
	background: var(--pec-accent);
	transform: scale(1.35);
}
.pharaon-evidence-carousel .pec-dot:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.pharaon-evidence-carousel .pec-live {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------- lightbox */
.pec-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4vh 4vw;
	background: rgba(5, 9, 26, .93);
	opacity: 0;
	transition: opacity .28s ease;
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
}
.pec-lightbox.is-open { opacity: 1; }
.pec-lightbox figure { margin: 0; max-width: 100%; max-height: 100%; text-align: center; }
.pec-lightbox img {
	display: block;
	max-width: 100%;
	max-height: 82vh;
	width: auto;
	height: auto;
	object-fit: contain;         /* never crop the document */
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 30px 90px rgba(0, 0, 0, .7);
}
.pec-lightbox figcaption {
	margin-top: 16px;
	color: #fff;
	font-size: 15px;
	font-weight: 500;
	letter-spacing: .02em;
}
.pec-lightbox .pec-close {
	position: absolute;
	top: 18px;
	right: 18px;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, .3);
	background: rgba(255, 255, 255, .1);
	color: #fff;
	cursor: pointer;
}
.pec-lightbox .pec-close:hover { background: var(--pec-accent, #F5901F); border-color: transparent; }
.pec-lightbox .pec-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.pec-lightbox .pec-close svg { width: 22px; height: 22px; }
body.pec-lock { overflow: hidden; }

/* ---------------------------------------------------------------- responsive */
/*
 * Each breakpoint keeps the geometry it had before the sharpness fix: --pec-h
 * is the old base height multiplied by the old active scale, and every tier
 * scale is divided by that same number. Same pixels on screen, no magnification.
 */
@media (max-width: 1439px) {
	.pharaon-evidence-carousel {
		--pec-h: 362px;      /* was 250 x 1.45 */
		--pec-stage-h: 405px;
		--pec-gap-1: 210px; --pec-gap-2: 350px; --pec-gap-3: 450px;
	}
}
@media (max-width: 1024px) {
	.pharaon-evidence-carousel {
		--pec-k: 1.32;
		--pec-h: 277px;      /* was 210 x 1.32 */
		--pec-stage-h: 340px;
		--pec-s1: .8485; --pec-s2: .6515; --pec-s3: .4697; --pec-s4: .3788;
		--pec-gap-1: 170px; --pec-gap-2: 285px; --pec-gap-3: 360px;
	}
}
@media (max-width: 767px) {
	.pharaon-evidence-carousel {
		--pec-k: 1.2;
		--pec-h: 282px;      /* was 235 x 1.2 */
		--pec-stage-h: 353px;
		--pec-s1: .9333; --pec-s2: .7167; --pec-s3: .5167; --pec-s4: .4167;
		--pec-gap-1: 150px; --pec-gap-2: 240px; --pec-gap-3: 300px;
	}
	.pharaon-evidence-carousel .pec-item[data-dist="1"] { opacity: .5; filter: brightness(.6); }
	.pharaon-evidence-carousel .pec-item[data-dist="2"],
	.pharaon-evidence-carousel .pec-item[data-dist="3"] { opacity: 0; pointer-events: none; }
	.pharaon-evidence-carousel .pec-nav { width: 46px; height: 46px; }
	.pharaon-evidence-carousel .pec-prev { left: 6px; }
	.pharaon-evidence-carousel .pec-next { right: 6px; }
	.pharaon-evidence-carousel .pec-caption {
		font-size: calc(12px * var(--pec-k));
		padding: calc(34px * var(--pec-k)) calc(10px * var(--pec-k)) calc(11px * var(--pec-k));
	}
}

/* ---------------------------------------------------------------- a11y */
@media (prefers-reduced-motion: reduce) {
	.pharaon-evidence-carousel { --pec-speed: .001s; }
	.pharaon-evidence-carousel .pec-item,
	.pharaon-evidence-carousel .pec-caption,
	.pec-lightbox { transition: none !important; }
}
