/**
 * DKM Product Gallery
 *
 * Every colour is a custom property with a default, so a theme can restyle the
 * gallery without touching this file. Sizing properties are written inline on
 * the root element from the widget settings.
 */

.wcg {
	--wcg-thumb-size: 40px;
	--wcg-thumb-gap: 8px;
	--wcg-visible: 99;
	--wcg-ratio: auto;
	--wcg-fit: cover;

	/* Diilikaubamaja Design System v2. The accent is what marks the active
	   thumbnail and draws the focus rings, so it is the system's interactive
	   colour - Blue 500, which the kit keeps as Secondary - rather than the
	   brand lime, which is a fill and not an outline. The shop's own global
	   comes first; the literal is that token's value. */
	--wcg-accent: var(--action-primary);

	--wcg-gap: 16px;
	--wcg-hint-gap: 6px;
	--wcg-dots-gap: 10px;
	--wcg-stage-bg: transparent;
	--wcg-thumb-border: var(--border-default);
	--wcg-thumb-border-active: var(--wcg-accent);
	--wcg-thumb-radius: var(--radius-sm);
	--wcg-lens-bg: rgba(120, 170, 255, 0.28);
	--wcg-lens-border: rgba(0, 0, 0, 0.25);
	--wcg-panel-bg: var(--bg-surface);
	/* The zoom panel lies over the buy box: one step stronger than a card,
	   so its edge reads against white (Amazon draws it heavier still). */
	--wcg-panel-shadow: var(--shadow-lift);
	--wcg-panel-border: var(--border-default);
	--wcg-panel-radius: var(--radius-sm);
	--wcg-backdrop: rgba(0, 0, 0, 0.72);
	--wcg-text: var(--text-primary);
	--wcg-muted: var(--text-tertiary);
	/* --wcg-arrow-bg is the name these had before the buttons became
	   settable; still honoured so an existing theme override keeps working. */
	--wcg-btn-bg: var(--wcg-arrow-bg, rgba(255, 255, 255, 0.9));
	--wcg-btn-icon: var(--wcg-text);
	/* The arrows and the close button sit on the photo, and a photo can be
	   any colour - so they are a disc that is never transparent enough to
	   lose: 90% white under an ink icon is about 15:1 even over black. The
	   hairline and the soft shadow are the disc's edge on a white photo. */
	/* One step darker than the disc, whatever colour it was set to. */
	--wcg-btn-hover: color-mix(in srgb, var(--wcg-btn-bg), var(--action-inverse-hover) 6%);
	--wcg-btn-edge: 0 0 0 1px rgba(10, 10, 10, 0.18), 0 2px 6px rgba(10, 10, 10, 0.28);
	/* One size for width, height and the centring offset. Width was a fixed
	   40px while height followed --control-md, so when that token went to
	   44px the arrows turned into 40x44 ovals sitting 2px off centre. */
	--wcg-btn-size: var(--control-md, 44px);
	--wcg-dot: currentColor;
	--wcg-dot-active: var(--wcg-accent);
	--wcg-focus-ring: var(--wcg-accent);

	/* Elementor renders this element as the flex child itself, so it has to
	   claim its width - without this it shrink-wraps to the image and the
	   whole gallery collapses.

	   The width is claimed with width, not by stretching: stretched in a row,
	   the element took the row's height too, and a background or border set
	   on it in the Style tab ran on below the images to the bottom of the
	   tallest column beside it. Start keeps it to its own height in a row and
	   changes nothing in a column, where the width already fills. */
	display: block;
	width: 100%;
	flex: 1 1 auto;
	align-self: flex-start;
	min-width: 0;

	/* No spacing of our own: margin and padding are the Style tab's job. */
	margin: 0;
	padding: 0;

	position: relative;
	color: var(--wcg-text);
}

.wcg *,
.wcg-lb * {
	box-sizing: border-box;
}

/* Several parts below set an explicit display, which would otherwise beat the
   [hidden] attribute the script toggles. */
.wcg [hidden],
.wcg-lb [hidden] {
	display: none !important;
}

.wcg__layout {
	display: flex;
	gap: var(--wcg-gap);
	align-items: stretch;
}

.wcg[data-wcg-thumbs="right"] .wcg__layout {
	flex-direction: row-reverse;
}

.wcg[data-wcg-thumbs="bottom"] .wcg__layout {
	flex-direction: column-reverse;
	align-items: stretch;
}

