/* Stray wpautop <p></p> between prev control and viewport (no effect if markup is clean). */
.ic-carousel > p:empty {
	display: none;
	margin: 0;
	padding: 0;
}

.ic-carousel {
	--ic-gap: 30px;
	--ic-radius: 32px;
	--ic-gutter: 24px;
	--ic-edge: 30px;
	--ic-btn-size: 48px;
	--ic-slide-w: min(42vw, 520px);
	position: relative;
	width: 100vw;
	max-width: 100vw;
	left: 50%;
	right: 50%;
	margin-left: -50vw;
	margin-right: -50vw;
	box-sizing: border-box;
}

.ic-carousel__viewport {
	position: relative;
	z-index: 0;
	width: 100%;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
	scroll-snap-type: x mandatory;
	padding-inline: var(--ic-gutter);
	box-sizing: border-box;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.ic-carousel__viewport::-webkit-scrollbar {
	display: none;
	width: 0;
	height: 0;
}

.ic-carousel__viewport:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.ic-carousel__track {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: var(--ic-gap);
	width: max-content;
	box-sizing: border-box;
	padding-inline: var(--ic-track-pad, 0px);
}

.ic-carousel__slide {
	flex: 0 0 var(--ic-slide-w);
	width: var(--ic-slide-w);
	max-width: var(--ic-slide-w);
	box-sizing: border-box;
	scroll-snap-align: center;
	scroll-snap-stop: normal;
	background-color: #ebebeb;
	border-radius: var(--ic-radius);
	overflow: hidden;
}

.ic-carousel__frame {
	position: relative;
	display: block;
	width: 100%;
}

/* wpautop can still leave an empty <p> after the img; hide if it slips through. */
.ic-carousel__frame > p:empty {
	display: none !important;
	margin: 0 !important;
	padding: 0 !important;
	height: 0 !important;
	overflow: hidden !important;
}

.ic-carousel__img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 0;
	vertical-align: middle;
	opacity: 0;
	transition: opacity 0.35s ease;
	cursor: zoom-in;
}

.ic-carousel__caption {
	position: absolute;
	left: 30px;
	right: 30px;
	bottom: 30px;
	width: auto;
	margin: 0;
	padding: 12px 16px;
	box-sizing: border-box;
	font-family: Jost, ui-sans-serif, system-ui, sans-serif;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.35;
	color: #fff;
	text-align: center;
	text-shadow:
		0 1px 2px rgba(0, 0, 0, 0.9),
		0 0 20px rgba(0, 0, 0, 0.45);
	white-space: pre-line;
	pointer-events: none;
	border-radius: 16px;
	background-color: #ffffff1c;
	-webkit-backdrop-filter: blur(5px);
	backdrop-filter: blur(5px);
}

.ic-carousel__img.ic-carousel__img--loaded {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.ic-carousel__img {
		opacity: 1;
		transition: none;
	}
}

.ic-carousel__btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	margin: 0;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
	line-height: 0;
}

.ic-carousel__btn--prev {
	left: var(--ic-edge);
}

.ic-carousel__btn--next {
	right: var(--ic-edge);
}

.ic-carousel__btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.ic-carousel__btn-circle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--ic-btn-size);
	height: var(--ic-btn-size);
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
	color: #1a1a1a;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ic-carousel__btn:hover .ic-carousel__btn-circle {
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
}

.ic-carousel__btn:active .ic-carousel__btn-circle {
	transform: scale(0.96);
}

.ic-carousel__btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
	pointer-events: none;
}

@media (max-width: 767px) {
	.ic-carousel {
		--ic-btn-size: 40px;
		--ic-gutter: 18px;
		/* Full-bleed slide within viewport gutters; JS sets exact px. */
		--ic-slide-w: min(calc(100vw - 2 * var(--ic-gutter)), 520px);
	}

	.ic-carousel__btn-circle svg {
		width: 20px;
		height: 20px;
	}
}

/* Tap / click to enlarge */
body.ic-lightbox-open {
	overflow: hidden;
}

.ic-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
		max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
	box-sizing: border-box;
}

.ic-lightbox[hidden] {
	display: none !important;
}

.ic-lightbox__backdrop {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(0, 0, 0, 0.88);
	cursor: pointer;
}

.ic-lightbox__inner {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	box-sizing: border-box;
}

.ic-lightbox__figure {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	max-width: min(100%, calc(100vw - 48px));
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	overflow-y: auto;
	overflow-x: hidden;
	line-height: normal;
}

.ic-lightbox__img {
	display: block;
	flex-shrink: 0;
	max-width: 100%;
	max-height: min(calc(100vh - 120px), calc(100dvh - 120px));
	width: auto;
	height: auto;
	object-fit: contain;
	pointer-events: auto;
	border-radius: 8px;
}

/* No caption: let the image use more vertical space. */
.ic-lightbox__figure:has(.ic-lightbox__caption[hidden]) .ic-lightbox__img {
	max-height: min(calc(100vh - 48px), calc(100dvh - 48px));
}

.ic-lightbox__caption {
	position: static;
	flex-shrink: 0;
	width: 100%;
	max-width: 768px;
	margin: 30px auto 0;
	padding: 0 16px 12px;
	box-sizing: border-box;
	font-family: Jost, ui-sans-serif, system-ui, sans-serif;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.35;
	color: #fff;
	text-align: center;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
	white-space: pre-line;
	pointer-events: auto;
}

.ic-lightbox__caption[hidden] {
	display: none !important;
}

.ic-lightbox__close {
	position: fixed;
	top: max(12px, env(safe-area-inset-top, 0px));
	right: max(12px, env(safe-area-inset-right, 0px));
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.95);
	color: #1a1a1a;
	cursor: pointer;
	line-height: 0;
	pointer-events: auto;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.ic-lightbox__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
