/* chrome.css - the site shell on every page: the announcement banner
   (#site-banner > .c-banner), the header bar (#site-header >
   .site-header), the sidebar (#site-nav.sidebar) and the footer
   (#site-footer.site-footer). Builder-emitted (webpage_builder/shell.py);
   not for page use.

   <body> says how the sidebar is shown: data-shell="sidebar" puts it beside
   the page from 901 px, data-shell="drawer" (a full-width surface) keeps it
   a drawer at every width, and data-sidebar="collapsed" is the viewer's own
   choice, read from a cookie. A page with no shell (the game tables) has no
   data-shell and none of this draws. navbar.js sets data-drawer="open".

   The header is --header-h tall at every width; whatever sticks under it
   reads that token. The touch layer for these rules is in components.css,
   each selector prefixed with its chrome root so it outranks the rule here
   that it overrides (this file loads after components.css). */

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

#site-header {
	position: sticky;
	inset-block-start: 0;
	z-index: var(--z-header);
}

.site-header {
	box-sizing: border-box;
	block-size: var(--header-h);
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	padding-inline: var(--sp-4);
	background: var(--bg);
	border-block-end: 1px solid var(--border);
	font-family: var(--font-sans);
	font-size: var(--fs-sm);
	line-height: 1.5;
}

.skip-link {
	position: absolute;
	inset-block-start: var(--sp-2);
	inset-inline-start: var(--sp-4);
	z-index: 1;
	padding: var(--sp-2) var(--sp-4);
	border-radius: var(--radius-md);
	background: var(--accent);
	color: var(--on-accent);
	transform: translateY(-200%);
}
.skip-link:focus { transform: none; color: var(--on-accent); }
/* Unfocused it is clipped away too: moved up only, it showed over a banner. */
.skip-link:not(:focus) { clip-path: inset(50%); }
/* The header and the sidebar clip at their edges: the focus ring sits inside. */
:is(.site-header, .sidebar) :focus-visible { outline-offset: -2px; }