.wcg[data-wcg-thumbs="bottom"] .wcg__rail-wrap,
.wcg--mobile .wcg__main {
	width: 100%;
}

.wcg[data-wcg-thumbs="none"] .wcg__rail-wrap,
.wcg--mobile .wcg__rail-wrap {
	display: none;
}

/* Small screens keeping the thumbnails: tighter gap. The rail itself moves
   below the image further down, once the bottom-rail rules have been set. */
.wcg--small:not(.wcg--mobile) {
	--wcg-gap: 10px;
}

/* --------------------------------------------------------- thumbnail rail */

.wcg__rail-wrap {
	position: relative;
	flex: 0 0 auto;
}

.wcg__rail {
	--wcg-rail-bleed: 4px;

	display: flex;
	flex-direction: column;
	gap: var(--wcg-thumb-gap);
	/* Padding leaves room for the focus ring, which is drawn outside the tile
	   and would be clipped by the overflow below; the negative margin takes
	   that room back so the rail still lines up with the image. */
	margin: calc(-1 * var(--wcg-rail-bleed));
	padding: var(--wcg-rail-bleed);
	list-style: none;
	overflow: hidden;
	scroll-behavior: smooth;
	max-height: calc(var(--wcg-visible) * (var(--wcg-thumb-size) + var(--wcg-thumb-gap)) - var(--wcg-thumb-gap) + 2 * var(--wcg-rail-bleed));
}

.wcg[data-wcg-thumbs="bottom"] .wcg__rail {
	flex-direction: row;
	/* One row, like the vertical rail is one column: whatever does not fit is
	   reached through the "+N" tile, not through a second row. */
	flex-wrap: nowrap;
	max-height: none;
	max-width: calc(var(--wcg-visible) * (var(--wcg-thumb-size) + var(--wcg-thumb-gap)) - var(--wcg-thumb-gap) + 2 * var(--wcg-rail-bleed));
}

.wcg__thumb-item {
	margin: 0;
	padding: 0;
	list-style: none;
	flex: 0 0 auto;
}

.wcg .wcg__thumb,
.wcg .wcg__thumb:is(:hover, :focus, :active) {
	display: block;
	width: var(--wcg-thumb-size);
	height: var(--wcg-thumb-size);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 1px solid var(--wcg-thumb-border);
	border-radius: var(--wcg-thumb-radius);
	background: none;
	cursor: pointer;
	overflow: hidden;
	transition: var(--motion-control);
}

.wcg .wcg__thumb img,
.wcg .wcg__thumb-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.wcg .wcg__thumb:hover {
	border-color: var(--wcg-thumb-border-active);
}

.wcg .wcg__thumb.is-active {
	border-color: var(--wcg-thumb-border-active);
	/* Inset: an outer ring is drawn outside the tile's box, where the rail's
	   overflow clips it - the corners of the active thumbnail came out cut. */
	box-shadow: inset 0 0 0 1px var(--wcg-thumb-border-active);
}

.wcg__thumb--more {
	position: relative;
}

.wcg__thumb-more-badge {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.86);
	font: 600 12px/1 system-ui, -apple-system, sans-serif;
	color: var(--wcg-text);
}

/* A side rail is a desktop luxury: on a phone the image needs the full width,
   so the thumbnails go under it whichever side they were configured on. */
.wcg--small:not(.wcg--mobile) .wcg__layout {
	flex-direction: column-reverse;
	align-items: stretch;
}

.wcg--small:not(.wcg--mobile) .wcg__rail-wrap {
	width: 100%;
}

.wcg--small:not(.wcg--mobile) .wcg__rail {
	flex-direction: row;
	flex-wrap: nowrap;
	justify-content: center;
	max-height: none;
	max-width: 100%;
}

/* ----------------------------------------------------------------- stage */

.wcg__main {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
}

.wcg__stage {
	position: relative;
	width: 100%;
	max-width: 100%;
	aspect-ratio: var(--wcg-ratio);
	background: var(--wcg-stage-bg);
	overflow: hidden;
}

.wcg__slide {
	position: absolute;
	inset: 0;
}

.wcg:not(.wcg--mobile) .wcg__slide:not(.is-active) {
	display: none;
}

/* Scoped through .wcg on purpose: Elementor ships ".elementor img { height:
   auto }", which is one specificity point above a bare class and would take
   the height back - the picture then ignores the locked ratio, overflowing a
   portrait image out of the box (which reads as a crop) and leaving
   object-fit with nothing to do. */
