/* The Menu link, the sticky bar that carries it and the poster index (src/lib/menu-markup.ts), for the
   site (design 1) and design 2. Colours are the pages' own tokens (--red, --indigo, --butter, --ink,
   --paper). */

:root {
	--sticky-bar-h: 60px;
}
/* Whatever keyboard focus scrolls to lands below the sticky bar, not under it. */
html {
	scroll-padding-top: var(--sticky-bar-h);
}
/* Out of sight above the screen until src/lib/menu.ts slides it down, once the header's universe row
   has gone. Without JavaScript it never comes; the universe row and the footer's index serve. Design 1's
   look; a design sets the --sticky-bar- properties for its own. */
.sticky-bar {
	position: fixed;
	inset: 0 0 auto;
	z-index: 30;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	box-sizing: border-box;
	height: var(--sticky-bar-h);
	padding: 8px var(--sticky-bar-pad, max(var(--gutter, 16px), (100% - var(--content, 100%)) / 2));
	border-bottom: var(--sticky-bar-rule, 1px solid var(--ink));
	background: var(--sticky-bar-bg, var(--paper));
	color: var(--sticky-bar-fg, var(--ink));
	visibility: hidden;
	transform: translateY(-100%);
}
.sticky-bar.is-shown {
	visibility: visible;
	transform: none;
}
@media (prefers-reduced-motion: no-preference) {
	.sticky-bar {
		transition:
			transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
			visibility 0s 220ms;
	}
	.sticky-bar.is-shown {
		transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
	}
}
.sticky-bar__mark {
	display: block;
	width: 150px;
	line-height: 0;
}
.sticky-bar__mark svg {
	width: 100%;
	height: auto;
}

.menu-button,
.search-button {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 6px 16px;
	border: 2px solid currentColor;
	color: inherit;
	font-family: "Anybody", "Arial Narrow", Arial, sans-serif;
	font-size: 0.85rem;
	font-weight: 800;
	font-stretch: 105%;
	letter-spacing: 0.08em;
	line-height: 1;
	text-decoration: none;
	text-transform: uppercase;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background-color 150ms,
		color 150ms,
		border-color 150ms;
}
/* Three bars, drawn, before the word. */
.menu-button::before {
	content: "";
	width: 16px;
	height: 12px;
	background:
		linear-gradient(currentColor 0 0) top / 100% 2px no-repeat,
		linear-gradient(currentColor 0 0) center / 100% 2px no-repeat,
		linear-gradient(currentColor 0 0) bottom / 100% 2px no-repeat;
}
.menu-button:hover,
.search-button:hover {
	border-color: var(--butter);
	background: var(--butter);
	color: var(--ink);
}

/* Search beside the Menu link, in the site's sticky bar (src/lib/menu.ts opens it). */
.sticky-bar__tools {
	display: flex;
	align-items: center;
	gap: 10px;
}
/* A magnifier, drawn, before the word. */
.search-button::before {
	content: "";
	width: 15px;
	height: 15px;
	background: currentColor;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='6.5' cy='6.5' r='5' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='m10.2 10.2 4.6 4.6' stroke='black' stroke-width='2.2'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sticky-bar.is-searching .search-button {
	display: none;
}
.sticky-search {
	display: flex;
	align-items: center;
	gap: 8px;
}
.sticky-search[hidden] {
	display: none;
}
.sticky-search__input {
	width: min(320px, 34vw);
	min-width: 0;
	height: 44px;
	padding: 0 14px;
	border: 2px solid currentColor;
	border-radius: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-body, Georgia, serif);
	font-size: 1rem;
}
/* The bar has its own close button; the browser's clear cross beside it would be a second. */
.sticky-search__input::-webkit-search-cancel-button {
	appearance: none;
}
.sticky-search__close {
	position: relative;
	flex: none;
	width: 44px;
	height: 44px;
	border: 2px solid currentColor;
	background: transparent;
	color: inherit;
	cursor: pointer;
}
/* A cross, drawn. */
.sticky-search__close::before,
.sticky-search__close::after {
	content: "";
	position: absolute;
	inset: 50% 10px auto;
	height: 2px;
	background: currentColor;
	rotate: 45deg;
}
.sticky-search__close::after {
	rotate: -45deg;
}
.sticky-search__close:hover {
	border-color: var(--butter);
	background: var(--butter);
	color: var(--ink);
}
/* On a phone the open field takes the whole bar, and Search is its magnifier alone (still named Search). */
@media (max-width: 699px) {
	.sticky-search {
		position: absolute;
		inset: 0;
		z-index: 1;
		padding: 8px var(--gutter, 16px);
		background: var(--sticky-bar-bg, var(--paper));
	}
	.sticky-search__input {
		flex: 1;
		width: auto;
	}
	/* Covered by the open field, so they must not take focus. */
	.sticky-bar.is-searching > .sticky-bar__mark,
	.sticky-bar.is-searching .menu-button {
		visibility: hidden;
	}
}
/* Windows High Contrast paints backgrounds over; the drawn magnifier and cross keep their ink. */
@media (forced-colors: active) {
	.search-button::before,
	.sticky-search__close::before,
	.sticky-search__close::after {
		forced-color-adjust: none;
		background: CanvasText;
	}
}
@media (max-width: 499px) {
	.sticky-bar__mark {
		width: 120px;
	}
	.search-button {
		gap: 0;
		padding-inline: 13px;
		font-size: 0;
	}
}

