/* ============================================================
   Events Archive Block
   ============================================================ */

.events-archive .container {
	container-type: inline-size;
	/* Shared height for every filter control (search, selects, Apply button)
	   so the row stays perfectly aligned. Border (1px ×2) is added on top. */
	--ea-control-height: 3rem;
}

.events-archive__heading {
	margin-bottom: 0;
}

/* Related Events title ("More {Category} Events") — same bottom border as the
   archive month labels. */
.events-archive__heading--bordered {
	border-bottom: 1px solid var(--color-border);
	padding-block-end: var(--space-xs);
	margin-block-end: var(--space-lg);
}

/* ── Filter bar ─────────────────────────────────────────────── */

/* Full-bleed grey band: escapes the container's padding + max-width to span
   the full viewport width. Uses the theme's standard 100vw + translateX
   technique (see navigation.css) so it works regardless of ancestor padding. */
.events-archive__filters {
	width: 100vw;
	position: relative;
	left: 50%;
	margin-left: -50vw;
	/* Pull the band up flush to the block top, cancelling the section's top
	   padding (--space-3xl from .section-padding-3xl). */
	margin-block-start: calc(var(--space-3xl) * -1);
	margin-block-end: var(--space-xl);
	padding-block: var(--space-xl);
	background-color: var(--wp--preset--color--gray-light);
}

/* Inner wrapper re-centers the controls to the content column, mirroring
   .container's max-width + responsive inline padding. */
.events-archive__filters-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	column-gap: var(--space-xs);
	max-width: var(--max-width-content-2xl);
	margin-inline: auto;
	padding-inline: var(--space-xl);
	box-sizing: border-box;
	row-gap: var(--space-sm);
}

/* Match the container's fluid width when the XL breakpoint is enabled. */
body.has-xl-breakpoint .events-archive__filters-inner {
	max-width: min(90dvw, 1800px);
}

/* Search grows most; the dropdown groups also grow so the row fills the band
   (matching the mockup's wide pills) instead of shrinking to content width.
   A high shrink factor + min-width:0 lets the search bar give up width first —
   so at narrow widths the view toggle stays on the same row instead of wrapping
   to a new line. */
.events-archive__filter-group--search {
	flex: 2 4 240px;
	min-width: 0;
}

.events-archive__filter-row .events-archive__filter-group {
	flex: 1 1 200px;
}

/* Date Range only filters the list view; hide it in calendar view, where it
   would be an inert control (the calendar browses months freely). */
.events-archive.is-calendar-view .events-archive__filter-group--daterange {
	display: none;
}

/* Dropdowns row is now the same flex container — no separate row div needed */
.events-archive__filter-row {
	display: contents;
}

.events-archive__filter-group {
	display: flex;
	flex-direction: column;
	gap: var(--space-2xs);
}

.events-archive__filter-label {
	color: var(--color-primary);
	font-weight: var(--font-weight-medium);
	text-transform: uppercase;
}