.wcg .wcg__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: var(--wcg-fit);
}

/* Natural ratio: the active slide has to carry the height itself. */
.wcg[data-wcg-ratio="auto"] .wcg__stage {
	aspect-ratio: auto;
}

.wcg[data-wcg-ratio="auto"]:not(.wcg--mobile) .wcg__slide.is-active {
	position: relative;
}

.wcg[data-wcg-ratio="auto"] .wcg__img {
	height: auto;
}

.wcg.is-zoomable .wcg__stage {
	cursor: crosshair;
}

.wcg[data-wcg-lightbox="1"]:not(.is-zoomable) .wcg__stage {
	cursor: zoom-in;
}

.wcg__hint {
	margin: var(--wcg-hint-gap) 0 0;
	font-size: 12px;
	color: var(--wcg-muted);
	text-align: center;
}

/* ------------------------------------------------------------ hover zoom */

.wcg__lens {
	position: absolute;
	top: 0;
	left: 0;
	pointer-events: none;
	background: var(--wcg-lens-bg);
	border: 1px solid var(--wcg-lens-border);
	will-change: transform;
}

.wcg__zoom {
	position: fixed;
	top: 0;
	left: 0;
	overflow: hidden;
	/* On <body>, outside .wcg: the script copies the gallery's values onto
	   it; these are for a panel built before it does. */
	background: var(--wcg-panel-bg, var(--bg-surface, #fff));
	border: 1px solid var(--wcg-panel-border, var(--border-default, #d4d4d4));
	border-radius: var(--wcg-panel-radius, var(--radius-sm, 4px));
	box-shadow: var(--wcg-panel-shadow, var(--shadow-lift, 0 8px 24px rgba(10, 10, 10, 0.1)));
	z-index: 99990;
	pointer-events: none;
}

/* Doubled class: WooCommerce's `.woocommerce img { max-width: 100% }` is as
   specific as a single class and loads later, and it capped the magnified
   photo at the panel's width while its height stayed - the photo came out
   squeezed sideways. */
.wcg__zoom.wcg__zoom img {
	position: absolute;
	top: 0;
	left: 0;
	max-width: none;
	max-height: none;
	will-change: transform;
}

.wcg__inner-zoom {
	position: absolute;
	inset: 0;
	background-repeat: no-repeat;
	background-color: var(--wcg-panel-bg);
	pointer-events: none;
}

/* ------------------------------------------------- carousel (mobile) bits */

.wcg--mobile .wcg__stage {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.wcg--mobile .wcg__stage::-webkit-scrollbar {
	display: none;
}

.wcg--mobile .wcg__slide {
	position: relative;
	inset: auto;
	flex: 0 0 100%;
	scroll-snap-align: center;
}

.wcg .wcg__nav {
	position: absolute;
	/* Centred by top alone: a theme's button:focus rule that resets margin
	   would otherwise drop the arrow just tapped below the other one. */
	top: calc(50% - var(--wcg-btn-size) / 2);
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: var(--wcg-btn-size);
	height: var(--wcg-btn-size);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wcg-btn-bg);
	color: var(--wcg-btn-icon);
	box-shadow: var(--wcg-btn-edge);
	cursor: pointer;
	z-index: 2;
}

/* Every state of every button this gallery draws, held above the theme's own
   button rules. Hover and focus are the ones a theme almost always styles,
   and the ones that were being taken. */
.wcg .wcg__nav.wcg__nav,
.wcg-lb .wcg-lb__close.wcg-lb__close,
.wcg-lb .wcg-lb__nav.wcg-lb__nav {
	background: var(--wcg-btn-bg);
	color: var(--wcg-btn-icon);
}

/* :focus is deliberately not here. A mouse click leaves a button focused, so
   a button that darkens on focus stays dark until something else is clicked -
   which reads as stuck. Keyboard focus is drawn as a ring, further down. */
.wcg .wcg__nav.wcg__nav:hover,
.wcg .wcg__nav.wcg__nav:active,
.wcg-lb .wcg-lb__close.wcg-lb__close:hover,
.wcg-lb .wcg-lb__close.wcg-lb__close:active,
.wcg-lb .wcg-lb__nav.wcg-lb__nav:hover,
.wcg-lb .wcg-lb__nav.wcg-lb__nav:active {
	/* One step darker, and solid: a hover never makes the button fainter. */
	background: var(--wcg-btn-hover);
	color: var(--wcg-btn-icon);
}

.wcg .wcg__nav.wcg__nav:focus,
.wcg-lb .wcg-lb__close.wcg-lb__close:focus,
.wcg-lb .wcg-lb__nav.wcg-lb__nav:focus {
	outline: none;
}

.wcg__nav--prev {
	left: 8px;
}

.wcg__nav--next {
	right: 8px;
}

.wcg__nav::before {
	content: "";
	display: block;
	width: 9px;
	height: 9px;
	border-left: 2px solid currentColor;
	border-top: 2px solid currentColor;
	/* The rotated square's optical centre is off by half its stroke. */
	transform: translateX(2px) rotate(-45deg);
}

.wcg__nav--next::before {
	transform: translateX(-2px) rotate(135deg);
}

.wcg__dots {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: var(--wcg-dots-gap);
}

.wcg .wcg__dot,
.wcg .wcg__dot:is(:hover, :focus, :active) {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wcg-dot);
	opacity: 0.3;
	cursor: pointer;
}

.wcg .wcg__dot.is-active {
	background: var(--wcg-dot-active);
	opacity: 1;
}

.wcg__counter {
	position: absolute;
	right: 10px;
	bottom: 10px;
	padding: 2px 8px;
	border-radius: var(--radius-full);
	background: rgba(15, 17, 17, 0.72);
	color: var(--text-inverse);
	font-size: 12px;
	z-index: 2;
}

/* Without color-mix the hover would be an invalid value - a transparent
   button. It keeps its resting colour instead. */
@supports not (background: color-mix(in srgb, #ffffff, #0a0a0a 6%)) {
	.wcg,
	.wcg-lb {
		--wcg-btn-hover: var(--wcg-btn-bg);
	}
}

/* -------------------------------------------------------------- lightbox */

.wcg-lb {
	/* The fullscreen view is one shared element at the end of <body>, so it
	   cannot inherit the widget's variables - the gallery that opened it
	   copies its own values onto this element. */
	--wcg-btn-bg: rgba(255, 255, 255, 0.9);
	--wcg-btn-icon: var(--text-primary);
	/* One step darker than the disc, whatever colour it was set to. */
	--wcg-btn-hover: color-mix(in srgb, var(--wcg-btn-bg), var(--action-inverse-hover) 6%);
	--wcg-btn-edge: 0 0 0 1px rgba(10, 10, 10, 0.18), 0 2px 6px rgba(10, 10, 10, 0.28);
	--wcg-btn-size: var(--control-md, 44px);

	--wcg-dismiss-fade: 0;

	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	z-index: 999999;
}

.wcg-lb[hidden] {
	display: none;
}

/* Dragging the view down to close it fades the backdrop out from under the
   picture, so how far the gesture has got is readable before letting go. The
   backdrop is a layer of its own for this: its colour is a variable the theme
   can set to anything, and only a whole layer can be faded without knowing
   what colour that turned out to be. */
.wcg-lb::before {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--wcg-backdrop, rgba(0, 0, 0, 0.72));
	opacity: calc(1 - var(--wcg-dismiss-fade));
	pointer-events: none;
}

/* The backdrop is a positioned child now, so the panel needs a stacking order
   of its own to stay in front of it. */
.wcg-lb__panel {
	position: relative;
	z-index: 1;
}

.wcg-lb__panel,
.wcg-lb__close {
	transition: transform 200ms ease;
}

/* While a finger is on the glass the picture has to track it exactly; the
   transition above is only there to spring it back when the drag falls short. */
.wcg-lb.is-dismissing .wcg-lb__panel,
.wcg-lb.is-dismissing .wcg-lb__close {
	transition: none;
}

@media (prefers-reduced-motion: reduce) {
	.wcg-lb__panel,
	.wcg-lb__close {
		transition: none;
	}
}

.wcg-lb__panel {
	display: flex;
	flex: 1 1 auto;
	gap: 16px;
	margin: 24px;
	/* Right padding keeps the thumbnail column clear of the close button. */
	padding: 16px 56px 16px 16px;
	background: var(--bg-surface);
	border-radius: var(--radius-md);
	overflow: hidden;
}

.wcg-lb__stage {
	position: relative;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	cursor: zoom-in;
	touch-action: none;
}

.wcg-lb__stage.is-zoomed {
	cursor: grab;
}

.wcg-lb__frame {
	position: relative;
	/* Sized in JS to the largest any image in the set will be drawn, and the
	   picture is centred in it, so the arrows and the counter keep the same
	   place from one image to the next. */
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 100%;
	line-height: 0;
}

/* line-height:0 above removes the inline gap under the image; the overlays
   inside the frame need it back. */
.wcg-lb__frame > :not(img) {
	line-height: normal;
}

.wcg-lb .wcg-lb__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	/* The frame carries the height - it is measured from the room the stage
	   has - so the picture fills it instead of being capped again here. */
	max-height: 100%;
	object-fit: contain;
	transform-origin: 0 0;
	will-change: transform;
}

.wcg-lb__scroll {
	/* Positioned so the images' offsetTop is measured against this column,
	   which is what the counter's index maths reads. */
	position: relative;
	flex: 1 1 auto;
	width: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.wcg-lb__scroll::-webkit-scrollbar {
	display: none;
}

.wcg-lb .wcg-lb__stacked-img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0 0 8px;
	/* Tapping one opens it in the single-image view, where the zoom lives. */
	cursor: zoom-in;
}

.wcg-lb__stacked-img:last-child {
	margin-bottom: 0;
}

.wcg-lb--stacked .wcg-lb__stage {
	display: block;
	height: 100%;
	overflow: hidden;
	cursor: default;
	touch-action: pan-y pinch-zoom;
}

/* The column itself is what scrolls; without a definite height it would just
   grow and the images below the fold would be unreachable. */
.wcg-lb--stacked .wcg-lb__scroll {
	height: 100%;
}

.wcg-lb--stacked .wcg-lb__panel {
	padding: 0;
	margin: 0;
	border-radius: 0;
}

.wcg-lb--stacked .wcg-lb__counter {
	position: fixed;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	z-index: 3;
}

.wcg-lb__thumbs {
	flex: 0 0 auto;
	display: grid;
	grid-template-columns: repeat(4, 68px);
	gap: 8px;
	align-content: flex-start;
	overflow-y: auto;
	max-height: 100%;
}

.wcg-lb .wcg-lb__thumb,
.wcg-lb .wcg-lb__thumb:is(:hover, :focus, :active) {
	width: 68px;
	height: 68px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 1px solid var(--wcg-thumb-border, var(--border-default));
	border-radius: var(--radius-sm);
	background: none;
	cursor: pointer;
	overflow: hidden;
}

.wcg-lb .wcg-lb__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.wcg-lb .wcg-lb__thumb.is-active {
	border-color: var(--wcg-thumb-border-active, var(--border-selected));
	box-shadow: inset 0 0 0 1px var(--wcg-thumb-border-active, var(--border-focus));
}

/* Doubled classes on purpose: a theme reaches its buttons as
   `.woocommerce button.button` or `.elementor button:hover`, which outranks a
   single class, so any state left undeclared here is painted by the theme -
   which is how the fullscreen close button came out in a colour nobody had
   set. */
.wcg-lb .wcg-lb__close.wcg-lb__close,
.wcg-lb .wcg-lb__nav.wcg-lb__nav,
.wcg-lb .wcg-lb__close.wcg-lb__close:is(:hover, :focus, :active),
.wcg-lb .wcg-lb__nav.wcg-lb__nav:is(:hover, :focus, :active) {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	/* The size has to be held here too, box model and all: a theme's button
	   rules (min-width, padding, line-height, a width per breakpoint) won the
	   single-class size and squeezed these into narrow pills. */
	box-sizing: border-box;
	min-width: 0;
	min-height: 0;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--wcg-btn-bg);
	color: var(--wcg-btn-icon);
	border-radius: 50%;
	font: 400 22px/1 system-ui, -apple-system, sans-serif;
	letter-spacing: 0;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
	z-index: 2;
	/* These sit on whatever the photo happens to be - and on a phone the
	   close button sits on the white panel itself, where a white button
	   disappears. The ring and the shadow give it an edge on any background,
	   whatever colour it has been set to. */
	box-shadow: var(--wcg-btn-edge);
}

.wcg-lb .wcg-lb__close.wcg-lb__close {
	top: 34px;
	right: 34px;
	width: var(--wcg-btn-size);
	height: var(--wcg-btn-size);
}

.wcg-lb .wcg-lb__nav.wcg-lb__nav {
	/* Centred by top alone. The shared rule above resets margin on :focus,
	   and a tapped arrow keeps focus, so a margin-top here left the arrow
	   last pressed 20px lower than the other. */
	top: calc(50% - var(--wcg-btn-size) / 2);
	width: var(--wcg-btn-size);
	height: var(--wcg-btn-size);
}

.wcg-lb .wcg-lb__nav--prev.wcg-lb__nav--prev {
	left: 12px;
}

.wcg-lb .wcg-lb__nav--next.wcg-lb__nav--next {
	right: 12px;
}

.wcg-lb__nav::before {
	content: "";
	display: block;
	width: 11px;
	height: 11px;
	border-left: 2px solid currentColor;
	border-top: 2px solid currentColor;
	transform: translateX(3px) rotate(-45deg);
}

.wcg-lb__nav--next::before {
	transform: translateX(-3px) rotate(135deg);
}

.wcg-lb__counter {
	position: absolute;
	left: 50%;
	bottom: 12px;
	transform: translateX(-50%);
	padding: 4px 12px;
	border-radius: var(--radius-full);
	background: rgba(15, 17, 17, 0.72);
	color: var(--text-inverse);
	font-size: 13px;
}

/* The icons are Lucide's chevrons and cross, drawn as a mask so they take the
   icon colour, on the same 90% white disc as the gallery's own arrows. They
   used to be bare icons, which vanished on a dark or busy photo - the arrows
   are inside the picture's frame, and in the stacked view, on a phone or with
   a zoomed picture the close button is over the picture too. Comes after the
   rules above on purpose: same selectors, so it wins on order. */
.wcg-lb .wcg-lb__close.wcg-lb__close,
.wcg-lb .wcg-lb__nav.wcg-lb__nav,
.wcg-lb .wcg-lb__close.wcg-lb__close:is(:hover, :focus, :active),
.wcg-lb .wcg-lb__nav.wcg-lb__nav:is(:hover, :focus, :active) {
	background: var(--wcg-btn-bg);
	box-shadow: var(--wcg-btn-edge);
	filter: none;
	font-size: 0;
}

.wcg-lb .wcg-lb__close.wcg-lb__close:is(:hover, :active),
.wcg-lb .wcg-lb__nav.wcg-lb__nav:is(:hover, :active) {
	background: var(--wcg-btn-hover);
}

.wcg-lb .wcg-lb__close.wcg-lb__close:focus-visible,
.wcg-lb .wcg-lb__nav.wcg-lb__nav:focus-visible {
	outline: 2px solid var(--wcg-focus-ring);
	outline-offset: 2px;
}

.wcg-lb__nav::before,
.wcg-lb__nav--next::before,
.wcg-lb__close::before {
	content: "";
	display: block;
	width: 24px;
	height: 24px;
	border: 0;
	background: currentColor;
	transform: none;
	-webkit-mask: var(--wcg-lb-icon) center / contain no-repeat;
	mask: var(--wcg-lb-icon) center / contain no-repeat;
}

.wcg-lb__nav--prev {
	--wcg-lb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 18-6-6 6-6'/%3E%3C/svg%3E");
}

.wcg-lb__nav--next {
	--wcg-lb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
}

.wcg-lb__close {
	--wcg-lb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

/* On a desktop the counter is plain text in a strip the stage keeps free
   under the picture (the frame is sized less the stage's padding). On a
   phone and in the stacked view it floats over the pictures and keeps its
   dark pill. */
@media (min-width: 768px) {
	.wcg-lb:not(.wcg-lb--stacked) .wcg-lb__stage {
		padding-bottom: 32px;
	}

	.wcg-lb:not(.wcg-lb--stacked) .wcg-lb__counter {
		bottom: -28px;
		padding: 0;
		border-radius: 0;
		background: transparent;
		color: var(--wcg-muted);
		font-size: 13px;
		font-weight: 500;
	}
}

@media (max-width: 767px) {
	.wcg-lb__panel {
		margin: 0;
		padding: 16px;
		border-radius: 0;
	}

	.wcg-lb__thumbs {
		display: none;
	}

	.wcg-lb .wcg-lb__close.wcg-lb__close {
		top: 10px;
		right: 10px;
	}

	.wcg-lb .wcg-lb__nav--prev.wcg-lb__nav--prev {
		left: 8px;
	}

	.wcg-lb .wcg-lb__nav--next.wcg-lb__nav--next {
		right: 8px;
	}

	/* On a phone the counter sits at the foot of the screen, as it does in
	   the stacked view, rather than under the frame - where a zoomed picture
	   spills over it and a tall one pushes it about. */
	.wcg-lb__counter {
		position: fixed;
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
		z-index: 3;
	}
}

/* --------------------------------------------------------- editor states */

.wcg--loading .wcg__stage,
.wcg--loading .wcg__rail {
	background: repeating-linear-gradient(135deg, var(--bg-subtle), var(--bg-subtle) 12px, var(--bg-press) 12px, var(--bg-press) 24px);
	min-height: var(--wcg-thumb-size);
}

.wcg--loading .wcg__rail {
	width: var(--wcg-thumb-size);
	height: calc(var(--wcg-visible) * (var(--wcg-thumb-size) + var(--wcg-thumb-gap)) - var(--wcg-thumb-gap));
}

/* ------------------------------------------------------------- a11y bits */

.wcg__stage:focus-visible,
.wcg .wcg__thumb:focus-visible,
.wcg__nav:focus-visible,
.wcg .wcg__dot:focus-visible,
.wcg-lb .wcg-lb__thumb:focus-visible,
.wcg-lb__nav:focus-visible,
.wcg-lb__close:focus-visible {
	outline: 2px solid var(--wcg-focus-ring, var(--border-focus));
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.wcg__rail,
	.wcg--mobile .wcg__stage {
		scroll-behavior: auto;
	}

	.wcg__thumb {
		transition: none;
	}
}

/* Match the configured breakpoint before JavaScript initializes the gallery.
   Otherwise a desktop side rail first paints on phones and moves below later. */
@media (max-width: 1024px) {
	.wcg[data-wcg-breakpoint="1024"] { --wcg-gap: 10px; }
	.wcg[data-wcg-breakpoint="1024"] .wcg__layout { flex-direction: column-reverse; align-items: stretch; }
	.wcg[data-wcg-breakpoint="1024"] .wcg__rail-wrap { width: 100%; }
	.wcg[data-wcg-breakpoint="1024"] .wcg__rail {
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: flex-start;
		max-height: none;
		max-width: 100%;
	}
	.wcg[data-wcg-breakpoint="1024"][data-wcg-mobile-layout="carousel"] .wcg__rail-wrap { display: none; }
	.wcg[data-wcg-breakpoint="1024"][data-wcg-mobile-layout="carousel"] .wcg__main { width: 100%; }
	.wcg[data-wcg-breakpoint="1024"][data-wcg-mobile-layout="carousel"] .wcg__stage {
		display: flex;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.wcg[data-wcg-breakpoint="1024"][data-wcg-mobile-layout="carousel"] .wcg__stage::-webkit-scrollbar { display: none; }
	.wcg[data-wcg-breakpoint="1024"][data-wcg-mobile-layout="carousel"] .wcg__slide {
		display: block;
		position: relative;
		inset: auto;
		flex: 0 0 100%;
		scroll-snap-align: center;
	}
}
@media (max-width: 767px) {
	.wcg[data-wcg-breakpoint="767"] { --wcg-gap: 10px; }
	.wcg[data-wcg-breakpoint="767"] .wcg__layout { flex-direction: column-reverse; align-items: stretch; }
	.wcg[data-wcg-breakpoint="767"] .wcg__rail-wrap { width: 100%; }
	.wcg[data-wcg-breakpoint="767"] .wcg__rail {
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: flex-start;
		max-height: none;
		max-width: 100%;
	}
	.wcg[data-wcg-breakpoint="767"][data-wcg-mobile-layout="carousel"] .wcg__rail-wrap { display: none; }
	.wcg[data-wcg-breakpoint="767"][data-wcg-mobile-layout="carousel"] .wcg__main { width: 100%; }
	.wcg[data-wcg-breakpoint="767"][data-wcg-mobile-layout="carousel"] .wcg__stage {
		display: flex;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.wcg[data-wcg-breakpoint="767"][data-wcg-mobile-layout="carousel"] .wcg__stage::-webkit-scrollbar { display: none; }
	.wcg[data-wcg-breakpoint="767"][data-wcg-mobile-layout="carousel"] .wcg__slide {
		display: block;
		position: relative;
		inset: auto;
		flex: 0 0 100%;
		scroll-snap-align: center;
	}
}
