/*
 * layout.css — the three-column shell, the header, the footer and the mobile bottom bar.
 *
 * Mobile first: everything above the first media query is the phone layout.
 */

/* ------------------------------------------------------------------------------- Header. */

.srt-header {
	position: sticky;
	top: 0;
	z-index: 30;
	background: var(--srt-bg-elevated);
	border-bottom: 1px solid var(--srt-border);
}

.srt-header__inner {
	display: flex;
	align-items: center;
	gap: var(--srt-space-md);
	max-width: var(--srt-wide);
	min-height: var(--srt-header-height);
	margin: 0 auto;
	padding: var(--srt-space-xs) var(--srt-space-md);
}

.srt-brand {
	display: flex;
	align-items: center;
	gap: var(--srt-space-xs);
	margin-right: auto;
	text-decoration: none;
	color: var(--srt-text);
}

.srt-brand__mark {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	background: var(--srt-accent);
	color: var(--srt-on-accent);
	border-radius: var(--srt-radius);
	font-weight: 700;
}

.srt-brand__name {
	display: block;
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: 0.01em;
}

.srt-brand__tagline {
	display: block;
	font-size: 0.75rem;
	color: var(--srt-text-muted);
	line-height: 1.3;
}

.srt-header__nav ul {
	display: flex;
	align-items: center;
	gap: var(--srt-space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

.srt-header__nav a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 var(--srt-space-sm);
	border-radius: var(--srt-radius);
	color: var(--srt-text-muted);
	text-decoration: none;
	font-weight: 600;
	white-space: nowrap;
}

.srt-header__nav a:hover {
	background: var(--srt-surface-hover);
	color: var(--srt-text);
}

.srt-header__nav .current-menu-item > a,
.srt-header__nav [aria-current="page"] {
	color: var(--srt-text);
	background: var(--srt-surface-2);
}

.srt-header__actions {
	display: flex;
	align-items: center;
	gap: var(--srt-space-2xs);
}

.srt-icon-button {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--srt-radius);
	color: var(--srt-text-muted);
	cursor: pointer;
}

.srt-icon-button:hover {
	background: var(--srt-surface-hover);
	color: var(--srt-text);
}

.srt-badge-dot {
	position: relative;
}

.srt-badge-dot__count {
	position: absolute;
	top: 4px;
	right: 4px;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	background: var(--srt-accent);
	color: var(--srt-on-accent);
	border-radius: var(--srt-radius-pill);
	font-size: 0.68rem;
	font-weight: 700;
	line-height: 17px;
	text-align: center;
}

/*
 * ⚠️ 640px, and it is the same number as the bottom bar's. Below it the bar carries navigation and
 * the ask button, so showing them here too pushed the language switcher onto a third row.
 */
@media (max-width: 639px) {
	.srt-header__nav,
	.srt-header__actions .srt-header__auth {
		display: none;
	}

	.srt-brand__tagline {
		display: none;
	}
}

/* ------------------------------------------------------------------------- The shell. */

/*
 * ⚠️ DOCUMENT ORDER IS main, rail, utility — and the rail is put back on the left by CSS below.
 *
 * On a phone the shell is display:block and the columns stack in document order, so a reader opening
 * a question sees the question rather than twenty-two category links. Content before navigation is
 * also the better order for a screen reader and for the no-CSS fallback a theme swap can produce.
 *
 * ⚠️ THE SHELL MUST NOT BE A FLEX CONTAINER ON MOBILE, and reordering with `order:` is the trap that
 * makes it one. Two separate mechanisms then blow the page sideways:
 *
 *   - flex-wrap: wrap in a COLUMN-direction container wraps along the HORIZONTAL axis, so a child
 *     wider than the container starts its own flex line beside it instead of being constrained by it.
 *   - align-items: start, which the desktop grid wants, means "as wide as your content asks for" on
 *     the cross axis of a column flex container.
 *
 * Either one lets the category strip size to all 22 categories laid end to end and drags the
 * document ~4700px sideways — the exact failure NF-07 235 forbids, produced by the rule meant to
 * prevent it. Neither min-width: 0 nor overflow-x: auto on the child prevents either.
 *
 * So: plain display:block on mobile, and nothing is reordered.
 */
.srt-shell {
	display: block;
	max-width: var(--srt-wide);
	margin: 0 auto;
	padding: var(--srt-space-md);
}

.srt-shell > * + * {
	margin-top: var(--srt-space-lg);
}

.srt-main {
	min-width: 0;
}

.srt-rail,
.srt-utility {
	min-width: 0;
}

@media (min-width: 1024px) {
	.srt-shell {
		display: grid;
		grid-template-columns: var(--srt-rail-width) minmax(0, 1fr) var(--srt-utility-width);
		align-items: start;
		gap: var(--srt-space-lg);
		padding: var(--srt-space-lg) var(--srt-space-md);
	}

	.srt-shell > * + * {
		margin-top: 0;
	}

	/* Main is first in the markup and second on screen; the rail moves left without `order:`. */
	.srt-main {
		grid-column: 2;
		grid-row: 1;
	}

	.srt-rail {
		grid-column: 1;
		grid-row: 1;
	}

	.srt-utility {
		grid-column: 3;
		grid-row: 1;
	}

	.srt-shell--two-column {
		grid-template-columns: var(--srt-rail-width) minmax(0, 1fr);
	}

	.srt-shell--two-column .srt-utility {
		display: none;
	}

	.srt-shell--single {
		display: block;
		max-width: calc(var(--srt-content) + 8rem);
	}
}

