/**
 * Listing layer — hero, lead card, card, grid tweaks, filter, pagination,
 * page-head, search hero, 404, no-results.
 *
 * Depends on css/base.css for .lc-container, .lc-section, .lc-grid,
 * .lc-button*, .lc-chip*, .lc-chip-list, .lc-eyebrow, .lc-meta,
 * .lc-visually-hidden, and every .ds-* type utility. Nothing here redefines
 * those — only listing-specific components and the handful of places a
 * shared component needs a scoped tweak (e.g. .lc-card .lc-meta spacing).
 *
 * Tokens only. No literal hex/rgb — the two overlays below are built from
 * --ds-color-overlay-default/-dark, and the bottom gradient fades one of
 * those tokens to `transparent`. No !important anywhere.
 *
 * @package lifted-corduroy
 */

/* -------------------------------------------------------------------------
 * 1. Home hero
 * ---------------------------------------------------------------------- */

.lc-hero {
	position: relative;
	overflow: hidden;
	min-height: 70vw; /* spec §6 Home: "60vh (xs 70vw)" */
	display: flex;
	align-items: flex-end;
	isolation: isolate; /* contains .lc-hero__img's negative z-index */
}

@media ( min-width: 768px ) {
	.lc-hero {
		min-height: 60vh;
	}
}

/* z-index -1: the photo must paint BELOW the ::before/::after overlays. It is
   positioned and comes after ::before in tree order, so at z-index auto it
   painted over the flat overlay, which never reached the screen (QA
   2026-10-06: 55% of the headline's backdrop was under 3:1 at 390px). */
.lc-hero__img {
	position: absolute;
	inset: 0;
	z-index: -1;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.lc-hero__img--fallback {
	background: var( --ds-color-background-dark );
}

/* Overlays keep the white headline readable on light and dark photos alike
   (spec §3: "verify against the darkest and lightest plausible photo").
   Below 768px the headline fills most of the hero, so it gets the flat 50%
   overlay plus a bottom gradient. From 768px the text block sits in the
   bottom ~45% of the hero, so a gradient that holds overlay-default up to
   60% of the height gives the same guarantee and leaves the sky bright. */
.lc-hero::before,
.lc-hero::after {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.lc-hero::before {
	background: var( --ds-color-overlay-default );
}

.lc-hero::after {
	background: linear-gradient( to top, var( --ds-color-overlay-dark ), transparent 60% );
}

@media ( min-width: 768px ) {
	.lc-hero::before {
		content: none;
	}
	.lc-hero::after {
		background: linear-gradient( to top, var( --ds-color-overlay-dark ), var( --ds-color-overlay-default ) 60%, transparent );
	}
}

/* width: 100% — as a flex item with auto margins (.lc-container) this box
   otherwise shrink-wrapped the headline and centred itself, so the text did
   not share the container's left edge. */
.lc-hero__content {
	position: relative;
	z-index: 1;
	width: 100%;
	padding-block-end: var( --ds-space-300 );
}

.lc-hero__headline,
.lc-hero__subline {
	color: var( --ds-color-text-on-dark );
}

.lc-hero__headline {
	margin: 0;
}

.lc-hero__subline {
	margin: var( --ds-space-050 ) 0 0;
}

/* -------------------------------------------------------------------------
 * 2. Category filter
 * ---------------------------------------------------------------------- */

.lc-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var( --ds-space-100 );
	margin-bottom: var( --ds-space-200 );
}

.lc-filter__list {
	display: flex;
	flex-wrap: wrap;
	gap: var( --ds-space-050 );
}

/* Below 768px, 18 category pills wrapping into a grid pushed the first
   story off screen. A single-row horizontal scroll strip keeps the filter
   to one line; APPLY/CLEAR (.lc-filter__actions) still wrap to their own
   row below it because .lc-filter__list is forced to its own full-width
   flex line here. Real checkbox labels remain the tab stops, so keyboard
   users already get native scroll-into-view on focus — no JS needed. */
@media ( max-width: 767px ) {
	.lc-filter__list {
		flex-wrap: nowrap;
		flex: 1 1 100%;
		overflow-x: auto;
		scroll-snap-type: x proximity;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		padding-inline: var( --lc-gutter );
		margin-inline: calc( -1 * var( --lc-gutter ) );
		/* Snap positions measure from the scrollport, not the padding box.
		   Without this the first pill's `start` snap scrolled the strip by
		   one gutter on load, leaving "Activities" flush at the screen edge. */
		scroll-padding-inline: var( --lc-gutter );
		/* Right-edge fade so the strip reads as scrollable. mask-image's
		   default alpha mode: opaque (black) stays fully visible, the
		   gradient to transparent hides the last 2.5rem. */
		mask-image: linear-gradient( to right, black calc( 100% - 2.5rem ), transparent );
		-webkit-mask-image: linear-gradient( to right, black calc( 100% - 2.5rem ), transparent );
	}

	.lc-filter__list::-webkit-scrollbar {
		display: none;
	}

	.lc-filter__item {
		flex: 0 0 auto;
	}

	.lc-filter__pill {
		scroll-snap-align: start;
	}
}

/* position: relative makes the item the containing block of its visually
   hidden (position: absolute) checkbox. Without it the 18 checkboxes were
   placed against the page, escaped the phone scroll strip and widened the
   document to ~1670px, so the home page could be dragged sideways. */
.lc-filter__item {
	position: relative;
	display: inline-flex;
}

.lc-filter__pill {
	cursor: pointer;
	user-select: none;
}

/* Selected state — rendered server-side (is-selected) and kept live by
   js/category-filter.js toggling the same class; either way this is the
   only rule that needs to react to it. */
.lc-filter__pill.is-selected {
	background: var( --ds-color-background-action-selected-default );
	color: var( --ds-color-text-on-dark );
	border-color: transparent;
}

.lc-filter__pill.is-selected:hover {
	background: var( --ds-color-background-action-selected-hover );
}

/* The checkbox itself is visually hidden (.lc-visually-hidden) but must
   still show a focus ring on its label when reached by keyboard. */
.lc-filter__checkbox:focus-visible + .lc-filter__pill {
	outline: 2px solid var( --ds-color-border-focused-default );
	outline-offset: 2px;
}

.lc-filter__actions {
	display: flex;
	align-items: center;
	gap: var( --ds-space-150 );
}

.lc-filter__clear {
	color: var( --ds-color-text-link-default );
}

.lc-filter__clear:hover {
	color: var( --ds-color-text-link-hover );
}

/* -------------------------------------------------------------------------
 * 3. Cards
 * ---------------------------------------------------------------------- */

.lc-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var( --ds-color-background-default );
	border-radius: var( --ds-radius-emphasis );
	box-shadow: var( --ds-elevation-dark );
	overflow: hidden;
	transition: transform var( --lc-speed ) var( --lc-ease ), box-shadow var( --lc-speed ) var( --lc-ease );
}

