/**
 * YES Internet - Clients — front-end styles.
 *
 * Every value the design exposes is a --yic-* custom property, declared once in
 * a zero-specificity :where() block below. That block is deliberately
 * specificity-free: a theme overriding a property on :root, on body, on the
 * component, or inline all win against it. A plain `.yic-clients { ... }`
 * selector would shadow a :root override, because equal specificity is broken
 * by proximity to the element.
 */

:where(.yic-logo-wall, .yic-clients) {
	/* Palette */
	--yic-color-primary: #285282;
	--yic-color-accent: #1e6fb0;
	--yic-color-ink: #2a2622;
	--yic-color-body: #4a443c;
	--yic-color-muted: #6e675e;
	--yic-color-surface: #ffffff;
	--yic-color-line: #e6ded1;
	--yic-color-line-strong: #e0d8cb;
	--yic-color-sand: #ece4d6;
	--yic-color-canvas: #f6f2ea;
	--yic-tint-default: #285282;

	/* Shape and motion */
	--yic-radius: 14px;
	--yic-radius-pill: 999px;
	--yic-gap: 22px;
	--yic-transition: 0.2s ease;
	--yic-font-display: "IBM Plex Serif", Georgia, serif;

	/* Logo wall */
	--yic-wall-cols: 4;
	--yic-wall-cols-md: 2;
	--yic-wall-cols-sm: 2;
	--yic-wall-gap: 1px;
	--yic-wall-tile-min-h: 104px;
	--yic-wall-tile-pad: 18px 20px;
	--yic-logo-h: 30px;

	/* Cards */
	--yic-card-min: 280px;
	--yic-card-ratio: 4 / 3;
	--yic-initials-size: 34px;
	--yic-initials-color: rgba(255, 255, 255, 0.62);
	--yic-tint: var(--yic-tint-default);

	/*
	 * Filter bar. --yic-filters-top and --yic-filters-bg are deliberately NOT
	 * declared here: the script measures the page's own fixed header and
	 * background and publishes them as --yic-filters-auto/-auto-bg. Declaring
	 * a default would make the var() fallback chain below resolve to it and
	 * the measurement would never apply. Set either one from your theme to
	 * override the measurement entirely.
	 */
	--yic-filter-pad: 11px 18px;
	--yic-filter-size: 14.5px;
}

/* --------------------------------------------------------------------------
 * Logo wall
 *
 * The 1px gap is filled by the container background, which is what draws the
 * grid lines. The container clips so the radius cuts the corner tiles.
 * ----------------------------------------------------------------------- */

.yic-logo-wall {
	background: var(--yic-color-line);
	border: 1px solid var(--yic-color-line);
	border-radius: var(--yic-radius);
	display: grid;
	gap: var(--yic-wall-gap);
	grid-auto-rows: 1fr;
	grid-template-columns: repeat(var(--yic-wall-cols), minmax(0, 1fr));
	overflow: hidden;
}

.yic-logo-wall__tile {
	align-items: center;
	background: var(--yic-color-surface);
	display: flex;
	justify-content: center;
	min-height: var(--yic-wall-tile-min-h);
	padding: var(--yic-wall-tile-pad);
	text-align: center;
}

.yic-logo-wall__link {
	align-items: center;
	display: flex;
	height: 100%;
	justify-content: center;
	max-width: 100%;
	text-decoration: none;
	transition: opacity var(--yic-transition);
	width: 100%;
}

.yic-logo-wall__link:hover,
.yic-logo-wall__link:focus-visible {
	opacity: 0.7;
}

/* The height is authored per client so a wall of mixed logos reads evenly. */
.yic-logo-wall__img {
	display: block;
	height: var(--yic-logo-h);
	max-width: 100%;
	object-fit: contain;
	width: auto;
}

.yic-logo-wall__text {
	color: var(--yic-color-muted);
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.3;
	text-transform: uppercase;
}

.yic-logo-wall--grayscale .yic-logo-wall__img {
	filter: grayscale(1);
	opacity: 0.75;
	transition: filter var(--yic-transition), opacity var(--yic-transition);
}

.yic-logo-wall--grayscale .yic-logo-wall__tile:hover .yic-logo-wall__img {
	filter: grayscale(0);
	opacity: 1;
}

