/* =============================================================================
   Darplay Tweaks - product photo gallery, "Примерни карти" and full-screen
   viewer (0.10.0, includes/gallery.php, assets/js/gallery.js).
   Square frame for every photo (no height jumps); desktop: thumbnail column
   + arrows; phones (<= 781px, WooCommerce's breakpoint): edge-to-edge photo,
   swipe, dots and counter.
   ============================================================================= */

.darplay-gallery {
	--darplay-soft: #f6f8f7;
	--darplay-green: #518459;
	position: relative;
	display: grid;
	grid-template-columns: 76px minmax(0, 1fr);
	gap: 12px;
	align-items: start;
	min-width: 0;
}

.darplay-gallery.is-single,
.darplay-gallery.is-empty {
	grid-template-columns: minmax(0, 1fr);
}

.darplay-gallery__main {
	position: relative;
	grid-column: -2;
	grid-row: 1;
	min-width: 0;
}

/* The square frame; slides sit side by side and snap. */
.darplay-gallery__frame {
	aspect-ratio: 1;
	width: 100%;
	max-width: 100%;
	background: var(--darplay-soft);
	border-radius: 10px;
	overflow: hidden;
}

.darplay-gallery__track {
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}

.darplay-gallery__track::-webkit-scrollbar {
	display: none;
}

.darplay-gallery__track:focus-visible {
	outline: 3px solid var(--darplay-green);
	outline-offset: 3px;
}

.darplay-gallery__slide {
	flex: 0 0 100%;
	height: 100%;
	scroll-snap-align: center;
	scroll-snap-stop: always;
	overflow: hidden;
}

.darplay-gallery__open {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

.darplay-gallery .darplay-gallery__img,
.darplay-gallery__frame > img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	/* Crops the white frame built into the 2560px product photos. */
	transform: scale(var(--darplay-zoom, 1));
}

/* Arrows, counter and full-screen button over the photo. */
.darplay-gallery__arrow,
.darplay-gallery__expand {
	position: absolute;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
	color: #202020;
	cursor: pointer;
	transition: opacity .15s ease, background-color .15s ease;
}

.darplay-gallery__arrow {
	top: 50%;
	width: 40px;
	height: 40px;
	margin-top: -20px;
	font-size: 26px;
	line-height: 1;
	padding-bottom: 3px;
}

.darplay-gallery__arrow.is-prev { left: 12px; }
.darplay-gallery__arrow.is-next { right: 12px; }

.darplay-gallery__arrow:disabled {
	opacity: 0;
	pointer-events: none;
}

.darplay-gallery__expand {
	top: 12px;
	right: 12px;
	width: 38px;
	height: 38px;
}

@media (hover: hover) {
	.darplay-gallery__arrow:hover,
	.darplay-gallery__expand:hover {
		background: #fff;
	}
}

.darplay-gallery__arrow:focus-visible,
.darplay-gallery__expand:focus-visible,
.darplay-gallery__thumb:focus-visible {
	outline: 3px solid var(--darplay-green);
	outline-offset: 2px;
}