/* The page behind stays where it is while the index is open. */
html:has(.menu[open]) {
	overflow: hidden;
}

.menu {
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--ink);
	color: var(--paper);
}
.menu::backdrop {
	background: var(--ink);
}
.menu__bar {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px clamp(16px, 4vw, 48px);
	background: var(--ink);
}
.menu__title {
	margin: 0;
	font-family: "Anybody", "Arial Narrow", Arial, sans-serif;
	font-size: 0.85rem;
	font-weight: 800;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}
.menu__close {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 6px 16px;
	border: 2px solid currentColor;
	background: none;
	color: inherit;
	font-family: "Anybody", "Arial Narrow", Arial, sans-serif;
	font-size: 0.85rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
}
/* The cross, drawn: the display font has no multiplication sign. */
.menu__x {
	width: 12px;
	height: 12px;
	background: currentColor;
	clip-path: polygon(20% 0, 50% 30%, 80% 0, 100% 20%, 70% 50%, 100% 80%, 80% 100%, 50% 70%, 20% 100%, 0 80%, 30% 50%, 0 20%);
}
.menu__close:hover {
	background: var(--paper);
	color: var(--ink);
}
.menu__tiles {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-auto-rows: minmax(calc((100svh - 68px) / 2), auto);
	margin: 0;
	padding: 0;
	list-style: none;
}
.menu__tile {
	position: relative;
	isolation: isolate;
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: clamp(20px, 3vw, 44px);
	overflow: hidden;
	background: var(--tile-bg);
	color: var(--tile-fg);
}
/* The current universe: a slanted marker in the corner. */
.menu__tile.is-current::after {
	content: "";
	position: absolute;
	top: clamp(20px, 3vw, 44px);
	right: clamp(20px, 3vw, 44px);
	width: 30px;
	height: 28px;
	background: currentColor;
	clip-path: polygon(33% 0, 100% 0, 67% 100%, 0 100%);
}
.menu__universe {
	align-self: flex-start;
	color: inherit;
	font-family: "Anybody", "Arial Narrow", Arial, sans-serif;
	font-size: clamp(2.4rem, 1rem + 3.6vw, 5rem);
	font-weight: 900;
	font-stretch: 70%;
	line-height: 0.88;
	text-decoration: none;
	text-transform: uppercase;
}
.menu__universe:hover,
.menu__universe[aria-current] {
	text-decoration: underline;
	text-decoration-thickness: 0.06em;
	text-underline-offset: 0.08em;
}
.menu__blurb {
	max-width: 34ch;
	margin: 0;
	font-family: "Newsreader", Georgia, serif;
	font-size: 1.05rem;
	line-height: 1.4;
}
.menu__subs {
	display: grid;
	margin: auto 0 0;
	padding: 0;
	list-style: none;
}
.menu__subs a {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	color: inherit;
	font-family: "Anybody", "Arial Narrow", Arial, sans-serif;
	font-size: 1rem;
	font-weight: 700;
	font-stretch: 105%;
	letter-spacing: 0.06em;
	text-decoration: none;
	text-transform: uppercase;
}
.menu__subs a::before {
	content: "";
	flex: none;
	width: 12px;
	height: 11px;
	background: currentColor;
	clip-path: polygon(33% 0, 100% 0, 67% 100%, 0 100%);
}
.menu__subs a:hover,
.menu__subs a[aria-current] {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
}
.menu :focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}
/* The tiles come in one after another, quickly; with reduced motion the index simply appears. */
@media (prefers-reduced-motion: no-preference) {
	.menu[open] .menu__tile {
		animation: menu-tile-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
		animation-delay: calc(var(--i) * 45ms);
	}
}
@keyframes menu-tile-in {
	from {
		opacity: 0;
		transform: translateY(24px);
	}
}
@media (max-width: 899px) {
	.menu__tiles {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-auto-rows: auto;
	}
}
/* Phones: one column of six bands. */
@media (max-width: 599px) {
	.menu__tiles {
		grid-template-columns: minmax(0, 1fr);
	}
	.menu__universe {
		font-size: 2.6rem;
	}
}
