/* ==========================================================================
   Visual brand filter - premium logo tiles (0.6.5.1-staging)

   A tile is a light card with the mark centred inside a fixed figure box.
   The logo is sized with `object-fit: contain`, so it always keeps its own
   aspect ratio and is never cropped, stretched or boxed in colour. Brands with
   no logo asset fall back to a wordmark tile of identical dimensions, so the
   grid stays even whether 0 or 25 logos are present.
   ========================================================================== */

.wt-brandbar {
	margin: 0 0 clamp(1.25rem, 2.5vw, 1.9rem);
	padding: 1.05rem 1.15rem 1.2rem;
	border: 1px solid #e3e8ed;
	border-radius: 18px;
	background: linear-gradient(180deg, #fff, #fbfcfd);
	box-shadow: 0 6px 22px rgba(18, 35, 51, .06);
}

.wt-brandbar__title {
	margin: 0 0 .85rem;
	color: #6a7885;
	font-size: .7rem;
	font-weight: 900;
	letter-spacing: .1em;
	text-transform: uppercase;
}

/*
 * Compact auto-fill grid. Tiles stay a consistent size and the row count
 * adapts to the container, so 26 tiles never become a wall of oversized
 * buttons.
 */
.wt-brandbar__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
	gap: .6rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wt-brandbar__grid > li {
	margin: 0;
}

/* ------------------------------------------------------------------- tile */

.wt-brand-tile {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: .3rem;
	height: 100%;
	min-height: 86px;
	padding: .6rem .5rem .55rem;
	border: 1px solid #e0e6ec;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(18, 35, 51, .05);
	color: #203241;
	text-decoration: none;
	transition: transform .18s ease, box-shadow .18s ease,
	            border-color .18s ease, background-color .18s ease;
}

.wt-brand-tile__figure {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 34px;
}

/* The mark fills as much of the box as it can without deforming. */
.wt-brand-tile__logo {
	display: block;
	width: auto;
	max-width: 100%;
	height: 100%;
	max-height: 34px;
	object-fit: contain;
	object-position: center;
}

.wt-brand-tile__icon {
	width: 30px;
	height: 30px;
	color: #33475a;
}

.wt-brand-tile__wordmark {
	color: #1d2f3f;
	text-transform: uppercase;
	font-family: var(--wt-font-display, inherit);
	font-size: .84rem;
	font-weight: 900;
	letter-spacing: .015em;
	line-height: 1.1;
	text-align: center;
	overflow-wrap: anywhere;
}

.wt-brand-tile__name {
	color: #6a7885;
	font-size: .63rem;
	font-weight: 800;
	letter-spacing: .05em;
	text-align: center;
	text-transform: uppercase;
}

/* A wordmark tile already states the brand, so the caption is redundant. */
.wt-brand-tile.is-text .wt-brand-tile__name {
	display: none;
}

.wt-brand-tile__count {
	position: absolute;
	top: .32rem;
	right: .34rem;
	min-width: 1.15rem;
	padding: .05rem .28rem;
	border-radius: 999px;
	background: #eef1f4;
	color: #5b6874;
	font-size: .62rem;
	font-variant-numeric: tabular-nums;
	font-weight: 800;
	line-height: 1.5;
	text-align: center;
}

/* ------------------------------------------------------------------ states */

@media (prefers-reduced-motion: no-preference) {
	.wt-brand-tile:hover {
		transform: translateY(-2px);
	}
}

.wt-brand-tile:hover {
	border-color: #d6532e;
	box-shadow: 0 10px 24px rgba(18, 35, 51, .14);
}

/* Selected brand: orange border plus a soft orange glow. */
.wt-brand-tile.is-active {
	border-color: #d6532e;
	background: #fffaf8;
	box-shadow: 0 0 0 3px rgba(214, 83, 46, .17),
	            0 8px 20px rgba(214, 83, 46, .16);
}

.wt-brand-tile.is-active .wt-brand-tile__count {
	background: #d6532e;
	color: #fff;
}

.wt-brand-tile.is-active .wt-brand-tile__wordmark,
.wt-brand-tile.is-active .wt-brand-tile__icon {
	color: #97381a;
}

.wt-brand-tile:focus-visible {
	outline: 3px solid #172838;
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 1023px) {
	.wt-brandbar {
		padding-inline: .9rem;
	}

	/*
	 * Single scroll-snap row. Tiles are sized so roughly 2.5 are visible, which
	 * leaves the third clipped at the edge - the clearest signal that the row
	 * scrolls. Negative margins let it bleed to the card edge.
	 */
	.wt-brandbar__grid {
		display: flex;
		gap: .55rem;
		margin-inline: -.9rem;
		padding-inline: .9rem;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scroll-padding-left: .9rem;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior-x: contain;
		scrollbar-width: none;
	}

	.wt-brandbar__grid::-webkit-scrollbar {
		display: none;
	}

	.wt-brandbar__grid > li {
		flex: 0 0 calc((100% - 1.1rem) / 2.5);
		min-width: 118px;
		scroll-snap-align: start;
	}

	.wt-brand-tile {
		min-height: 96px;
		padding: .7rem .55rem .6rem;
	}

	.wt-brand-tile__figure,
	.wt-brand-tile__logo {
		height: 38px;
		max-height: 38px;
	}

	.wt-brand-tile__icon {
		width: 34px;
		height: 34px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wt-brand-tile {
		transition: none;
	}
}


/* ==========================================================================
   Collapsed one-row state (0.6.5.3-staging)

   Desktop opens on a single row so a long brand list cannot dominate the page.
   `grid-auto-rows` pins every row to the tile height, which makes one row a
   predictable max-height rather than a guess. The rule is scoped to
   `.is-collapsible.is-collapsed`, both of which are only ever present when the
   script is running - so with JavaScript off the full grid renders and the
   button stays hidden.
   ========================================================================== */

@media (min-width: 1024px) {
	.wt-brandbar__grid {
		grid-auto-rows: 86px;
	}

	.wt-brandbar.is-collapsible.is-collapsed .wt-brandbar__grid {
		max-height: 86px;
		overflow: hidden;
	}

	.wt-brandbar.is-collapsible .wt-brandbar__grid {
		transition: max-height .28s ease;
	}
}

.wt-brandbar__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .4rem;
	margin: .85rem auto 0;
	padding: .5rem 1rem;
	border: 1px solid #d7dee5;
	border-radius: 999px;
	background: #fff;
	color: #33475a;
	font-size: .76rem;
	font-weight: 900;
	letter-spacing: .04em;
	text-transform: uppercase;
	cursor: pointer;
	transition: border-color .16s ease, color .16s ease, background-color .16s ease;
}

/* Centred under the grid. */
.wt-brandbar__toggle:not([hidden]) {
	display: flex;
	width: fit-content;
}

.wt-brandbar__toggle:hover {
	border-color: #d6532e;
	background: #fffaf8;
	color: #97381a;
}

.wt-brandbar__toggle:focus-visible {
	outline: 3px solid #172838;
	outline-offset: 2px;
}

.wt-brandbar__chevron {
	width: 15px;
	height: 15px;
	transition: transform .22s ease;
}

.wt-brandbar__toggle[aria-expanded="true"] .wt-brandbar__chevron {
	transform: rotate(180deg);
}

/* Mobile keeps the single scrollable row, so the toggle is meaningless there. */
@media (max-width: 1023px) {
	.wt-brandbar__toggle {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wt-brandbar__grid,
	.wt-brandbar__chevron {
		transition: none;
	}
}

/* ==========================================================================
   Brand tile consistency pass (0.6.5.9)

   The tiles already used real brand logos on light cards with object-fit
   contain, so nothing here introduces imagery. What was uneven was the
   perceived size: a wide wordmark (Bridgestone is roughly 8:1) hit the 100%
   width limit long before the height limit and rendered visually smaller than
   a compact mark. Giving the figure a fixed box and allowing the logo to use
   its full width equalises the optical area without stretching anything -
   contain still preserves every logo's own proportions.
   ========================================================================== */

.wt-brand-tile__figure {
	width: 100%;
	height: 38px;
	padding-inline: 0.15rem;
}

.wt-brand-tile__logo {
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 38px;
	object-fit: contain;
	object-position: center;
}

/* A caption under the mark aids recognition for less familiar brands. */
.wt-brand-tile.has-logo .wt-brand-tile__name {
	display: block;
	margin-top: 0.1rem;
	font-size: 0.58rem;
	letter-spacing: 0.06em;
	color: #7b8894;
}

.wt-brand-tile {
	min-height: 96px;
	padding: 0.65rem 0.5rem 0.55rem;
	background: #fff;
	border-color: #e4e9ee;
	box-shadow: 0 1px 2px rgba(18, 35, 51, .05);
}

.wt-brand-tile.is-active {
	background: #fffaf8;
	border-color: #d6532e;
}

@media (max-width: 1023px) {
	/* Keep roughly 2.5 cards in view so the row reads as scrollable. */
	.wt-brandbar__grid > li {
		flex-basis: calc((100% - 1.1rem) / 2.5);
		min-width: 122px;
	}

	.wt-brand-tile {
		min-height: 104px;
	}

	.wt-brand-tile__figure,
	.wt-brand-tile__logo {
		height: 42px;
		max-height: 42px;
	}
}
