/*
 * TownsUp — the parts theme.json cannot express.
 *
 * The brand's signature device is the lime dotted rule: in the mini-ID the "Up"
 * climbs on dotted stems (Level 01 -> Level 02 -> To the sky) and dotted lines
 * divide the page. Everything below is built from that one idea.
 *
 * Contrast, measured against cream #FBFAF0 and teal #00313B:
 *   teal   #00313B on cream -> 13.3:1   body text, headings
 *   muted  #4F6B71 on cream ->  5.4:1   meta, excerpts (AA at any size)
 *   cream  #FBFAF0 on teal  -> 13.3:1   header band
 *   teal   #00313B on lime  -> 12.0:1   chips, buttons
 * Lime is never text on cream (1.2:1); magenta is decorative only.
 */

:root {
	--townsup-dot: var(--wp--preset--color--lime);
	--townsup-rule: 3px;
	/* One gutter used by every full-bleed band, so nothing ever sits flush to
	   the viewport edge. */
	--townsup-gutter: clamp(1.25rem, 4vw, 3rem);
}

/* ---------------------------------------------------------------- links ---- */

.wp-site-blocks a:where(:not(.wp-element-button)) {
	text-decoration-thickness: 1px;
	text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
	text-underline-offset: 0.18em;
	transition: text-decoration-color 120ms ease, color 120ms ease;
}

.wp-site-blocks a:where(:not(.wp-element-button)):hover {
	text-decoration-color: var(--wp--preset--color--lime);
}

.wp-block-post-title a,
.wp-block-site-title a {
	text-decoration: none;
}

.wp-block-post-title a:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-decoration-color: var(--wp--preset--color--lime);
}

/* ------------------------------------------------------- dotted motif ------ */

.wp-block-separator.is-style-townsup-dotted {
	border: 0;
	border-top: var(--townsup-rule) dotted var(--townsup-dot);
	background: none;
	opacity: 1;
	height: 0;
	margin-block: var(--wp--preset--spacing--50);
}

/* Only bleed wide when the editor explicitly says so — otherwise the rule
   should line up with the text it divides, not run past it. */
.wp-block-separator.is-style-townsup-dotted.alignwide,
.wp-block-separator.is-style-townsup-dotted.alignfull {
	max-width: none;
}

.wp-block-group.is-style-townsup-ruled {
	border-top: var(--townsup-rule) dotted var(--townsup-dot);
	padding-top: var(--wp--preset--spacing--40);
}

.is-style-townsup-stem {
	position: relative;
	padding-left: var(--wp--preset--spacing--40);
}

.is-style-townsup-stem::before {
	content: "";
	position: absolute;
	inset-block: 0.35em 0;
	left: 0;
	border-left: var(--townsup-rule) dotted var(--townsup-dot);
}

/* ------------------------------------------------------------- eyebrows ---- */

.wp-block-post-terms.is-style-townsup-chips a {
	display: inline-block;
	padding: 0.2em 0.6em;
	background: var(--wp--preset--color--lime);
	color: var(--wp--preset--color--teal);
	text-decoration: none;
}

.wp-block-post-terms.is-style-townsup-chips a:hover {
	background: var(--wp--preset--color--teal);
	color: var(--wp--preset--color--lime);
}

/* ------------------------------------------------- header: the teal band --- */

/* The band bleeds full width; its contents stay inside the 84rem measure with a
   real gutter on both sides. */
.townsup-header {
	padding-inline: var(--townsup-gutter);
	border-bottom: var(--townsup-rule) dotted var(--townsup-dot);
}

.townsup-header .townsup-logo {
	margin: 0;
	line-height: 0;
}

.townsup-header .townsup-logo img {
	display: block;
	height: auto;
}

/* ----------------------------------------------------------- navigation ---- */

.wp-block-navigation {
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	/* Romanian uppercase carries breves and circumflexes — Ă, Â, Î. A tight
	   line box clips them, so give the diacritics room. */
	line-height: 1.6;
}

.wp-block-navigation .wp-block-navigation-item__content {
	text-decoration: none;
	padding-block: 0.15rem;
	border-bottom: 2px solid transparent;
}

/* Current page. WordPress marks the anchor with aria-current="page" and the
   item with .current-menu-item; custom links get neither, which is why every
   nav entry here is a real page link or the home-link block. */
.wp-block-navigation .wp-block-navigation-item__content:hover,
.wp-block-navigation .wp-block-navigation-item__content[aria-current="page"],
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content,
.wp-block-navigation .current_page_item > .wp-block-navigation-item__content {
	border-bottom-color: var(--wp--preset--color--lime);
}

/* On the teal band the links are cream; lime is the underline, not the text. */
.townsup-header .wp-block-navigation a,
.townsup-header .wp-block-navigation a:hover {
	color: var(--wp--preset--color--cream);
	text-decoration: none;
}

