/**
 * Styled to the Garrards Replica theme's design tokens (style.css :root) so
 * the library reads as part of the site, not a bolted-on admin screen.
 * Falls back gracefully if a --r-* token is ever missing (var() defaults).
 *
 * Documents themselves are rendered as the theme's own .doc-pills/.doc-pill*
 * component (defined in the theme's style.css, used on product cards and
 * the product page) rather than plugin-specific markup, so a document looks
 * identical everywhere it appears on the site. This file only styles the
 * library's own chrome around that: the filter bar, the A-Z browse index,
 * per-product row (with its "Download all" button) and the load-more control.
 */

.celink-library {
	margin: 1.5em 0;
	font-size: 1rem;
}

/* Toolbar: same treatment as the theme's .branch-finder__bar. */
.celink-library__controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75em 1em;
	background: #fff;
	border: 1px solid var(--r-line, #dfe3e6);
	border-radius: var(--r-radius, 6px);
	box-shadow: var(--r-shadow-sm, 0 1px 3px rgba(20, 20, 30, 0.08));
	padding: 0.85em 1em;
	margin-bottom: 0.9em;
}

.celink-library__controls input[type="search"] {
	flex: 1 1 240px;
	max-width: 24em;
}

.celink-library__controls input[type="search"]:focus {
	outline: 2px solid var(--r-red, #8c131a);
	outline-offset: 1px;
	border-color: var(--r-red, #8c131a);
}

.celink-library__controls button {
	flex: none;
}

.celink-library__controls [data-celink-group] {
	flex: 1 1 220px;
	max-width: 20em;
}

/* A-Z browse index: same pill shape/behaviour as the theme's .chip, one
   letter per pill. Zero-count letters render as a disabled <span> (not a
   link) so the index holds its width instead of reshuffling as filters
   narrow the result set. */
.celink-library__az {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em;
	margin: 0 0 1em;
}

.celink-library__az-letter {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.9em;
	height: 1.9em;
	padding: 0 0.4em;
	background: var(--r-tab, #f2f3f4);
	color: var(--r-ink, #22262a);
	border: 1px solid var(--r-line, #dfe3e6);
	border-radius: 999px;
	font-size: 0.85em;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}

a.celink-library__az-letter:hover {
	background: var(--r-tab-hover, #e6e8ea);
	text-decoration: none;
}

.celink-library__az-letter.is-active {
	background: var(--r-red, #8c131a);
	border-color: var(--r-red, #8c131a);
	color: #fff;
}

a.celink-library__az-letter.is-active:hover {
	background: var(--r-red-dark, #6b0a10);
}

.celink-library__az-letter.is-disabled {
	color: var(--r-line, #dfe3e6);
	border-color: var(--r-line-soft, #eef1f3);
	background: transparent;
	cursor: default;
}

.celink-library__count {
	font-size: 0.9em;
	color: var(--r-muted, #6d757c);
	margin: 0 0 0.75em;
}

/* ---------- Results: one card per product, docs as pills ---------- */
.celink-library__results {
	display: flex;
	flex-direction: column;
	gap: 0.75em;
}

.celink-library__row {
	background: #fff;
	border: 1px solid var(--r-line, #dfe3e6);
	border-radius: var(--r-radius, 6px);
	padding: 0.9em 1em;
	transition: box-shadow 0.15s, border-color 0.15s;
}

.celink-library__row:hover {
	box-shadow: var(--r-shadow-sm, 0 1px 3px rgba(20, 20, 30, 0.08));
	border-color: #cfd5da;
}

.celink-library__row-head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5em 0.75em;
	margin-bottom: 0.6em;
}

.celink-library__row-title {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	color: var(--r-ink, #22262a);
}

.celink-library__row-title a {
	color: var(--r-ink, #22262a);
}

.celink-library__row-title a:hover {
	color: var(--r-red, #8c131a);
}

.celink-library__row-title--none {
	color: var(--r-muted, #6d757c);
	font-weight: 400;
	font-style: italic;
}

/* Second line under the title: a document group's subtitle (its lead
   product's active constituent, or a hand-typed one) / a product's active
   constituent — the same line the theme's product header shows. */
.celink-library__row-sub {
	display: block;
	color: var(--r-muted, #6d757c);
	font-size: 0.85em;
	font-weight: 400;
	line-height: 1.3;
	margin-top: 0.1em;
}

/* v1.9.0: the chemical facts under the title (rows whose product has
   <H3> Specifications sections), compact:
     400 g/kg dinotefuran · Water soluble granule (WSG)
     Targets: Ants, Cockroaches, … +4 more                              */
.celink-library__facts {
	min-width: 0;
	margin: -0.3em 0 0.6em;
	font-size: 0.84em;
	line-height: 1.45;
	color: var(--r-body, #41474d);
}

.celink-library__facts p {
	margin: 0;
}

.celink-library__facts-spec {
	color: var(--r-ink, #22262a);
	font-weight: 600;
}

.celink-library__facts-spec span + span::before {
	content: "\00B7";
	color: var(--r-muted, #6d757c);
	font-weight: 400;
	margin: 0 0.45em;
}

.celink-library__facts-pests b {
	color: var(--r-muted, #6d757c);
	font-weight: 600;
}

.celink-library__facts-more {
	color: var(--r-red, #8c131a);
	font-weight: 600;
	white-space: nowrap;
}

a.celink-library__facts-more:hover {
	text-decoration: underline;
}

/* images="on": [ product image ] [ title row / facts / pills ] */
.celink-library__row--images {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	column-gap: 1em;
	align-items: start;
}

.celink-library__row-media {
	grid-row: 1 / span 3;
	display: block;
	width: 72px;
	height: 72px;
	background: #fff;
	border: 1px solid var(--r-line-soft, #eceff1);
	border-radius: 4px;
	overflow: hidden;
}

.celink-library__row-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 3px;
	box-sizing: border-box;
}

.celink-library__pills {
	margin: 0;
}

.celink-library__download-all {
	flex: none;
	background: #fff;
	color: var(--r-ink, #22262a);
	border: 1px solid var(--r-line, #dfe3e6);
	border-radius: 4px;
	padding: 0.4em 0.85em;
	font-size: 0.85em;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
}

.celink-library__download-all:hover,
.celink-library__download-all:focus-visible {
	border-color: var(--r-red, #8c131a);
	color: var(--r-red, #8c131a);
}

.celink-library__empty {
	background: #fff;
	border: 1px dashed var(--r-line, #dfe3e6);
	border-radius: var(--r-radius, 6px);
	padding: 1.5em;
	text-align: center;
	color: var(--r-muted, #6d757c);
}

/* Infinite scroll: a real, focusable "Load more" link/button (same shape as
   the theme's .button--outline) — JS auto-clicks it via IntersectionObserver
   as it nears the viewport, but it stays keyboard/no-JS operable throughout. */
.celink-library__load-more-wrap {
	display: flex;
	justify-content: center;
	margin-top: 1.25em;
}

.celink-library__load-more {
	display: inline-block;
	background: #fff;
	color: var(--r-red, #8c131a);
	box-shadow: inset 0 0 0 1px var(--r-line, #dfe3e6);
	border-radius: 4px;
	padding: 0.6em 1.4em;
	font-weight: 600;
	font-size: 0.95em;
	text-decoration: none;
	cursor: pointer;
}

.celink-library__load-more:hover,
.celink-library__load-more:focus-visible {
	background: var(--r-red, #8c131a);
	color: #fff;
	box-shadow: inset 0 0 0 1px var(--r-red, #8c131a);
	text-decoration: none;
}

.celink-library__load-more[aria-busy="true"] {
	opacity: 0.6;
	pointer-events: none;
}

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
	.celink-library__controls {
		padding: 0.75em 0.85em;
	}

	.celink-library__controls input[type="search"],
	.celink-library__controls [data-celink-group] {
		flex: 1 1 100%;
		max-width: none;
	}

	.celink-library__row {
		padding: 0.8em 0.9em;
	}

	.celink-library__row--images {
		grid-template-columns: 56px minmax(0, 1fr);
		column-gap: 0.75em;
	}

	.celink-library__row-media {
		width: 56px;
		height: 56px;
	}

	.celink-library__download-all {
		width: 100%;
		text-align: center;
	}
}