.events-archive__select {
	appearance: none;
	background-color: var(--color-white, #fff);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--space-sm) center;
	border: 1px solid var(--color-border, #ddd);
	border-radius: var(--radius-button);
	box-sizing: border-box;
	color: var(--color-text-primary);
	cursor: pointer;
	font-size: var(--font-size-small);
	font-family: inherit;
	line-height: calc(var(--ea-control-height) - 2px);
	min-height: unset;
	min-width: 200px;
	/* Zero the theme's inherited vertical padding so the line-height defines the
	   height, matching the search input and Apply button. */
	padding-block: 0;
	padding-inline: var(--space-md) var(--space-xl);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	width: 100%;
}

.events-archive__select:focus-visible {
	border-color: var(--color-primary);
	box-shadow: 0 0 0 2px var(--color-primary, #006ab3);
	outline: none;
}

/* Search input */
.events-archive__search-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.events-archive__search-input {
	appearance: none;
	background-color: var(--color-white);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-button);
	box-sizing: border-box;
	color: var(--color-text-primary);
	font-size: var(--font-size-small);
	font-family: inherit;
	line-height: calc(var(--ea-control-height) - 2px); /* match dropdown height */
	padding-block: 0;
	padding-inline: var(--space-md);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	width: 100%;
}

.events-archive__search-input:focus-visible {
	border-color: var(--color-primary);
	box-shadow: 0 0 0 2px var(--color-primary);
	outline: none;
}

.events-archive__search-clear {
	background: none;
	border: none;
	color: var(--color-text-secondary);
	cursor: pointer;
	font-size: 1.1em;
	line-height: 1;
	padding: 0 var(--space-sm);
	position: absolute;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
}

.events-archive__search-clear:hover {
	color: var(--color-text-primary);
}

/* Groups Apply/Clear with the view toggle so they wrap to the next line
   together — otherwise the toggle can split off onto a line of its own
   when the row is too narrow to fit everything. */
.events-archive__actions {
	display: flex;
	align-items: flex-start;
	gap: var(--space-xs);
	margin-inline-start: 0;
}

.events-archive__apply-wrap {
	align-self: flex-end;
}

/* Apply button — height matches the inputs (2.5rem) by zeroing the theme
   button's vertical padding and driving height from line-height instead. */
.events-archive__apply.btn {
	box-sizing: border-box;
	display: block;
	font-size: var(--font-size-small);
	line-height: calc(var(--ea-control-height) - 2px);
	padding-block: 0;
	padding: 0 15px;
}

/* Clear link — sits inline with the status text (see .events-archive__status-row);
   hidden (but still laid out, so the row doesn't shift) until a filter is active. */
.events-archive__clear {
	background: none;
	border: none;
	color: var(--color-text-secondary);
	cursor: pointer;
	flex-shrink: 0;
	font-size: var(--font-size-small);
	padding: 0;
	pointer-events: none;
	text-decoration: underline;
	visibility: hidden;
	white-space: nowrap;
}

.events-archive__clear.is-active {
	pointer-events: auto;
	visibility: visible;
}

.events-archive__clear:hover {
	color: var(--color-text-primary);
}

.events-archive__count {
	align-self: center;
	color: var(--color-text-secondary);
	font-size: var(--font-size-small);
	margin: 0;
}

/* Status line + Clear filters row (e.g. "Showing all upcoming events" ⋯ "Clear filters").
   Lives inside the full-bleed filter band, below the controls row, so it
   re-centers to the content column the same way .events-archive__filters-inner
   does (max-width + responsive inline padding). */
.events-archive__status-row {
	align-items: baseline;
	box-sizing: border-box;
	display: flex;
	gap: var(--space-md);
	justify-content: space-between;
	margin-block: var(--space-sm) 0;
	margin-inline: auto;
	max-width: var(--max-width-content-2xl);
	padding-inline: var(--space-xl);
}

body.has-xl-breakpoint .events-archive__status-row {
	max-width: min(90dvw, 1800px);
}

.events-archive__status {
	color: var(--color-text-secondary);
	font-size: var(--font-size-small);
	line-height: var(--line-height-tight);
	font-style: italic;
	margin: 0;
}

/* ── No results ─────────────────────────────────────────────── */

.events-archive__no-results,
.events-archive__error {
	color: var(--color-text-secondary);
	padding: var(--space-2xl) 0;
	text-align: center;
}

/* ── Load more ──────────────────────────────────────────────── */

.events-archive__load-more-wrap {
	align-items: center;
	text-align: center;
}

.events-archive__cta-wrap {
	display: flex;
	justify-content: center;
}

.events-archive__cta-wrap--left {
	justify-content: flex-start;
}

.events-archive__cta-wrap--center {
	justify-content: center;
}

.events-archive__load-more {
	align-self: center;
	width: auto;
}

.events-archive__loading {
	font-size: var(--font-size-small);
}

/* ── Month-grouped list layout ──────────────────────────────── */

.events-archive__list-wrap {
	display: flex;
	flex-direction: column;
}

.events-month-group {
	margin-block-end: var(--space-lg);
}

.events-month-label {
	font-size: var(--font-size-h6);
	text-transform: uppercase;
	border-bottom: 1px solid var(--color-border);
	padding-block-end: var(--space-xs);
	margin-block-end: var(--space-lg);
}

.events-grid {
	display: grid;
	/* minmax(0, 1fr) instead of 1fr: a plain 1fr floors each track at the card's
	   min-content width, which for content-heavy cards exceeds half the grid — so
	   two tracks + gap overflow the grid and the second column runs off-screen.
	   minmax(0, …) lets the tracks shrink to an equal split (matches the calendar
	   grid below). */
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-md) var(--space-md);
	margin-bottom: var(--space-xl);
}

/* ── Event item row ─────────────────────────────────────────── */

.event-item {
	display: flex;
	flex-direction: column;
	background: var(--wp--preset--color--gray-light);
	padding: var(--space-lg);
	height: 100%;
}

.event-item__details {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: var(--space-2xs);
}

/* Eyebrow row: date + divider + category */
.event-item__eyebrow {
	display: flex;
	align-items: center;
	gap: var(--space-xs);
	margin-block-end: var(--space-xs);
}

.event-item__date {
	display: inline-flex;
	align-items: center;
	gap: var(--space-3xs);
	color: var(--color-navy);
	font-size: var(--font-size-body);
	font-weight: var(--font-weight-bold);
	line-height: 1em;
	text-transform: uppercase;
}

.event-item__date .icon-calendar {
	flex-shrink: 0;
	margin-top: -3px;
	margin-right: 3px;
}

.event-item__eyebrow-divider {
	width: 1px;
	height: 1em;
	background-color: var(--color-border);
}

.event-item__category.eyebrow-text {
	font-weight: var(--font-weight-normal);
	line-height: 1em;
}

.event-item__title {
	font-size: var(--font-size-h5);
	color: var(--color-heading);
	margin-bottom: var(--space-sm);
}

.event-item__title a {
	color: inherit;
	text-decoration: none;
}

.event-item__title a:hover {
	text-decoration: underline;
}

.event-item__meta {
	margin: 0;
}

.event-item__excerpt {
	margin-block-start: var(--space-sm);
	/* Clamp to 3 lines so cards stay even regardless of excerpt length */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
	/* Without this, the line-clamp box's min-content width is its longest
	   unbreakable run of text, which can exceed the grid track and force
	   the whole card (and page) wider than the viewport on narrow screens. */
	overflow-wrap: anywhere;
}

.event-item__cta {
	align-self: flex-start;
	width: fit-content;
	margin-block-start: var(--space-md);
	color: var(--color-navy);
	font-weight: var(--font-weight-semibold);
}

.event-item__cta.btn-arrow:before {
	display: none;
}


/* ── Responsive ─────────────────────────────────────────────── */

@container (max-width: 700px) {
	.events-grid {
		grid-template-columns: 1fr;
	}

	.events-archive__apply-wrap {
		align-self: stretch;
	}

	.events-archive__apply.btn {
		width: 100%;
	}
}

@container (max-width: 560px) {
	.events-archive__select {
		min-width: 120px;
	}
}

/* ── View toggle (list / calendar) ──────────────────────────── */

/* Block is the positioning context for the calendar popover. */
.events-archive {
	position: relative;
}

.events-archive__view-toggle {
	align-self: flex-end;
	display: inline-flex;
	flex-shrink: 0;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-button);
	overflow: hidden;
}

