/* Full-screen photo and video viewer: product gallery and review media. */

.lightbox {
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--paper);
	overscroll-behavior: contain;
}

.lightbox, .lightbox::backdrop {
	transition: opacity var(--dur-panel-exit) ease, display var(--dur-panel-exit) allow-discrete, overlay var(--dur-panel-exit) allow-discrete;
	opacity: 0;
}

.lightbox[open], .lightbox[open]::backdrop { opacity: 1; transition-duration: 300ms; }

@starting-style {
	.lightbox[open], .lightbox[open]::backdrop { opacity: 0; }
}

.lightbox::backdrop { background: var(--paper); }
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; }

.lightbox__bar {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 16px;
	padding: calc(16px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 16px max(24px, env(safe-area-inset-left, 0px));
}
.lightbox__count { font-size: 12px; font-weight: 500; letter-spacing: 0.117em; text-transform: uppercase; color: var(--stone); font-variant-numeric: tabular-nums; }
.lightbox__count span { color: var(--ink); }
.lightbox__name { overflow: hidden; font-size: 14px; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.lightbox__close { display: inline-flex; align-items: center; justify-self: end; gap: 10px; min-height: 44px; font-size: 18px; }

.lightbox__stage { position: relative; min-height: 0; }
.lightbox__track {
	display: flex;
	height: 100%;
	overflow-x: auto;
	overscroll-behavior: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}
.lightbox__track::-webkit-scrollbar { display: none; }
.lightbox__slide { display: flex; flex: 0 0 100%; align-items: center; justify-content: center; height: 100%; padding: 0 96px; scroll-snap-align: center; }

/* Video player: sized to the film so the side areas still step between slides. */
.player {
	position: relative;
	z-index: 1;
	width: min(100%, calc(100cqh * var(--ratio)));
	aspect-ratio: var(--ratio);
	overflow: hidden;
	background: var(--ink);
	color: var(--paper);
}
.player__video { display: block; width: 100%; height: 100%; object-fit: contain; cursor: pointer; }
.player:fullscreen { width: 100%; aspect-ratio: auto; }

.player__big {
	position: absolute;
	top: 50%;
	left: 50%;
	display: grid;
	place-items: center;
	width: 72px;
	height: 72px;
	border-radius: 50%;
	background: rgb(17 16 15 / 0.45);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	transform: translate(-50%, -50%);
	transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}
.player__big .icon { width: 26px; height: 26px; margin-left: 3px; }
.player__big:active { transform: translate(-50%, -50%) scale(0.96); }
.player.is-playing .player__big { opacity: 0; pointer-events: none; }

.player__bar {
	position: absolute;
	inset: auto 0 0;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 32px 8px 8px;
	background: linear-gradient(180deg, rgb(17 16 15 / 0) 0%, rgb(17 16 15 / 0.6) 100%);
	transition: opacity 300ms ease;
}
.player.is-idle .player__bar { opacity: 0; }
.player.is-idle { cursor: none; }
.player.is-idle .player__video { cursor: none; }
.player__bar:focus-within { opacity: 1; }

.player__button { display: grid; flex: none; place-items: center; width: 40px; height: 40px; color: var(--paper); }
.player__button .icon { width: 20px; height: 20px; }
.player__button:focus-visible, .player__big:focus-visible { outline: 2px solid var(--paper); outline-offset: -2px; }
.player__when-playing, .player.is-playing .player__when-paused { display: none; }
.player.is-playing .player__when-playing { display: block; }
.player__when-muted, .player.is-muted .player__when-sound { display: none; }
.player.is-muted .player__when-muted { display: block; }

.player__time { flex: none; padding: 0 6px; font-size: 12px; font-variant-numeric: tabular-nums; }

.player__seek {
	flex: 1;
	min-width: 0;
	height: 24px;
	margin: 0 6px;
	background: transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}
.player__seek::-webkit-slider-runnable-track {
	height: 3px;
	border-radius: 2px;
	background: linear-gradient(90deg, var(--paper) var(--progress, 0%), rgb(246 243 238 / 0.3) var(--progress, 0%));
}
.player__seek::-moz-range-track { height: 3px; border-radius: 2px; background: rgb(246 243 238 / 0.3); }
.player__seek::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--paper); }
.player__seek::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4.5px; border: 0; border-radius: 50%; background: var(--paper); -webkit-appearance: none; appearance: none; }
.player__seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--paper); }
.player__seek:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
	.player__big:hover { background: rgb(17 16 15 / 0.6); }
	.player__button:hover { opacity: 0.75; }
}
.lightbox__slide img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; background: var(--bone); }

/* Product photos are 2:3, so the photo is two thirds of the stage height wide; the arrows sit a fixed gap outside it. */
.lightbox__stage { --photo-half: calc(100cqh / 3); --arrow-gap: 40px; container-type: size; }
.lightbox__nav { position: absolute; top: 0; bottom: 0; width: 50%; cursor: pointer; }
.lightbox__nav--prev { left: 0; }
.lightbox__nav--next { right: 0; }
.lightbox__arrow {
	position: absolute;
	top: 50%;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	color: var(--ink);
	transform: translateY(-50%);
	transition: transform var(--dur-fast) var(--ease-out);
}
.lightbox__nav--prev .lightbox__arrow { right: min(calc(100% - 72px), calc(var(--photo-half) + var(--arrow-gap))); }
.lightbox__nav--next .lightbox__arrow { left: min(calc(100% - 72px), calc(var(--photo-half) + var(--arrow-gap))); }
.lightbox__arrow .icon { width: 40px; height: 40px; }
.lightbox__nav:focus-visible { outline: none; }
.lightbox__nav:focus-visible .lightbox__arrow { outline: 2px solid var(--ink); outline-offset: 2px; }

.lightbox__thumbs { display: flex; justify-content: safe center; gap: 8px; overflow-x: auto; padding: 16px 24px calc(20px + env(safe-area-inset-bottom, 0px)); scrollbar-width: none; }
.lightbox__thumb { flex: none; width: 48px; aspect-ratio: 4 / 5; opacity: 0.5; transition: opacity var(--dur-fast) ease; }
.lightbox__thumb[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--ink); }

@media (hover: hover) and (pointer: fine) {
	.lightbox__nav--prev:hover .lightbox__arrow { transform: translate(-4px, -50%); }
	.lightbox__nav--next:hover .lightbox__arrow { transform: translate(4px, -50%); }
	.lightbox__thumb:hover { opacity: 1; }
}

@media (hover: none) {
	.lightbox__nav { display: none; }
	.lightbox__slide { padding: 0; }
}

@media (max-width: 720px) {
	.lightbox__bar { grid-template-columns: auto 1fr; padding-inline: 20px; }
	.lightbox__name { display: none; }
	.lightbox__slide { padding: 0; }
	.lightbox__nav { display: none; }
}

