/* =============================================================================
   gallery.css — canonical PDP gallery component (v1.60.0)
   =============================================================================
   Plugin-owned. Enqueued by Frontend\PdpAssets only on
   InventoryController::getRoute() === 'single'. Markup is emitted by
   templates/partials/single-gallery.php.

   Scoping: every selector is rooted at .fule-gallery (or .fule-gallery-toast /
   .fule-gallery-lightbox for body-level chrome). Nothing escapes that scope,
   so the gallery is theme-portable.

   Token portability: theme CSS custom properties are referenced with literal
   fallbacks (var(--navy, #0d2745)) so the gallery still renders coherently on
   a theme that doesn't define the dealer-fule tokens.
   ============================================================================= */

/* ----------------------------------------------------------------------------
   1. Outer wrapper + empty state
   ---------------------------------------------------------------------------- */

.fule-gallery {
	position: relative;
}

.fule-gallery--empty .fule-gallery__placeholder {
	width: 100%;
	aspect-ratio: 4 / 3;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #c5d3e3 0%, #8fa6c0 100%);
	color: rgba(255, 255, 255, 0.85);
	font-size: 14px;
	border-radius: 12px;
}

/* ----------------------------------------------------------------------------
   2. Lead (hero) image + overlay chrome
   ---------------------------------------------------------------------------- */

.fule-gallery__lead {
	position: relative;
	aspect-ratio: 4 / 3;
	background: linear-gradient(135deg, #c5d3e3 0%, #8fa6c0 100%);
	border-radius: 12px;
	overflow: hidden;
}

.fule-gallery__main-link {
	display: block;
	width: 100%;
	height: 100%;
}

.fule-gallery__main-image,
.fule-gallery__lead img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ----- Counter pill (top-left of lead) ----- */
.fule-gallery__counter {
	position: absolute;
	top: 16px;
	left: 16px;
	background: rgba(13, 39, 69, 0.85);
	color: #fff;
	font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
	font-size: 11px;
	padding: 6px 10px;
	border-radius: 4px;
	letter-spacing: 0.05em;
	backdrop-filter: blur(8px);
	pointer-events: none;
	z-index: 2;
}

/* ----- Actions overlay (top-right of lead) — save + share ----- */
.fule-gallery__actions {
	position: absolute;
	top: 16px;
	right: 16px;
	display: flex;
	gap: 8px;
	z-index: 2;
}

.fule-gallery__icon-btn {
	/* v1.60.1: brand cream surface. Hardcoded literal #f2ebdb (no var) with
	   !important on the background — defensive against any high-specificity
	   theme/Elementor rule painting <button> backgrounds. The icon color is
	   forced navy with !important for the same reason. */
	flex: 0 0 40px !important;
	width: 40px !important;
	height: 40px !important;
	padding: 0 !important;
	box-sizing: border-box !important;
	border-radius: 50% !important;
	background: #f2ebdb !important;
	display: grid !important;
	place-items: center !important;
	transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, color 0.15s ease !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18) !important;
	border: none !important;
	cursor: pointer !important;
	color: #0d2745 !important;
}
.fule-gallery__icon-btn:hover {
	transform: scale(1.05) !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22) !important;
	background: #f2ebdb !important;
}
.fule-gallery__icon-btn:disabled {
	opacity: 0.6;
	cursor: wait;
	transform: none !important;
}
/* Force icon visibility: width/height/fill all !important so no theme or
   Elementor "svg{width:1em}" / "svg{fill:none}" rule can shrink-to-zero or
   blank the glyph. SVG paths use fill="currentColor" inline; this anchors
   the cascade explicitly to navy. */
.fule-gallery__icon-btn svg {
	width: 18px !important;
	height: 18px !important;
	color: #0d2745 !important;
	fill: currentColor !important;
	stroke: currentColor !important;
	display: block !important;
}
.fule-gallery__icon-btn svg path,
.fule-gallery__icon-btn svg polyline,
.fule-gallery__icon-btn svg line,
.fule-gallery__icon-btn svg rect,
.fule-gallery__icon-btn svg circle {
	fill: currentColor !important;
}

