/*
 * Cinematic Curtain Loader - front-end + admin stylesheet.
 *
 * Dynamic, admin-configurable values (curtain color, background
 * color, z-index, animation timing, texture URL) are supplied as CSS
 * custom properties on :root via wp_add_inline_style() from
 * includes/class-assets.php. The fallback values below only apply if
 * that inline block fails to load for any reason.
 */

:root {
	--ccl-color: #7a0c0c;
	--ccl-bg: #000000;
	--ccl-zindex: 999999;
	--ccl-duration: 1.8s;
	--ccl-fade-duration: 0.3s;
	--ccl-texture: none;
}

/* -------------------------------------------------------------- */
/* Overlay + stage                                                 */
/* -------------------------------------------------------------- */

.ccl-curtain-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: var(--ccl-zindex, 999999);
	/* Intentionally NO background color/image here. The overlay itself
	   is just a positioning container for the two opaque fabric
	   panels; it must stay fully transparent so that the instant the
	   panels start sliding apart, the real page underneath is what
	   gets revealed - never a black/solid backdrop. The `--ccl-bg`
	   custom property is still generated for advanced/custom theming
	   but is deliberately not painted across the whole viewport. */
	background: transparent;
	opacity: 1;
	overflow: hidden;
	transition: opacity var(--ccl-fade-duration, 0.3s) linear;
}

.ccl-curtain-overlay.ccl-fading {
	opacity: 0;
}

.ccl-curtain-stage {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

/* Stage spotlight glow from above, gives depth to the fabric */
.ccl-spotlight {
	position: absolute;
	top: -5%;
	left: 50%;
	width: 160%;
	height: 75%;
	transform: translateX(-50%);
	background: radial-gradient(
		ellipse at 50% 0%,
		rgba(255, 244, 214, 0.4) 0%,
		rgba(255, 224, 170, 0.16) 28%,
		rgba(255, 224, 170, 0) 62%
	);
	mix-blend-mode: screen;
	pointer-events: none;
	z-index: 5;
}

/* -------------------------------------------------------------- */
/* Panels                                                           */
/* -------------------------------------------------------------- */

.ccl-panel {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 50%;
	height: 100%;
	z-index: 2;
	/* GPU-accelerated, transform-only motion. Only `transform` is ever
	   animated - never width/left/margin - and `translate3d()` (rather
	   than translateX()) forces the browser onto its own compositor
	   layer for a smooth 60fps slide. `linear` timing means the panel
	   travels at one constant speed for the full duration, exactly
	   like a curtain pulled along a rail, with no slow-start/speed-up
	   or slow-down at either end. */
	will-change: transform;
	backface-visibility: hidden;
	transform: translate3d(0, 0, 0);
	transition: transform var(--ccl-duration, 1.8s) linear;
	box-shadow: 0 0 80px rgba(0, 0, 0, 0.65);
}

.ccl-panel-left {
	left: 0;
	transform-origin: left center;
}

.ccl-panel-right {
	right: 0;
	transform-origin: right center;
}

.ccl-open .ccl-panel-left {
	transform: translate3d(-101%, 0, 0);
}

.ccl-open .ccl-panel-right {
	transform: translate3d(101%, 0, 0);
}

/* Velvet fabric base: color + texture + fold shading, all composited
   with layered gradients so nothing ever looks like a flat color. */
.ccl-fabric {
	position: absolute;
	inset: 0;
	background-color: var(--ccl-color, #7a0c0c);
	background-image:
		var(--ccl-texture, none),
		repeating-linear-gradient(
			100deg,
			rgba(0, 0, 0, 0.38) 0%,
			rgba(0, 0, 0, 0.05) 4%,
			rgba(255, 255, 255, 0.14) 8%,
			rgba(0, 0, 0, 0.32) 13%
		),
		linear-gradient(
			to bottom,
			rgba(0, 0, 0, 0.3) 0%,
			rgba(0, 0, 0, 0) 14%,
			rgba(0, 0, 0, 0) 76%,
			rgba(0, 0, 0, 0.6) 100%
		),
		radial-gradient(ellipse at 50% -15%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 55%);
	background-size: cover, 240px 100%, 100% 100%, 100% 100%;
	background-repeat: no-repeat, repeat-x, no-repeat, no-repeat;
	background-blend-mode: normal, multiply, multiply, screen;
	box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.55);
}

/* Extra soft fold highlights/shadows layered above the base fabric */
.ccl-fold {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 20%;
	background: linear-gradient(
		90deg,
		rgba(0, 0, 0, 0) 0%,
		rgba(255, 255, 255, 0.16) 32%,
		rgba(0, 0, 0, 0.34) 62%,
		rgba(0, 0, 0, 0) 100%
	);
	filter: blur(7px);
	opacity: 0.85;
	pointer-events: none;
	z-index: 1;
}

.ccl-fold-1 { left: 8%; }
.ccl-fold-2 { left: 38%; }
.ccl-fold-3 { left: 68%; }

/* Decorative swagged top valance */
.ccl-valance {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 12%;
	background:
		repeating-radial-gradient(
			circle at 10% -20%,
			rgba(0, 0, 0, 0.35) 0 8px,
			rgba(0, 0, 0, 0) 9px 46px
		),
		linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 100%);
	box-shadow: inset 0 -24px 34px -12px rgba(0, 0, 0, 0.55);
	z-index: 3;
	pointer-events: none;
}

