/* DAPPER Gallery For CD Tours — frontend CSS
 * Namespace: .dapr-gallery / .dapr-lb
 * Heights/ratios via aspect-ratio CSS property (no padding-bottom hacks, no :has() selectors).
 */

/* ═══════════════════════════════════════════════════════════════════
   Globals
═══════════════════════════════════════════════════════════════════ */
.dapr-gallery {
	--dapr-lb-bg:            rgba(0,0,0,0.93);
	--dapr-lb-arrow:         #fff;
	--dapr-lb-arrow-bg:      rgba(255,255,255,0.15);
	--dapr-lb-counter-color: rgba(255,255,255,0.7);
	--dapr-lb-caption-color: #fff;
	position: relative;
	width: 100%;
	box-sizing: border-box;
}
.dapr-gallery *, .dapr-gallery *::before, .dapr-gallery *::after { box-sizing: border-box; }

/* JS-managed visibility. Inline display:none for hidden overflow thumbs. */
.dapr-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════
   Shared item — main img, thumbs, carousel items
═══════════════════════════════════════════════════════════════════ */
.dapr-item {
	position: relative;
	display: block;
	overflow: hidden;
	cursor: pointer;
	outline-offset: 2px;
	-webkit-tap-highlight-color: transparent;
}
.dapr-item:focus-visible { outline: 2px solid #2563eb; }

.dapr-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .45s cubic-bezier(.25,.46,.45,.94);
}

/* Hover overlay */
.dapr-img-overlay {
	position: absolute;
	inset: 0;
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s ease;
	background: rgba(0,0,0,0.12);
}
.dapr-item:hover .dapr-img-overlay { opacity: 1; }

/* Caption slide-up */
.dapr-caption {
	position: absolute;
	bottom: 0; left: 0; right: 0;
	padding: 28px 12px 10px;
	background: linear-gradient(transparent, rgba(0,0,0,0.6));
	color: #fff;
	font-size: 13px;
	line-height: 1.4;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .25s ease, transform .25s ease;
	pointer-events: none;
}
.dapr-item:hover .dapr-caption { opacity: 1; transform: translateY(0); }

/* +N overflow overlay (added by JS) */
.dapr-overflow-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	font-weight: 700;
	pointer-events: none; /* click handled by parent .dapr-item */
	background: rgba(0,0,0,0.65);
	color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   CLASSIC layout
═══════════════════════════════════════════════════════════════════ */
.dapr-classic-wrap {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* ── Main image ──────────────────────────────────────────────────── */
/* Default ratio 16:9. PHP overrides via inline style="aspect-ratio:X/Y" */
.dapr-main-img {
	width: 100%;
	aspect-ratio: 16/9;
	overflow: hidden;
	border-radius: 12px;
	display: block;
}
/* Zoom-on-hover class added by widget */
.dapr-zoom-on .dapr-main-img:hover img { transform: scale(1.06); }
/* Remove zoom override when custom height is set — Elementor handles the height */
.dapr-main-img img {
	height: 100%;
	width: 100%;
	object-fit: cover;
	display: block;
}

/* ── Thumbnail strip ─────────────────────────────────────────────── */
.dapr-strip {
	display: flex;
	flex-direction: row;
	gap: 8px;
	overflow: hidden; /* prevents layout bleed */
}
.dapr-strip .dapr-thumb {
	flex: 1 1 0;
	min-width: 0;
	height: 82px;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	transition: border-color .2s ease, transform .2s ease;
	flex-shrink: 0;
}
.dapr-strip .dapr-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.dapr-strip .dapr-thumb:hover { transform: translateY(-2px); }

/* ═══════════════════════════════════════════════════════════════════
   MOSAIC layout
═══════════════════════════════════════════════════════════════════ */
.dapr-mosaic-wrap {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	/* Prevent wrap from growing taller than its largest child */
	align-items: start;
}
.dapr-mosaic-main {
	grid-row: 1;
	grid-column: 1;
	border-radius: 12px;
	overflow: hidden;
	width: 100%;
	/* aspect-ratio set by PHP inline style, same as classic */
}
.dapr-mosaic-main img { height: 100%; width: 100%; object-fit: cover; }

.dapr-mosaic-thumbs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	align-content: start; /* don't stretch rows to fill height */
}
/* Mosaic side thumbs — 4:3 aspect ratio, overridable via thumb_height Elementor control */
.dapr-mosaic-thumbs .dapr-thumb {
	aspect-ratio: 4/3;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	transition: border-color .2s ease;
}
.dapr-mosaic-thumbs .dapr-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
/* When Elementor thumb_height control is set, it writes height: Xpx which overrides aspect-ratio (correct) */