/* Saved state — heart glyph turns red; button background stays cream
   (the idle look) so the visual matches dealer-fule's listing card
   (.dealer-fule-listing .icon-btn.is-saved). The svg's color is
   overridden directly because the armored idle rule
   `.fule-gallery__icon-btn svg { color: #0d2745 !important }` above
   would otherwise win — same-element !important beats inherited color
   from the button. Re-declaring on the same svg selector (with the
   active class on the button parent for added specificity) wins, then
   `fill: currentColor` on the path rules above carries the red into
   the heart shape. Color #d64545 is the canonical saved-heart red;
   dealer-fule v1.8.x's inventory.css uses the same literal at
   .dealer-fule-listing .icon-btn.is-saved. Keep them in sync. */
.fule-gallery__icon-btn[data-saved="1"] svg,
.fule-gallery__icon-btn.is-active svg {
	color: #d64545 !important;
}
.fule-gallery__icon-btn[data-saved="1"]:hover svg,
.fule-gallery__icon-btn.is-active:hover svg {
	color: #c03a3a !important;
}

/* ----- Prev / Next arrows on the main image (vertically centered) ----- */
.fule-gallery__nav {
	position: absolute !important;
	top: 50% !important;
	transform: translateY(-50%) !important;
	width: 44px !important;
	height: 44px !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: #f2ebdb !important;
	color: #0d2745 !important;
	display: grid !important;
	place-items: center !important;
	cursor: pointer !important;
	transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
	z-index: 3 !important;
}
.fule-gallery__nav:hover {
	background: #f2ebdb !important;
	transform: translateY(-50%) scale(1.05) !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}
.fule-gallery__nav--prev { left: 12px !important; }
.fule-gallery__nav--next { right: 12px !important; }
.fule-gallery__nav svg {
	width: 22px !important;
	height: 22px !important;
	color: #0d2745 !important;
	fill: none !important;
	stroke: currentColor !important;
	display: block !important;
}
.fule-gallery__nav svg polyline,
.fule-gallery__nav svg path {
	stroke: currentColor !important;
	fill: none !important;
}

/* ----- "View all N" pill (bottom-right of lead) ----- */
.fule-gallery__view-all {
	/* v1.60.1: cream surface + navy text, matching save/share buttons.
	   No yellow/dark-navy anywhere. !important guards against theme rules. */
	position: absolute !important;
	bottom: 16px !important;
	right: 16px !important;
	background: #f2ebdb !important;
	color: #0d2745 !important;
	border: 0 !important;
	padding: 9px 16px !important;
	font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace) !important;
	font-size: 11px !important;
	font-weight: 600 !important;
	letter-spacing: 0.05em !important;
	border-radius: 999px !important;
	cursor: pointer !important;
	transition: transform 0.15s ease, box-shadow 0.15s ease !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
	z-index: 3 !important;
}
.fule-gallery__view-all:hover {
	background: #f2ebdb !important;
	color: #0d2745 !important;
	transform: scale(1.03) !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* ----------------------------------------------------------------------------
   3. Thumb strip — horizontal scroll-snap row (no photo cap)
   ---------------------------------------------------------------------------- */

.fule-gallery__strip {
	display: flex;
	gap: 8px;
	margin-top: 12px;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: 8px;
	scrollbar-width: thin;
	scrollbar-color: rgba(13, 39, 69, 0.35) transparent;
	padding-bottom: 4px;
}
.fule-gallery__strip::-webkit-scrollbar {
	height: 6px;
}
.fule-gallery__strip::-webkit-scrollbar-thumb {
	background: rgba(13, 39, 69, 0.35);
	border-radius: 3px;
}
.fule-gallery__strip::-webkit-scrollbar-track {
	background: transparent;
}

.fule-gallery__thumb {
	/* v1.60.1: transparent shell with rounded corners. The image fills
	   edge-to-edge via object-fit:cover; overflow:hidden clips its corners
	   to the parent's border-radius so the rounded edges are real, not
	   just on the tile boundary.
	   M0 responsive: a single flex-basis (not min-width/max-width armor)
	   per breakpoint — the old min-width: 88px !important pushed the
	   strip's intrinsic min-content above the viewport on mobile, which
	   propagated through the .pdp-hero grid track (1fr defaults to
	   minmax(auto, 1fr) → grows to fit children's min-content) and
	   triggered iOS Safari's scale-to-fit on a 390px viewport. Fixed
	   alongside the grid track in dealer-fule v1.8.x's inventory-pdp.css
	   (.pdp-hero @ <=960px → minmax(0, 1fr)). Mobile override below uses
	   !important so it actually wins over this base rule. */
	flex: 0 0 110px !important;
	aspect-ratio: 4 / 3 !important;
	background: transparent !important;
	background-color: transparent !important;
	border-radius: 10px !important;
	cursor: pointer !important;
	overflow: hidden !important;
	position: relative !important;
	transition: opacity 0.15s ease, border-color 0.15s ease !important;
	border: 2px solid transparent !important;
	padding: 0 !important;
	scroll-snap-align: start !important;
	box-shadow: none !important;
}
.fule-gallery__thumb img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	display: block !important;
	border-radius: 8px !important;
}
.fule-gallery__thumb:hover { opacity: 0.85 !important; }
.fule-gallery__thumb.is-active {
	border-color: #0d2745 !important;
}

