/* ==========================================================================
   COMMUNITY

   /community and its single posts. Everything here exists because an archive
   of 115 posts spanning ten years -- with nothing published in 2024 or 2025 --
   needs more than one repeated card to read honestly. Three weights of card,
   a filter row that admits how full each section is, and an age cue on the
   posts that need one.

   Depends on style.css for tokens and components.css for .kbia-card. Loaded
   after both; see the sheet list in functions.php.
   ========================================================================== */

/* --- The filter row ------------------------------------------------------
   .kbia-filters already exists in listing.css for the directory. This is the
   community variant: it adds counts to each tab and a year form on the end. */

.kbia-filters--community {
	padding-block: 1.125rem;
	border-bottom: 1px solid var(--kbia-border);
	row-gap: 0.5rem;
}

.kbia-filter__count {
	margin-left: 0.4rem;
	font-family: var(--kbia-font-mono);
	font-size: 0.72rem;
	font-variant-numeric: tabular-nums;
	color: var(--kbia-muted);
}

.kbia-filter.is-active .kbia-filter__count { color: rgb(255 255 255 / 75%); }

/* A section with nothing in it is still listed -- Organizations holds zero
   posts and hiding the tab would be a quieter lie than showing the count. It
   is dimmed so the eye skips it without having to read the number. */
.kbia-filter.is-empty { opacity: 0.55; }

/* --- The year filter ----------------------------------------------------- */

.kbia-yearfilter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-left: auto;
}

.kbia-yearfilter__label {
	font-family: var(--kbia-font-mono);
	font-size: var(--kbia-fs-eyebrow);
	letter-spacing: var(--kbia-ls-eyebrow);
	text-transform: uppercase;
	color: var(--kbia-muted);
}

.kbia-yearfilter__select {
	font-family: var(--kbia-font-body);
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--kbia-body);
	background: var(--kbia-surface);
	border: 1px solid var(--kbia-border);
	border-radius: var(--kbia-radius);
	padding: 0.5rem 2rem 0.5rem 0.75rem;

	/* An explicit chevron rather than the platform one. My Listing sets
	   `overflow: hidden` on several of its wrappers and the native control's
	   arrow was being clipped inside them -- the same defect fixed on the
	   directory's select. Drawn as a background image so nothing can crop it. */
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235f6672' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.7rem center;
	background-size: 0.7rem;
}

.kbia-yearfilter__select option:disabled { color: var(--kbia-muted); }

.kbia-yearfilter__go { padding: 0.5rem 1rem; font-size: 0.875rem; }

.kbia-yearfilter__clear {
	font-size: 0.8125rem;
	color: var(--kbia-muted);
}

/* --- Band furniture ------------------------------------------------------
   Every rule below is scoped to .kbia-archive--community, and that scoping is
   load-bearing rather than tidiness.

   .kbia-band__title is a shared global owned by homepage.css, used by
   template-homepage.php, 404.php and search.php as well as this archive. This
   sheet is enqueued last (see the sheet list in functions.php), so an
   unscoped redefinition here has equal specificity and simply wins everywhere
   -- which is exactly what it did: it dropped all seven homepage band
   headings from --kbia-fs-h2 (48px at 1440) to 28px, and replaced the
   1.5rem bottom margin with 0. .kbia-band__standfirst carries a deliberate
   -0.75rem pull designed to close against that margin, so with nothing left
   to cancel, every standfirst on the homepage overlapped its heading by 12px.

   The community archive wants a quieter heading than a homepage band does --
   these are section labels above a grid, not the openers of a landing page --
   so the smaller ramp stays. It just has to stay here.

   .kbia-band--alt is not redefined at all: base.css already provides it
   globally, and duplicating it was how the collision above got its foothold.
   ------------------------------------------------------------------------ */

.kbia-archive--community .kbia-band__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem 1.25rem;
	margin-bottom: 1.5rem;
}

.kbia-archive--community .kbia-band__title {
	font-family: var(--kbia-font-heading);
	color: var(--kbia-heading);
	font-size: clamp(1.25rem, 1.4vw + 0.8rem, 1.75rem);
	line-height: var(--kbia-lh-heading);
	margin: 0;
}

.kbia-archive--community .kbia-band__meta {
	margin: 0;
	font-family: var(--kbia-font-mono);
	font-size: var(--kbia-fs-eyebrow);
	font-variant-numeric: tabular-nums;
	color: var(--kbia-muted);
}

