/* Wrapper: flex column stacks gallery above dots; height:100% fills a parent that has
   an explicit height (e.g. a group block with height:200px); overflow:hidden clips the
   gallery when the wrapper is constrained. When the parent height is auto the wrapper
   is also auto-height and overflow:hidden has no visible effect. */
.elcwg-carousel-wrapper {
	display: flex !important;
	flex-direction: column;
	float: none !important;
	position: relative;
	width: 100%;
	min-width: 0;
	height: 100%;
	overflow: hidden;
	margin: 0 auto;
}

/* Gallery: clips the sliding track.
   flex:1 + min-height:0 let the gallery fill the wrapper's available height in
   constrained mode while still shrinking to image height in free-flowing mode.
   clip-path:inset(0) is required alongside overflow:hidden — browsers do not always
   apply overflow:hidden from a non-composited parent to GPU-composited children
   (will-change:transform on the inner promotes it to its own layer). */
.wp-block-gallery.elcwg_carousel_active {
	display: block !important;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	clip-path: inset(0);
	width: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	box-sizing: border-box;
	gap: 0 !important;
	position: relative;
}

/* Sliding track */
.elcwg-carousel-inner {
	display: flex;
	flex-wrap: nowrap;
	height: 100%;
	transition: transform 0.4s ease;
	will-change: transform;
}

/* Each slide */
.elcwg-carousel-inner .wp-block-image {
	flex: 0 0 calc(100% / var(--slides-per-view, 1)) !important;
	width: calc(100% / var(--slides-per-view, 1)) !important;
	max-width: calc(100% / var(--slides-per-view, 1)) !important;
	height: 100%;
	padding: 0 4px;
	box-sizing: border-box;
	margin: 0 !important;
	box-shadow: none !important;
	position: relative;
}

/* Image: object-fit:cover prevents distortion when height is constrained by a parent
   block with an explicit height. When parent height is auto, height:100% resolves to
   auto (CSS percentage of auto-height containing block = auto) — natural size is kept. */
.elcwg-carousel-inner .wp-block-image img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	object-fit: cover;
	box-shadow: none !important;
}

/* Caption */
.elcwg-carousel-inner .wp-block-image figcaption {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 6px 10px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 0.85em;
	line-height: 1.3;
	text-align: center;
}

/* Navigation arrows */
.elcwg-carousel-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	border: none;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	font-size: 1.25rem;
	line-height: 36px;
	text-align: center;
	cursor: pointer;
	transition: background 0.2s;
}

.elcwg-carousel-nav.prev { left: 8px; }
.elcwg-carousel-nav.next { right: 8px; }
.elcwg-carousel-nav:hover  { background: rgba(0, 0, 0, 0.75); }
.elcwg-carousel-nav:active { transform: translateY(-50%) scale(0.9); }

/* Navigation dots */
.elcwg-carousel-dots {
	display: flex;
	flex-shrink: 0;
	justify-content: center;
	gap: 6px;
	padding: 10px 0 4px;
}

.elcwg-carousel-dot {
	width: 8px;
	height: 8px;
	background: #ccc;
	border-radius: 50%;
	cursor: pointer;
	border: none;
	padding: 0;
	transition: background 0.2s, transform 0.2s;
}

.elcwg-carousel-dot.active {
	background: #555;
	transform: scale(1.25);
}

/* Mobile: force 1 column, remove slide padding */
@media (max-width: 480px) {
	.wp-block-gallery.elcwg_carousel_active {
		--slides-per-view: 1;
	}

	.elcwg-carousel-inner .wp-block-image {
		padding: 0;
	}
}

/* Paused state */
.elcwg-carousel-wrapper.paused .elcwg-carousel-nav,
.elcwg-carousel-wrapper.paused .elcwg-carousel-dot {
	opacity: 0.6;
}

/* Full-width modifier — also applied automatically when gallery has alignfull.
   !important on width/max-width/margins: WordPress block themes apply a container rule
   that sets margin-left:auto !important and max-width:80% to all direct non-alignfull
   children of a group block. Those overrides break the breakout technique without !important. */
.elcwg-carousel-wrapper.elcwg-full-width {
	width: 100vw !important;
	max-width: 100vw !important;
	margin-left: 50% !important;
	margin-right: 0 !important;
	transform: translateX(-50%);
}

/* WordPress "Wide width" alignment — let WordPress's constrained-layout container CSS
   control max-width (it carries the group's actual content/wide-size, including any
   custom value set in Block Settings). We only enforce centering here; adding an
   explicit width would override the group's custom value via higher specificity. */
.elcwg-carousel-wrapper.alignwide {
	margin-left: auto !important;
	margin-right: auto !important;
}

/* Overlay dots modifier */
.elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dots {
	position: absolute;
	bottom: 10px;
	left: 0;
	right: 0;
	padding: 0;
	z-index: 10;
}

/* Hide arrows modifier */
.elcwg-carousel-wrapper.elcwg-no-arrows .elcwg-carousel-nav { display: none; }

/* Hide dots modifier */
.elcwg-carousel-wrapper.elcwg-no-dots .elcwg-carousel-dots { display: none; }

/* Hide captions modifier */
.elcwg-carousel-wrapper.elcwg-no-captions figcaption { display: none; }

/* Loading state: hide slides until JS initializes the carousel.
   visibility:hidden on .wp-block-image keeps image placeholder space so the gallery
   keeps its height; the ::after spinner is visible above the invisible slides.
   Once JS adds .elcwg-initialized the selector stops matching and everything shows. */
.wp-block-gallery.elcwg_carousel_active:not(.elcwg-initialized) {
	min-height: 100px;
}

.wp-block-gallery.elcwg_carousel_active:not(.elcwg-initialized) .wp-block-image {
	visibility: hidden;
}

.wp-block-gallery.elcwg_carousel_active:not(.elcwg-initialized)::after {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	margin: auto;
	width: 28px;
	height: 28px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: rgba(0, 0, 0, 0.45);
	border-radius: 50%;
	animation: elcwg-spin 0.8s linear infinite;
}

@keyframes elcwg-spin {
	to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-gallery.elcwg_carousel_active:not(.elcwg-initialized)::after {
		animation: none;
	}
}
