/* ===========================================================================
   gallery-modern-lightbox — calm modular gallery with a native image dialog
   ---------------------------------------------------------------------------
   Scope: .vbs-gallery-modern-lightbox
   Depends on: css/tokens.css, css/base.css

   The gallery is complete before the initializer runs: every tile is a link
   to its full-size image. Browsers with <dialog> support enhance those links
   into one modal viewer with native focus containment and Escape dismissal.
   There is no animation layer and no external JavaScript dependency.

   Contains no literal colour, font, type size, weight, radius, shadow or
   duration. The grid values and breakpoints are composition only.
   ========================================================================= */

.vbs-gallery-modern-lightbox {
	overflow: clip;
}

/* --- introduction -------------------------------------------------------- */
.vbs-gallery-modern-lightbox__head {
	display: grid;
	gap: clamp(1.75rem, 4vw, 4rem);
	padding-block-end: clamp(2rem, 4vw, 3.5rem);
	border-block-end: var(--vb-border-hair) solid var(--vb-color-rule);
}

.vbs-gallery-modern-lightbox__title {
	max-inline-size: 17ch;
	margin-block-start: 1.1rem;
}

.vbs-gallery-modern-lightbox__intro {
	max-inline-size: var(--vb-max-prose);
}

.vbs-gallery-modern-lightbox__hint {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	margin-block-start: 1.25rem;
	padding-block-start: 1.25rem;
	border-block-start: var(--vb-border-hair) solid var(--vb-color-rule);
}

.vbs-gallery-modern-lightbox__hint svg {
	flex: none;
	margin-block-start: 0.15rem;
	color: var(--vb-color-accent);
}

@media (min-width: 56rem) {
	.vbs-gallery-modern-lightbox__head {
		grid-template-columns: minmax(0, 1.08fr) minmax(20rem, 0.92fr);
		align-items: end;
	}
}

/* --- gallery ------------------------------------------------------------- */
.vbs-gallery-modern-lightbox__grid {
	display: grid;
	gap: clamp(0.875rem, 1.6vw, 1.35rem);
	margin-block-start: clamp(1.75rem, 3vw, 2.75rem);
}

.vbs-gallery-modern-lightbox__item {
	min-inline-size: 0;
}

.vbs-gallery-modern-lightbox__link {
	display: block;
	block-size: 100%;
	background-color: var(--vb-panel);
	background-image: var(--vb-panel-image);
	background-blend-mode: var(--vb-panel-blend);
	border: var(--vb-border-hair) solid var(--vb-color-rule);
	border-radius: var(--vb-radius-card);
	overflow: hidden;
	transition: border-color var(--vb-dur-base) var(--vb-ease-out-soft),
	            box-shadow var(--vb-dur-base) var(--vb-ease-out-soft);
}

.vbs-gallery-modern-lightbox__link:hover,
.vbs-gallery-modern-lightbox__link:focus-visible {
	border-color: var(--vb-color-ink);
	box-shadow: var(--vb-shadow-card-hover);
}

.vbs-gallery-modern-lightbox__figure {
	display: flex;
	flex-direction: column;
	block-size: 100%;
}

.vbs-gallery-modern-lightbox__media {
	flex: 1 1 auto;
	min-block-size: 0;
	border-radius: 0;
}

.vbs-gallery-modern-lightbox__media--landscape { --vb-ratio: 4 / 3; }
.vbs-gallery-modern-lightbox__media--wide { --vb-ratio: 3 / 2; }
.vbs-gallery-modern-lightbox__media--portrait { --vb-ratio: 4 / 5; }

.vbs-gallery-modern-lightbox__expand {
	position: absolute;
	inset-block-start: 0.75rem;
	inset-inline-end: 0.75rem;
	display: grid;
	place-items: center;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	color: var(--vb-color-ink);
	background-color: color-mix(in srgb, var(--vb-panel) 88%, transparent);
	border: var(--vb-border-hair) solid var(--vb-color-rule);
	border-radius: var(--vb-radius-btn);
	box-shadow: var(--vb-shadow-card);
	transition: color var(--vb-dur-base) var(--vb-ease-out-soft),
	            background-color var(--vb-dur-base) var(--vb-ease-out-soft),
	            border-color var(--vb-dur-base) var(--vb-ease-out-soft);
}