.townsup-header .wp-block-navigation__responsive-container-open,
.townsup-header .wp-block-navigation__responsive-container-close {
	color: var(--wp--preset--color--cream);
}

/* --------------------------------------------------------------- footer ---- */

.townsup-footer {
	padding-inline: var(--townsup-gutter);
	border-top: var(--townsup-rule) dotted var(--townsup-dot);
}

.townsup-footer .wp-block-site-logo {
	margin: 0;
}

.townsup-footer .wp-block-navigation {
	row-gap: var(--wp--preset--spacing--20);
}

/* ------------------------------------------------------ section intro ------ */

/*
 * The category description, printed above a section page's article lists.
 * Reads as a lede — a step up from body copy — and closes with the same dotted
 * rule that separates every other block on the page.
 */
.townsup-section-intro {
	margin-bottom: var(--wp--preset--spacing--50);
	padding-bottom: var(--wp--preset--spacing--50);
	border-bottom: var(--townsup-rule) dotted var(--townsup-dot);
	font-size: var(--wp--preset--font-size--lg);
}

.townsup-section-intro > p:last-child {
	margin-bottom: 0;
}

/* --------------------------------------------------------------- lede ------ */

/*
 * The lede title sits in the 46rem content column, where the `display` size
 * (4.5rem) ran to four lines. `xxl` keeps it clearly dominant over the grid
 * titles below without shouting.
 */
.townsup-featured .wp-block-post-title {
	font-size: var(--wp--preset--font-size--xxl);
	letter-spacing: -0.025em;
}

.townsup-featured {
	border-bottom: var(--townsup-rule) dotted var(--townsup-dot);
	padding-bottom: var(--wp--preset--spacing--50);
}

.townsup-grid .wp-block-post-template > li {
	padding-bottom: var(--wp--preset--spacing--40);
	border-bottom: 1px dotted var(--wp--preset--color--teal-line);
}

/* -------------------------------------------------------------- sidebar ---- */

@media (min-width: 782px) {
	.townsup-sidebar {
		position: sticky;
		top: var(--wp--preset--spacing--40);
		align-self: start;
	}
}

/* -------------------------------------------------------------- content ---- */

.wp-block-post-content p {
	line-height: 1.7;
}

/* Keep the title, rule and body on one left edge — no stray centring. */
main > .wp-block-post-title,
main > .wp-block-query-title {
	text-align: left;
	text-wrap: balance;
}

/* ------------------------------------------------------------------ a11y --- */

/*
 * A tap or click must not leave a ring behind — that is what put a cream box
 * around the menu button and around menu items after pressing them. Keyboard
 * focus keeps a clearly visible indicator, which is the part that matters for
 * accessibility, so this suppresses only the pointer case.
 */
.wp-site-blocks :focus:not(:focus-visible) {
	outline: none;
}

:where(.wp-site-blocks) :focus-visible {
	outline: 3px solid var(--wp--preset--color--lime);
	outline-offset: 2px;
}

/* Beat the UA's own ring so keyboard focus is lime, not white, on the teal
   band and inside the overlay. */
.townsup-header .wp-block-navigation__responsive-container-open:focus-visible,
.townsup-header .wp-block-navigation__responsive-container-close:focus-visible,
.townsup-header .wp-block-navigation-item__content:focus-visible,
.wp-block-navigation__responsive-container.is-menu-open a:focus-visible {
	outline: 2px solid var(--wp--preset--color--lime);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.wp-site-blocks a:where(:not(.wp-element-button)) {
		transition: none;
	}
}

/* ------------------------------------------------- sticky footer ----------- */

/* Short pages left a large void between the content and the footer, with the
   footer floating mid-viewport. Push it to the bottom instead. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.wp-site-blocks > main {
	flex: 1 0 auto;
}

/* ------------------------------------------------- narrow navigation ------- */

/*
 * The header uses the Navigation block's own overlay below 782px. An earlier
 * revision replaced it with a grid because the hamburger appeared to be missing
 * on phones — that was a measurement artifact: this machine's headless Chrome
 * clamps the layout viewport to about 500px while still cropping the screenshot
 * to the requested width, so the button was simply outside the crop. The
 * overlay was never broken. Core switches at 600px; 782px is used here instead
 * because six uppercase Romanian labels need more room than 600px allows.
 *
 * The footer has no overlay option, so its links stay visible and go into a
 * grid. Tracks there are minmax(0, 1fr), never a rem floor: a floor gives the
 * grid a min-content width that forces the row wider than the viewport, which
 * pushes the last labels off-screen.
 */

