/**
 * Page shell: header, navigation, footer, and the containers pages sit in.
 *
 * @package ActivityMaker
 */

.am-shell {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	/* On a phone browser, 100vh is the height the page would have if the address
	   bar were hidden, which it usually is not - so a full-height layout ends up
	   taller than the screen and the footer sits below the fold with a scrollbar
	   for nothing. Dynamic viewport units measure what is actually visible. */
	min-height: 100dvh;
}

.am-main {
	flex: 1 0 auto;
}

.am-container {
	width: 100%;
	max-width: var(--am-max-width);
	margin: 0 auto;
	/* max() with the safe-area inset keeps content clear of the rounded corners
	   and the camera cutout when a phone is held in landscape. It resolves to
	   the plain padding everywhere else. */
	padding-inline:
		max(var(--am-4), env(safe-area-inset-left))
		max(var(--am-4), env(safe-area-inset-right));
}

@media (min-width: 640px) {
	.am-container {
		padding-inline:
			max(var(--am-5), env(safe-area-inset-left))
			max(var(--am-5), env(safe-area-inset-right));
	}
}

.am-container--narrow {
	max-width: 46rem;
}

.am-container--prose {
	max-width: 44rem;
}

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

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

/* A phone in landscape has very little height to spare, and a permanently
   pinned header spends a sixth of it on navigation nobody is looking at while
   they solve a puzzle. It scrolls away and comes back on the way up. */
@media (max-height: 560px) and (orientation: landscape) {
	.am-header {
		position: relative;
	}
}

.am-header__inner {
	display: flex;
	align-items: center;
	gap: var(--am-4);
	min-height: var(--am-header-height);
}

.am-brand {
	display: inline-flex;
	align-items: center;
	gap: var(--am-2);
	font-size: var(--am-text-md);
	font-weight: 680;
	letter-spacing: -0.015em;
	color: var(--am-text);
	text-decoration: none;
	flex: none;
}

.am-brand:hover {
	color: var(--am-text);
}

.am-brand__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: var(--am-radius-sm);
	background: var(--am-accent);
	color: var(--am-accent-ink);
	flex: none;
}

.am-brand img {
	max-height: 34px;
	width: auto;
}

.am-header__menu {
	display: none;
	flex: 1;
	align-items: center;
	gap: var(--am-4);
}

.am-header__account {
	display: none;
	align-items: center;
	gap: var(--am-2);
	margin-left: auto;
}

.am-menu-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin-left: auto;
	border: 1px solid var(--am-border);
	border-radius: var(--am-radius);
	background: var(--am-bg-raised);
	color: var(--am-text);
	cursor: pointer;
}

@media (min-width: 900px) {
	.am-menu-toggle {
		display: none;
	}

	.am-header__menu,
	.am-header__account {
		display: flex;
	}
}

/* --------------------------------------------------------------- Nav. */

.am-nav__list {
	display: flex;
	align-items: center;
	gap: var(--am-1);
	list-style: none;
	margin: 0;
	padding: 0;
}

.am-nav__item {
	position: relative;
	margin: 0;
}

.am-nav__link {
	display: inline-flex;
	align-items: center;
	gap: var(--am-2);
	padding: 0.45rem 0.6rem;
	border-radius: var(--am-radius);
	color: var(--am-text-muted);
	font-size: var(--am-text-base);
	font-weight: 550;
	text-decoration: none;
}

.am-nav__link:hover {
	background: var(--am-bg-sunken);
	color: var(--am-text);
}

.am-nav__item.is-current > .am-nav__link,
.am-nav__link[aria-current="page"] {
	color: var(--am-text);
	background: var(--am-bg-sunken);
}

.am-nav__icon {
	display: inline-flex;
	color: var(--am-text-faint);
}

.am-nav__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	margin-left: -6px;
	padding: 0;
	border: 0;
	border-radius: var(--am-radius-sm);
	background: transparent;
	color: var(--am-text-faint);
	cursor: pointer;
}

.am-nav__toggle:hover {
	color: var(--am-text);
}

.am-nav__toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

.am-nav__submenu {
	list-style: none;
	margin: 0;
	padding: var(--am-2);
}

@media (min-width: 900px) {
	.am-nav__submenu {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		z-index: 30;
		min-width: 16rem;
		background: var(--am-bg-raised);
		border: 1px solid var(--am-border);
		border-radius: var(--am-radius-lg);
		box-shadow: var(--am-shadow-2);
	}

	.am-nav__submenu .am-nav__link {
		width: 100%;
		padding: 0.5rem 0.6rem;
	}

	.am-nav__submenu li {
		margin: 0;
	}
}

