/* Shared site chrome: the wrap, the top nav and the buttons.

   The nav is one component (src/components/SiteNav.astro) used by both the
   story layout and the article layout, so these rules have to reach both.
   Article-specific styles stay in article.css, which carries :root and body
   rules the story page must not inherit.

   Every value comes from comparedrawing.css, which both layouts import first. */

.wrap {
	max-width: var(--wrap-max);
	margin: 0 auto;
	padding: 0 var(--wrap-pad);
}

/* --- nav --------------------------------------------------------------- */

.nav {
	position: sticky;
	top: 0;
	z-index: 20;
	background: var(--blue-800);
	border-bottom: var(--border-width) solid var(--line-on-dark);
}

.nav .wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-5);
	flex-wrap: wrap;
	padding-top: 18px;
	padding-bottom: 18px;
}

.mark {
	display: flex;
	align-items: center;
	gap: var(--gap-icon-text);
	font:
		var(--weight-medium) var(--text-meta) / var(--leading-flat)
		var(--font-sans);
	color: var(--paper);
}

.mark:hover {
	color: var(--paper);
}

.mark svg {
	flex: none;
}

.navlinks {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--space-7);
}

.navlink {
	font:
		var(--weight-medium) var(--text-meta) / var(--leading-flat)
		var(--font-sans);
	color: var(--paper-dim);
	padding: 6px 0;
	border-top: 2px solid transparent;
	border-bottom: 2px solid transparent;
}

.navlink:hover {
	color: var(--paper);
}

.navlink[aria-current="page"] {
	color: var(--paper);
	border-bottom-color: var(--redline-500);
}

/* --- button ------------------------------------------------------------ */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--gap-icon-text);
	font: var(--type-button);
	padding: var(--pad-button-y) var(--pad-button-x);
	border: var(--border-action);
	border-radius: var(--radius-none);
	background: var(--action-bg);
	color: var(--action-fg);
	cursor: pointer;
	transition: var(--transition-action);
}

.btn:hover {
	background: var(--action-bg-hover);
	color: var(--action-fg-hover);
	border-color: var(--action-border);
}

.btn-sm {
	font-size: var(--text-meta);
	padding: 10px 18px;
}

/* --- language switcher -------------------------------------------------- */

/* Component-scoped in the Astro site (a <style> block inside
   LanguageSwitcher.astro, which Astro scopes to that component). A classic
   WordPress theme has no scoping, so the rules live here, next to the nav they
   sit in. Nothing else on the site uses a .lang* class, so the move changes
   nothing but where the file boundary falls. */

.langswitch {
	position: relative;
}

/* The triangle the browser adds to a summary, removed in both engines. */
.langtoggle {
	list-style: none;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 5px 8px;
	font:
		var(--weight-medium) var(--text-micro) / var(--leading-flat)
		var(--font-mono);
	letter-spacing: var(--tracking-mono-wide);
	color: var(--paper-dim);
	border: var(--border-width) solid var(--line-on-dark);
	cursor: pointer;
	user-select: none;
	transition: var(--transition-action);
}

.langtoggle::-webkit-details-marker {
	display: none;
}

.langtoggle:hover {
	color: var(--paper);
	border-color: var(--line-on-dark-strong);
}

.langtoggle:focus-visible {
	outline: var(--border-width) solid var(--focus-ring);
	outline-offset: 2px;
}

.langswitch[open] > .langtoggle {
	color: var(--paper);
	border-color: var(--redline-500);
}

.langcaret {
	transition: transform 120ms ease;
}

.langswitch[open] .langcaret {
	transform: rotate(180deg);
}

/* Right-aligned: the switcher is the last thing in the nav, so a menu hanging
   left of its edge is the one that stays on screen. */
.langmenu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	z-index: 30;
	min-width: 9.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
	background: var(--blue-900);
	border: var(--border-width) solid var(--line-on-dark-strong);
}

.langmenu li + li {
	border-top: var(--border-width) solid var(--line-on-dark);
}

.langlink {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-5);
	padding: 9px 12px;
	font:
		var(--weight-medium) var(--text-meta) / var(--leading-flat)
		var(--font-sans);
	color: var(--paper-dim);
	white-space: nowrap;
	transition: var(--transition-action);
}

.langlink:hover {
	color: var(--paper);
	background: var(--fill-on-dark);
}

.langlink:focus-visible {
	outline: var(--border-width) solid var(--focus-ring);
	outline-offset: -2px;
}

.langabbr {
	font:
		var(--weight-regular) var(--text-micro) / var(--leading-flat)
		var(--font-mono);
	letter-spacing: var(--tracking-mono-wide);
	opacity: 0.55;
}

/* The current language stays listed, marked rather than removed, so the menu is
   the same length and in the same order on every page. */
.langlink[aria-current="true"] {
	color: var(--paper);
}

.langlink[aria-current="true"] .langabbr {
	color: var(--redline-500);
	opacity: 1;
}

/* --- skip link ---------------------------------------------------------- */

/* Not in the Astro site, and it should have been: the nav is the first thing
   in the tab order on every page and a keyboard reader has to walk all of it
   to reach the article. Visible only when focused. */
.skip {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 40;
	padding: var(--space-3) var(--space-5);
	background: var(--redline-500);
	color: var(--paper);
	font: var(--type-button);
	font-size: var(--text-meta);
}

.skip:focus {
	left: 0;
	color: var(--paper);
}

@media (prefers-reduced-motion: reduce) {
	.langcaret {
		transition: none;
	}
}