/* ═══════════════════════════════════════════════════════════════════
   CAROUSEL layout
═══════════════════════════════════════════════════════════════════ */
.dapr-carousel-wrap {
	position: relative;
	display: flex;
	align-items: center;
}
.dapr-carousel-track {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
	flex: 1;
	padding-bottom: 4px; /* prevent box-shadow clip */
}
.dapr-carousel-track::-webkit-scrollbar { display: none; }

.dapr-carousel-item {
	scroll-snap-align: start;
	flex-shrink: 0;
	width: 200px;
	height: 140px;
	border-radius: 6px;
	overflow: hidden;
	transition: transform .2s ease;
}
.dapr-carousel-item:hover { transform: scale(1.02); }
.dapr-carousel-item img { height: 100%; width: 100%; object-fit: cover; }

.dapr-carousel-wrap:hover .dapr-carousel-item:not(:hover) { opacity: 0.9; }

/* Carousel arrows */
.dapr-arrow {
	flex-shrink: 0;
	width: 40px; height: 40px;
	border: none;
	border-radius: 50%;
	background: rgba(0,0,0,0.5);
	color: #fff;
	font-size: 16px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .2s ease, transform .15s ease;
	z-index: 2;
}
.dapr-arrow:hover { background: rgba(0,0,0,0.75); transform: scale(1.05); }
.dapr-arrow:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.dapr-arrow-prev { margin-right: 6px; }
.dapr-arrow-next { margin-left: 6px; }
.dapr-arrow[disabled] { opacity: 0.3; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════════════
   LIGHTBOX
═══════════════════════════════════════════════════════════════════ */
.dapr-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	opacity: 0;
	pointer-events: none;
	transition: opacity .22s ease;
}
.dapr-lb.dapr-lb-open { opacity: 1; pointer-events: auto; }

.dapr-lb-bg {
	position: absolute;
	inset: 0;
	background: var(--dapr-lb-bg);
	cursor: pointer;
}

.dapr-lb-close {
	position: absolute;
	top: 14px; right: 18px;
	z-index: 10;
	background: none;
	border: none;
	color: rgba(255,255,255,0.8);
	font-size: 24px;
	cursor: pointer;
	padding: 6px;
	line-height: 1;
	transition: color .2s, transform .2s;
}
.dapr-lb-close:hover { color: #fff; transform: scale(1.15); }
.dapr-lb-close:focus-visible { outline: 2px solid rgba(255,255,255,0.6); }

.dapr-lb-prev, .dapr-lb-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;
	width: 48px; height: 48px;
	border: none;
	border-radius: 50%;
	background: var(--dapr-lb-arrow-bg);
	color: var(--dapr-lb-arrow);
	font-size: 20px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .2s, transform .15s;
}
.dapr-lb-prev { left: 16px; }
.dapr-lb-next { right: 16px; }
.dapr-lb-prev:hover, .dapr-lb-next:hover {
	background: rgba(255,255,255,0.3);
	transform: translateY(-50%) scale(1.08);
}
.dapr-lb-prev:focus-visible, .dapr-lb-next:focus-visible { outline: 2px solid rgba(255,255,255,0.5); }