/* --- The lead story and its secondaries ---------------------------------- */

.kbia-lead {
	display: grid;
	gap: clamp(1.25rem, 2.6vw, 2.375rem);
	align-items: start;
}

@media (min-width: 60rem) {
	/* The lead takes a little over half the row. Much wider and the two
	   secondaries beside it lose their images to a column too narrow to
	   carry one. */
	.kbia-lead { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
}

.kbia-lead__stack {
	display: flex;
	flex-direction: column;
	gap: clamp(1.125rem, 2vw, 1.625rem);
}

.kbia-card--lead .kbia-card__media { aspect-ratio: var(--kbia-ratio-news); }
.kbia-card--lede .kbia-card__media { aspect-ratio: var(--kbia-ratio-lede); }
.kbia-card--community .kbia-card__media { aspect-ratio: var(--kbia-ratio-news); }

.kbia-card__title--lead {
	font-size: clamp(1.375rem, 1.9vw + 0.8rem, 2.125rem);
	line-height: var(--kbia-lh-heading);
}

.kbia-card--lead .kbia-card__summary { max-width: 54ch; }

/* The secondaries carry no summary, so their titles do the work and sit a
   step above the archive grid's. */
.kbia-card--lede .kbia-card__title { font-size: 1.0625rem; }

/* --- The notice list -----------------------------------------------------
   No imagery, on purpose. Road, transit and construction updates decay within
   weeks; a photographic card gives a two-year-old closure the weight of a
   feature, which is most of why this section reads as abandoned. */

.kbia-notice-list {
	display: flex;
	flex-direction: column;
	border-top: 1px solid var(--kbia-border);
}

.kbia-notice-row {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.25rem 1.25rem;
	padding-block: 0.8125rem;
	border-bottom: 1px solid var(--kbia-border);
}

@media (min-width: 42rem) {
	.kbia-notice-row {
		grid-template-columns: 9rem minmax(0, 1fr);
		align-items: baseline;
	}
}

.kbia-notice-row__date {
	font-family: var(--kbia-font-mono);
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
	color: var(--kbia-muted);
}

.kbia-notice-row__title {
	font-family: var(--kbia-font-heading);
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.4;
	margin: 0;
}

.kbia-notice-row__title a {
	color: var(--kbia-heading);
	text-decoration: none;
}

.kbia-notice-row__title a:hover,
.kbia-notice-row__title a:focus-visible { color: var(--kbia-accent); }

/* --- Previous / next within a section ------------------------------------ */

.kbia-postnav {
	display: grid;
	gap: 0.875rem;
	max-width: var(--kbia-measure);
	margin-top: 2.75rem;
	padding-top: 1.625rem;
	border-top: 1px solid var(--kbia-border);
}

@media (min-width: 42rem) {
	.kbia-postnav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.kbia-postnav__link {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
	padding: 0.9375rem 1rem;
	border: 1px solid var(--kbia-border);
	border-radius: var(--kbia-radius-lg);
	text-decoration: none;
	transition: border-color var(--kbia-dur) var(--kbia-ease-out);
}

.kbia-postnav__link:hover,
.kbia-postnav__link:focus-visible { border-color: var(--kbia-accent); }

/* A lone "next" keeps the right-hand cell rather than sliding left, so the
   two directions always read in the order the reader expects. */
.kbia-postnav__link--next {
	text-align: right;
	align-items: flex-end;
	grid-column: 2;
}

@media (max-width: 41.999rem) {
	.kbia-postnav__link--next { grid-column: auto; }
}

.kbia-postnav__dir {
	font-family: var(--kbia-font-mono);
	font-size: 0.6875rem;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--kbia-muted);
}

.kbia-postnav__title {
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.34;
	color: var(--kbia-heading);
}

.kbia-postnav__link:hover .kbia-postnav__title,
.kbia-postnav__link:focus-visible .kbia-postnav__title { color: var(--kbia-accent); }

/* --- The sticky rail on a single post -------------------------------------
   Ten years of archive is only worth having if there is a way sideways out of
   whichever post a search result dropped you on. A list under the article is
   below the fold on every one of them, so this travels with the reader.

   The layout override is scoped to .kbia-single--community on purpose:
   .kbia-single__layout is shared with single-kbia_event.php, whose aside holds
   a facts box rather than a list of cards and wants the wider 2fr/1fr split it
   already has. */

@media (min-width: 60rem) {
	.kbia-single--community .kbia-single__layout {
		grid-template-columns: minmax(0, 1fr) minmax(17rem, 21rem);
	}

	/*
	 * The aside must span the full row height or the rail cannot stick.
	 *
	 * A sticky element travels inside its containing block and no further.
	 * .kbia-single__layout sets `align-items: start` -- correct for the event
	 * template's facts box -- which shrinks this column to exactly the height
	 * of its contents, leaving the rail zero distance to travel. It then
	 * scrolls away like a static element and the rule looks like it is being
	 * ignored. Stretching the column back to the row height is what gives it
	 * somewhere to go.
	 */
	.kbia-single--community .kbia-single__aside { align-self: stretch; }
}

.kbia-rail__inner {
	padding: 1.25rem;
	border-radius: var(--kbia-radius-xl);
	background: var(--kbia-surface-alt);
}

@media (min-width: 60rem) {
	/*
	 * Sticky, not fixed. Fixed would lift the rail out of the flow, and on a
	 * short post it would then sit over the footer; sticky keeps it inside its
	 * own grid column, so it travels with the article and stops where the
	 * column stops.
	 *
	 * The offset is --kbia-anchor-offset, the token that already records My
	 * Listing's fixed header height at each of its breakpoints (60/80/89px --
	 * see style.css). Re-measuring the header here would mean two values to
	 * keep in step after a parent theme update instead of one.
	 *
	 * .kbia-single__layout already sets `align-items: start`, without which a
	 * stretched grid item is full-height and sticky has nothing to travel in.
	 */
	.kbia-rail__inner {
		position: sticky;
		top: calc(var(--kbia-anchor-offset) + 1.5rem);

		/* If the rail ever outgrows the viewport -- a longer list, a large
		   text size -- it scrolls internally rather than stranding its last
		   card somewhere unreachable above the fold. Lenis is initialised
		   with allowNestedScroll, so this keeps native scrolling. */
		max-height: calc(100vh - var(--kbia-anchor-offset) - 3rem);
		overflow-y: auto;
		overscroll-behavior: contain;
	}
}

.kbia-rail__heading {
	margin: 0 0 1rem;
	font-family: var(--kbia-font-heading);
	font-size: 1.125rem;
	font-weight: 700;
	line-height: var(--kbia-lh-heading);
	color: var(--kbia-heading);
	letter-spacing: -0.01em;
}

.kbia-rail__list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.kbia-rail__item {
	display: grid;
	grid-template-columns: 4.5rem minmax(0, 1fr);
	gap: 0.875rem;
	align-items: start;
	padding: 0.75rem;
	border-radius: var(--kbia-radius-lg);
	background: var(--kbia-surface);
}

.kbia-rail__media {
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: var(--kbia-radius);
	background: var(--kbia-blue-800);
}

.kbia-rail__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.kbia-rail__title {
	margin: 0;
	font-family: var(--kbia-font-heading);
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.35;
	letter-spacing: -0.005em;
}

.kbia-rail__title a {
	color: var(--kbia-heading);
	text-decoration: none;
	transition: color var(--kbia-dur-fast) var(--kbia-ease-out);
}

.kbia-rail__item:hover .kbia-rail__title a,
.kbia-rail__title a:focus-visible { color: var(--kbia-accent); }

.kbia-rail__date {
	display: block;
	margin-top: 0.3125rem;
	font-family: var(--kbia-font-mono);
	font-size: 0.6875rem;
	font-variant-numeric: tabular-nums;
	color: var(--kbia-muted);
}

.kbia-rail__more {
	margin-top: 1rem;
	font-size: 0.8125rem;
}

@media (prefers-reduced-motion: reduce) {
	.kbia-rail__title a { transition: none; }
}

/* --- Single-post details -------------------------------------------------- */

.kbia-hero__sep { color: rgb(255 255 255 / 45%); margin-inline: 0.35rem; }

.kbia-single__figure figcaption {
	margin-top: 0.625rem;
	font-family: var(--kbia-font-mono);
	font-size: 0.75rem;
	line-height: var(--kbia-lh-body);
	color: var(--kbia-muted);
}

@media (prefers-reduced-motion: reduce) {
	.kbia-postnav__link { transition: none; }
}