.darplay-gallery__count {
	position: absolute;
	right: 12px;
	bottom: 12px;
	padding: 3px 10px;
	border-radius: 99px;
	background: rgba(29, 36, 32, .72);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.5;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

/* Desktop thumbnails: one column left of the photo. */
.darplay-gallery__thumbs {
	grid-column: 1;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 100%;
	overflow-y: auto;
	scrollbar-width: thin;
}

.darplay-gallery__thumb {
	flex: 0 0 auto;
	width: 76px;
	height: 76px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 8px;
	background: var(--darplay-soft);
	overflow: hidden;
	cursor: pointer;
	opacity: .6;
	transition: opacity .15s ease, border-color .15s ease;
}

.darplay-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.darplay-gallery__thumb[aria-current="true"] {
	border-color: var(--darplay-green);
	opacity: 1;
}

@media (hover: hover) {
	.darplay-gallery__thumb:hover {
		opacity: 1;
	}
}

.darplay-gallery__dots {
	display: none;
}

/* Sale badge from WooCommerce stays on top of the photo. */
.darplay-gallery > .onsale {
	z-index: 2;
}

/* ---------------------------------------------------------------- phones */
@media (max-width: 781px) {
	.wp-block-woocommerce-product-image-gallery.darplay-gallery {
		grid-template-columns: minmax(0, 1fr);
		gap: 10px;
		/* small tablets: centred, not wider than 560px (WooCommerce's block
		   CSS caps it at 512px and left-aligns it) */
		width: 100%;
		max-width: 560px;
		margin-inline: auto;
	}

	.darplay-gallery__main {
		grid-column: 1;
	}

	.darplay-gallery__thumbs,
	.darplay-gallery__arrow {
		display: none;
	}

	.darplay-gallery__dots {
		display: flex;
		justify-content: center;
		gap: 6px;
		grid-row: 2;
	}

	.darplay-gallery__dot {
		width: 7px;
		height: 7px;
		border-radius: 4px;
		background: #c9d3cc;
		transition: width .2s ease, background-color .2s ease;
	}

	.darplay-gallery__dot.is-on {
		width: 18px;
		background: var(--darplay-green);
	}
}

/* Phones: edge to edge, out of the page's side padding. */
@media (max-width: 599px) {
	.wp-block-woocommerce-product-image-gallery.darplay-gallery {
		width: 100vw;
		max-width: none;
		margin-left: calc(50% - 50vw);
		margin-right: 0;
	}

	.darplay-gallery__frame {
		border-radius: 0;
		/* 0.11.1 (owner: too much photo on phones): 4:3 instead of square, so
		   the price and "Купи" are on the first screen. The whole photo is
		   shown (contain), smaller, on the soft background - filling the
		   frame cut the text on the game boxes. */
		aspect-ratio: 4 / 3;
	}

	.darplay-gallery__track,
	.darplay-gallery__slide {
		height: 100%;
	}

	/* The photo sits in a square box as tall as the frame, centred, which
	   still trims the white border built into the photos (see
	   .darplay-gallery__img); soft background on both sides. */
	.darplay-gallery__open {
		width: auto;
		height: 100%;
		aspect-ratio: 1;
		margin-inline: auto;
		overflow: hidden;
	}
}

/* ------------------------------------------------------- "Примерни карти" */
.darplay-cards {
	display: grid;
	gap: 12px;
	margin: 0 0 40px;
	min-width: 0;
}

.darplay-cards__title {
	margin: 0;
	font-size: 24px;
	line-height: 1.25;
}

.darplay-cards__intro,
.darplay-cards__more {
	margin: 0;
	font-size: 15px;
	color: #444;
}

.darplay-cards__more a {
	color: #518459;
}

.darplay-cards__strip {
	display: flex;
	gap: 12px;
	overflow-x: auto;
	padding: 2px 2px 8px;
	scroll-snap-type: x proximity;
	scrollbar-width: thin;
}

.darplay-cards__card {
	flex: 0 0 auto;
	display: block;
	border: 1px solid #e3e8e4;
	border-radius: 8px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
	cursor: zoom-in;
	scroll-snap-align: start;
	transition: box-shadow .15s ease, transform .15s ease;
}

.darplay-cards__card .darplay-cards__img {
	display: block;
	width: auto;
	height: 190px;
	max-width: none;
}

@media (hover: hover) {
	.darplay-cards__card:hover {
		box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
		transform: translateY(-2px);
	}
}

.darplay-cards__card:focus-visible {
	outline: 3px solid #518459;
	outline-offset: 2px;
}

@media (max-width: 781px) {
	.darplay-cards__title {
		font-size: 22px;
	}

	.darplay-cards__card .darplay-cards__img {
		height: 160px;
	}

	.darplay-cards__strip {
		width: 100vw;
		margin-left: calc(50% - 50vw);
		padding-inline: max(16px, calc(50vw - 50%));
		scroll-padding-inline: 16px;
	}
}

/* ---------------------------------------------------- full-screen viewer */
html.darplay-lb-open,
html.darplay-lb-open body {
	overflow: hidden;
}

.darplay-lb {
	position: fixed;
	inset: 0;
	z-index: 100000; /* above the sticky header and the cookie banner */
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	background: rgba(12, 16, 14, .95);
	color: #fff;
	padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

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

.darplay-lb__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 8px 8px 16px;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
}

.darplay-lb__close {
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 32px;
	line-height: 1;
	cursor: pointer;
}

.darplay-lb__mid {
	position: relative;
	min-height: 0;
}

.darplay-lb__track {
	display: flex;
	height: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	overscroll-behavior: contain;
}

.darplay-lb__track::-webkit-scrollbar {
	display: none;
}

.darplay-lb__slide {
	flex: 0 0 100%;
	height: 100%;
	display: grid;
	/* One fixed-size cell: Firefox measures the picture's max-height: 100%
	   against the grid cell, and an "auto" cell let the picture grow past
	   the screen (owner's Firefox screenshots, 0.11.1). */
	grid-template: minmax(0, 1fr) / minmax(0, 1fr);
	place-items: center;
	padding: 8px 16px;
	scroll-snap-align: center;
	scroll-snap-stop: always;
}

.darplay-lb__slide img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	background: rgba(255, 255, 255, .04);
}

.darplay-lb__arrow {
	position: absolute;
	top: 50%;
	width: 48px;
	height: 48px;
	margin-top: -24px;
	padding: 0 0 3px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	font-size: 30px;
	line-height: 1;
	cursor: pointer;
}

.darplay-lb__arrow.is-prev { left: 16px; }
.darplay-lb__arrow.is-next { right: 16px; }

.darplay-lb__arrow:disabled {
	opacity: 0;
	pointer-events: none;
}

.darplay-lb__arrow[hidden] {
	display: none;
}

.darplay-lb button:focus-visible {
	outline: 3px solid #9fd3a8;
	outline-offset: 2px;
}

.darplay-lb__cap {
	margin: 0;
	padding: 8px 16px 16px;
	min-height: 3.2em;
	text-align: center;
	font-size: 14px;
	line-height: 1.5;
	color: #d7e0da;
}

@media (max-width: 781px) {
	.darplay-lb__arrow {
		display: none;
	}

	.darplay-lb__slide {
		padding: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.darplay-gallery__track,
	.darplay-lb__track {
		scroll-behavior: auto;
	}

	.darplay-cards__card,
	.darplay-gallery__dot,
	.darplay-gallery__thumb {
		transition: none;
	}
}