.menu-button {
	flex: none;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	min-block-size: var(--ctl-h-btn-base);
	padding-inline: var(--sp-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	color: var(--text);
	text-decoration: none;
	cursor: pointer;
	user-select: none;
}
.menu-button:hover { background: var(--surface-3); color: var(--text); }
.menu-button__icon { inline-size: 16px; block-size: 16px; flex: none; }
/* Beside the page the button hides or shows the sidebar; where the sidebar
   is a drawer it is the Menu. */
.menu-button__label--drawer { display: none; }
/* Its words (navbar.js) swap in a column as wide as the wider of the two,
   so the button and the brand after it hold still. */
.menu-button__label--desk { display: inline-grid; }
.menu-button__label--desk::before { content: "Hide menu" / ""; }
.menu-button__label--desk::after { content: "Show menu" / ""; }
.menu-button__label--desk::before,
.menu-button__label--desk::after { block-size: 0; visibility: hidden; }
body[data-shell="drawer"] .menu-button__label--desk { display: none; }
body[data-shell="drawer"] .menu-button__label--drawer { display: inline; }

/* The pending figure: on the Admin group, and on the Menu button at every
   width (the Admin group sits last, below the sidebar's fold on a laptop). */
.nav-count {
	color: var(--warn);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

/* The site name keeps its width; a long user name gives way instead. */
.brand {
	flex-shrink: 0;
	min-inline-size: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--text);
	font-weight: 600;
	text-decoration: none;
}
.brand:hover { color: var(--text); }

.site-header__end {
	margin-inline-start: auto;
	min-inline-size: 0;
	display: flex;
	align-items: center;
	gap: var(--sp-4);
}
.site-header__end a {
	color: var(--text);
	text-decoration: none;
	white-space: nowrap;
}
.site-header__end a:hover { color: var(--accent-hover); }
.site-header__user {
	min-inline-size: 0;
	max-inline-size: var(--sidebar-w);
	overflow: hidden;
	text-overflow: ellipsis;
}
/* The shortcut is for the widths where the sidebar is a drawer. On the
   narrowest phones it gives way before the brand and the account name are
   cut (the header is a size container). */
.site-header__quick { display: none; }
.site-header { container: site-header / inline-size; }
@container site-header (max-width: 22.5rem) {
	.site-header .site-header__quick { display: none; }
}

/* -- Shell ------------------------------------------------------------ */

body[data-shell] .shell {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	min-block-size: calc(100dvh - var(--header-h));
}
body[data-shell] .shell__main {
	min-inline-size: 0;
	display: flex;
	flex-direction: column;
}
body[data-shell] .shell__main > main { flex: 1 0 auto; }

/* -- Sidebar ---------------------------------------------------------- */

.sidebar {
	display: none;
	box-sizing: border-box;
	background: var(--surface-2);
	border-inline-end: 1px solid var(--border);
	font-family: var(--font-sans);
	font-size: var(--fs-sm);
	line-height: 1.5;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Beside the page. */
body[data-shell="sidebar"]:not([data-sidebar="collapsed"]) .shell {
	grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
body[data-shell="sidebar"]:not([data-sidebar="collapsed"]) .sidebar {
	display: block;
	position: sticky;
	inset-block-start: var(--header-h);
	align-self: start;
	block-size: calc(100dvh - var(--header-h));
}

/* Over the page. */
body[data-shell][data-drawer="open"] { overflow: hidden; }
/* The drawer hangs from the header at --header-h: a banner above the header
   would push the header down under it, over the Menu button that closes it,
   so the banner steps aside while the drawer is open (it is inert then). */
body[data-shell][data-drawer="open"] #site-banner { display: none; }
body[data-shell][data-drawer="open"] .sidebar {
	display: block;
	position: fixed;
	z-index: var(--z-drawer);
	inset-block: var(--header-h) 0;
	inset-inline-start: 0;
	inline-size: min(var(--sidebar-w), 85%);
	block-size: auto;
	/* Stretched between the insets: a start alignment would size a
	   positioned box to its content. */
	align-self: stretch;
}

.shell-backdrop {
	display: none;
	position: fixed;
	z-index: calc(var(--z-drawer) - 1);
	inset: var(--header-h) 0 0 0;
	background: var(--modal-backdrop);
}
body[data-shell][data-drawer="open"] .shell-backdrop { display: block; }

@media (prefers-reduced-motion: no-preference) {
	body[data-shell][data-drawer="open"] .sidebar { animation: shell-drawer-in 160ms ease-out; }
	body[data-shell][data-drawer="open"] .shell-backdrop { animation: shell-fade-in 160ms ease-out; }
}
@keyframes shell-drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes shell-fade-in { from { opacity: 0; } to { opacity: 1; } }

.sidebar__inner {
	display: grid;
	gap: var(--sp-5);
	padding: var(--sp-5) var(--sp-3) var(--sp-7);
}

.nav-group { display: grid; gap: var(--sp-1); }

.nav-group > summary {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	min-block-size: var(--ctl-h-chip-base);
	padding-inline: var(--sp-2);
	border-radius: var(--radius-sm);
	color: var(--text-muted);
	font-size: var(--fs-xs);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	cursor: pointer;
	list-style: none;
	user-select: none;
	position: relative;
}
.nav-group > summary::-webkit-details-marker { display: none; }
/* The triangle sits in a one-step box, so its centre is on the scale and the
   open group's guide line can start from it. */
.nav-group > summary::before {
	content: "";
	flex: none;
	inline-size: var(--sp-2);
	block-size: var(--sp-2);
	background: currentColor;
	clip-path: polygon(20% 0, 80% 50%, 20% 100%);
}
.nav-group[open] > summary::before { transform: rotate(90deg); }

/* An open group's guide: one line from under the triangle down beside the
   entries, which start level with the group's label. Each part draws its own
   length and reaches up over the gap above it, so the line is unbroken. */
.nav-group[open] > summary::after,
.nav-group > .nav-sub::before,
.nav-group > .nav-list::before {
	content: "";
	position: absolute;
	inset-inline-start: var(--sp-3);
	inline-size: 1px;
	background: var(--border);
	pointer-events: none;
}
.nav-group[open] > summary::after { inset-block-end: 0; block-size: calc(50% - var(--sp-1)); }
.nav-group > .nav-sub::before,
.nav-group > .nav-list::before { inset-block: calc(-1 * var(--sp-1)) 0; }
.nav-group > .nav-sub,
.nav-group > .nav-list { position: relative; }
.nav-group > .nav-sub { padding-inline-start: var(--sp-5); }
.nav-group > .nav-list { padding-inline-start: var(--sp-4); }
/* A group's name is one line (the account group is the member's name). */
.sidebar__inner > .nav-group,
.nav-group > summary { min-inline-size: 0; }
.nav-group__label {
	min-inline-size: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.nav-group > summary:hover { color: var(--text); }
.nav-group > summary .nav-count { margin-inline-start: auto; letter-spacing: 0; }

.nav-sub {
	margin: 0;
	padding: var(--sp-2) var(--sp-2) 0;
	color: var(--text-muted);
	font-size: var(--fs-xs);
}

.nav-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
}

.nav-link {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	min-block-size: var(--ctl-h-btn-base);
	padding: var(--sp-1) var(--sp-2);
	border-radius: var(--radius-sm);
	color: var(--text);
	text-decoration: none;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
/* A menu that is one link (Tools) is a link, not a group with its triangle
   missing: its text starts level with every other entry's. */
.nav-link--top { padding-inline-start: var(--sp-5); }
.nav-link[aria-current="page"] {
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 600;
}

/* -- Drawer widths ---------------------------------------------------- */

@media (max-width: 900px) {
	body[data-shell]:not([data-drawer="open"]) .shell { grid-template-columns: minmax(0, 1fr); }
	body[data-shell]:not([data-drawer="open"]) .sidebar { display: none; }
	body[data-shell] .menu-button .nav-count { display: inline; }
	.site-header__quick { display: inline; }
	.menu-button__label--desk { display: none; }
	.menu-button__label--drawer { display: inline; }
}

@media (max-width: 600px) {
	.site-header { gap: var(--sp-2); padding-inline: var(--sp-3); }
	.site-header__end { gap: var(--sp-3); }
	.menu-button__label, .menu-button .nav-count__word {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
}

/* Without script nothing can open a drawer: the sidebar follows the page,
   and the Menu link goes to it. */
@media (scripting: none) {
	body[data-shell="drawer"]:not([data-drawer="open"]) .sidebar {
		display: block;
		position: static;
		order: 1;
		block-size: auto;
		border-inline-end: 0;
		border-block-start: 1px solid var(--border);
	}
}
@media (scripting: none) and (max-width: 900px) {
	body[data-shell]:not([data-drawer="open"]) .sidebar {
		display: block;
		position: static;
		order: 1;
		block-size: auto;
		border-inline-end: 0;
		border-block-start: 1px solid var(--border);
	}
}

/* -- Footer (default_footer.html) --------------------------------------
   One quiet row: the contact links on the left, the build-time stamp on the
   right (it keeps the right edge when the row wraps on a narrow phone).
   Links inherit the global `a` colour. */

.site-footer {
	padding: var(--sp-4) var(--page-gutter);
	font-size: var(--fs-sm);
	line-height: 1.5;
	color: var(--text-muted);
	border-top: 1px solid var(--border);
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--sp-1) var(--sp-5);
}

.site-footer__links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0 var(--sp-2);
}

.site-footer__links li + li::before {
	content: "|" / "";
	padding-right: var(--sp-2);
}

/* Two classes: the shell's margin reset (body.ui :where(p)) outranks one. */
.site-footer .site-footer__build {
	margin-inline-start: auto;
}

.site-footer__ms {
	font-variant-numeric: tabular-nums;
}

/* -- Print -------------------------------------------------------------
   A printed page is its content: no banner, header, sidebar, footer or
   outline, black text on white paper, the column the paper's width. */

@media print {
	#site-banner, #site-header, #site-nav, .shell-backdrop, #site-footer, .l-outline, .l-page__actions { display: none; }
	body[data-shell] .shell { display: block; min-block-size: 0; }
	html, body { background: #fff; }
	body * { color: #000 !important; background-color: transparent !important; }
	body .l-page { max-inline-size: none; padding: 0; }
	body .c-panel { border-color: #999; }
	body img { break-inside: avoid; }
}