/* Gold center trim running down the inner seam of each panel */
.ccl-trim {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 14px;
	z-index: 4;
	background: linear-gradient(
		90deg,
		rgba(110, 82, 18, 0.4) 0%,
		#f6e27a 35%,
		#fff6d3 50%,
		#f6e27a 65%,
		rgba(110, 82, 18, 0.4) 100%
	);
}

.ccl-panel-left .ccl-trim {
	right: 0;
	box-shadow: 2px 0 16px rgba(255, 216, 122, 0.55), inset 0 0 5px rgba(255, 255, 255, 0.6);
}

.ccl-panel-right .ccl-trim {
	left: 0;
	box-shadow: -2px 0 16px rgba(255, 216, 122, 0.55), inset 0 0 5px rgba(255, 255, 255, 0.6);
}

/* Small decorative gold tieback near the base of each panel */
.ccl-tieback {
	position: absolute;
	bottom: 14%;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	z-index: 4;
	background: radial-gradient(circle at 35% 32%, #ffe9a8 0%, #caa53d 58%, #6b501a 100%);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.ccl-panel-left .ccl-tieback { right: 22px; }
.ccl-panel-right .ccl-tieback { left: 22px; }

/* Optional centered logo shown while the curtain is closed */
.ccl-logo {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 6;
	max-width: 180px;
	width: 40%;
	opacity: 1;
	transition: opacity calc(var(--ccl-duration, 1.8s) * 0.35) ease;
	pointer-events: none;
}

.ccl-logo img {
	display: block;
	width: 100%;
	height: auto;
	filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.6));
}

.ccl-open .ccl-logo {
	opacity: 0;
}

/* -------------------------------------------------------------- */
/* Scroll lock while curtain is present                            */
/* -------------------------------------------------------------- */

body.ccl-curtain-active {
	overflow: hidden !important;
	height: 100% !important;
}

/* Client-side skip state (added pre-paint by assets/js/critical.js
   for repeat visitors / disabled-mobile visitors) instantly hides the
   curtain and restores scrolling, with higher specificity so it
   always wins over the rules above regardless of source order. */
html.ccl-skip .ccl-curtain-overlay {
	display: none !important;
}

html.ccl-skip body.ccl-curtain-active {
	overflow: auto !important;
	height: auto !important;
}

/* -------------------------------------------------------------- */
/* Reduced motion: keep the reveal, drop the sliding transform       */
/* -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.ccl-panel {
		transition: opacity 0.6s ease !important;
	}

	.ccl-open .ccl-panel-left,
	.ccl-open .ccl-panel-right {
		transform: none !important;
		opacity: 0;
	}
}

/* -------------------------------------------------------------- */
/* Responsive scaling                                               */
/* -------------------------------------------------------------- */

@media (max-width: 1024px) {
	.ccl-trim { width: 10px; }
	.ccl-tieback { width: 28px; height: 28px; }
	.ccl-valance { height: 10%; }
	.ccl-logo { max-width: 140px; }
}

@media (max-width: 767px) {
	.ccl-fold { filter: blur(4px); }
	.ccl-trim { width: 8px; }
	.ccl-tieback { width: 22px; height: 22px; bottom: 10%; }
	.ccl-valance { height: 8%; }
	.ccl-logo { max-width: 110px; }
}

/* -------------------------------------------------------------- */
/* Admin settings page (Settings -> Curtain Loader)                 */
/* -------------------------------------------------------------- */

.ccl-admin-wrap .ccl-media-preview {
	margin-top: 8px;
}

.ccl-admin-wrap .ccl-media-preview img {
	display: block;
	max-width: 160px;
	height: auto;
	border: 1px solid #ccd0d4;
	background: #fff;
	padding: 4px;
	border-radius: 2px;
}

.ccl-admin-wrap .ccl-media-url {
	background: #f6f7f7;
}

.ccl-admin-wrap h2 {
	margin-top: 2em;
}
