/* ===========================================================================
   RING — the 3-D boxing ring under the coaches grid
   The scene itself is drawn by assets/js/ring.js. Everything here is the frame
   around it: the box it occupies, the photograph that stands in until the
   first WebGL frame lands, and the atmosphere laid over the top.
   =========================================================================== */

.vub-ring {
	/* The canvas clears to this colour and ring.js reads it back off the
	   element, so the scene's background can never drift from the section's.
	   Change the band to .vub-section--alt and this follows it. */
	--vub-ring-bg: var(--vub-black);

	position: relative;
	/* Opens the section now, so it needs no gap above it — the band's own
	   dark headroom is the space. */
	margin-bottom: clamp(3rem, 6vw, 5.5rem);

	/* Full bleed. Cancels .vub-container's gutter so the band runs edge to
	   edge and there is no strip of page background either side of it.
	   .vub-container is width:100% with the gutter as padding, so negating it
	   lands exactly on the viewport edges — never wider, so this cannot
	   introduce a horizontal scrollbar. */
	margin-inline: calc(var(--vub-gutter) * -1);
}

.vub-ring__stage {
	position: relative;
	/* Taller than the ring needs. The renderer holds the horizontal field
	   fixed and derives the vertical one, so the extra height becomes room
	   around the ring rather than a smaller ring — see assets/js/ring.js.

	   The ceiling matters now the band runs full width: cap the height too low
	   and a wide screen leaves no vertical room to push the ring clear of the
	   heading laid over it. */
	height: clamp(420px, 62vw, 1000px);
	background-color: var(--vub-ring-bg);
	overflow: hidden;

	/* The floor in the scene already fades to --vub-ring-bg at its rim, so
	   this does nothing to the live render. It is what stops the stand-in
	   photograph reading as a cropped rectangle. */
	-webkit-mask-image: radial-gradient(126% 104% at 50% 44%, #000 56%, transparent 100%);
	mask-image: radial-gradient(126% 104% at 50% 44%, #000 56%, transparent 100%);
}

/* The hall as a photograph, behind a transparent canvas (ring.js draws
   only the ring and its shadow when this is present). Hung from above the
   stage and taller than it, at the picture's own proportions: cover-fitted
   to that taller box, its floor-to-seating line lands about a third of the
   way down the band, just behind the ring's far side, on every width, and
   its bottom edge never clears the band. The sides crop to the width;
   nothing is stretched. */
.vub-ring__backdrop {
	position: absolute;
	top: -14%;
	left: 0;
	width: 100%;
	height: 114%;
	object-fit: cover;
	object-position: 50% 50%;
	pointer-events: none;
}

/* Its haze is in the picture already. */
.vub-ring--backdrop .vub-ring__glow { display: none; }

.vub-ring__poster,
.vub-ring__canvas {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
}

.vub-ring__poster {
	object-fit: cover;
	object-position: 60% 50%;
	opacity: 1;
	transition: opacity var(--vub-duration-slow) var(--vub-ease-out);
}

.vub-ring__canvas {
	opacity: 0;
	transition: opacity var(--vub-duration-slow) var(--vub-ease-out);
}

/* ring.js adds this while the pointer is over one of the four corner
   assemblies — the only part of the scene that is clickable. */
.vub-ring__canvas.is-over-corner { cursor: pointer; }

/* The stage becomes focusable once the scene is running, so it needs a focus
   ring like every other control. Drawn outside the mask, which clips the
   canvas but not the outline. */
.vub-ring__stage:focus-visible {
	outline: 2px solid var(--vub-focus);
	outline-offset: 3px;
}

/* First frame is on the canvas: cross-fade the photograph out from under it.
   Both layers are already the same near-black, so the swap reads as the lights
   coming up rather than as one picture replacing another. */
.vub-ring.is-ready .vub-ring__poster { opacity: 0; }
.vub-ring.is-ready .vub-ring__canvas { opacity: 1; }

/* No WebGL2, or the context was lost: the photograph simply stays. */
.vub-ring.is-unavailable .vub-ring__canvas { display: none; }

/* The section's heading, laid over the top-left of the band.

   Real markup rather than anything painted into the canvas, so it stays
   selectable and is the section's only <h2>. The renderer keeps the top of the
   frame clear of geometry (CAMERA.headroom in ring.js), so the two never
   collide however the ring is turned. */
.vub-ring__overlay {
	position: absolute;
	inset: 0 0 auto 0;
	z-index: 2;
	padding-top: var(--vub-ring-head-pad);
	padding-bottom: clamp(3rem, 7vw, 6rem);
	/* Puts the gutter back for the heading alone, so it stays on the same
	   left edge as the coach cards below while the band behind it runs full
	   width. */
	padding-inline: var(--vub-gutter);
	/* Clicks fall through to the ring; the heading itself takes them back so
	   the text can still be selected. */
	pointer-events: none;

	/* Belt and braces. The renderer already keeps the top of the frame clear,
	   but on a band wide enough that it cannot free the full headroom the
	   post caps can reach up behind the text. This guarantees the contrast
	   either way, and it fades out before the ring at every normal shape, so
	   it costs nothing when it is not needed. */
	background: linear-gradient(
		to bottom,
		rgba(8, 9, 10, 0.88) 0%,
		rgba(8, 9, 10, 0.55) 45%,
		transparent 100%
	);
}

.vub-ring__overlay .vub-section__head {
	max-width: min(46rem, 100%);
	margin-bottom: 0;
	pointer-events: auto;
}

/* Atmosphere. Haze from the rig overhead and the red spill off the back wall,
   screened over the render the way it sits in the reference photograph. Doing
   it in CSS keeps it out of the shader, where it would have cost a
   raymarch. */
.vub-ring__glow {
	position: absolute;
	inset: 0;
	/* Above the vignette below, which is generated content and would otherwise
	   paint last and darken the haze at exactly the top edge it lives on. */
	z-index: 1;
	pointer-events: none;
	opacity: 0;
	mix-blend-mode: screen;
	transition: opacity 900ms var(--vub-ease-out);
	background:
		radial-gradient(44% 32% at 62% 0%,  rgba(255, 246, 232, 0.10), transparent 68%),
		radial-gradient(24% 20% at 37% 0%,  rgba(255, 246, 232, 0.07), transparent 72%),
		radial-gradient(38% 50% at 94% 44%, rgba(216, 31, 42, 0.11),   transparent 74%);
}

.vub-ring.is-ready .vub-ring__glow { opacity: 1; }

/* Vignette, over the render and under the glow. Pulls the corners down into
   the section background so the band has no perceptible edge. */
.vub-ring__stage::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: radial-gradient(78% 88% at 50% 46%, transparent 42%, rgba(8, 9, 10, 0.55) 100%);
}

/* The room (ring.js, FS_ROOM): the band above and the band below carried on
   as the wall behind the ring and the floor under it, read from where the
   page lays them out. It is the page's background, so nothing here may
   cover, mask, shade or fade it: the stage, its mask and vignette, the
   heading's shade and the haze all stand down. (The stand-in photograph is
   still there until the first frame, and stays without WebGL; the scene
   starts loading well before the section is in view.) */
.vub-ring--room .vub-ring__stage {
	-webkit-mask-image: none;
	mask-image: none;
	background-color: transparent;
	overflow: visible;
}

.vub-ring--room .vub-ring__stage::after,
.vub-ring--room .vub-ring__glow { display: none; }

.vub-ring--room .vub-ring__overlay { background: none; }

/* The canvas reaches 2px into each band, over them (z-index): what it draws
   there is their own picture, so the overlap is invisible, and the section's
   edges, which rarely fall on whole device pixels, are never a row the two
   share half and half with the page's black between them. */
.vub-ring--room { z-index: 1; }

.vub-ring--room .vub-ring__canvas {
	top: -2px;
	height: calc(100% + 4px);
}

/* The band below opens on the room's floor, not on the page's black: its
   picture runs right up to its top edge (it fades out only at its foot). */
.vub-coaches:has(.vub-ring--room) + .vub-band.vub-parallax--seamless::after {
	background: linear-gradient(
		to bottom,
		rgba(8, 9, 10, 0) calc(100% - var(--vub-seam)),
		var(--vub-black) 100%
	);
}

/* --------------------------------------------------------------------------
   Narrow viewports. The scene reframes itself from the canvas aspect ratio, so
   the only thing to do here is give it a shape that suits a phone.
   -------------------------------------------------------------------------- */
@media (max-width: 782px) {
	.vub-ring {
		margin-bottom: var(--vub-space-xl);
	}

	.vub-ring__stage {
		/* The renderer keeps a fixed *fraction* of the frame clear for the
		   heading, so on a short band that fraction is too few pixels for the
		   title to sit above the posts. Tall enough here that it is not. */
		height: clamp(440px, 92vw, 560px);
	}

	/* On :root, not the overlay, so the gallery heading's matching gap
	   follows it — see sections.css. */
	:root {
		--vub-ring-head-pad: var(--vub-space-sm);
	}
}

/* Reduced motion: ring.js draws a single static frame instead of animating,
   and the cross-fade goes with the duration tokens, which are already 1ms. */
