/* Photo slides on product cards and in the product-page gallery (card-slides.js, gallery.js).
   From SghiraBrand 900aa69 and f953889. */

/* The slideshow's layers stack inside the photo, under the arrows and buttons. */
.product-card__media {
	isolation: isolate;
}

.product-card__badge {
	z-index: 3; /* Above the slideshow's photos. */
}

/* Photo dots: one per photo, the shown one longer. Shared by the cards and the product page. */
.slide-dots {
	display: flex;
	align-items: center;
	gap: 3px;
	padding: 3px 5px;
	background: rgb(0 0 0 / 0.22);
	border-radius: var(--radius-pill);
	pointer-events: none;
}

.slide-dots__dot {
	inline-size: 4px;
	block-size: 4px;
	background: rgb(255 255 255 / 0.6);
	border-radius: var(--radius-pill);
	transition: inline-size var(--duration-panel) var(--ease-out), background-color var(--duration-panel) var(--ease-out);
}

.slide-dots__dot[aria-current="true"] {
	inline-size: 10px;
	background: #fff;
}

/* Previous / next arrows over a photo. The chevron points to the end of the line: turned for "previous", and mirrored
   in Arabic, where the next photo is on the left. */
.slide-arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	/* See-through, so the arrow never hides the product; the blur keeps the chevron readable on any photo. */
	background: rgb(255 255 255 / 0.5);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	color: var(--color-ink);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	pointer-events: auto;
	transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.slide-arrow:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.slide-arrow[data-slide="prev"] .icon {
	transform: rotate(180deg);
}

[dir="rtl"] .slide-arrow .icon {
	scale: -1 1;
}

.slide-arrow:active {
	transform: scale(0.94);
}

/* Card slideshow: small arrows in the photo's bottom corners, on the dots' line, so the product stays in view. The row
   is placed by the photo's height (--card-photo-block, components.css). */
.product-card__slides {
	--card-arrow-size: 1.375rem;
	--card-arrow-inset: 0.3125rem;
	position: absolute;
	z-index: 1; /* Above the link's photo. */
	inset-inline: var(--card-arrow-inset);
	inset-block-start: calc(var(--card-photo-block) - var(--card-arrow-inset) - var(--card-arrow-size));
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	block-size: var(--card-arrow-size);
	pointer-events: none;
}

.product-card__arrow {
	position: relative;
	inline-size: var(--card-arrow-size);
	block-size: var(--card-arrow-size);
}

/* A 22px arrow, a 44px thumb target. */
.product-card__arrow::before {
	content: "";
	position: absolute;
	inset: calc((var(--card-arrow-size) - 2.75rem) / 2);
	border-radius: 50%;
}

.product-card__arrow .icon {
	inline-size: 60%;
	block-size: 60%;
}

.product-card__arrow[data-slide="next"] {
	grid-column: 3;
}

.product-card__dots {
	grid-column: 2; /* In the middle, also while the arrows wait for their script. */
	justify-self: center;
}

/* Time left before the next photo: a thin bar along the bottom of the photo, filled while a preview plays. */
.slide-progress {
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	z-index: 3;
	block-size: 3px;
	background: rgb(0 0 0 / 0.16);
	pointer-events: none;
}

.slide-progress__fill {
	display: block;
	block-size: 100%;
	background: var(--color-accent-text);
	transform: scaleX(0);
	transform-origin: left;
}

[dir="rtl"] .slide-progress__fill {
	transform-origin: right;
}

/* With a mouse, the arrows show when the card is pointed at or reached with the keyboard. */
@media (hover: hover) and (pointer: fine) {
	.product-card__arrow {
		opacity: 0;
	}

	.product-card:hover .product-card__arrow,
	.product-card:focus-within .product-card__arrow {
		opacity: 1;
	}
}

/* The other photos, laid over the main one and faded in (card-slides.js adds them when first needed). */
.product-card__media .product-card__slide {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity 700ms var(--ease-out), transform var(--duration-panel) var(--ease-out);
}

.product-card__media .product-card__slide[data-active] {
	opacity: 1;
}

/* Product page: the photo being left stays behind as the background while the next one fades in over it. */
.product-gallery__main {
	position: relative;
	background-position: center;
	background-size: cover;
}

.product-gallery__main .product-gallery__image {
	transition: opacity 700ms var(--ease-out);
}

.product-gallery__main .product-gallery__image[data-fading] {
	opacity: 0;
	transition: none;
}

.product-gallery__arrow {
	position: absolute;
	inset-block-start: 50%;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	margin-block-start: -1.25rem;
}

.product-gallery__arrow[data-slide="prev"] {
	inset-inline-start: var(--space-3);
}

.product-gallery__arrow[data-slide="next"] {
	inset-inline-end: var(--space-3);
}

.product-gallery__dots {
	position: absolute;
	inset-block-end: var(--space-3);
	inset-inline-start: 50%;
	translate: -50% 0;
}

[dir="rtl"] .product-gallery__dots {
	translate: 50% 0;
}

@media (prefers-reduced-motion: reduce) {
	.product-card__media .product-card__slide,
	.product-gallery__main .product-gallery__image,
	.slide-dots__dot {
		transition: none;
	}
}