.dapr-lb-stage {
	position: relative;
	z-index: 5;
	flex: 1;
	width: 100%;
	max-height: calc(100dvh - 160px);
	padding: 20px 72px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.dapr-lb-img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	display: block;
	border-radius: 6px;
	opacity: 1;
	transition: opacity .18s ease, transform .25s ease;
	cursor: zoom-in;
	user-select: none;
	-webkit-user-drag: none;
	-webkit-user-select: none;
}
.dapr-lb-img.dapr-fading { opacity: 0; }

/* Zoom state */
.dapr-lb-stage.dapr-zoomed { overflow: auto; cursor: zoom-out; }
.dapr-lb-stage.dapr-zoomed .dapr-lb-img {
	transform: scale(2);
	transform-origin: center center;
	cursor: zoom-out;
	max-width: none;
	max-height: none;
}

/* Info bar */
.dapr-lb-info {
	position: relative;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 10px 16px;
	padding: 6px 16px;
	flex-shrink: 0;
	text-align: center;
}
.dapr-lb-counter {
	font-size: 13px;
	color: var(--dapr-lb-counter-color);
	white-space: nowrap;
}
.dapr-lb-caption {
	font-size: 14px;
	color: var(--dapr-lb-caption-color);
	max-width: 600px;
	line-height: 1.5;
}

/* Thumbnail strip in lightbox */
.dapr-lb-thumbs {
	position: relative;
	z-index: 5;
	display: flex;
	gap: 6px;
	padding: 6px 16px 12px;
	overflow-x: auto;
	flex-shrink: 0;
	scrollbar-width: thin;
	scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.dapr-lb-thumbs::-webkit-scrollbar { height: 4px; }
.dapr-lb-thumbs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }

.dapr-lb-thumb {
	flex-shrink: 0;
	width: 56px; height: 42px;
	border-radius: 4px;
	overflow: hidden;
	opacity: 0.5;
	cursor: pointer;
	border: 2px solid transparent;
	transition: opacity .2s, border-color .2s;
}
.dapr-lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dapr-lb-thumb:hover, .dapr-lb-thumb.dapr-lb-thumb-active { opacity: 1; border-color: rgba(255,255,255,0.75); }

/* Conditional visibility toggled by JS class on .dapr-lb */
.dapr-lb.dapr-lb-no-counter .dapr-lb-counter { display: none; }
.dapr-lb.dapr-lb-no-caption  .dapr-lb-caption  { display: none; }
.dapr-lb.dapr-lb-no-thumbs   .dapr-lb-thumbs   { display: none; }

/* Scroll lock when lightbox open */
body.dapr-lb-open { overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════════
   Editor placeholder
═══════════════════════════════════════════════════════════════════ */
.dapr-editor-empty {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 20px 16px;
	background: #f0f4ff;
	border: 1px dashed #8099d8;
	color: #3a4f9b;
	font-size: 13px;
	border-radius: 8px;
}
.dapr-editor-empty .eicon-gallery-grid { font-size: 22px; }

/* ═══════════════════════════════════════════════════════════════════
   Responsive
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
	.dapr-carousel-item { width: 160px; height: 120px; }
}

@media (max-width: 767px) {
	/* Mosaic collapses to stacked on mobile */
	.dapr-mosaic-wrap { grid-template-columns: 1fr; }
	.dapr-mosaic-main { grid-column: 1; }
	.dapr-mosaic-thumbs { grid-template-columns: repeat(3, 1fr); }

	.dapr-carousel-item { width: 130px; height: 100px; }

	/* Lightbox — compact arrows + stage */
	.dapr-lb-stage { padding: 8px 48px; }
	.dapr-lb-prev { left: 4px; }
	.dapr-lb-next { right: 4px; }
	.dapr-lb-prev, .dapr-lb-next { width: 36px; height: 36px; font-size: 14px; }
	.dapr-lb-thumb { width: 44px; height: 33px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.dapr-item img, .dapr-img-overlay, .dapr-caption,
	.dapr-lb, .dapr-lb-img, .dapr-arrow { transition: none; }
}
