/*
 * The doors (2026-10-27; inc/doors.php, assets/js/doors.js): one component
 * for the Home intro and the course finder's results. Red
 * panels framed in gold, a gold seam, the crest split over it, the name and
 * motto on a plaque under it. Fixed above everything, so nothing shifts;
 * only without a reduced-motion preference. The script moves everything
 * (transform and opacity); the start states are here.
 *
 * Home (.doors--intro): under html.intro-on (set in <head>), closed from the
 * first paint; hidden after 4 s even if its script never runs.
 * Finder (.doors--finder): while they move (.is-active), and closed from the
 * first paint for a deep link (html.finder-closed).
 */
.doors {
	display: none;
}

@media (prefers-reduced-motion: no-preference) {
	.intro-on .doors--intro,
	.finder-closed .doors--finder,
	.doors--finder.is-active {
		--crest-w: clamp(7rem, 5rem + 6vw, 10rem);
		--crest-h: calc(var(--crest-w) * 353 / 320);
		--crest-y: 40%;
		display: block;
		position: fixed;
		inset: 0;
		z-index: 1001; /* above the skip link */
		overflow: hidden;
		perspective: clamp(40rem, 100vw, 90rem);
		perspective-origin: 50% var(--crest-y);
	}

	.intro-on .doors--intro {
		animation: doors-safety 0s linear 4s forwards;
	}
}

@keyframes doors-safety {
	to {
		visibility: hidden;
	}
}

/* Warm light, behind the doors: seen through the gap as they part. */
.doors__light {
	position: absolute;
	inset: 0;
	background: linear-gradient(
		90deg,
		transparent 32%,
		color-mix(in srgb, var(--color-accent) 70%, transparent) 50%,
		transparent 68%
	);
	opacity: 0;
	transform: scaleX(0.15);
}

.doors__door {
	position: absolute;
	top: 0;
	bottom: 0;
	width: calc(50% + 1px);
	overflow: hidden;
	background: var(--color-frame);
	backface-visibility: hidden;
	will-change: transform;
}

/* Two frames per panel: the finder's, and a finer one inside it. */
.doors__door::before,
.doors__door::after {
	content: "";
	position: absolute;
	border-radius: 0.5rem;
}

.doors__door::before {
	inset: clamp(1rem, 4vw, 2.5rem);
	border: 2px solid color-mix(in srgb, var(--color-accent) 55%, transparent);
}

.doors__door::after {
	inset: clamp(1.75rem, 6vw, 3.75rem);
	border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
}

.doors__door--left {
	left: 0;
	transform-origin: 0 50%;
	box-shadow: inset -3px 0 0 var(--color-accent);
}

.doors__door--right {
	right: 0;
	transform-origin: 100% 50%;
	box-shadow: inset 3px 0 0 var(--color-accent);
}

/* Darkens the panel as it turns away. */
.doors__shade {
	position: absolute;
	inset: 0;
	z-index: 2;
	background: var(--color-primary-dark);
	opacity: 0;
}

.doors__door img {
	position: absolute;
	top: var(--crest-y);
	z-index: 1;
	width: var(--crest-w);
	max-width: none;
	height: auto;
	opacity: 0;
}

.doors__door--left img {
	right: 0;
	transform: translate(50%, -50%) scale(0.8);
}

.doors__door--right img {
	left: 0;
	transform: translate(-50%, -50%) scale(0.8);
}

/* The finder's crest is on the seam from the start (the doors close with it). */
.doors--finder .doors__door img {
	opacity: 1;
}

.doors--finder .doors__door--left img {
	transform: translate(50%, -50%);
}

.doors--finder .doors__door--right img {
	transform: translate(-50%, -50%);
}

/* The hold's glow, and the light sweeping across the crest (its shape). */
.doors__glow,
.doors__sweep {
	position: absolute;
	top: var(--crest-y);
	left: 50%;
	pointer-events: none;
	opacity: 0;
}

.doors__glow {
	width: calc(var(--crest-w) * 2.4);
	aspect-ratio: 1;
	border-radius: 50%;
	background: radial-gradient(
		closest-side,
		color-mix(in srgb, var(--color-accent) 75%, transparent),
		color-mix(in srgb, var(--color-accent) 25%, transparent) 55%,
		transparent
	);
	mix-blend-mode: screen;
	transform: translate(-50%, -50%) scale(0.85);
}

.doors__sweep {
	width: var(--crest-w);
	height: var(--crest-h);
	overflow: hidden;
	transform: translate(-50%, -50%);
	-webkit-mask: url("../img/crest-320.webp") center / 100% 100% no-repeat;
	mask: url("../img/crest-320.webp") center / 100% 100% no-repeat;
}

.doors__shine {
	position: absolute;
	inset: 0;
	background: linear-gradient(
		105deg,
		transparent 25%,
		color-mix(in srgb, var(--color-on-dark) 45%, var(--color-accent)) 50%,
		transparent 75%
	);
	transform: translateX(-110%);
}

/* The plaque covers the seam behind the text; same text in both languages. */
.doors__text {
	position: absolute;
	top: calc(var(--crest-y) + var(--crest-h) / 2 + clamp(1rem, 3vh, 2rem));
	left: 50%;
	width: max-content;
	max-width: calc(100% - 2 * var(--space));
	padding: 0.75rem clamp(1rem, 3vw, 2rem);
	border-block: 1px solid color-mix(in srgb, var(--color-accent) 60%, transparent);
	background: var(--color-frame);
	color: var(--color-on-dark);
	font-family: var(--font-latin);
	text-align: center;
	text-wrap: balance;
	opacity: 0;
	translate: -50% 0;
}

.doors__name,
.doors__motto {
	margin: 0;
	opacity: 0;
	transform: translateY(0.75rem);
}

.doors__name {
	font-size: clamp(1.375rem, 1rem + 2vw, 2.25rem);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: 0.04em;
}

.doors__motto {
	margin-top: 0.5rem;
	color: var(--color-accent); /* on the frame 5.7:1 */
	font-size: clamp(0.9375rem, 0.85rem + 0.6vw, 1.25rem);
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.03em;
}

@media print {
	.doors {
		display: none !important;
	}
}