@media (max-width: 1150px) {
	.yic-logo-wall {
		grid-template-columns: repeat(var(--yic-wall-cols-md), minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.yic-logo-wall {
		grid-template-columns: repeat(var(--yic-wall-cols-sm), minmax(0, 1fr));
	}
}

/* --------------------------------------------------------------------------
 * Filter bar
 *
 * Hidden until the script marks the component as interactive, so a visitor
 * without working JavaScript sees the complete, unfiltered list rather than a
 * row of buttons that do nothing.
 * ----------------------------------------------------------------------- */

.yic-clients__filters {
	display: none;
}

.yic-clients--js .yic-clients__filters {
	border-bottom: 1px solid var(--yic-color-line);
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 34px;
	padding-bottom: 20px;
}

/*
 * Astra — and a great many other themes — set `body { overflow-x: hidden }` to
 * contain stray wide elements. That turns body into a scroll container, which
 * silently disables position:sticky for every descendant. `clip` does exactly
 * the same clipping without creating a scroll container, so sticky keeps
 * working and nothing else changes. The class is added by the script, and only
 * when a sticky filter bar is actually on the page.
 */
.yic-sticky-host body {
	overflow-x: clip;
	overflow-y: visible;
}

.yic-clients--js.yic-clients--sticky .yic-clients__filters {
	backdrop-filter: blur(10px);

	/* Author override, else the measured page background, else the design's. */
	background: var( --yic-filters-bg, var( --yic-filters-auto-bg, var( --yic-color-canvas ) ) );

	/*
	 * The bar's own padding is what keeps the pills clear of the header while
	 * stuck — a margin would sit outside the sticky box and let cards scroll
	 * through the gap.
	 */
	padding-top: 16px;
	position: sticky;

	/* Author override, else the height of whatever fixed chrome the script
	   found occluding the top of the viewport. */
	top: var( --yic-filters-top, var( --yic-filters-auto, 0px ) );
	z-index: 20;
}

.yic-clients__filter {
	background: var(--yic-color-surface);
	border: 1px solid var(--yic-color-line-strong);
	border-radius: var(--yic-radius-pill);
	color: var(--yic-color-body);
	cursor: pointer;
	font-family: inherit;
	font-size: var(--yic-filter-size);
	font-weight: 500;
	line-height: 1.2;
	padding: var(--yic-filter-pad);
	transition: background-color var(--yic-transition), border-color var(--yic-transition), color var(--yic-transition);
}

.yic-clients__filter:hover {
	border-color: var(--yic-color-primary);
	color: var(--yic-color-primary);
}

/* Styled off the ARIA state, so the visual and assistive states cannot drift. */
.yic-clients__filter[aria-selected="true"] {
	background: var(--yic-color-primary);
	border-color: var(--yic-color-primary);
	color: #fff;
	font-weight: 600;
}

.yic-clients__filter:focus-visible {
	outline: 2px solid var(--yic-color-accent);
	outline-offset: 2px;
}

.yic-clients__count {
	font-weight: 500;
	margin-left: 7px;
	opacity: 0.6;
}

/* --------------------------------------------------------------------------
 * Card grid
 * ----------------------------------------------------------------------- */

.yic-clients__grid {
	display: grid;
	gap: var(--yic-gap);
	grid-template-columns: repeat(auto-fill, minmax(var(--yic-card-min), 1fr));
}

.yic-clients__grid--fixed {
	grid-template-columns: repeat(var(--yic-card-cols, 3), minmax(0, 1fr));
}

.yic-client-card {
	background: var(--yic-color-surface);
	border: 1px solid var(--yic-color-line);
	border-radius: var(--yic-radius);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* The UA rule for [hidden] is display:none, which loses to display:flex. */
.yic-client-card[hidden] {
	display: none !important;
}

.yic-client-card__media {
	aspect-ratio: var(--yic-card-ratio);
	background: var(--yic-color-sand);
	overflow: hidden;
}

.yic-client-card__media--initials {
	align-items: center;
	background: var(--yic-tint);
	display: flex;
	justify-content: center;
}

.yic-client-card__initials {
	color: var(--yic-initials-color);
	font-family: var(--yic-font-display);
	font-size: var(--yic-initials-size);
	font-weight: 600;
	letter-spacing: 0.06em;
	line-height: 1;
}

.yic-client-card__img {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

.yic-client-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 12px;
	padding: 20px 22px 22px;
}

.yic-client-card__eyebrow {
	color: var(--yic-color-accent);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.11em;
	line-height: 1.3;
	margin: 0;
	text-transform: uppercase;
}

.yic-client-card__title {
	color: var(--yic-color-primary);
	font-family: var(--yic-font-display);
	font-size: 19px;
	font-weight: 600;
	line-height: 1.25;
	margin: 0;
}

.yic-client-card__link {
	color: inherit;
	text-decoration: none;
}

.yic-client-card__link:hover,
.yic-client-card__link:focus-visible {
	text-decoration: underline;
}

/* margin-top:auto pins the details to the bottom, so cards with titles of
   different lengths still line their detail rows up across the grid. */
.yic-client-card__details {
	display: grid;
	font-size: 13.5px;
	gap: 6px 14px;
	grid-template-columns: auto 1fr;
	margin: auto 0 0;
}

.yic-client-card__details dt {
	color: var(--yic-color-muted);
	margin: 0;
}

.yic-client-card__details dd {
	color: var(--yic-color-ink);
	font-weight: 600;
	margin: 0;
}

/* --------------------------------------------------------------------------
 * Responsive
 * ----------------------------------------------------------------------- */

@media (max-width: 700px) {
	.yic-clients__grid,
	.yic-clients__grid--fixed {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px;
	}

	/* The bar scrolls sideways instead of wrapping to three rows of pills. */
	.yic-clients--js .yic-clients__filters {
		flex-wrap: nowrap;
		gap: 8px;
		margin-bottom: 24px;
		overflow-x: auto;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.yic-clients--js .yic-clients__filters::-webkit-scrollbar {
		display: none;
	}

	.yic-clients__filter {
		flex: 0 0 auto;
		font-size: 13.5px;
		padding: 9px 14px;
		white-space: nowrap;
	}
}

@media (max-width: 440px) {
	.yic-clients__grid,
	.yic-clients__grid--fixed {
		grid-template-columns: 1fr;
	}
}

/* --------------------------------------------------------------------------
 * Utilities
 *
 * Defined here rather than assumed: the plugin has to work on themes that
 * never declare .screen-reader-text.
 * ----------------------------------------------------------------------- */

.yic-clients .screen-reader-text {
	border: 0;
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

@media (prefers-reduced-motion: reduce) {
	.yic-logo-wall__link,
	.yic-clients__filter,
	.yic-logo-wall--grayscale .yic-logo-wall__img {
		transition: none;
	}
}