/* Mobile menu panel. */
@media (max-width: 899px) {
	.am-header__menu,
	.am-header__account {
		display: none;
	}

	.am-header__menu.is-open {
		display: block;
		position: absolute;
		top: var(--am-header-height);
		left: 0;
		right: 0;
		background: var(--am-bg-raised);
		border-bottom: 1px solid var(--am-border);
		box-shadow: var(--am-shadow-2);
		padding: var(--am-3) var(--am-4) var(--am-5);
		max-height: calc(100vh - var(--am-header-height));
		max-height: calc(100dvh - var(--am-header-height));
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.am-header__menu.is-open .am-nav__list {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}

	.am-header__menu.is-open .am-nav__item {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		border-bottom: 1px solid var(--am-border);
	}

	.am-header__menu.is-open .am-nav__link {
		flex: 1;
		padding-block: 0.7rem;
		min-height: 44px;
	}

	.am-header__menu.is-open .am-nav__submenu {
		flex-basis: 100%;
		padding-left: var(--am-4);
		background: var(--am-bg-sunken);
		border-radius: var(--am-radius);
		margin-bottom: var(--am-2);
	}

	.am-header__menu.is-open .am-nav__item--child {
		border-bottom: 0;
	}

	.am-header__menu.is-open .am-header__account {
		display: flex;
		flex-wrap: wrap;
		gap: var(--am-2);
		margin: var(--am-4) 0 0;
	}

	body.am-menu-open {
		overflow: hidden;
	}
}

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

.am-footer {
	flex: none;
	margin-top: var(--am-8);
	padding-block: var(--am-6);
	background: var(--am-bg-sunken);
	border-top: 1px solid var(--am-border);
	font-size: var(--am-text-sm);
	color: var(--am-text-muted);
}

.am-footer__grid {
	display: grid;
	gap: var(--am-5);
	grid-template-columns: 1fr;
}

@media (min-width: 720px) {
	.am-footer__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: var(--am-5) var(--am-6);
	}
}

@media (min-width: 1020px) {
	/* The first column carries the site name and a sentence, so it gets more
	   room; every link column after it takes an equal share of what is left.
	   Implicit columns rather than a fixed count of four, because the "More"
	   column is not rendered when there is nothing to put in it - and a fixed
	   count would leave an empty gap where it used to be. */
	.am-footer__grid {
		grid-template-columns: 1.6fr;
		grid-auto-flow: column;
		grid-auto-columns: minmax(0, 1fr);
		gap: var(--am-6);
	}
}

.am-footer__title {
	font-size: var(--am-text-sm);
	font-weight: 650;
	color: var(--am-text);
	margin-bottom: var(--am-2);
	text-transform: none;
}

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

.am-footer li + li {
	margin-top: var(--am-1);
}

.am-footer a {
	color: var(--am-text-muted);
	text-decoration: none;
}

.am-footer a:hover {
	color: var(--am-accent);
	text-decoration: underline;
}

.am-footer__bar {
	display: flex;
	flex-wrap: wrap;
	gap: var(--am-3);
	align-items: center;
	margin-top: var(--am-5);
	padding-top: var(--am-4);
	border-top: 1px solid var(--am-border);
	font-size: var(--am-text-xs);
	color: var(--am-text-faint);
}

/* --------------------------------------------------------------- Page heads. */

.am-pagehead {
	padding-block: var(--am-6) var(--am-4);
}

.am-pagehead__title {
	font-size: var(--am-text-2xl);
	margin-bottom: var(--am-2);
}

.am-pagehead__lead {
	font-size: var(--am-text-md);
	color: var(--am-text-muted);
	max-width: 42rem;
	margin: 0;
}

@media (min-width: 900px) {
	.am-pagehead__title {
		font-size: var(--am-text-3xl);
	}
}

.am-breadcrumbs {
	padding-top: var(--am-4);
	font-size: var(--am-text-sm);
	color: var(--am-text-faint);
}

.am-breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: var(--am-2);
	list-style: none;
	margin: 0;
	padding: 0;
}

.am-breadcrumbs li {
	margin: 0;
	display: flex;
	align-items: center;
	gap: var(--am-2);
}

.am-breadcrumbs li + li::before {
	content: "/";
	color: var(--am-border-strong);
}

.am-breadcrumbs a {
	color: var(--am-text-muted);
	text-decoration: none;
}

.am-breadcrumbs a:hover {
	color: var(--am-accent);
	text-decoration: underline;
}

/* --------------------------------------------------------------- Ads. */

.am-ad {
	display: block;
	margin: var(--am-5) 0;
	text-align: center;
	max-width: 100%;
	overflow: hidden;
}

.am-ad:empty {
	display: none;
	margin: 0;
}
