/* Backs up the lenis.stop() call in page-index.js — Lenis intercepts
   wheel/touch itself regardless of native overflow. */
html:has(#page.index-page),
body:has(#page.index-page) {
	overflow: hidden;
	height: 100%;
}

#page.index-page {
	--intro-gap-y: min(var(--spacing-container), var(--spacing-md));

	height: 100svh;
	grid-template-rows: 1fr auto;
}
#page.index-page > #main {
	grid-row: 1;
	min-height: 0;
	display: flex;
}
#page.index-page > #header {
	grid-row: 2;
}

[data-section="intro"] {
	position: relative;
	min-height: 0;
	display: grid;
	grid-template-columns: 100%;
	grid-template-rows: auto 1fr;
	overflow: hidden;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}
[data-section="intro"] .sc-headline {
	grid-row: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding: var(--spacing-stack--sm) var(--spacing-container);
}
[data-section="intro"] .sc-content {
	grid-row: 2;
	position: relative;
	overflow: hidden;
}

@media (min-width: 768px) {
	#page.index-page {
		grid-row-gap: var(--intro-gap-y);
	}

	[data-section="intro"] .sc-headline {
		min-height: calc(var(--header-height, 0) + var(--intro-gap-y));
	}
}

@media (max-width: 767px) {
	#header.index-header {
		--logo-height: 1.8rem;
	}
	#header.index-header .header-nav {
		height: auto;
		padding-top: min(var(--spacing-container), var(--spacing-sm));
	}
	#header.index-header .header-nav::after {
		display: none !important;
	}
	#header.index-header .header-nav > .header-menu {
		grid-column: span 3;
	}

	[data-section="intro"] .sc-heading {
		font-size: var(--font-size-h3);
	}
}

/* ==================================================
intro load-in — heading shows centered over everything first, then the
loader fades to reveal the header + gallery (random, staggered)
================================================== */

/* pointer-events:none from the start (not just once the fade-out begins) —
   it's a purely visual cover for the gallery build-up. Header clickability
   is gated on the header's own opacity/.is-intro-revealed state below, so
   the loader never needs to intercept clicks itself. */
.intro-loader {
	position: fixed;
	inset: 0;
	z-index: 100;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	background: rgb(var(--color-background));
}

#page.index-page #header {
	opacity: 0;
	pointer-events: none;
}
#page.index-page.is-intro-revealed #header {
	opacity: 1;
	pointer-events: auto;
	transition: opacity var(--duration-slow) var(--easing);
}

/* The real heading (top of the section) has no cover of its own before JS
   creates .intro-loader — CSS paints faster than JS runs, so without this it
   flashes at the top before the loader (with its own cloned heading, kept
   visible since the clone isn't inside .sc-headline) takes over. */
[data-section="intro"] .sc-headline {
	opacity: 0;
}
#page.index-page.is-intro-revealed [data-section="intro"] .sc-headline {
	opacity: 1;
	transition: opacity var(--duration-slow) var(--easing);
}

.intro-gallery__item {
	opacity: 0;
	will-change: opacity;
}
.intro-gallery.is-revealed .intro-gallery__item {
	opacity: 1;
}

.cky-consent-container {
	opacity: 0;
	pointer-events: none;
}
.cky-consent-container.is-revealed {
	opacity: 1;
	pointer-events: auto;
	transition: opacity var(--duration-slow) var(--easing);
}
.cky-consent-container:not(.is-revealed),
.cky-consent-container:not(.is-revealed) * {
	pointer-events: none !important;
}

/* ==================================================
intro gallery — height-driven auto-fit rows, recalculated on resize
================================================== */

.intro-gallery {
	--gallery-item-ratio: 173 / 130;
	--gallery-item-min-height: 8.8rem;
	--gallery-item-max-height: 13rem;

	--gallery-rows: auto-fit;
	--gallery-rows-height: minmax(var(--gallery-item-min-height), var(--gallery-item-max-height));
	--gallery-rows-height--fixed: minmax(0, min(var(--gallery-item-max-height), calc((100% - ((var(--gallery-rows) - 1) * var(--gallery-gap))) / var(--gallery-rows))));

	--gallery-gap: clamp(0.4rem, 0.4166666667vw, 0.6rem);

	position: relative;
	width: -webkit-max-content;
	width: -moz-max-content;
	width: max-content;
	height: 100%;
	display: grid;
	align-content: center;
	grid-auto-flow: column;
	grid-template-rows: repeat(var(--gallery-rows), var(--gallery-rows-height));
	grid-gap: var(--gallery-gap);
}
.intro-gallery__item {
	position: relative;
	width: auto;
	height: 100%;
	aspect-ratio: var(--gallery-item-ratio);
	overflow: hidden;
}
.intro-gallery__item .object-fit {
	width: 100%;
	height: 100%;
}
@media (min-height: 480px) {
	.intro-gallery {
		--gallery-rows: 2;
		--gallery-rows-height: var(--gallery-rows-height--fixed);
	}
}

@media (min-height: 600px) {
	.intro-gallery {
		--gallery-rows: 3;
		--gallery-rows-height: var(--gallery-rows-height--fixed);
	}
}

@media (min-height: 681px) {
	.intro-gallery {
		--gallery-rows: 4;
		--gallery-rows-height: var(--gallery-rows-height--fixed);
	}
}

@media (orientation: portrait) and (max-width: 991px) {
	.intro-gallery {
		--gallery-rows: 6;
		--gallery-rows-height: var(--gallery-rows-height--fixed);
	}
}
