/*
 * Shell: the fixed sidebar rail, the content pane, and the page background.
 *
 * Desktop (62em+): the rail is pinned to the left edge at full height and the
 * pane scrolls beside it. Below that the rail becomes a bar above the content;
 * on inner pages it collapses to the name alone, as the 2025 theme did.
 *
 * The dock (dock.css) is fixed to the bottom on every screen size, so the rail
 * and pane both reserve --mc-dock-height at their bottom edge.
 */

:root {
	--cmdr-rail: var(--wp--custom--rail-width, 320px);
	--cmdr-admin-bar: var(--wp-admin--admin-bar--height, 0px);
	--cmdr-hairline: var(--wp--custom--hairline, rgba(141, 154, 168, 0.18));
	--cmdr-gutter: clamp(1.25rem, 4vw, 4rem);
}

/*
 * The stream-screen splatter (assets/images/splatter*) sits on a fixed layer
 * behind everything. A fixed pseudo-element works on iOS, where
 * background-attachment: fixed does not. Anchored left and low so the amber
 * glow in the image's bottom-left corner stays in view.
 *
 * html must stay without a background: that lets body's Basement color
 * propagate to the canvas instead of painting a box over this layer.
 */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background-color: var(--wp--preset--color--primary);
	background-image: var(--cmdr-bg-image);
	background-image: var(--cmdr-bg-image-set, var(--cmdr-bg-image));
	background-position: 0% 75%;
	background-size: cover;
	background-repeat: no-repeat;
}

/* Long words and wide embeds never push the page sideways on phones. */
.cmdr-shell {
	overflow-x: clip;
}

.wp-site-blocks > .cmdr-shell,
.cmdr-shell > * {
	margin-block: 0;
}

/* Rail
---------------------------------------------------------------------------- */

.cmdr-rail {
	position: relative;
	z-index: 20;
	background-color: rgba(12, 16, 21, 0.92);
	border-bottom: 1px solid var(--cmdr-hairline);
}

.cmdr-rail__inner {
	gap: 1.75rem;
	padding: 2.25rem 1.5rem;
	text-align: center;
}

.cmdr-rail__avatar {
	margin: 0;
}

.cmdr-rail__avatar img {
	display: block;
	width: 200px;
	height: auto;
	border-radius: 50%;
}

.cmdr-rail__avatar a {
	display: block;
	border-radius: 50%;
}

.cmdr-roles {
	margin: 0;
	padding: 0 !important;
	list-style: none;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: var(--wp--custom--tracking--label, 0.22em);
	text-transform: uppercase;
}

.cmdr-roles li {
	margin: 0;
	padding: 0.3rem 0;
}

/* One palette color per line: the old rainbow stack, brought into the basement. */
.cmdr-roles li:nth-child(4n + 1) { color: var(--wp--preset--color--aetheryte); }
.cmdr-roles li:nth-child(4n + 2) { color: var(--wp--preset--color--secondary); }
.cmdr-roles li:nth-child(4n + 3) { color: var(--wp--preset--color--haze); }
.cmdr-roles li:nth-child(4n + 4) { color: var(--wp--preset--color--lamplight); }

.cmdr-rail__id {
	gap: 0.75rem;
}

.cmdr-rail__name {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(2.5rem, 2rem + 1.5vw, 3.5rem);
	font-weight: 400;
	font-synthesis: none;
	line-height: 0.95;
	letter-spacing: 0.01em;
	text-transform: uppercase;
}

.cmdr-rail__name a {
	color: var(--wp--preset--color--secondary);
	text-decoration: none;
}

.cmdr-rail__name a:hover,
.cmdr-rail__name a:focus-visible {
	color: var(--wp--preset--color--lamplight);
}

/* Pane
---------------------------------------------------------------------------- */

.cmdr-pane {
	display: flex;
	flex-direction: column;
	min-height: calc(100vh - var(--cmdr-admin-bar));
	min-height: calc(100dvh - var(--cmdr-admin-bar));
	padding-bottom: calc(var(--mc-dock-height, 68px) + env(safe-area-inset-bottom, 0px));
}

.cmdr-pane > * {
	margin-block: 0;
}

.cmdr-main {
	flex: 1 0 auto;
	padding-top: clamp(2.5rem, 6vw, 5.5rem);
	padding-bottom: clamp(3rem, 6vw, 5rem);
}