.vbs-gallery-modern-lightbox__link:hover .vbs-gallery-modern-lightbox__expand,
.vbs-gallery-modern-lightbox__link:focus-visible .vbs-gallery-modern-lightbox__expand {
	color: var(--vb-color-accent-contrast);
	background-color: var(--vb-color-accent);
	border-color: var(--vb-color-accent);
}

.vbs-gallery-modern-lightbox__caption {
	flex: none;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 0.85rem;
	align-items: start;
	padding: clamp(0.9rem, 1.5vw, 1.2rem);
	border-block-start: var(--vb-border-hair) solid var(--vb-color-rule);
}

.vbs-gallery-modern-lightbox__index {
	font-family: var(--vb-font-mono);
	font-size: var(--vb-fs-small);
	line-height: var(--vb-lh-small);
	color: var(--vb-color-accent);
}

.vbs-gallery-modern-lightbox__caption-copy {
	display: grid;
	gap: 0.2rem;
}

.vbs-gallery-modern-lightbox__name {
	font-family: var(--vb-font-display);
	font-size: var(--vb-fs-body);
	font-weight: var(--vb-weight-heading);
	line-height: var(--vb-lh-body);
	color: var(--vb-color-ink);
}

.vbs-gallery-modern-lightbox__meta {
	font-size: var(--vb-fs-small);
	line-height: var(--vb-lh-small);
	color: var(--vb-color-mute);
}

@media (min-width: 42rem) {
	.vbs-gallery-modern-lightbox__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.vbs-gallery-modern-lightbox__item--lead,
	.vbs-gallery-modern-lightbox__item:last-child {
		grid-column: 1 / -1;
	}

	.vbs-gallery-modern-lightbox__item--lead .vbs-gallery-modern-lightbox__media,
	.vbs-gallery-modern-lightbox__item:last-child .vbs-gallery-modern-lightbox__media {
		--vb-ratio: 16 / 9;
	}
}

@media (min-width: 64rem) {
	.vbs-gallery-modern-lightbox__grid {
		grid-template-columns: repeat(12, minmax(0, 1fr));
		grid-auto-rows: clamp(14rem, 19vw, 17.5rem);
	}

	.vbs-gallery-modern-lightbox__item--lead {
		grid-column: span 7;
		grid-row: span 2;
	}

	.vbs-gallery-modern-lightbox__item:nth-child(2),
	.vbs-gallery-modern-lightbox__item:nth-child(3) {
		grid-column: span 5;
	}

	.vbs-gallery-modern-lightbox__item:nth-child(n + 4) {
		grid-column: span 4;
	}

	.vbs-gallery-modern-lightbox__media,
	.vbs-gallery-modern-lightbox__item--lead .vbs-gallery-modern-lightbox__media,
	.vbs-gallery-modern-lightbox__item:last-child .vbs-gallery-modern-lightbox__media {
		aspect-ratio: auto;
	}

	/* The whole tile already communicates that it opens. On pointer-sized
	   layouts, keep the repeated corner marks quiet until intent is shown. */
	.vbs-gallery-modern-lightbox__expand {
		inline-size: 2.25rem;
		block-size: 2.25rem;
		background-color: color-mix(in srgb, var(--vb-panel) 70%, transparent);
		box-shadow: none;
		opacity: 0.68;
	}

	.vbs-gallery-modern-lightbox__link:hover .vbs-gallery-modern-lightbox__expand,
	.vbs-gallery-modern-lightbox__link:focus-visible .vbs-gallery-modern-lightbox__expand {
		opacity: 1;
	}
}

/* --- native dialog -------------------------------------------------------
   The dialog itself fills the top layer and stays transparent. Its child is
   the visible panel, which makes the padded area a dependable light-dismiss
   target without putting a second click-catcher over the page. */
.vbs-gallery-modern-lightbox__dialog {
	inline-size: 100%;
	block-size: 100%;
	max-inline-size: none;
	max-block-size: none;
	margin: 0;
	padding: clamp(0.5rem, 2vw, 1.5rem);
	border: 0;
	color: inherit;
	background-color: transparent;
	overflow: hidden;
}

.vbs-gallery-modern-lightbox__dialog[open] {
	display: grid;
	place-items: center;
}

.vbs-gallery-modern-lightbox__dialog::backdrop {
	background-color: color-mix(in srgb, var(--vb-color-ink) 76%, transparent);
}