.lc-card:hover {
	transform: translateY( -2px );
	box-shadow: var( --ds-elevation-default );
}

@media ( prefers-reduced-motion: reduce ) {
	.lc-card {
		transition: none;
	}
	.lc-card:hover {
		transform: none;
	}
}

.lc-card__media {
	display: block;
	position: relative;
	aspect-ratio: 3 / 2;
	background: var( --ds-color-background-secondary );
}

.lc-card__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.lc-card__body {
	display: flex;
	flex-direction: column;
	gap: var( --ds-space-075 );
	padding: var( --ds-space-150 );
	flex: 1 1 auto;
}

/* Chips must sit above the title link's whole-card overlay (below) so they
   stay independently clickable to their own category archive. */
.lc-card__chips {
	position: relative;
	z-index: 1;
}

.lc-card__title {
	margin: 0;
}

.lc-card__title a {
	color: var( --ds-color-text-headline );
	text-decoration: none;
}

/* Whole card is a click target: the title link gets a full-bleed ::after,
   the card is the positioning context, and the media link above is
   tabindex="-1" aria-hidden="true" so this stays the only real link a
   keyboard/AT user encounters for "open this story". */
.lc-card__title a::after {
	content: '';
	position: absolute;
	inset: 0;
}

.lc-card__excerpt {
	margin: 0;
	color: var( --ds-color-text-subdued );
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
}

.lc-card .lc-meta {
	margin-top: auto;
	padding-top: var( --ds-space-075 );
}

/* -------------------------------------------------------------------------
 * 4. Lead card
 * ---------------------------------------------------------------------- */

.lc-card--lead {
	grid-column: 1 / -1;
}

@media ( min-width: 1024px ) {
	.lc-card--lead {
		flex-direction: row;
	}
	.lc-card--lead .lc-card__media {
		flex: 0 0 60%;
		aspect-ratio: auto;
		align-self: stretch;
	}
	.lc-card--lead .lc-card__body {
		flex: 1 1 40%;
		justify-content: center;
	}
}

.lc-card--lead .lc-card__title {
	color: var( --ds-color-text-headline );
}

/* The date belongs to the story, the button is the action: the meta follows
   the excerpt at the body gap (not pinned to the bottom like a grid card's,
   which also lets justify-content centre the group), and the button stands
   off below it. Before, the date sat closer to the button than the text. */
.lc-card--lead .lc-meta {
	margin-top: 0;
	padding-top: 0;
}

.lc-card--lead .lc-card__cta {
	position: relative;
	z-index: 1;
	align-self: flex-start;
	margin-top: var( --ds-space-100 );
}

/* -------------------------------------------------------------------------
 * 5. Grid states
 * ---------------------------------------------------------------------- */

.lc-grid--loading {
	opacity: 0.5;
	transition: opacity var( --lc-speed ) var( --lc-ease );
}

@media ( prefers-reduced-motion: reduce ) {
	.lc-grid--loading {
		transition: none;
	}
}

.lc-no-results {
	grid-column: 1 / -1;
}