.events-archive__view-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background-color: var(--color-white);
	border: none;
	color: var(--color-text-secondary);
	cursor: pointer;
	/* Match the filter controls' height (border lives on the toggle wrapper,
	   so subtract its 1px top/bottom to keep the group at --ea-control-height). */
	height: calc(var(--ea-control-height) - 2px);
	width: 2.75rem;
	padding: 0;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.events-archive__view-btn + .events-archive__view-btn {
	border-inline-start: 1px solid var(--color-border);
}

.events-archive__view-btn.is-active {
	background-color: var(--color-primary);
	color: var(--color-white);
}

.events-archive__view-btn:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: -2px;
}

/* ── Calendar grid ──────────────────────────────────────────── */

.events-archive__calendar-wrap.is-loading {
	position: relative;
	min-height: 12rem; /* keeps the spinner visible on first load, when the wrap is still empty */
	opacity: 0.6;
	pointer-events: none;
}

/* Spinner overlay — same pattern as .archive-grid-row.loading::after
   (theme pagination.css): centered ring using the shared `spin` keyframes. */
.events-archive__calendar-wrap.is-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 40px;
	height: 40px;
	border: 3px solid var(--color-border);
	border-top-color: var(--color-primary);
	border-radius: 50%;
	animation: spin 1s linear infinite;
	z-index: 10;
}

