/*
 * Framleiðendur (page-templates/brands.php) – „less is more" (MINIMAL-PLAN §6.4): one toolbar row
 * (sector chips, search, count) and every brand as a plain tile – logo, name and one muted line; the
 * tile is the link. Enqueued by inc/content-pages.php (maras_content_page_styles()). Tokens only.
 */

.ms-brand-card[hidden],
.ms-brands-empty[hidden],
.ms-brand-search[hidden] {
	display: none;
}

.ms-brands-page {
	padding-block: clamp(32px, 4vw, 56px) var(--ms-section-gap);
}

.ms-brands-page__intro {
	margin-bottom: var(--ms-space-6);
}

/* ------------------------------------------------------------------ Toolbar */
.ms-brand-toolbar {
	margin-bottom: var(--ms-space-6);
}

.ms-brand-toolbar__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ms-space-3) var(--ms-space-5);
}

.ms-brand-filter ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ms-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.ms-brand-filter .ms-chip.is-active,
.ms-brand-filter .ms-chip[aria-current="true"] {
	border-color: var(--ms-color-ink);
	background: var(--ms-color-ink);
	color: var(--ms-color-surface);
}

.ms-brand-filter .ms-chip[aria-current="true"] .ms-chip__count {
	color: inherit;
}

/* Phones: one swipeable chip row. */
@media (max-width: 560px) {
	.ms-brand-filter {
		flex: 0 0 calc(100% + var(--ms-gutter) * 2);
		min-width: 0;
		margin-inline: calc(var(--ms-gutter) * -1);
	}

	.ms-brand-filter ul {
		flex-wrap: nowrap;
		overflow-x: auto;
		padding: 2px var(--ms-gutter) 4px;
		scrollbar-width: none;
	}

	.ms-brand-filter ul::-webkit-scrollbar {
		display: none;
	}

	.ms-brand-filter li {
		flex: none;
	}
}

.ms-brand-search {
	position: relative;
	flex: 1 1 220px;
	max-width: 320px;
	margin-left: auto;
}

@media (max-width: 560px) {
	.ms-brand-search {
		flex-basis: 100%;
		max-width: none;
		margin-left: 0;
	}
}

.ms-brand-search__icon {
	position: absolute;
	top: 50%;
	left: 13px;
	color: var(--ms-color-text-muted);
	pointer-events: none;
	transform: translateY(-50%);
}

.ms-brand-search__input {
	width: 100%;
	height: 40px;
	padding: 0 14px 0 38px;
	border: 1px solid var(--ms-color-field-border);
	border-radius: var(--ms-field-radius);
	background: var(--ms-color-surface);
	color: var(--ms-color-ink);
	font: inherit;
	font-size: .9375rem;
}

.ms-brand-search__input:focus-visible {
	border-color: var(--ms-color-link);
	outline: none;
	box-shadow: var(--ms-field-focus-ring);
}

.ms-brand-toolbar__status {
	margin: 0;
	color: var(--ms-color-text-muted);
	font-size: var(--ms-fs-sm);
	font-variant-numeric: var(--ms-num);
}

.ms-brand-search[hidden] + .ms-brand-toolbar__status {
	margin-left: auto;
}

/* ------------------------------------------------------------------ Brand tiles */
.ms-brand-index {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--ms-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 700px) {
	.ms-brand-index {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 1000px) {
	.ms-brand-index {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (min-width: 1300px) {
	.ms-brand-index {
		grid-template-columns: repeat(6, minmax(0, 1fr));
		gap: var(--ms-space-4);
	}
}

.ms-brand-card {
	position: relative;
	display: grid;
	align-content: start;
	gap: 2px;
	min-width: 0;
	padding: var(--ms-space-3) var(--ms-space-3) var(--ms-space-4);
	border: 1px solid var(--ms-color-hairline);
	border-radius: var(--ms-radius-lg);
	background: var(--ms-color-surface);
	transition: border-color var(--ms-t-fast) var(--ms-ease);
}

.ms-brand-card:hover {
	border-color: var(--ms-color-rule-strong);
}

.ms-brand-card:focus-within {
	border-color: var(--ms-color-ink);
}

.ms-brand-card__logo {
	display: grid;
	place-items: center;
	height: 56px;
	margin-bottom: var(--ms-space-2);
}

.ms-brand-card__image {
	width: auto;
	max-width: 80%;
	height: auto;
	max-height: 40px;
	object-fit: contain;
}

.ms-brand-card__wordmark {
	color: var(--ms-color-text-muted);
	font-size: var(--ms-fs-sm);
	font-weight: var(--ms-fw-bold);
	text-align: center;
}

.ms-brand-card__link {
	color: var(--ms-color-ink);
	font-size: .9375rem;
	font-weight: var(--ms-fw-bold);
	line-height: 1.3;
	text-decoration: none;
	overflow-wrap: anywhere;
}

/* The whole tile is the link. */
.ms-brand-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.ms-brand-card__link:focus-visible {
	outline: none;
}

.ms-brand-card__link:focus-visible::after {
	outline: 2px solid var(--ms-color-focus);
	outline-offset: 2px;
}

.ms-brand-card:hover .ms-brand-card__link {
	text-decoration: underline;
	text-underline-offset: .2em;
}

.ms-brand-card__meta {
	margin: 0;
	color: var(--ms-color-text-muted);
	font-size: .8125rem;
	line-height: 1.4;
}

/* Phones: one calm list – logo beside the name, thin dividers instead of tiles. */
@media (max-width: 559px) {
	.ms-brand-index {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
		border-top: 1px solid var(--ms-color-rule);
	}

	.ms-brand-card {
		grid-template-columns: 72px minmax(0, 1fr);
		align-content: center;
		column-gap: var(--ms-space-4);
		padding: var(--ms-space-3) 0;
		border: 0;
		border-bottom: 1px solid var(--ms-color-rule);
		border-radius: 0;
	}

	.ms-brand-card:hover,
	.ms-brand-card:focus-within {
		border-color: var(--ms-color-rule);
	}

	.ms-brand-card__logo {
		grid-row: 1 / span 2;
		justify-items: start;
		height: 40px;
		margin: 0;
	}

	.ms-brand-card__image {
		max-width: 100%;
		max-height: 30px;
	}

	.ms-brand-card__wordmark {
		display: none;
	}
}

/* ------------------------------------------------------------------ Empty filter result + note */
.ms-brands-empty {
	padding: var(--ms-space-6) 0;
	color: var(--ms-color-text-muted);
}

.ms-brands-empty p {
	margin: 0;
}

.ms-brands-note {
	margin-top: var(--ms-space-6);
}
