/**
 * Unified Library ([ffa_library]) — faceted discovery surface.
 * Brand colours come from theme.json presets (--wp--preset--color--*) when the
 * FFA Brand theme is active, with neutral fallbacks so the plugin works anywhere.
 */
.ffarl-ul {
	--ul-blue: var(--wp--preset--color--ffa-blue, #004C97);
	--ul-navy: var(--wp--preset--color--corduroy, #25306D);
	--ul-teal: var(--wp--preset--color--steel-teal, #167C90);
	--ul-ink: var(--wp--preset--color--ink, #23303D);
	--ul-line: var(--wp--preset--color--line, #DCE6F2);
	--ul-paper: var(--wp--preset--color--paper, #EDEEF1);
	--ul-surface: var(--wp--preset--color--surface, #F4F7FB);
	--ul-white: var(--wp--preset--color--white, #fff);
	--ul-sans: var(--wp--preset--font-family--sans, system-ui, sans-serif);
	max-width: 1280px;
	margin: 0 auto;
	font-family: var(--ul-sans);
	color: var(--ul-ink);
	/* When a filter re-render scrolls the user back to the top, stop clear of the
	   sticky site header (matches the sidebar's sticky offset). */
	scroll-margin-top: 110px;
}

/* ---- Search bar ---- */
/* Grid (not flex) so the search column deterministically takes all free space and
   spans over the results — flex-grow proved unreliable under the theme's wrapper. */
.ffarl-ul__searchbar {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 1rem;
	align-items: center;
	width: 100%;
	margin: 0 0 1.5rem;
}
.ffarl-ul__search {
	display: flex;
	min-width: 0;
}
/* ElasticPress autosuggest wraps the <input> in .ep-autosuggest-container at
   runtime; that wrapper then becomes the flex child, so it (not the input) must
   grow — otherwise the bar collapses to the input's intrinsic width. */
.ffarl-ul__search .ep-autosuggest-container {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
}
@media (max-width: 600px) {
	/* Stack the language picker under a full-width search on small screens. */
	.ffarl-ul__searchbar { grid-template-columns: 1fr; }
}
/* Language picker — grouped with the search bar, not buried in the sidebar. */
.ffarl-ul__lang {
	display: inline-flex;
	flex: 0 0 auto;
	border: 1.5px solid color-mix(in srgb, var(--ul-navy) 22%, transparent);
	border-radius: 9px;
	overflow: hidden;
}
.ffarl-ul__lang-opt {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.5rem 0.9rem;
	font-size: 0.85rem;
	cursor: pointer;
	white-space: nowrap;
}
.ffarl-ul__lang-opt + .ffarl-ul__lang-opt {
	border-left: 1.5px solid color-mix(in srgb, var(--ul-navy) 14%, transparent);
}
.ffarl-ul__lang-opt input { margin: 0; accent-color: var(--ul-teal); }
.ffarl-ul__lang-opt:hover { background: var(--ul-surface); color: var(--ul-blue); }
.ffarl-ul__search input[type="search"] {
	/* flex:1 fills the bar when autosuggest is off; width:100% fills the
	   .ep-autosuggest-container wrapper when it is on. */
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	font: inherit;
	font-size: 0.95rem;
	padding: 0.6rem 0.8rem;
	border: 1.5px solid color-mix(in srgb, var(--ul-navy) 25%, transparent);
	border-right: 0;
	border-radius: 9px 0 0 9px;
}
.ffarl-ul__search input:focus { outline: none; border-color: var(--ul-blue); }
.ffarl-ul__search button {
	border: 0;
	border-radius: 0 9px 9px 0;
	padding: 0 1.1rem;
	font-size: 1.1rem;
	cursor: pointer;
	background: var(--ul-teal);
	color: var(--ul-white);
}

/* ---- Layout: sidebar + results ---- */
.ffarl-ul__layout {
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	gap: 2rem;
	align-items: start;
}
/* The mobile "Filters" toggle is hidden on desktop — the sidebar is always shown. */
.ffarl-ul__filters-toggle { display: none; }
@media (max-width: 781px) {
	.ffarl-ul__layout { grid-template-columns: 1fr; gap: 1rem; }
	/* Filters collapse behind a toggle so results are visible first, not buried
	   under a full-height wall of facets. */
	.ffarl-ul__filters-toggle {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		padding: 0.8rem 1rem;
		background: var(--ul-blue);
		color: var(--ul-white);
		border: 0;
		border-radius: 4px;
		font-size: 1rem;
		font-weight: 700;
		cursor: pointer;
	}
	.ffarl-ul__filters-toggle::after {
		content: "\25BE";
		font-size: 0.9em;
		transition: transform 0.15s ease;
	}
	.ffarl-ul__layout.filters-open .ffarl-ul__filters-toggle::after { transform: rotate(180deg); }
	.ffarl-ul__sidebar { display: none; position: static; top: auto; }
	.ffarl-ul__layout.filters-open .ffarl-ul__sidebar { display: block; }
}

/* ---- Sidebar ---- */
.ffarl-ul__sidebar {
	background: var(--ul-white);
	border: 1px solid color-mix(in srgb, var(--ul-navy) 18%, transparent);
	border-top: 4px solid var(--ul-blue);
	border-radius: 4px;
	padding: 0.5rem;
	position: sticky;
	top: 110px;
}

/* ---- Facet groups ---- */
.ffarl-ul__facet { border-bottom: 1px solid var(--ul-line); padding: 0.85rem 0.6rem; }
.ffarl-ul__facet:last-of-type { border-bottom: 0; }
.ffarl-ul__facet-label {
	margin: 0 0 0.5rem;
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--ul-navy);
}
/* No internal scrollbars — facets size to their content; the page scrolls instead
   (nested scrollbars were a pain on small screens). Long lists are tamed by the
   collapsible Competitive Events group and the collapsed Career Pathways / Format. */
.ffarl-ul__facet-list { }

/* Collapsible facet section (Career Pathways, Format): heading is a toggle button
   with an active-count chip; the list hides until opened. */
.ffarl-ul__facet-head {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	width: 100%;
	margin: 0 0 0.5rem;
	padding: 0;
	background: none;
	border: 0;
	cursor: pointer;
	font-family: inherit;
}
.ffarl-ul__facet-head .ffarl-ul__facet-label { margin: 0; }
.ffarl-ul__facet-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.15rem;
	height: 1.15rem;
	padding: 0 0.3rem;
	border-radius: 999px;
	background: var(--ul-teal);
	color: var(--ul-white);
	font-size: 0.68rem;
	font-weight: 700;
}
.ffarl-ul__facet-caret {
	margin-left: auto;
	width: 0.9rem;
	height: 0.9rem;
	color: var(--ul-navy);
}
.ffarl-ul__facet-caret::before {
	content: "\25BE";
	font-size: 0.8rem;
	display: inline-block;
	transition: transform 0.15s ease;
}
.ffarl-ul__facet--collapsible:not(.is-open) .ffarl-ul__facet-caret::before { transform: rotate(-90deg); }
.ffarl-ul__facet--collapsible:not(.is-open) .ffarl-ul__facet-list { display: none; }
.ffarl-ul__facet-head:hover .ffarl-ul__facet-label,
.ffarl-ul__facet-head:hover .ffarl-ul__facet-caret { color: var(--ul-blue); }

.ffarl-ul__check {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	padding: 0.28rem 0;
	font-size: 0.85rem;
	line-height: 1.3;
	cursor: pointer;
}
.ffarl-ul__check input { margin-top: 0.15rem; accent-color: var(--ul-teal); flex: 0 0 auto; }
.ffarl-ul__check:hover { color: var(--ul-blue); }
.ffarl-ul__check.is-child { font-size: 0.82rem; }

/* Collapsible term group within a facet (e.g. Competitive Events ▸ its events). */
.ffarl-ul__group-head { display: flex; align-items: center; gap: 0.1rem; }
.ffarl-ul__group-head .ffarl-ul__check { flex: 1; }
.ffarl-ul__toggle {
	flex: 0 0 auto;
	width: 1.3rem;
	height: 1.3rem;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	color: var(--ul-navy);
	display: flex;
	align-items: center;
	justify-content: center;
}
.ffarl-ul__toggle::before {
	content: "\25B8";
	font-size: 0.7rem;
	transition: transform 0.15s ease;
}
.ffarl-ul__group.is-open > .ffarl-ul__group-head .ffarl-ul__toggle::before { transform: rotate(90deg); }
.ffarl-ul__group-children { padding-left: 1.35rem; }
.ffarl-ul__group:not(.is-open) > .ffarl-ul__group-children { display: none; }
.ffarl-ul__toggle:hover { color: var(--ul-blue); }

/* Live-update loading state */
.ffarl-ul__layout.is-loading { opacity: 0.55; transition: opacity 0.1s ease; }

/* ---- Sidebar actions ---- */
.ffarl-ul__actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.8rem 0.6rem 0.5rem;
	border-top: 1px solid var(--ul-line);
	margin-top: 0.25rem;
}
.ffarl-ul__apply {
	flex: 1;
	background: var(--ul-blue);
	color: var(--ul-white);
	border: 0;
	border-radius: 999px;
	padding: 0.55rem 1rem;
	font: inherit;
	font-weight: 700;
	font-size: 0.82rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	cursor: pointer;
}
.ffarl-ul__clear { font-size: 0.82rem; color: color-mix(in srgb, var(--ul-ink) 65%, transparent); text-decoration: none; }
.ffarl-ul__clear:hover { color: var(--ul-blue); text-decoration: underline; }

/* ---- Results bar: count + active chips ---- */
.ffarl-ul__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	margin-bottom: 1.1rem;
}
.ffarl-ul__count { font-size: 0.85rem; font-weight: 700; color: color-mix(in srgb, var(--ul-ink) 70%, transparent); }
.ffarl-ul__chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ffarl-ul__chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.78rem;
	font-weight: 600;
	text-decoration: none;
	padding: 0.25rem 0.6rem;
	border-radius: 999px;
	background: color-mix(in srgb, var(--ul-teal) 12%, transparent);
	color: var(--ul-teal);
	border: 1px solid color-mix(in srgb, var(--ul-teal) 30%, transparent);
}
.ffarl-ul__chip span { font-size: 0.95rem; line-height: 1; }
.ffarl-ul__chip:hover { background: color-mix(in srgb, var(--ul-teal) 20%, transparent); }
.ffarl-ul__chip--clear { background: none; color: color-mix(in srgb, var(--ul-ink) 60%, transparent); border-color: var(--ul-line); }

/* ---- Result cards ---- */
.ffarl-ul__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 1rem;
}
.ffarl-ul__card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--ul-line);
	border-radius: 8px;
	overflow: hidden;
	text-decoration: none;
	color: inherit;
	background: var(--ul-white);
	transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.ffarl-ul__card:hover { border-color: var(--ul-blue); box-shadow: 0 4px 14px color-mix(in srgb, var(--ul-navy) 14%, transparent); }
/* Media placeholder: the striped background + icon sizing come from the theme's
 * .ffa-card__media--ph; centre the icon here since the card is the link (the
 * theme centres on an inner <a> the unified card cannot nest). */
.ffarl-ul__media {
	margin: 0;
	aspect-ratio: 16 / 9;
	display: flex;
	align-items: center;
	justify-content: center;
	color: color-mix(in srgb, var(--ul-blue) 50%, transparent);
}
.ffarl-ul__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.ffarl-ul__body {
	display: flex;
	flex-direction: column;
	padding: 0.8rem 0.95rem 0.95rem;
}
.ffarl-ul__kind {
	font-size: 0.66rem;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--ul-teal);
	font-weight: 800;
}
.ffarl-ul__title {
	display: block;
	font-weight: 700;
	margin: 0.3rem 0 0;
	line-height: 1.3;
	color: var(--ul-navy);
}
/* ElasticPress search-term highlight inside titles. */
.ffarl-ul__title mark,
.ffarl-ul__title .ep-highlight {
	background: color-mix(in srgb, var(--wp--preset--color--ffa-yellow, #F2CE1B) 45%, transparent);
	color: inherit;
	padding: 0 0.1em;
	border-radius: 2px;
}
.ffarl-ul__excerpt {
	margin-top: 0.4rem;
	font-size: 0.82rem;
	line-height: 1.45;
	color: color-mix(in srgb, var(--ul-ink) 68%, transparent);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ffarl-ul__empty { margin-top: 1.5rem; color: color-mix(in srgb, var(--ul-ink) 65%, transparent); }
.ffarl-ul__suggest { margin: 0 0 1rem; font-size: 1.05rem; color: color-mix(in srgb, var(--ul-ink) 75%, transparent); }
.ffarl-ul__suggest a { font-style: italic; font-weight: 600; color: var(--ul-accent, #16274A); text-decoration: underline; }

/* ---- Pagination ---- */
.ffarl-ul__pagination {
	display: flex;
	gap: 0.6rem;
	align-items: center;
	justify-content: center;
	margin-top: 1.75rem;
}
.ffarl-ul__page {
	padding: 0.45rem 0.85rem;
	border: 1px solid var(--ul-line);
	border-radius: 999px;
	text-decoration: none;
	color: var(--ul-navy);
	font-size: 0.85rem;
	font-weight: 600;
}
.ffarl-ul__page:hover { border-color: var(--ul-blue); color: var(--ul-blue); }
.ffarl-ul__page-of { font-size: 0.82rem; color: color-mix(in srgb, var(--ul-ink) 60%, transparent); }