.vbs-gallery-modern-lightbox__dialog-shell {
	inline-size: min(100%, 86rem);
	block-size: min(92dvh, 56rem);
	min-block-size: 0;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	color: var(--vb-color-ink);
	background-color: var(--vb-panel);
	background-image: var(--vb-panel-image);
	background-blend-mode: var(--vb-panel-blend);
	border: var(--vb-border-hair) solid var(--vb-color-rule);
	border-radius: var(--vb-radius-lg);
	box-shadow: var(--vb-shadow-pop);
	overflow: hidden;
}

.vbs-gallery-modern-lightbox__dialog-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.75rem clamp(0.85rem, 2vw, 1.35rem);
	border-block-end: var(--vb-border-hair) solid var(--vb-color-rule);
}

.vbs-gallery-modern-lightbox__dialog-kicker {
	font-family: var(--vb-font-sans);
	font-size: var(--vb-fs-eyebrow);
	font-weight: var(--vb-weight-eyebrow);
	line-height: var(--vb-lh-eyebrow);
	letter-spacing: var(--vb-ls-eyebrow);
	text-transform: var(--vb-case-eyebrow);
	color: var(--vb-color-mute);
}

.vbs-gallery-modern-lightbox__dialog-status,
.vbs-gallery-modern-lightbox__dialog-nav {
	display: flex;
	align-items: center;
	gap: 0.55rem;
}

.vbs-gallery-modern-lightbox__counter {
	font-family: var(--vb-font-mono);
	font-size: var(--vb-fs-small);
	line-height: var(--vb-lh-small);
	color: var(--vb-color-mute);
	white-space: nowrap;
}

.vbs-gallery-modern-lightbox__icon-button {
	appearance: none;
	display: inline-grid;
	place-items: center;
	inline-size: 2.75rem;
	block-size: 2.75rem;
	flex: none;
	padding: 0;
	color: var(--vb-color-ink);
	background-color: var(--vb-panel-2);
	background-image: var(--vb-panel-image);
	background-blend-mode: var(--vb-panel-blend);
	border: var(--vb-border-hair) solid var(--vb-color-rule);
	border-radius: var(--vb-radius-btn);
	cursor: pointer;
	touch-action: manipulation;
	transition: color var(--vb-dur-base) var(--vb-ease-out-soft),
	            background-color var(--vb-dur-base) var(--vb-ease-out-soft),
	            border-color var(--vb-dur-base) var(--vb-ease-out-soft);
}

.vbs-gallery-modern-lightbox__icon-button:hover {
	color: var(--vb-color-paper);
	background-color: var(--vb-color-ink);
	border-color: var(--vb-color-ink);
}

.vbs-gallery-modern-lightbox__dialog-figure {
	min-block-size: 0;
	display: grid;
	grid-template-rows: minmax(0, 1fr) auto;
}

.vbs-gallery-modern-lightbox__dialog-media {
	min-block-size: 0;
	display: grid;
	place-items: center;
	padding: clamp(0.5rem, 1.6vw, 1.25rem);
	background-color: var(--vb-panel-2);
	background-image: var(--vb-panel-image);
	background-blend-mode: var(--vb-panel-blend);
	overflow: hidden;
}

.vbs-gallery-modern-lightbox__dialog-image {
	inline-size: auto;
	block-size: auto;
	max-inline-size: 100%;
	max-block-size: 100%;
	object-fit: contain;
	border-radius: var(--vb-radius-sm);
}

.vbs-gallery-modern-lightbox__dialog-foot {
	display: grid;
	gap: 1rem;
	padding: clamp(0.9rem, 2vw, 1.35rem);
	border-block-start: var(--vb-border-hair) solid var(--vb-color-rule);
}

.vbs-gallery-modern-lightbox__dialog-title {
	margin: 0;
}

.vbs-gallery-modern-lightbox__dialog-meta {
	margin-block-start: 0.2rem;
}

@media (min-width: 40rem) {
	.vbs-gallery-modern-lightbox__dialog-foot {
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
	}
}

@media (max-width: 39.99rem) {
	.vbs-gallery-modern-lightbox__dialog-shell {
		block-size: calc(100dvh - 1rem);
	}

	.vbs-gallery-modern-lightbox__dialog-kicker {
		max-inline-size: 20ch;
	}

	.vbs-gallery-modern-lightbox__dialog-nav {
		justify-content: flex-end;
	}
}