/* -------------------------------------------------------------------------
 * 6. Pagination
 * ---------------------------------------------------------------------- */

.lc-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var( --ds-space-075 );
	margin-top: var( --lc-space-block );
}

.lc-pagination__num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.25rem;
	min-height: 2.25rem;
	padding: var( --ds-space-025 ) var( --ds-space-075 );
	border-radius: var( --ds-radius-default );
	font: var( --ds-font-button-2 );
	text-decoration: none;
	color: var( --ds-color-text-default );
}

a.lc-pagination__num:hover {
	background: var( --ds-color-background-secondary );
}

.lc-pagination__num.is-current {
	background: var( --ds-color-background-action-selected-default );
	color: var( --ds-color-text-on-dark );
}

.lc-pagination__dots {
	color: var( --ds-color-text-subdued );
}

/* -------------------------------------------------------------------------
 * 7. Archive / search / 404 page heads
 * ---------------------------------------------------------------------- */

/* The one definition of .lc-page-head, shared by archive.php (with an
   eyebrow) and page.php (title only). article.css used to redefine its
   padding, and since it loads later it silently overrode this one.
   Header → title is a section gap; the bottom padding IS the block gap into
   the content below, so the next section/content drops its own top space
   (that stacking was the ~130px gap bug on category archives at 1024+).
   Never write a path glob like category-slash-star-slash in a CSS comment:
   its star-slash ends the comment early. This comment once did, which
   silently dropped the padding-bottom declaration that followed it. */
.lc-page-head {
	padding-top: var( --lc-space-section );
	padding-bottom: var( --lc-space-block );
}

.lc-page-head + .lc-section {
	padding-top: 0;
}

/* Eyebrow → title: ~15px optical (display-3's line box adds ~6px above the
   caps), matching the category chip → title gap on articles and cards. */
.lc-page-head__title {
	margin: var( --ds-space-050 ) 0 0;
	color: var( --ds-color-text-headline );
}

.lc-page-head__title:first-child {
	margin-top: 0;
}

.lc-page-head__desc {
	margin: var( --ds-space-100 ) 0 0;
	color: var( --ds-color-text-subdued );
	max-width: var( --lc-measure );
}

/* -------------------------------------------------------------------------
 * 8. Search hero
 * ---------------------------------------------------------------------- */

/* No overflow: hidden. It turned off aspect-ratio's content-based minimum
   height, so at 390px the 219px-tall box could not grow to fit the title and
   form, and clipped the first line of "SEARCH RESULTS FOR …". Every child is
   inset: 0 or in normal flow, so there is nothing else to clip. */
.lc-search-hero {
	position: relative;
	aspect-ratio: 16 / 9;
	max-height: 70vh;
	display: flex;
	align-items: flex-end;
	background: var( --ds-color-background-dark );
	isolation: isolate; /* contains .lc-search-hero__img's negative z-index */
}

@media ( min-width: 1024px ) {
	.lc-search-hero {
		aspect-ratio: 21 / 9;
	}
}

/* No image configured: collapse to a compact navy head instead of an empty 21:9 band. */
.lc-search-hero--no-image,
.lc-search-hero--no-image.lc-search-hero {
	aspect-ratio: auto;
	max-height: none;
}

.lc-search-hero--no-image::before,
.lc-search-hero--no-image::after {
	content: none;
}

/* Same stacking fix and overlay split as .lc-hero (section 1). */
.lc-search-hero__img {
	position: absolute;
	inset: 0;
	z-index: -1;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.lc-search-hero::before,
.lc-search-hero::after {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.lc-search-hero::before {
	background: var( --ds-color-overlay-default );
}

.lc-search-hero::after {
	background: linear-gradient( to top, var( --ds-color-overlay-dark ), transparent 60% );
}

@media ( min-width: 768px ) {
	.lc-search-hero::before {
		content: none;
	}
	.lc-search-hero::after {
		background: linear-gradient( to top, var( --ds-color-overlay-dark ), var( --ds-color-overlay-default ) 60%, transparent );
	}
}

.lc-search-hero__content {
	position: relative;
	z-index: 1;
	width: 100%;
	padding-block: var( --ds-space-300 );
}

.lc-search-hero__title {
	margin: 0 0 var( --ds-space-150 );
	color: var( --ds-color-text-on-dark );
}

.lc-search__form--hero {
	max-width: 32rem;
}

/* The count heads the results grid, so it takes the same gap as a
   .lc-section__head. */
.lc-search-results__count {
	margin: 0 0 var( --ds-space-200 );
	color: var( --ds-color-text-subdued );
}

/* -------------------------------------------------------------------------
 * 9. 404
 * ---------------------------------------------------------------------- */

.lc-404__title {
	margin: 0;
	color: var( --ds-color-text-headline );
}

.lc-404__copy {
	margin: var( --ds-space-150 ) 0;
	color: var( --ds-color-text-subdued );
}

.lc-404__search {
	max-width: 28rem;
}
