/* Gallery chrome only — NOT part of any container's CSS (exempt from token lint). */
.cl-copy-bar {
	display: flex;
	align-items: center;
	gap: 0.75em;
	margin-block-end: 1em;
	padding: 0.4em 0.75em;
	border: 1px dashed var(--neutral-light, #c5ccd4);
	border-radius: 0.4em;
	font-size: 0.8rem;
}

.cl-copy-bar__slug {
	font-family: ui-monospace, monospace;
	color: var(--text-dark, #333);
	opacity: 0.75;
}

.cl-copy-btn {
	margin-inline-start: auto;
	padding: 0.35em 0.9em;
	border: 1px solid var(--primary, #85161b);
	border-radius: 0.35em;
	background: var(--primary, #85161b);
	color: var(--white, #fff);
	font-weight: 600;
	cursor: pointer;
}

.cl-copy-btn:hover { filter: brightness(1.1); }
.cl-copy-btn:focus-visible { outline: 2px solid var(--primary, #85161b); outline-offset: 2px; }

/* Category-page deep-link highlight (gallery.js adds/removes on hash scroll). */
[data-cl-slug].cl-section--highlight {
	outline: 2px solid var(--accent, var(--primary, #85161b));
	outline-offset: 0.5em;
}
@media (prefers-reduced-motion: no-preference) {
	[data-cl-slug] { transition: outline-color 0.3s ease; }
}

/* Utility. */
.cl-visually-hidden {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
	padding: 0;
	margin: -1px;
}

/* ---------------------------------------------------------------------
 * /library/ index — hero, sticky filter bar, card grid.
 * Chrome only (see TOKEN-CONTRACT.md): exempt from token lint, but keeps
 * the same "ACSS var with a hard fallback" convention as the rest of
 * this file so it still adopts a site's palette/type/space where present.
 *
 * NOTE on --bg-light: this site's own ACSS settings alias
 * `--bg-light: var(--neutral-light)` (a mid-gray, #d9d9d9) — using it for
 * page/card surfaces was the actual source of the "flat gray scaffolding"
 * look (a solid gray filter bar and gray card bodies against an otherwise
 * white theme background). Surfaces below intentionally use `--white`
 * instead: it is the one ACSS token that is reliably an actual white
 * across installs, which is what a clean "white card on white page" design
 * needs regardless of how a given site maps its `bg-*` aliases.
 * ------------------------------------------------------------------- */

.cl-index {
	display: flex;
	flex-direction: column;
	gap: var(--space-m, 1.5rem);
	padding-block: var(--space-l, 2rem);
	padding-inline: var(--space-m, 1.5rem);
	max-inline-size: var(--content-width, 75rem);
	margin-inline: auto;
	background: var(--white, #fff);
}

.cl-index__hero {
	display: flex;
	flex-direction: column;
	gap: var(--space-xs, 0.5rem);
	padding-block-end: var(--space-xs, 0.5rem);
}

.cl-index__title {
	font-family: var(--heading-font-family, inherit);
	font-size: var(--h1, 2.5rem);
	color: var(--text-dark, #1a1a1a);
	margin: 0;
}

/* Thin accent rule under the title, in place of the old gray band look. */
.cl-index__title::after {
	content: '';
	display: block;
	inline-size: 3.5rem;
	block-size: 4px;
	margin-block-start: 0.5em;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--primary, #85161b), var(--accent, var(--primary, #85161b)));
}

.cl-index__promise {
	font-family: var(--text-font-family, inherit);
	font-size: var(--text-l, 1.15rem);
	color: var(--text-dark, #333);
	opacity: 0.85;
	margin: 0;
	max-inline-size: 60ch;
}

.cl-index__stats {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-s, 0.75rem);
	margin: 0;
	font-size: var(--text-s, 0.9rem);
}

.cl-index__stat {
	display: inline-flex;
	align-items: center;
	color: var(--text-dark, #333);
	opacity: 0.75;
	font-weight: 600;
}

.cl-index__stat + .cl-index__stat {
	padding-inline-start: var(--space-s, 0.75rem);
	border-inline-start: 1px solid var(--neutral-light, #c5ccd4);
}

/* Two-column body: sticky left filter rail + results column. Collapses to a
 * single stacked column on narrow viewports (rail above results, not sticky). */
.cl-index__body {
	display: grid;
	grid-template-columns: minmax(13rem, 15rem) 1fr;
	gap: var(--space-l, 2rem);
	align-items: start;
}

.cl-index__rail {
	position: sticky;
	inset-block-start: var(--space-s, 0.75rem);
	max-block-size: calc(100vh - 2 * var(--space-s, 0.75rem));
	overflow-y: auto;
	overscroll-behavior: contain;
}

.cl-index__results { min-inline-size: 0; }

@media (max-width: 52rem) {
	.cl-index__body { grid-template-columns: 1fr; }
	.cl-index__rail {
		position: static;
		max-block-size: none;
		overflow: visible;
		padding-block-end: var(--space-s, 0.75rem);
		border-block-end: 1px solid var(--neutral-light, #c5ccd4);
	}
}

.cl-index__filters {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--space-m, 1.25rem);
}

.cl-index__chips-legend {
	margin: 0;
	font-size: var(--text-s, 0.85rem);
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--text-dark, #333);
	opacity: 0.7;
}

.cl-index__chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-xs, 0.5rem);
	margin-block-start: calc(-1 * var(--space-xs, 0.5rem));
}

/* Rail context: category chips stack full-width as a vertical list, count
 * pushed to the trailing edge (a scannable menu, not a wrapping pill cloud). */
@media (min-width: 52.0625rem) {
	.cl-index__chips { flex-direction: column; align-items: stretch; }
	.cl-index__chips .cl-chip { justify-content: space-between; inline-size: 100%; }
}

.cl-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.4em 0.9em;
	border: 1px solid var(--neutral-light, #c5ccd4);
	border-radius: var(--radius, 999px);
	background: transparent;
	color: var(--text-dark, #333);
	font-size: var(--text-s, 0.9rem);
	font-weight: 600;
	cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
	.cl-chip { transition: border-color 0.15s ease, background-color 0.15s ease; }
}

.cl-chip:hover { border-color: var(--primary, #85161b); }
.cl-chip:focus-visible { outline: 2px solid var(--primary, #85161b); outline-offset: 2px; }

.cl-chip[aria-pressed="true"] {
	background: var(--primary, #85161b);
	border-color: var(--primary, #85161b);
	color: var(--white, #fff);
}

.cl-chip__count {
	padding: 0.1em 0.5em;
	border-radius: var(--radius, 999px);
	background: var(--neutral-ultra-light, #f2f2f2);
	color: var(--text-dark, #333);
	font-size: 0.85em;
}

.cl-chip[aria-pressed="true"] .cl-chip__count {
	/* Solid white + dark text (not translucent-on-primary): the actual
	   --primary token's lightness varies per site and a semi-transparent
	   white pill on top of it cannot guarantee 4.5:1 either way. */
	background: var(--white, #fff);
	color: var(--text-dark, #1a1a1a);
}

.cl-index__search-input {
	inline-size: 100%;
	padding: 0.5em 0.9em;
	border: 1px solid var(--neutral-light, #c5ccd4);
	border-radius: var(--radius, 0.4em);
	background: transparent;
	color: var(--text-dark, #333);
	font-size: var(--text-s, 0.9rem);
}

.cl-index__search-input::placeholder { color: var(--text-dark, #333); opacity: 0.5; }

.cl-index__search-input:focus-visible {
	outline: 2px solid var(--primary, #85161b);
	outline-offset: 2px;
	border-color: var(--primary, #85161b);
}

/* ---------------------------------------------------------------------
 * Facet rows — Tier / Interactivity, injected by gallery.js after the
 * manifest fetch resolves. `flex-basis: 100%` on `.cl-index__facets-row`
 * forces it onto its own line inside the existing `.cl-index__filters`
 * flex-wrap container (chips + search stay on the row above) — additive,
 * no restructuring of the server-rendered hero/count/empty/grid stack.
 * See gallery.js's wireIndexFilters() docblock for the rail-vs-top-bar
 * design call. ------------------------------------------------------- */

.cl-index__facets-row {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--space-m, 1.25rem);
	padding-block-start: var(--space-m, 1rem);
	border-block-start: 1px solid var(--neutral-light, #c5ccd4);
	/* Flows last in the rail: Search -> Category -> Tier -> Interactivity. */
}

/* On narrow viewports the rail is horizontal again: let facets + chips wrap. */
@media (max-width: 52rem) {
	.cl-index__facets-row { flex-direction: row; flex-wrap: wrap; }
}

.cl-facet {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4em;
	border: 0;
	margin: 0;
	padding: 0;
	min-inline-size: 0;
}

.cl-facet__legend {
	padding: 0;
	margin-inline-end: 0.3em;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--text-dark, #333);
	opacity: 0.6;
}

.cl-facet__option {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.3em 0.7em;
	border: 1px solid var(--neutral-light, #c5ccd4);
	border-radius: var(--radius, 999px);
	background: var(--white, #fff);
	color: var(--text-dark, #333);
	font-size: var(--text-s, 0.85rem);
	cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
	.cl-facet__option { transition: border-color 0.15s ease, background-color 0.15s ease; }
}

.cl-facet__option:hover { border-color: var(--primary, #85161b); }

/* JS toggles `is-checked` on change (authoritative); `:has()` is a
   progressive no-cost enhancement for browsers that support it so the
   very first paint (before JS finishes wiring) already looks right once
   restored from a hash. Both target the same visual result. */
.cl-facet__option.is-checked,
.cl-facet__option:has(input:checked) {
	background: var(--primary-ultra-light, #fbe9ea);
	border-color: var(--primary, #85161b);
	color: var(--primary-dark, #6e1216);
}

.cl-facet__option--empty {
	opacity: 0.45;
}

.cl-facet__checkbox {
	accent-color: var(--primary, #85161b);
	inline-size: 1em;
	block-size: 1em;
	margin: 0;
}

.cl-facet__checkbox:focus-visible {
	outline: 2px solid var(--primary, #85161b);
	outline-offset: 2px;
}

.cl-facet__count {
	opacity: 0.6;
	font-variant-numeric: tabular-nums;
}

.cl-index__count {
	margin: 0;
	font-size: var(--text-s, 0.9rem);
	color: var(--text-dark, #333);
	opacity: 0.75;
}

.cl-index__count:focus-visible {
	outline: 2px solid var(--primary, #85161b);
	outline-offset: 2px;
}

.cl-index__empty {
	padding: var(--space-l, 2rem);
	text-align: center;
	color: var(--text-dark, #333);
	opacity: 0.75;
	border: 1px dashed var(--neutral-light, #c5ccd4);
	border-radius: var(--radius, 0.4em);
}

.cl-index__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
	gap: var(--grid-gap, var(--space-m, 1.5rem));
}

.cl-card[hidden] { display: none; }

.cl-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--neutral-light, #c5ccd4);
	border-radius: var(--radius, 0.5em);
	overflow: clip;
	background: var(--white, #fff);
	box-shadow: var(--box-shadow-1, 0 1px 2px rgb(0 0 0 / 0.06));
}

@media (prefers-reduced-motion: no-preference) {
	.cl-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
	.cl-card:hover { transform: translateY(-2px); box-shadow: var(--box-shadow-2, 0 0.5em 1em rgb(0 0 0 / 0.1)); }
	.cl-card__img { transition: transform 0.2s ease; }
	.cl-card:hover .cl-card__img { transform: scale(1.02); }
}

.cl-card:focus-within { outline: 2px solid var(--primary, #85161b); outline-offset: 2px; }

.cl-card__thumb-link { display: block; }

.cl-card__thumb {
	position: relative;
	display: block;
	aspect-ratio: 16 / 10;
	background: var(--neutral-ultra-light, #f2f2f2);
	border-block-end: 1px solid var(--neutral-light, #c5ccd4);
	overflow: clip;
}

.cl-card__img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	object-position: top;
	display: block;
}

.cl-card__thumb--empty::after {
	content: 'No preview yet';
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: var(--text-s, 0.85rem);
	color: var(--text-dark, #333);
	opacity: 0.5;
}

.cl-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--space-xs, 0.5rem);
	padding: var(--space-s, 1rem);
}

.cl-card__title {
	margin: 0;
	font-family: var(--heading-font-family, inherit);
	font-size: var(--h6, 1.05rem);
	font-weight: 500;
}

.cl-card__title a {
	color: var(--text-dark, #1a1a1a);
	text-decoration: none;
}

.cl-card__title a:hover { text-decoration: underline; }
.cl-card__title a:focus-visible { outline: 2px solid var(--primary, #85161b); outline-offset: 2px; }

.cl-card__category {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	margin: 0;
	padding: 0.2em 0.65em;
	border-radius: var(--radius, 999px);
	font-size: 0.75rem;
	font-weight: 600;
	/* Dark-tint-on-light-tint, both from the SAME primary family: the
	   spec pairing for the category tag. Real values on this site
	   (--primary-dark #6e1216 on --primary-ultra-light #fbe9ea, the
	   library's oxblood identity — see DESIGN-CONTRACT.md) hold a very
	   high contrast ratio (10.2:1), well above 4.5:1. */
	color: var(--primary-dark, #6e1216);
	background: var(--primary-ultra-light, #fbe9ea);
}

.cl-card__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em;
}

/* Light tinted pill + dark text, not a colored fill + white text: an ACSS
   token's actual lightness varies per site (verified — real accent/primary
   values in dev were too light for 4.5:1 white text). Dark text over a
   near-white "-ultra-light" tint holds contrast regardless of hue. */
.cl-badge {
	display: inline-flex;
	align-items: center;
	padding: 0.2em 0.6em;
	border-radius: var(--radius, 999px);
	font-size: 0.72rem;
	font-weight: 600;
	color: var(--text-dark, #1a1a1a);
	background: var(--neutral-ultra-light, #f2f2f2);
}

.cl-badge--tier-static { background: var(--neutral-ultra-light, #f2f2f2); }
.cl-badge--tier-dynamic { background: var(--accent-ultra-light, #faf4ea); }
.cl-badge--interactivity-none { background: var(--neutral-ultra-light, #f2f2f2); }
.cl-badge--interactivity-css { background: var(--secondary-ultra-light, #ecf8ee); }
.cl-badge--interactivity-js { background: var(--primary-ultra-light, #fbe9ea); }

.cl-card__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	margin-block-start: auto;
	padding-block-start: var(--space-xs, 0.5rem);
}

.cl-copy-btn--card {
	flex: 1 1 auto;
	padding: 0.4em 0.8em;
	font-size: var(--text-s, 0.85rem);
}

/* Quieter secondary action (dynamic-tier copy) — outline, not solid. */
.cl-copy-btn--outline {
	background: transparent;
	color: var(--primary-dark, #6e1216);
	border-color: var(--primary, #85161b);
}

.cl-copy-btn--outline:hover { background: var(--primary-ultra-light, #fbe9ea); filter: none; }
.cl-copy-btn--outline:focus-visible { outline: 2px solid var(--primary, #85161b); outline-offset: 2px; }

/* ---------------------------------------------------------------------
 * Load-more — injected by gallery.js after `.cl-index__grid`. The library
 * is 76+ containers and growing; this is the scale mechanism (renders
 * PAGE_SIZE matches at a time instead of the whole filtered set).
 * ------------------------------------------------------------------- */

.cl-show-more-wrap {
	display: flex;
	justify-content: center;
	padding-block: var(--space-l, 2rem);
}

.cl-show-more-wrap[hidden] { display: none; }

.cl-show-more {
	padding: 0.65em 1.6em;
	border: 1px solid var(--primary, #85161b);
	border-radius: var(--radius, 999px);
	background: transparent;
	color: var(--primary-dark, #6e1216);
	font-weight: 700;
	font-size: var(--text-s, 0.9rem);
	cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
	.cl-show-more { transition: background-color 0.15s ease, color 0.15s ease; }
}

.cl-show-more:hover { background: var(--primary-ultra-light, #fbe9ea); }

.cl-show-more:focus-visible {
	outline: 2px solid var(--primary, #85161b);
	outline-offset: 2px;
}
