/*
 * Header navigation and the full-screen menu.
 */

.cong-nav {
	display: flex;
	align-items: center;
	gap: clamp(0.75rem, 2vw, 1.75rem);
}

.cong-nav__primary {
	display: flex;
	align-items: center;
	gap: clamp(0.75rem, 1.8vw, 1.75rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

.cong-nav__primary a {
	display: inline-block;
	padding-block: 0.4rem;
	border-bottom: 2px solid transparent;
	color: var(--wp--preset--color--ink);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
}

.cong-nav__primary a:hover,
.cong-nav__primary a[aria-current="page"] {
	border-bottom-color: var(--wp--preset--color--lime);
}

.cong-nav__give {
	background: var(--wp--preset--color--leaf);
	color: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--sm);
	white-space: nowrap;
}

.cong-nav__give:hover {
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--base);
}

/* ---------- The toggle ---------------------------------------------------- */

.cong-nav__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.5rem 0.25rem;
	border: 0;
	background: none;
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	cursor: pointer;
}

.cong-nav__bars {
	display: grid;
	gap: 4px;
	width: 22px;
}

.cong-nav__bars span {
	display: block;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

@media (max-width: 62rem) {
	.cong-nav__primary {
		display: none;
	}
}

@media (max-width: 30rem) {
	.cong-nav__toggle-label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}
}

/* ---------- The panel ----------------------------------------------------- */

html.cong-menu-open {
	overflow: hidden;
}

.cong-menu {
	position: fixed;
	inset: 0;
	z-index: 200;
	overflow-y: auto;
	/* Center the columns on a tall screen; fall back to top-aligned when the
	   menu is taller than the viewport, so nothing scrolls out of reach. */
	display: grid;
	align-content: safe center;
	background: linear-gradient(155deg, #04436a 0%, #0a5c8c 100%);
	color: #fff;

	/* Fading alone is not enough to get the panel out of the way: a
	   transparent element still receives clicks, and this one covers the
	   whole viewport at z-index 200. Without these it silently swallows every
	   click on the site and sends people to whichever menu link happened to
	   be under the cursor. */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 220ms cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 220ms;
}

.cong-menu.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: opacity 220ms cubic-bezier(0.2, 0, 0, 1), visibility 0s;
}

/*
 * `display: grid` above outranks the browser's own `[hidden] { display: none }`
 * — a class selector beats a plain attribute one — so the hidden attribute
 * has to be restated here or it does nothing at all.
 */
.cong-menu[hidden] {
	display: none;
}

.cong-menu__inner {
	position: relative;
	max-width: 76rem;
	margin: 0 auto;
	padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.25rem, 5vw, 3rem) 4rem;
}

.cong-menu__close {
	position: absolute;
	top: clamp(1.25rem, 3vw, 2rem);
	right: clamp(1.25rem, 5vw, 3rem);
	width: 3rem;
	height: 3rem;
	border: 0;
	background: none;
	color: #fff;
	font-size: 2.25rem;
	line-height: 1;
	cursor: pointer;
}

.cong-menu__close:hover {
	color: var(--wp--preset--color--lime);
}

.cong-menu__columns {
	columns: 3;
	column-gap: clamp(1.5rem, 4vw, 3.5rem);
}

@media (max-width: 62rem) {
	.cong-menu__columns {
		columns: 2;
	}
}

@media (max-width: 40rem) {
	.cong-menu__columns {
		columns: 1;
	}
}

.cong-menu__group {
	break-inside: avoid;
	margin-bottom: clamp(1.75rem, 3vw, 2.5rem);
}

.cong-menu__title {
	margin: 0 0 0.6rem;
	color: var(--wp--preset--color--lime);
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--xl);
	font-weight: 700;
	letter-spacing: -0.015em;
}

.cong-menu__title a {
	color: inherit;
	text-decoration: none;
}

.cong-menu__title a:hover {
	text-decoration: underline;
	text-underline-offset: 0.16em;
}

.cong-menu__links {
	display: grid;
	gap: 0.3rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cong-menu__links a {
	display: flex;
	align-items: baseline;
	gap: 0.6rem;
	padding: 0.2rem 0;
	color: rgba(255, 255, 255, 0.92);
	font-size: var(--wp--preset--font-size--lg);
	text-decoration: none;
}

.cong-menu__links a:hover,
.cong-menu__links a:focus-visible,
.cong-menu__links a[aria-current="page"] {
	color: #fff;
}

.cong-menu__links a:hover .cong-menu__arrow {
	transform: translateX(3px);
}

.cong-menu__arrow {
	flex: 0 0 auto;
	color: var(--wp--preset--color--sky-mid);
	transition: transform var(--wp--custom--transition--base);
}

.cong-menu__links small {
	display: block;
	color: var(--wp--preset--color--sky-mid);
	font-size: var(--wp--preset--font-size--sm);
}

@media (prefers-reduced-motion: reduce) {
	.cong-menu,
	.cong-menu__arrow {
		transition: none;
	}
}

/* The panel is moved to <body> at runtime (see site.js), so it must carry its
   own typography rather than inheriting the header's. */
.cong-menu {
	font-family: var(--wp--preset--font-family--body);
}

.cong-menu:focus {
	outline: none;
}

/* ------------------------------------------------------------------ *
 * Header search
 *
 * Open, it takes over the nav row rather than squeezing in beside it. A field
 * narrow enough to fit between "Events" and "Give" is a field too narrow to
 * read what you typed, and the first version did exactly that.
 * ------------------------------------------------------------------ */
.cong-nav__search-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--wp--preset--color--ink, #04436a);
	cursor: pointer;
}