/* On narrow viewports each thumb shrinks to 88px so 4-ish fit per scroll
   page without the strip blowing past the column. !important is required
   because the base rule above uses !important — without it the override
   loses regardless of source order. */
@media (max-width: 720px) {
	.fule-gallery__thumb {
		flex: 0 0 88px !important;
	}
}

/* ----------------------------------------------------------------------------
   4. Toast — bottom-center status pill (gallery-local copy)
   ---------------------------------------------------------------------------- */

.fule-gallery-toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%) translateY(20px);
	background: var(--navy, #0d2745);
	color: #fff;
	padding: 12px 20px;
	border-radius: 6px;
	font-size: 14px;
	font-family: var(--sans, system-ui, -apple-system, sans-serif);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
	z-index: 10000;
	max-width: 90vw;
	text-align: center;
}
.fule-gallery-toast.is-visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

/* ----------------------------------------------------------------------------
   5. Lightbox — full-screen overlay, grid + single modes
   ---------------------------------------------------------------------------- */

.fule-gallery__lightbox {
	/* v1.60.1: z-index above the theme's --z-toast (2000) and any
	   reasonable Elementor sticky-header layer (typical max ~10000).
	   The JS portals this element to <body> on open, escaping any
	   transformed/filtered ancestor that would otherwise trap
	   position:fixed (Elementor sticky wraps in transform:translate). */
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.92);
	z-index: 100000;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.fule-gallery__lightbox[hidden] {
	display: none;
}

.fule-gallery-lightbox__close {
	position: absolute !important;
	top: 20px !important;
	right: 24px !important;
	width: 44px !important;
	height: 44px !important;
	border-radius: 50% !important;
	background: rgba(255, 255, 255, 0.15) !important;
	border: 0 !important;
	color: #fff !important;
	display: grid !important;
	place-items: center !important;
	cursor: pointer !important;
	transition: background 0.15s ease !important;
	z-index: 2 !important;
	padding: 0 !important;
}
.fule-gallery-lightbox__close:hover {
	background: rgba(255, 255, 255, 0.28) !important;
}
.fule-gallery-lightbox__close svg {
	width: 22px !important;
	height: 22px !important;
	color: #fff !important;
	fill: none !important;
	stroke: currentColor !important;
	display: block !important;
}
.fule-gallery-lightbox__close svg line,
.fule-gallery-lightbox__close svg path {
	stroke: currentColor !important;
	fill: none !important;
}

.fule-gallery-lightbox__content {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

/* ----- Grid mode -----
   v1.60.1: grid-wrap is a flex centering host. align-items: safe center
   degrades to flex-start when the grid overflows, so long manifests scroll
   from the top instead of clipping above the viewport. Tile backgrounds
   are forced transparent with !important — any theme/Elementor rule that
   paints <button> backgrounds gold would otherwise bleed through the
   previous rgba(255,255,255,0.05) and produce a gold halo around every
   thumbnail (the bug visible in the screenshot). */
.fule-gallery-lightbox__grid-wrap {
	flex: 1 1 auto;
	display: flex;
	align-items: safe center;
	justify-content: center;
	padding: 80px 24px 24px;
	min-height: 0;
	overflow-y: auto;
	width: 100%;
	box-sizing: border-box;
}
.fule-gallery-lightbox__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 12px;
	width: 100%;
	max-width: 1100px;
	margin: 0 auto;
}
.fule-gallery-lightbox__tile {
	aspect-ratio: 4 / 3 !important;
	background: transparent !important;
	background-color: transparent !important;
	border: 0 !important;
	padding: 0 !important;
	border-radius: 10px !important;
	overflow: hidden !important;
	cursor: pointer !important;
	transition: transform 0.15s ease, box-shadow 0.15s ease !important;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35) !important;
}
.fule-gallery-lightbox__tile:hover {
	transform: translateY(-2px) !important;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5) !important;
}
.fule-gallery-lightbox__tile img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	display: block !important;
	border-radius: 8px !important;
}

