/**
 * Radu Sava Widgets — Photo Gallery Styles
 *
 * Scoped strictly under .rs-photo-gallery.
 * Editorial grid with 4:5 portraits, big spanning tiles, slow hover zoom,
 * shop metadata fields, and responsive breakpoints.
 *
 * @package RaduSavaVisuals\Widgets
 */

/* ==========================================================================
   Section Base & Container
   ========================================================================== */

.rs-photo-gallery {
	position: relative;
	background-color: var(--rs-bd-hi, #e7e4df);
	color: var(--rs-graphite, #1b1a18);
	padding-block: clamp(72px, 9vw, 180px);
	box-sizing: border-box;
}

.rs-photo-gallery__wrap {
	width: 100%;
	max-width: 2000px;
	margin: 0 auto;
	padding-inline: var(--rs-gutter, clamp(16px, 3.2vw, 72px));
	box-sizing: border-box;
}

/* Inline modifier (when nested inside existing page sections/containers) */
.rs-photo-gallery--inline {
	padding-block: 0;
	background: transparent;
	background-color: transparent;
}

.rs-photo-gallery--inline .rs-photo-gallery__wrap {
	max-width: none;
	padding-inline: 0;
}

/* ==========================================================================
   Section Header
   ========================================================================== */

.rs-photo-gallery__shead {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid currentColor;
	margin-bottom: clamp(36px, 4.5vw, 96px);
	opacity: 0.75;
	font-family: var(--rs-font-mono, "IBM Plex Mono", ui-monospace, monospace);
	font-size: clamp(10px, 0.68vw, 14px);
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.rs-photo-gallery__hd {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 24px;
	flex-wrap: wrap;
	margin-bottom: clamp(28px, 3vw, 64px);
}

.rs-photo-gallery__heading {
	margin: 0;
	font-family: var(--rs-font-display, "Cormorant Garamond", Georgia, serif);
	font-weight: 300;
	font-size: clamp(44px, 5vw, 128px);
	line-height: 0.92;
	letter-spacing: -0.025em;
	color: inherit;
}

.rs-photo-gallery__heading i,
.rs-photo-gallery__heading em {
	font-style: italic;
	font-weight: inherit;
}

.rs-photo-gallery__desc {
	margin: 0;
	max-width: 26em;
	color: var(--rs-graphite-2, #45423e);
	font-family: var(--rs-font-body, "Manrope", system-ui, sans-serif);
	font-size: clamp(15px, 1vw, 20px);
	line-height: 1.7;
}

/* ==========================================================================
   Photo Grid
   ========================================================================== */

.rs-photo-gallery__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(10px, 1.2vw, 28px);
	grid-auto-flow: row dense;
}

.rs-photo-gallery__cell {
	display: flex;
	flex-direction: column;
	position: relative;
}

/* Cell spanning for Big tiles */
.rs-photo-gallery__cell:has(.rs-photo-gallery__item--big),
.rs-photo-gallery__cell--big {
	grid-column: 1 / 3;
	grid-row: span 2;
}

.rs-photo-gallery__cell:has(.rs-photo-gallery__item--big-r),
.rs-photo-gallery__cell--big-r {
	grid-column: 2 / 4;
	grid-row: span 2;
}

/* Tile Link / Anchor */
.rs-photo-gallery__item {
	display: block;
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 5;
	cursor: zoom-in;
	background-color: var(--rs-bd-lo, #b6b2ab);
	text-decoration: none !important;
	border: 0;
	outline-offset: 4px;
}

.rs-photo-gallery__item:focus-visible {
	outline: 1px solid currentColor;
}

/* Big item fills grid height when spanning */
.rs-photo-gallery__item--big,
.rs-photo-gallery__item--big-r {
	aspect-ratio: auto;
	height: 100%;
	min-height: clamp(380px, 45vw, 840px);
}

/* Image Wrapper & Image Tag */
.rs-photo-gallery__img-wrap {
	position: absolute;
	inset: 0;
	display: block;
	overflow: hidden;
}

.rs-photo-gallery .rs-photo-gallery__img {
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	display: block;
	transition: transform 1.2s var(--rs-ease, cubic-bezier(.2, .7, .2, 1));
	will-change: transform;
}

.rs-photo-gallery .rs-photo-gallery__item:hover .rs-photo-gallery__img {
	transform: scale(1.035);
}

/* Placeholder for missing image */
.rs-photo-gallery .rs-photo-gallery__img-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	background: var(--rs-bd-lo, #b6b2ab);
}

/* Hover "View" tag badge */
.rs-photo-gallery__item::after {
	content: "View";
	position: absolute;
	right: 14px;
	bottom: 12px;
	font-family: var(--rs-font-mono, "IBM Plex Mono", ui-monospace, monospace);
	font-size: 11px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--rs-white, #ffffff);
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.35s ease, transform 0.35s ease;
	text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
	z-index: 2;
	pointer-events: none;
}

.rs-photo-gallery__item:hover::after,
.rs-photo-gallery__item:focus-visible::after {
	opacity: 1;
	transform: translateY(0);
}

/* ==========================================================================
   Shop Fields (Prints for Sale)
   ========================================================================== */

.rs-photo-gallery__shop {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding-top: 10px;
}

.rs-photo-gallery__shop-title {
	margin: 0;
	font-family: var(--rs-font-display, "Cormorant Garamond", Georgia, serif);
	font-weight: 400;
	font-size: clamp(18px, 1.4vw, 26px);
	line-height: 1.2;
	color: var(--rs-graphite, #1b1a18);
}

.rs-photo-gallery__shop-meta {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	font-family: var(--rs-font-mono, "IBM Plex Mono", ui-monospace, monospace);
	font-size: clamp(10px, 0.68vw, 13px);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--rs-graphite-2, #45423e);
	opacity: 0.85;
}

/* ==========================================================================
   Empty State Hint
   ========================================================================== */

.rs-photo-gallery .rs-empty-hint {
	padding: 40px 20px;
	text-align: center;
	border: 1px dashed rgba(27, 26, 24, 0.3);
	font-family: var(--rs-font-mono, "IBM Plex Mono", ui-monospace, monospace);
	font-size: 13px;
	color: var(--rs-graphite-2, #45423e);
}

/* ==========================================================================
   Masonry Pattern
   ========================================================================== */

.rs-photo-gallery--masonry {
	--rs-pg-cols: 3;
	--rs-pg-gap: 16px;
}

/* Fallback without JS: CSS column-count */
.rs-photo-gallery__grid--masonry {
	display: block;
	column-count: var(--rs-pg-cols, 3);
	column-gap: var(--rs-pg-gap, 16px);
}

.rs-photo-gallery__grid--masonry .rs-photo-gallery__cell {
	break-inside: avoid;
	margin-bottom: var(--rs-pg-gap, 16px);
}

/* Masonry items: natural ratio, no 4:5 crop */
.rs-photo-gallery--masonry .rs-photo-gallery__item--masonry {
	aspect-ratio: auto;
	height: auto;
	width: 100%;
}

.rs-photo-gallery--masonry .rs-photo-gallery__item--masonry .rs-photo-gallery__img-wrap {
	position: relative;
	inset: auto;
	width: 100%;
	height: auto;
	display: block;
	overflow: hidden;
}

.rs-photo-gallery--masonry .rs-photo-gallery__item--masonry .rs-photo-gallery__img {
	width: 100%;
	height: auto;
	max-width: 100%;
	display: block;
}

/* JS-enhanced column flex container */
.rs-photo-gallery__masonry-cols {
	display: flex;
	gap: var(--rs-pg-gap, 16px);
	align-items: flex-start;
	width: 100%;
}

.rs-photo-gallery__masonry-col {
	flex: 1 1 0%;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: var(--rs-pg-gap, 16px);
}

.rs-photo-gallery__masonry-col .rs-photo-gallery__cell {
	width: 100%;
	margin-bottom: 0;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
	.rs-photo-gallery--masonry {
		--rs-pg-cols: 2;
		--rs-pg-gap: 12px;
	}

	.rs-photo-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: clamp(12px, 2vw, 24px);
	}

	.rs-photo-gallery__cell:has(.rs-photo-gallery__item--big),
	.rs-photo-gallery__cell:has(.rs-photo-gallery__item--big-r) {
		grid-column: 1 / -1;
		grid-row: auto;
	}

	.rs-photo-gallery__item--big,
	.rs-photo-gallery__item--big-r {
		min-height: clamp(340px, 50vw, 600px);
	}

	/* Last normal cell orphan spans full row when count of normal tiles is odd */
	.rs-photo-gallery__grid--editorial .rs-photo-gallery__cell--orphan {
		grid-column: 1 / -1;
	}
}

@media (max-width: 767px) {
	.rs-photo-gallery--masonry {
		--rs-pg-cols: 2;
		--rs-pg-gap: 10px;
	}

	.rs-photo-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
	}

	.rs-photo-gallery__cell:has(.rs-photo-gallery__item--big),
	.rs-photo-gallery__cell:has(.rs-photo-gallery__item--big-r) {
		grid-column: 1 / 3;
		grid-row: auto;
	}

	.rs-photo-gallery__item--big,
	.rs-photo-gallery__item--big-r {
		aspect-ratio: 4 / 5;
		min-height: 0;
	}

	.rs-photo-gallery__hd {
		flex-direction: column;
		align-items: flex-start;
		gap: 14px;
	}
}

/* ==========================================================================
   Prefers-Reduced-Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.rs-photo-gallery .rs-photo-gallery__img {
		transition: none !important;
		transform: none !important;
	}

	.rs-photo-gallery .rs-photo-gallery__item:hover .rs-photo-gallery__img {
		transform: none !important;
	}

	.rs-photo-gallery__item::after {
		transition: opacity 0.1s ease !important;
		transform: none !important;
	}
}
