/**
 * Image Gallery block styles.
 * Matches Figma Gallery Image Strip — desktop (823:11789); ≤768px (823:11818).
 */

.image-gallery {
	box-sizing: border-box;
	overflow: visible;
	padding-bottom: 0;
	padding-top: 20px;
	position: relative;
	width: 100%;
}

.image-gallery:not(.has-background) {
	background-color: var(--wp--preset--color--butter-yellow, #f5e29e);
}

.image-gallery:not(.has-text-color) {
	color: var(--wp--preset--color--coffee, #3c1f10);
}

.image-gallery *,
.image-gallery *::before,
.image-gallery *::after {
	box-sizing: border-box;
}

.image-gallery__inner {
	margin-left: auto;
	margin-right: auto;
	max-width: 94.5rem; /* 1512px */
	overflow: visible;
	padding: 2.5rem; /* 40px */
	position: relative;
	width: 100%;
}

/* -------------------------------------------------------------------------
   Polaroid strip — overlap, rotate, staggered sizes (Figma 823:11789)
   ------------------------------------------------------------------------- */

.image-gallery__strip {
	--image-gallery-scale: 1;
	--image-gallery-stagger: 110ms;
	align-items: center;
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	justify-content: center;
	margin: 0;
	overflow: visible;
	position: relative;
	width: 100%;
}

.image-gallery__slot {
	align-items: center;
	display: flex;
	flex-shrink: 0;
	justify-content: center;
	margin: 0;
	margin-right: calc(-1.875rem * var(--image-gallery-scale)); /* -30px overlap */
	opacity: 0;
	padding: 0;
	position: relative;
	transform: translate3d(0, 1.25rem, 0) scale(0.97);
	transition:
		opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
		transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
	will-change: opacity, transform;
	z-index: var(--image-gallery-z, 1);
}

.image-gallery__strip.is-revealed .image-gallery__slot {
	opacity: 1;
	transform: none;
}

.image-gallery__strip.is-revealed .image-gallery__slot:nth-child(1) { transition-delay: calc(var(--image-gallery-stagger) * 0); }
.image-gallery__strip.is-revealed .image-gallery__slot:nth-child(2) { transition-delay: calc(var(--image-gallery-stagger) * 1); }
.image-gallery__strip.is-revealed .image-gallery__slot:nth-child(3) { transition-delay: calc(var(--image-gallery-stagger) * 2); }
.image-gallery__strip.is-revealed .image-gallery__slot:nth-child(4) { transition-delay: calc(var(--image-gallery-stagger) * 3); }
.image-gallery__strip.is-revealed .image-gallery__slot:nth-child(5) { transition-delay: calc(var(--image-gallery-stagger) * 4); }

.image-gallery__slot,
.image-gallery__slot figcaption {
	margin-block: 0;
}

.image-gallery__slot:last-child {
	margin-right: 0;
}

.image-gallery__frame {
	border: 0.5rem solid var(--wp--preset--color--parchment-shade, #f0efe4); /* 8px */
	flex-shrink: 0;
	line-height: 0;
	overflow: hidden;
	padding: 0;
	transform: rotate(var(--image-gallery-rotate, 0deg));
}

.image-gallery__frame--editable {
	background: transparent;
	cursor: pointer;
	display: block;
}

.image-gallery__frame--editable:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.image-gallery__image {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

.image-gallery__image--placeholder {
	background-color: rgba(60, 31, 16, 0.08);
	display: block;
	height: 100%;
	width: 100%;
}

/* Slot + frame sizes and rotations from Figma. */
.image-gallery__slot--1 {
	--image-gallery-z: 1;
	height: calc(16.0625rem * var(--image-gallery-scale)); /* 257px slot */
	width: calc(20.25rem * var(--image-gallery-scale)); /* 324px slot */
}

.image-gallery__slot--1 .image-gallery__frame {
	--image-gallery-rotate: -3deg;
	height: calc(15.0625rem * var(--image-gallery-scale)); /* 241px */
	width: calc(19.5rem * var(--image-gallery-scale)); /* 312px */
}

.image-gallery__slot--2 {
	--image-gallery-z: 2;
	height: calc(20.875rem * var(--image-gallery-scale)); /* 335px slot */
	width: calc(16.5rem * var(--image-gallery-scale)); /* 265px slot */
}

.image-gallery__slot--2 .image-gallery__frame {
	--image-gallery-rotate: 3deg;
	height: calc(20.125rem * var(--image-gallery-scale)); /* 322px */
	width: calc(15.5rem * var(--image-gallery-scale)); /* 248px */
}

.image-gallery__slot--3 {
	--image-gallery-z: 3;
	height: calc(25.3125rem * var(--image-gallery-scale)); /* 405px slot */
	width: calc(20.0625rem * var(--image-gallery-scale)); /* 321px slot */
}

.image-gallery__slot--3 .image-gallery__frame {
	--image-gallery-rotate: -3deg;
	height: calc(24.375rem * var(--image-gallery-scale)); /* 390px */
	width: calc(18.8125rem * var(--image-gallery-scale)); /* 301px */
}

.image-gallery__slot--4 {
	--image-gallery-z: 4;
	height: calc(21.125rem * var(--image-gallery-scale)); /* 338px slot */
	width: calc(21.125rem * var(--image-gallery-scale));
}

.image-gallery__slot--4 .image-gallery__frame {
	--image-gallery-rotate: 3deg;
	height: calc(20.125rem * var(--image-gallery-scale)); /* 322px */
	width: calc(20.125rem * var(--image-gallery-scale));
}

.image-gallery__slot--5 {
	--image-gallery-z: 5;
	height: calc(20.875rem * var(--image-gallery-scale)); /* 335px slot */
	width: calc(16.5rem * var(--image-gallery-scale)); /* 265px slot */
}

.image-gallery__slot--5 .image-gallery__frame {
	--image-gallery-rotate: -3deg;
	height: calc(20.125rem * var(--image-gallery-scale)); /* 322px */
	width: calc(15.5rem * var(--image-gallery-scale)); /* 248px */
}

/* Each photo stacks over the one to its left (4 over 3, 5 over 4, etc.). */
.image-gallery__strip > .image-gallery__slot:nth-child(1) {
	z-index: 1;
}

.image-gallery__strip > .image-gallery__slot:nth-child(2) {
	z-index: 2;
}

.image-gallery__strip > .image-gallery__slot:nth-child(3) {
	z-index: 3;
}

.image-gallery__strip > .image-gallery__slot:nth-child(4) {
	z-index: 4;
}

.image-gallery__strip > .image-gallery__slot:nth-child(5) {
	z-index: 5;
}

/* -------------------------------------------------------------------------
   Responsive — scrollable strip on small screens
   ------------------------------------------------------------------------- */

/* Mid desktop (~1081–1400): shrink strip so polaroids stay on screen. */
@media (min-width: 67.5625rem) and (max-width: 87.5rem) {
	.image-gallery__strip {
		--image-gallery-scale: 0.82;
	}
}

/* ≤1080px — fluid scale so the polaroid strip fits the viewport. */
@media (max-width: 67.5rem) and (min-width: 48.0625rem) {
	.image-gallery {
		overflow-x: clip;
	}

	.image-gallery__strip {
		--image-gallery-scale: clamp(0.55, calc((100vw - 5rem) / 90rem), 0.75);
	}
}

/* ≤768px — Figma Gallery (node 823:11818). */
@media (max-width: 48rem) {
	.image-gallery {
		overflow-x: clip;
		padding-bottom: 1.875rem; /* 30px — Figma */
		padding-top: 0;
	}

	.image-gallery:has(+ .button-bar) {
		padding-bottom: 0;
	}

	.image-gallery__inner {
		padding: 2.5rem; /* 40px — Figma Hero */
	}

	.image-gallery__strip {
		--image-gallery-scale: 0.56; /* 768 Figma polaroids vs desktop */
		justify-content: center;
		overflow: visible;
		padding-bottom: 0;
	}

	.image-gallery__slot {
		margin-right: -1.875rem; /* -30px — Figma overlap, unscaled */
	}

	.image-gallery__slot:last-child {
		margin-right: 0;
	}

	.image-gallery__frame {
		border-width: 0.28rem; /* 4.48px — Figma */
	}

	.image-gallery + .button-bar {
		padding-bottom: 1.875rem; /* 30px — Figma Gallery */
		padding-top: 0;
	}

	.image-gallery + .button-bar .button-bar__inner {
		gap: 1.25rem; /* 20px — Figma CTAs */
		padding-left: 1.25rem;
		padding-right: 1.25rem;
	}

	.image-gallery + .button-bar .button-bar__heading,
	.image-gallery + .button-bar .button-bar .button-bar__heading,
	.image-gallery + .button-bar .button-bar__inner > .wp-block-heading {
		font-size: 1.5rem; /* 24px — Figma Desktop/H4 */
		letter-spacing: 0.01em;
		line-height: 1.1;
	}

	.image-gallery + .button-bar .button-bar__buttons,
	.image-gallery + .button-bar .wp-block-buttons.button-bar__buttons {
		flex-direction: column;
		gap: 1rem; /* 16px — Figma Button Group */
	}

	.image-gallery + .button-bar .button-bar__buttons .wp-block-button {
		width: 100%;
	}

	.image-gallery + .button-bar .button-bar__buttons .wp-block-button .wp-block-button__link,
	.image-gallery + .button-bar .button-bar__buttons .wp-block-button__link {
		font-size: 1rem; /* 16px — Figma Mobile/Button M */
		letter-spacing: 0.1em;
		padding: 0.5rem 1rem; /* 8px 16px */
		width: 100%;
	}
}

/* Seamless stack with Button Bar (composed page layout). */
.image-gallery + .button-bar:not(.has-background) {
	padding-top: 0;
}

@media (prefers-reduced-motion: reduce) {
	.image-gallery__frame,
	.image-gallery__slot {
		transition: none;
	}

	.image-gallery__slot {
		opacity: 1 !important;
		transform: none !important;
	}
}

/* Block editor: keep Polaroids visible while editing */
.editor-styles-wrapper .image-gallery__slot {
	opacity: 1;
	transform: none;
	transition: none;
}