/* A tablet gets the rail but not the utility column — NF-07 237. */
@media (min-width: 640px) and (max-width: 1023px) {
	.srt-utility {
		columns: 2;
		column-gap: var(--srt-space-lg);
	}

	.srt-utility > * {
		break-inside: avoid;
	}
}

/* -------------------------------------------------------------------------- Panels. */

.srt-panel {
	background: var(--srt-surface);
	border: 1px solid var(--srt-border);
	border-radius: var(--srt-radius-lg);
	padding: var(--srt-space-md);
}

.srt-panel + .srt-panel {
	margin-top: var(--srt-space-md);
}

.srt-panel__title {
	display: flex;
	align-items: center;
	gap: var(--srt-space-xs);
	margin: 0 0 var(--srt-space-sm);
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--srt-text-muted);
}

.srt-panel__footer {
	margin-top: var(--srt-space-sm);
	padding-top: var(--srt-space-sm);
	border-top: 1px solid var(--srt-border);
	font-size: 0.9rem;
}

/* ------------------------------------------------------------------------------ Hero. */

.srt-hero {
	position: relative;
	overflow: hidden;
	border-radius: var(--srt-radius-lg);
	border: 1px solid var(--srt-border);
	background: var(--srt-surface-2);
	padding: var(--srt-space-xl) var(--srt-space-lg);
	margin-bottom: var(--srt-space-lg);
}

.srt-hero__media {
	position: absolute;
	inset: 0;
	z-index: 0;
}

.srt-hero__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.srt-hero__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, var(--srt-overlay) 35%, transparent 100%);
}

.srt-hero__body {
	position: relative;
	z-index: 1;
	max-width: 34rem;
}

.srt-hero__title {
	margin-bottom: var(--srt-space-2xs);
}

.srt-hero__text {
	color: var(--srt-text-muted);
}

/* ------------------------------------------------------------------- Category list. */

.srt-termlist {
	margin: 0;
	padding: 0;
	list-style: none;
}

.srt-termlist a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--srt-space-xs);
	min-height: 40px;
	padding: var(--srt-space-2xs) var(--srt-space-xs);
	border-radius: var(--srt-radius-sm);
	color: var(--srt-text);
	text-decoration: none;
	font-size: 0.94rem;
}

.srt-termlist a:hover {
	background: var(--srt-surface-hover);
}

.srt-termlist__count {
	color: var(--srt-text-faint);
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------------------- Footer. */

.srt-footer {
	margin-top: var(--srt-space-2xl);
	padding: var(--srt-space-xl) var(--srt-space-md);
	border-top: 1px solid var(--srt-border);
	background: var(--srt-bg-elevated);
	color: var(--srt-text-muted);
}

.srt-footer__inner {
	display: flex;
	flex-wrap: wrap;
	gap: var(--srt-space-lg);
	justify-content: space-between;
	max-width: var(--srt-wide);
	margin: 0 auto;
}

.srt-footer ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.srt-footer a {
	color: var(--srt-text-muted);
}

.srt-footer a:hover {
	color: var(--srt-text);
}

/* -------------------------------------------------------------- Mobile bottom bar (F-35). */

.srt-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 40;
	display: flex;
	align-items: stretch;
	background: var(--srt-bg-elevated);
	border-top: 1px solid var(--srt-border);
	/* NF-08 242: respect the home indicator rather than sitting under it. */
	padding-bottom: env(safe-area-inset-bottom, 0);
}

.srt-bar__item {
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: var(--srt-bar-height);
	padding: var(--srt-space-3xs);
	color: var(--srt-text-muted);
	text-decoration: none;
	font-size: 0.68rem;
	font-weight: 600;
}

.srt-bar__item[aria-current="page"] {
	color: var(--srt-accent-text);
}

.srt-bar__icon {
	display: block;
	width: 22px;
	height: 22px;
}

/* The central + is the ask button, and carries no label in the mockup (F-35 187). */
.srt-bar__ask {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	margin: calc((var(--srt-bar-height) - 48px) / 2) var(--srt-space-2xs);
	background: var(--srt-accent);
	color: var(--srt-on-accent);
	border-radius: 50%;
	box-shadow: var(--srt-shadow-sm);
	text-decoration: none;
}

.srt-bar__ask:hover {
	background: var(--srt-accent-hover);
	color: var(--srt-on-accent);
}

/*
 * ⚠️ These two rules are ONE decision, and 640/639 is ONE number.
 *
 * The bar shows below 640px and the padding that clears it stops at 639px. Hiding the bar at a
 * larger breakpoint — 1024px, say — leaves a 384px-wide band in which a fixed bar sits on top of the
 * footer with nothing making room for it, and the last item of every page is unreachable.
 */
@media (max-width: 639px) {
	body {
		padding-bottom: calc(var(--srt-bar-height) + env(safe-area-inset-bottom, 0px));
	}
}

@media (min-width: 640px) {
	.srt-bar {
		display: none;
	}
}
