/**
 * Ajax Filter Search front-end styles.
 *
 * Everything is scoped to .afs and themed with custom properties, so a theme can
 * restyle it with, for example:  .afs { --afs-accent: #0a7; --afs-radius: 0; }
 */

.afs {
	--afs-accent: #f1b45c;
	--afs-text: inherit;
	--afs-muted: #566069;
	--afs-border: #dcdfe3;
	--afs-surface: #f6f7f8;
	--afs-radius: 4px;
	--afs-gap: 1rem;

	box-sizing: border-box;
	color: var(--afs-text);
}

.afs *,
.afs *::before,
.afs *::after {
	box-sizing: inherit;
}

.afs [hidden] {
	display: none !important;
}

/* Legacy (1.x) template overrides hide their summary panel with this class. */
.afs .afs-Hidden {
	display: none;
}

/* Visually hidden, still announced. */
.afs-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Tabs ------------------------------------------------------------------ */

.afs-Tabs {
	margin: 0 0 var(--afs-gap);
}

.afs-CommonTabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
	border-bottom: 1px solid var(--afs-border);
}

.afs-CommonTabs li {
	margin: 0;
}

.afs-CommonTabs a {
	display: block;
	padding: 0.5rem 0;
	border-bottom: 3px solid transparent;
	margin-bottom: -1px;
	color: var(--afs-muted);
	text-decoration: none;
}

.afs-CommonTabs a:hover,
.afs-CommonTabs a:focus-visible,
.afs-CommonTabs .active a {
	color: inherit;
	border-bottom-color: var(--afs-accent);
}

/* Filters ----------------------------------------------------------------- */

.afs-Filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: var(--afs-gap);
	padding: var(--afs-gap);
	background: var(--afs-surface);
	border-radius: var(--afs-radius);
}

.afs-field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 9rem;
}

.afs-field-search {
	flex: 1 1 14rem;
}

.afs-field label {
	font-size: 0.8125em;
	font-weight: 600;
	color: var(--afs-muted);
}

.afs-field input,
.afs-field select {
	width: 100%;
	min-height: 2.5rem;
	padding: 0.375rem 0.625rem;
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
	background: #fff;
	color: #222;
	font: inherit;
}

.afs-field input:focus-visible,
.afs-field select:focus-visible,
.afs-btn:focus-visible,
.afs-CommonTabs a:focus-visible,
.afs-summary-toggle:focus-visible {
	outline: 2px solid var(--afs-accent);
	outline-offset: 2px;
}

.afs-actions {
	display: flex;
	gap: 0.5rem;
	margin-left: auto;
}

.afs-btn {
	display: inline-block;
	min-height: 2.5rem;
	padding: 0.375rem 0.875rem;
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
	background: #fff;
	color: #222;
	font: inherit;
	line-height: 1.4;
	text-decoration: none;
	cursor: pointer;
}

.afs-btn:hover {
	border-color: var(--afs-accent);
}

.afs-btn-primary,
.afs-btn[aria-pressed="true"] {
	background: var(--afs-accent);
	border-color: var(--afs-accent);
	color: #1b1b1b;
}

/* Layout switch --------------------------------------------------------- */

.afs-Switch {
	display: none;
	justify-content: flex-end;
	gap: 0.5rem;
	margin: var(--afs-gap) 0 0;
}

.afs-js .afs-Switch {
	display: flex;
}

.afs-switch-btn {
	min-height: 2rem;
	padding: 0.125rem 0.75rem;
	font-size: 0.875em;
}

/* Results ----------------------------------------------------------------- */

.afs-results {
	margin-top: var(--afs-gap);
	transition: opacity 0.15s ease;
}

.afs-loading .afs-results {
	opacity: 0.5;
}

.afs-TableHeader {
	display: grid;
	grid-template-columns: 1fr 5fr;
	gap: var(--afs-gap);
	padding: 0.5rem 0;
	border-bottom: 2px solid var(--afs-accent);
	font-size: 0.8125em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--afs-muted);
}

.afs-layout-grid .afs-TableHeader {
	display: none;
}

.afs-items {
	display: block;
}

.afs-item {
	display: grid;
	grid-template-columns: 1fr 5fr;
	gap: var(--afs-gap);
	padding: var(--afs-gap) 0;
	border-bottom: 1px solid var(--afs-border);
	/* Legacy template markup used 12-column grid classes; these keep overrides working. */
}

.afs-item .col-sm-2,
.afs-item .col-sm-10 {
	width: auto;
	min-width: 0;
	float: none;
}

.afs-item h3,
.afs-item h4,
.afs-item h6,
.afs-item p {
	margin: 0 0 0.375rem;
}

.afs-item h6,
.afs-item .afs-terms {
	font-size: 0.75em;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--afs-muted);
}

.afs-item h3,
.afs-item h4 {
	font-size: 1.125em;
	line-height: 1.35;
}

.afs-item a {
	color: inherit;
	text-decoration-color: var(--afs-accent);
	text-underline-offset: 0.15em;
}

.afs-item a:hover {
	text-decoration-thickness: 2px;
}

.afs-PRDate {
	font-weight: 600;
}

.afs-PRTimezone {
	font-size: 0.8125em;
	color: var(--afs-muted);
}

.afs-summary-toggle {
	padding: 0;
	border: 0;
	background: none;
	color: var(--afs-muted);
	font: inherit;
	font-size: 0.875em;
	cursor: pointer;
}

.afs-summary-toggle::before {
	content: "+";
	display: inline-block;
	width: 1em;
	color: var(--afs-accent);
	font-weight: 700;
}

.afs-summary-toggle[aria-expanded="true"]::before {
	content: "\2212";
}

.afs-PRSummary {
	margin-top: 0.5rem;
}

.afs-more {
	font-size: 0.875em;
	font-weight: 600;
}

.afs-count {
	margin: var(--afs-gap) 0 0;
	font-size: 0.875em;
	color: var(--afs-muted);
}

.afs-none,
.afs-error {
	padding: var(--afs-gap);
	background: var(--afs-surface);
	border-radius: var(--afs-radius);
}

/* Grid layout ------------------------------------------------------------- */

.afs-layout-grid .afs-items {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: var(--afs-gap);
	margin-top: var(--afs-gap);
}

.afs-layout-grid .afs-item {
	display: block;
	padding: var(--afs-gap);
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
}

.afs-layout-grid .afs-col-date {
	margin-bottom: 0.5rem;
}

/* Pagination -------------------------------------------------------------- */

.afs-pagination {
	margin-top: var(--afs-gap);
}

.afs-pagination ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.afs-pagination li {
	margin: 0;
}

.afs-pagination .afs-btn {
	min-width: 2.5rem;
	text-align: center;
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 600px) {
	.afs-TableHeader {
		display: none;
	}

	.afs-item {
		display: block;
	}

	.afs-col-date {
		margin-bottom: 0.375rem;
	}

	.afs-actions {
		width: 100%;
		margin-left: 0;
	}

	.afs-actions .afs-btn {
		flex: 1;
	}

	.afs-pagination ul {
		justify-content: center;
	}
}

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