.events-calendar__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-lg);
	margin-block-end: var(--space-lg);
}

.events-calendar__label {
	margin: 0;
	min-width: 12ch;
	text-align: center;
}

.events-calendar__prev,
.events-calendar__next {
	background-color: var(--color-white);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-button);
	color: var(--color-text-primary);
	cursor: pointer;
	font-size: var(--font-size-lead);
	height: 2.5rem;
	line-height: 1;
	width: 2.5rem;
}

.events-calendar__prev:hover,
.events-calendar__next:hover {
	border-color: var(--color-primary);
	color: var(--color-primary);
}

.events-calendar__prev:disabled,
.events-calendar__next:disabled {
	cursor: default;
	opacity: 0.5;
}

.events-calendar__grid {
	display: grid;
	/* minmax(0, 1fr) lets tracks shrink below the pill's intrinsic (nowrap)
	   width so all 7 columns stay equal and the pill title can ellipsis. */
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 1px;
	background-color: var(--color-light-gray);
	border: 1px solid var(--color-border);
	/* border-box + full-width: without this, subpixel rounding across 7
	   fractional tracks can push the grid's own right border a hair past
	   its container on mobile, clipping it against the viewport edge. */
	box-sizing: border-box;
	width: 100%;
}

.events-calendar__weekday {
	background-color: var(--color-light-gray);
	color: var(--color-text-secondary);
	font-size: var(--font-size-small);
	font-weight: var(--font-weight-semibold);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	text-align: center;
	padding-block: var(--space-xs);
}

.events-calendar__day {
	background-color: var(--color-white);
	min-height: 7rem;
	min-width: 0; /* allow nowrap pill titles to ellipsis instead of widening the column */
	padding: var(--space-2xs);
	display: flex;
	flex-direction: column;
	gap: var(--space-2xs);
}

.events-calendar__day.is-outside {
	background-color: var(--color-light-gray);
}

.events-calendar__day.is-today {
	box-shadow: inset 0 0 0 2px var(--color-primary);
}

.events-calendar__date {
	font-size: var(--font-size-small);
	font-weight: var(--font-weight-semibold);
	color: var(--color-text-secondary);
}

.events-calendar__day.is-today .events-calendar__date {
	color: var(--color-primary);
}

.events-calendar__day-head {
	display: flex;
	align-items: center;
	gap: var(--space-3xs);
}

.events-calendar__pills {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: var(--space-3xs);
}

.events-calendar__pill {
	display: flex;
	align-items: baseline;
	gap: var(--space-2xs);
	width: 100%;
	background-color: var(--color-primary);
	border: none;
	border-radius: var(--radius-sm);
	color: var(--color-white);
	cursor: pointer;
	font-size: var(--font-size-small);
	padding: var(--space-3xs) var(--space-2xs);
	text-align: start;
}

.events-calendar__pill-time {
	flex-shrink: 0;
	font-weight: var(--font-weight-semibold);
}