@media (max-width: 781px) {
	.townsup-header,
	.townsup-footer {
		/* Belt and braces: nothing can push content past the band. */
		overflow-x: clip;
	}

	.townsup-header__inner,
	.townsup-footer__inner {
		flex-direction: column;
		/* stretch, not flex-start: in a column flex container align-items
		   governs the width, and flex-start shrink-wraps to max-content. */
		align-items: stretch;
		row-gap: var(--wp--preset--spacing--30);
	}

	/* The image block writes an inline width:190px, which a plain rule cannot
	   beat — hence !important, scoped to narrow screens only. */
	.townsup-header .townsup-logo img {
		width: 150px !important;
	}

	/* --- header: show the overlay button, hide the inline list --- */

	.townsup-header__inner {
		flex-direction: row;
		align-items: center;
	}

	.townsup-header__inner > .townsup-logo {
		align-self: center;
	}

	.townsup-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
		/* 44px minimum so it is a comfortable tap target... */
		min-width: 44px;
		min-height: 44px;
		/* ...and the icon sits in the middle of it. flex-end pushed the bars to
		   the right edge of the target, which read as badly aligned. */
		align-items: center;
		justify-content: center;
		color: var(--wp--preset--color--cream);
	}

	.townsup-header .wp-block-navigation__responsive-container:not(.is-menu-open) {
		display: none;
	}

	/* --- footer: no overlay available, so wrap the links into a grid --- */

	.townsup-footer__inner > .wp-block-site-logo {
		align-self: flex-start;
	}

	.townsup-footer__inner > .wp-block-navigation {
		width: 100%;
		max-width: 100%;
		min-width: 0;
		justify-content: flex-start;
	}

	.townsup-footer .wp-block-navigation {
		font-size: var(--wp--preset--font-size--xs);
		letter-spacing: 0.04em;
	}

	.townsup-footer .wp-block-navigation__container {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		width: 100%;
		max-width: 100%;
		box-sizing: border-box;
		column-gap: var(--wp--preset--spacing--30);
		row-gap: var(--wp--preset--spacing--20);
		justify-content: start;
		justify-items: start;
		align-items: start;
	}

	.townsup-footer .wp-block-navigation__container > li {
		min-width: 0;
		justify-content: flex-start;
		text-align: left;
	}
}

@media (min-width: 480px) and (max-width: 781px) {
	.townsup-footer .wp-block-navigation__container {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}
}

@media (min-width: 782px) {
	.townsup-header .wp-block-navigation__responsive-container-open {
		display: none;
	}
}

/* The open overlay: teal ground, cream links, generous tap targets. */
.wp-block-navigation__responsive-container.is-menu-open {
	background-color: var(--wp--preset--color--teal);
	color: var(--wp--preset--color--cream);
	/*
	 * Override the custom properties core actually reads, rather than trying to
	 * out-specify the computed values. The nav carries items-justified-right
	 * for its desktop row, which sets these to flex-end and fed straight into
	 * the overlay — that is what pinned every label to the right.
	 */
	--navigation-layout-justification-setting: center;
	--navigation-layout-justify: center;
	--navigation-layout-align: center;
	--navigation-layout-direction: column;
	--navigation-layout-wrap: wrap;

	/* The box must not exceed the viewport: padding on a fixed inset:0 element
	   with content-box sizing pushes the content wider than the screen. */
	box-sizing: border-box;
	max-width: 100vw;
	overflow-x: clip;
	padding-block: var(--townsup-gutter);
	padding-inline: var(--townsup-gutter);
}

/* Every wrapper between the overlay and the list inherits the same clamp, so a
   single over-wide ancestor cannot re-introduce the overflow. */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-close,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-dialog,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	margin-inline: 0;
}

/*
 * Centre the overlay items. The nav carries items-justified-right for its
 * desktop row, and core feeds that through to the overlay as
 * --navigation-layout-justification-setting, which right-aligned every label
 * and pushed them off the edge of the screen.
 */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	gap: var(--wp--preset--spacing--40);
	align-items: center !important;
	justify-content: center !important;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	align-items: center !important;
	justify-content: center !important;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
	text-align: center;
}

/*
 * The list item is itself a flex COLUMN, so its horizontal alignment comes from
 * align-items, not justify-content — and core sets it to flex-end from the
 * desktop row's items-justified-right. That, not the wrappers, is what pinned
 * the labels to the right edge: every ancestor measured a correct 520px.
 */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container > li {
	align-items: center !important;
	justify-content: center;
	text-align: center;
	width: 100%;
	min-width: 0;
}

/* Padding on the fixed container is overridden by core, so gutter the content
   wrapper instead — otherwise centred labels can still touch the edges. */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-inline: var(--townsup-gutter);
}

.wp-block-navigation__responsive-container.is-menu-open a {
	color: var(--wp--preset--color--cream);
	font-size: var(--wp--preset--font-size--lg);
	text-decoration: none;
	text-align: center;
	justify-content: center;
}

/* Keep the lime focus ring on brand inside the teal overlay. */
.wp-block-navigation__responsive-container.is-menu-open :focus-visible {
	outline: 3px solid var(--wp--preset--color--lime);
	outline-offset: 4px;
}

.wp-block-navigation__responsive-container-close {
	color: var(--wp--preset--color--cream);
	min-width: 44px;
	min-height: 44px;
}