@media (max-width: 61.99em) {
	.cmdr-main {
		flex: 0 0 auto;
		padding-top: 5rem !important;
		padding-bottom: 5rem);
	}
}

/* The front page centers its hero in the viewport, like the 2025 home. */
.cmdr-main--bare {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding-top: clamp(2rem, 4vw, 3rem);
}

.cmdr-main--404 {
	display: flex;
	flex-direction: column;
	justify-content: center;
}

/* Footer line
---------------------------------------------------------------------------- */

.cmdr-footer {
	padding: 1.25rem var(--cmdr-gutter) 1.5rem;
}

.cmdr-footline {
	gap: 0.5rem 2rem;
}

.cmdr-footline p {
	margin: 0;
	font-family: var(--wp--preset--font-family--mono);
	line-height: 1.3;
}

.cmdr-footline__link {
	font-size: clamp(1rem, 0.9rem + 0.4vw, 1.25rem);
}

.cmdr-footline__link a {
	color: var(--wp--preset--color--lamplight);
	text-decoration: none;
}

.cmdr-footline__link a:hover,
.cmdr-footline__link a:focus-visible {
	color: var(--wp--preset--color--secondary);
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

/* Matches .saying in screens/style.css. */
.cmdr-footline__saying {
	min-height: 1.3em;
	margin-left: auto !important;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	letter-spacing: 0.04em;
	text-align: right;
	overflow-wrap: anywhere;
	color: var(--wp--preset--color--haze);
}

@media (max-width: 61.99em) {
	.cmdr-footline__saying {
		margin-left: 0 !important;
		text-align: center;
		width: 100%;
	}
}

/* One span per character, built by assets/js/sayings.js for the scrambler. */
.cmdr-scramble span {
	display: inline-block;
	white-space: pre;
}

.cmdr-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Desktop: fixed rail
---------------------------------------------------------------------------- */

@media (min-width: 62em) {
	.cmdr-rail {
		position: fixed;
		top: var(--cmdr-admin-bar);
		bottom: 0;
		left: 0;
		width: var(--cmdr-rail);
		display: flex;
		flex-direction: column;
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-width: none;
		border-bottom: 0;
		border-right: 1px solid var(--cmdr-hairline);
	}

	.cmdr-rail::-webkit-scrollbar {
		display: none;
	}

	/*
	 * margin-block: auto centers the stack when it fits and lets it scroll
	 * from the top when it does not (short laptop screens), which
	 * justify-content: center would clip.
	 */
	.cmdr-rail__inner {
		margin-block: auto;
		gap: 2.5rem;
		padding: 3rem 1.75rem calc(var(--mc-dock-height, 78px) + 2rem);
	}

	.cmdr-pane {
		margin-left: var(--cmdr-rail);
	}

	/* Start the image at the rail's edge so the rail doesn't cover the glow. */
	body::before {
		left: var(--cmdr-rail);
	}
}

/* Short desktop screens: tighten the rail before it has to scroll. */
@media (min-width: 62em) and (max-height: 760px) {
	.cmdr-rail__inner {
		gap: 1.5rem;
		padding-top: 1.5rem;
	}

	.cmdr-rail__avatar img {
		width: 140px;
	}
}

/* Tablet and phone: rail becomes a top bar
---------------------------------------------------------------------------- */

@media (max-width: 61.99em) {
	.cmdr-rail__avatar img {
		width: 128px;
	}

	.cmdr-roles {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: 0.25rem 1.1rem;
		font-size: 0.75rem;
	}

	.cmdr-roles li {
		padding: 0;
	}

	/* Inner pages: the name alone, as in the 2025 compact header. */
	body:not(.home) .cmdr-rail__avatar,
	body:not(.home) .cmdr-roles,
	body:not(.home) .cmdr-socials {
		display: none;
	}

	body:not(.home) .cmdr-rail__inner {
		padding-block: 0.9rem 0.75rem;
	}

	body:not(.home) .cmdr-rail__name {
		font-size: 2.5rem;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.cmdr-rail__name a,
	.cmdr-footline a {
		transition: color 0.16s ease;
	}
}

@media print {
	body::before,
	.cmdr-rail,
	.cmdr-footer {
		display: none;
	}

	.cmdr-pane {
		margin: 0;
		padding: 0;
	}
}