/* ----- Single mode -----
   v1.60.1: nav arrows live on the IMAGE edges (inset 16px from the image
   bounds), not the page edges. The JS wraps the <img> in a relatively-
   positioned __image-wrap container so the arrows position relative to the
   actual image rectangle regardless of viewport width. The image is sized
   to fit the available stage area; arrows track that area. */
.fule-gallery-lightbox__stage {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	padding: 80px 24px 24px;
	min-height: 0;
}
.fule-gallery-lightbox__image-wrap {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 100%;
}
.fule-gallery-lightbox__hero {
	max-width: 100%;
	max-height: calc(100vh - 160px);
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
	border-radius: 4px;
}
.fule-gallery-lightbox__nav {
	position: absolute !important;
	top: 50% !important;
	transform: translateY(-50%) !important;
	width: 48px !important;
	height: 48px !important;
	padding: 0 !important;
	border-radius: 50% !important;
	background: rgba(0, 0, 0, 0.55) !important;
	border: 0 !important;
	color: #fff !important;
	display: grid !important;
	place-items: center !important;
	cursor: pointer !important;
	transition: background 0.15s ease !important;
	backdrop-filter: blur(4px) !important;
}
.fule-gallery-lightbox__nav:hover {
	background: rgba(0, 0, 0, 0.8) !important;
}
.fule-gallery-lightbox__nav--prev { left: 16px !important; }
.fule-gallery-lightbox__nav--next { right: 16px !important; }
.fule-gallery-lightbox__nav svg {
	width: 24px !important;
	height: 24px !important;
	color: #fff !important;
	fill: none !important;
	stroke: currentColor !important;
	display: block !important;
}
.fule-gallery-lightbox__nav svg polyline,
.fule-gallery-lightbox__nav svg path {
	stroke: currentColor !important;
	fill: none !important;
}

.fule-gallery-lightbox__bar {
	flex: 0 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 24px 20px;
	color: rgba(255, 255, 255, 0.85);
	font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
	font-size: 12px;
	letter-spacing: 0.05em;
}
.fule-gallery-lightbox__counter {
	padding: 6px 12px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 4px;
}
.fule-gallery-lightbox__view-grid {
	background: transparent !important;
	border: 1px solid rgba(255, 255, 255, 0.35) !important;
	color: #fff !important;
	padding: 8px 14px !important;
	border-radius: 999px !important;
	cursor: pointer !important;
	display: inline-flex !important;
	align-items: center !important;
	gap: 8px !important;
	font-family: inherit;
	font-size: inherit;
	letter-spacing: inherit;
	transition: background 0.15s ease !important;
}
.fule-gallery-lightbox__view-grid:hover {
	background: rgba(255, 255, 255, 0.12) !important;
}
.fule-gallery-lightbox__view-grid svg {
	width: 16px !important;
	height: 16px !important;
	color: #fff !important;
	fill: none !important;
	stroke: currentColor !important;
	display: block !important;
}
.fule-gallery-lightbox__view-grid svg rect,
.fule-gallery-lightbox__view-grid svg path {
	stroke: currentColor !important;
	fill: none !important;
}

@media (max-width: 720px) {
	.fule-gallery-lightbox__stage {
		padding: 64px 16px 16px;
	}
	.fule-gallery-lightbox__nav {
		width: 40px;
		height: 40px;
	}
	.fule-gallery-lightbox__nav--prev { left: 8px; }
	.fule-gallery-lightbox__nav--next { right: 8px; }
	.fule-gallery-lightbox__grid {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
		padding: 64px 12px 16px;
	}
	.fule-gallery-lightbox__close {
		top: 12px;
		right: 12px;
	}
}