.cong-nav__search-toggle:hover,
.cong-nav__search-toggle:focus-visible {
	background: var(--wp--preset--color--surface, #f3f8fb);
}

.cong-nav__search-toggle[aria-expanded="true"] {
	background: var(--wp--preset--color--surface, #f3f8fb);
}

/*
 * Laid over the links rather than inserted among them, so opening search does
 * not reflow the whole header — and so the field can be as wide as it needs.
 */
.cong-nav__search {
	position: absolute;
	inset-inline: 0;
	inset-block-start: 50%;
	transform: translateY(-50%);
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding-inline: var(--wp--preset--spacing--30, 1rem);
	background: var(--wp--preset--color--base, #fff);
}

.cong-nav__search[hidden] {
	display: none;
}

.cong-nav__search input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	padding: 0.7rem 1rem;
	border: 1px solid var(--wp--preset--color--sky-mid, #d8e3ea);
	border-radius: 999px;
	background: var(--wp--preset--color--surface, #f3f8fb);
	font: inherit;
	font-size: 1rem;
	color: var(--wp--preset--color--ink, #04436a);
	-webkit-appearance: none;
	appearance: none;
}

.cong-nav__search input[type="search"]:focus {
	outline: 2px solid var(--wp--preset--color--ink, #04436a);
	outline-offset: 1px;
	background: var(--wp--preset--color--base, #fff);
}

.cong-nav__search button[type="submit"] {
	flex: 0 0 auto;
	padding: 0.7rem 1.4rem;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--ink, #04436a);
	color: var(--wp--preset--color--base, #fff);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.cong-nav__search button[type="submit"]:hover {
	background: var(--wp--preset--color--leaf, #7a8b1e);
}

/* The nav is the positioning context the overlay hangs on. */
.cong-nav {
	position: relative;
}

/* ------------------------------------------------------------------ *
 * Header search on a phone
 *
 * Open, the field was sitting in the gap left between the logo and the menu
 * button — about a hundred pixels, showing four characters of what you typed.
 * The overlay spans the nav, and the nav is only part of the header row.
 *
 * So on a narrow screen it breaks out of its container entirely and takes the
 * full width of the viewport. `100vw` with a negative half-margin is the
 * old trick for this and it works regardless of how deeply the nav happens to
 * be nested, which matters because this is a block theme and that nesting is
 * not ours to rely on.
 * ------------------------------------------------------------------ */
@media (max-width: 880px) {
	/*
	 * Fixed to the viewport, not absolute inside the nav.
	 *
	 * The first attempt broke out of the nav with the `100vw` and negative
	 * half-margin trick, which centres on the element's own midpoint — and the
	 * nav sits to the right of the logo, so the field came out hanging off the
	 * left edge. Pinning to the viewport removes the guesswork; the script
	 * measures where the header ends and puts it there.
	 */
	.cong-nav__search {
		position: fixed;
		inset-inline: 0;
		inset-block-start: var(--cong-header-bottom, 7rem);
		transform: none;
		z-index: 60;
		padding: 0.75rem var(--wp--preset--spacing--30, 1rem);
		box-shadow: 0 6px 12px rgb(4 67 106 / 0.14);
		border-top: 1px solid var(--wp--preset--color--sky-mid, #d8e3ea);
	}

	.cong-nav__search input[type="search"] {
		/* The field is the point. The button can be small. */
		flex: 1 1 auto;
		font-size: 16px; /* Anything smaller makes iOS zoom the whole page. */
	}

	.cong-nav__search button[type="submit"] {
		padding: 0.7rem 1rem;
	}
}

/*
 * The strip on a phone: two lines, not three.
 *
 * The phone number goes. The address is the line that earns its place — it is
 * what somebody in a car park wants, and it links to a map. A number is one
 * tap away on the contact page, and keeping both pushed Realm and Subscribe
 * onto a third line of a strip that is meant to be incidental.
 */
@media (max-width: 48rem) {
	.cong-utility a[href^="tel:"] {
		display: none;
	}

	.cong-utility {
		font-size: 0.8rem;
	}
}

/*
 * The lifted search panel.
 *
 * Moved to <body> on a phone to escape a transformed ancestor, it leaves the
 * nav's positioning context behind and has to be pinned to the viewport.
 */
body > .cong-nav__search {
	position: fixed;
	inset-block-start: 0;
	inset-inline: 0;
	transform: none;
	z-index: 1000;
	padding-block: 0.75rem;
	box-shadow: 0 10px 24px rgb(0 0 0 / 0.14);
}

/* Anchored to the foot of the header, not to a 50% that depends on markup. */
.cong-header {
	position: relative;
}

.cong-header .cong-nav__search {
	inset-block-start: 100%;
	transform: none;
}

/*
 * One row on a phone. The logo and the search, Give and Menu buttons need
 * 309px together; the gap between them took a 375px phone past its 335px
 * of room, and the buttons dropped to a second row under the logo.
 */
@media (max-width: 30rem) {
	.cong-header > .wp-block-group.alignwide {
		flex-wrap: nowrap;
		gap: 0.75rem;
	}

	.cong-header .wp-block-site-logo {
		flex-shrink: 1;
		min-inline-size: 0;
	}

	.cong-header .wp-block-site-logo img {
		max-inline-size: 100%;
		block-size: auto;
	}
}
