/**
 * Shared content + sticky right rail layout (Ben, 22 Oct 2026).
 *
 * Ben approved the programme split from #116 (content 3/4, sticky rail 1/4)
 * and asked for "any page that has had the right hand column fixed" to get the
 * same treatment. Every template with a fixed right-hand column now carries:
 *
 *   .fz-rail-layout          the two-column grid wrapper
 *   .fz-rail-layout__main    the content column
 *   .fz-rail-layout__rail    the sticky aside
 *
 * Used by single-programme, single-experiment, single (articles and posts),
 * single-podcast and single-trivia. Per-template sheets keep their own
 * cosmetics (borders, boxes, gaps inside the rail) but no longer set the
 * column tracks, so the split is defined once, here.
 *
 * Selectors are doubled (0,2,0) so they beat the older per-template rules
 * such as `.programme-layout` and `.booking-rail` whatever the load order.
 *
 * Sticky offset: templates whose rail must clear the sticky site header set
 * --fz-rail-top on the wrapper (article.css does, 96px).
 */

/* Width. Each layout wrapper sits inside an `is-layout-constrained` group, so
 * it inherited theme.json contentSize (840px on experiments, 1200px on
 * articles) and the content column was left with ~488px at 1440 on the
 * experiments. Size it to the design-system container token instead, as #116
 * did for the programme pages. A max-width only: the wrapper never grows past
 * its parent's padded box, so this cannot cause horizontal scroll. */
.is-layout-constrained > .fz-rail-layout.fz-rail-layout {
	max-width: min(var(--container, 1200px), calc(100vw - 2rem));
	margin-left: auto;
	margin-right: auto;
}

.fz-rail-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--s-6, 2rem);
	align-items: start;
}

.fz-rail-layout__main,
.fz-rail-layout__rail {
	min-width: 0;
}

/* The content column is itself constrained (840px) in most templates; lift
 * that clamp so headings, images, tables and the AEO box use the full 3/4.
 * Body copy inside post-content keeps its own 840px reading width. */
.fz-rail-layout__main.is-layout-constrained > *:not(.alignfull) {
	max-width: none;
}

/* Below 1025px: one column, rail under the content, not sticky. */
@media (max-width: 1024px) {
	.fz-rail-layout > .fz-rail-layout__rail {
		position: static;
		max-width: none;
	}
}

/* 1025px and up: content 3/4, sticky rail 1/4. The rail never drops below
 * 300px so its boxes stay usable between 1025px and ~1280px; the content
 * column takes what is left. */
@media (min-width: 1025px) {
	.fz-rail-layout.fz-rail-layout {
		grid-template-columns: minmax(0, 3fr) minmax(300px, 1fr);
		gap: var(--s-7, 3rem);
	}

	.fz-rail-layout > .fz-rail-layout__rail {
		position: sticky;
		/* --fz-header-h is the live sticky-header height, set by mobile-nav.js. */
		top: calc(var(--fz-header-h, 0px) + var(--fz-rail-top, var(--s-5, 1.5rem)));
		align-self: start;
		max-width: none;
		/* Always reachable (Ben, Cliq 1793083078297_3429465617759, 27 Oct 2026): a rail
		 * taller than the space under the sticky header lost its top box while the page
		 * scrolled. It is capped to that space and scrolls on its own; a rail that fits
		 * never reaches the cap, so it looks and behaves exactly as before. */
		max-height: calc(100vh - var(--fz-header-h, 0px) - var(--fz-rail-top, var(--s-5, 1.5rem)) - var(--s-4, 1rem));
		overflow-y: auto;
		scrollbar-width: thin;
	}
}