.events-calendar__pill-title {
	min-width: 0; /* shrink within the flex pill so ellipsis engages */
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.events-calendar__more {
	background: none;
	border: none;
	color: var(--color-primary);
	cursor: pointer;
	font-size: var(--font-size-small);
	padding: var(--space-3xs) var(--space-2xs);
	text-align: start;
}

/* Compact mobile-only indicator (dot / count badge) — hidden by default,
   shown instead of the pill list below 700px (see mobile section). Must use
   the compound selector (.events-calendar__pill.events-calendar__pill--compact),
   not just .events-calendar__pill--compact alone — a single-class selector
   has the same specificity as .events-calendar__pill/.events-calendar__more
   above and would lose to whichever rule happens to come later in the
   cascade; the compound form is unambiguously higher-specificity. */
.events-calendar__pill.events-calendar__pill--compact,
.events-calendar__more.events-calendar__more--compact {
	display: none;
}

.events-calendar__empty {
	color: var(--color-text-secondary);
	padding: var(--space-lg) 0;
	text-align: center;
}

/* ── Calendar popover ───────────────────────────────────────── */

.events-calendar__popover {
	position: absolute;
	/* Must clear LaunchPad's persistent approval badge/edit-toggle (z-index:
	   99998) and its modal overlay (100000) so the popover isn't hidden
	   behind them in staging/review. */
	z-index: 100001;
	max-width: 20rem;
	background-color: var(--color-white);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-lg);
	padding: var(--space-md);
}

.events-calendar__popover-close {
	position: absolute;
	top: var(--space-2xs);
	right: var(--space-2xs);
	background: none;
	border: none;
	color: var(--color-text-secondary);
	cursor: pointer;
	font-size: 1.2em;
	line-height: 1;
	padding: var(--space-3xs);
}

.events-calendar__popover-title {
	margin: 0 var(--space-lg) var(--space-2xs) 0;
}

.events-calendar__popover-when {
	color: var(--color-text-secondary);
	font-size: var(--font-size-small);
	display: block;
	margin: 0;
	line-height: var(--line-height-tight);
}

.events-calendar__popover-location {
	color: var(--color-text-secondary);
	font-size: var(--font-size-small);
	margin: var(--space-3xs) 0 var(--space-sm);
}

/* "More Details →" CTA — matches the list-view card (.event-item__cta). */
.events-calendar__popover-link {
	align-self: flex-start;
	width: fit-content;
	color: var(--color-navy);
	font-weight: var(--font-weight-bold);
}

.events-calendar__popover-link.btn-arrow:before {
	display: none;
}

.events-calendar__popover-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: var(--space-sm);
}

/* Day-list popover event titles — same heading look as the single-event
   popover's .events-calendar__popover-title (which uses .h6 on a <p>).
   This is a link instead of a <p>, so also zero the .h6 margin and set
   underline-on-hover-only (heading color comes from .h6 itself). */
.events-calendar__popover-list-title {
	display: block;
	margin: 0;
	text-decoration: none;
}

.events-calendar__popover-list-title:hover {
	text-decoration: underline;
}

/* ── Calendar mobile: compact dot/badge instead of the pill list ────── */
/* Below 700px, swap the stacked title/time pill list for a single small
   indicator beside the date number — a plain dot for 1 event, a count
   badge for 2+ — so days don't need extra height to show event rows.
   Both still open the same popovers as the desktop pills/"+more". */

@container (max-width: 700px) {
	.events-calendar__day {
		min-height: 0;
	}

	.events-calendar__pills {
		display: none;
	}

	.events-calendar__pill.events-calendar__pill--compact,
	.events-calendar__more.events-calendar__more--compact {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		min-width: 1.1rem;
		height: 1.1rem;
		background-color: var(--color-primary);
		border: none;
		border-radius: 999px;
		color: var(--color-white);
		cursor: pointer;
		padding: 0 0.2rem;
	}

	.events-calendar__more-count {
		font-size: 0.65rem;
		font-weight: var(--font-weight-semibold);
		line-height: 1;
	}

	/* Single-event dot carries no visible label (aria-label announces the
	   event title instead) — keep it small and plain. */
	.events-calendar__pill.events-calendar__pill--compact {
		min-width: 0.5rem;
		width: 0.5rem;
		height: 0.5rem;
		padding: 0;
	}
}
