/**
 * Our Brands page.
 *
 * The directory is rendered by WordPress core Terms Query blocks using the
 * native WooCommerce product_brand taxonomy. Type sizes and spacing follow the
 * shared tokens in sections.css so the page matches the About and policy pages.
 */

.bm-brands-main {
	padding: 0;
	background: var(--wp--preset--color--ivory);
	color: var(--wp--preset--color--charcoal);
}

.bm-brands-content > * + * {
	margin-block-start: 0;
}

/* Sections ------------------------------------------------------------------ */

.bm-brands-main .bm-brands-section {
	padding: clamp(48px, 6vw, 88px) var(--bm-gutter);
}

.bm-brands-main .bm-brands-section > .alignwide {
	max-width: 1200px;
}

/* Flow layout puts a top margin on every block after the first; the grids below handle spacing. */
.bm-brands-section > * + *,
.bm-brands-section .alignwide > *,
.bm-brands-hero__grid > *,
.bm-brands-directory__head > *,
.bm-brands-directory .wp-block-term-template > *,
.bm-brand-card > * {
	margin-block: 0;
}

.bm-brands-main h1,
.bm-brands-main h2,
.bm-brands-main h3 {
	margin: 0;
	font-family: var(--wp--preset--font-family--cormorant-garamond);
	font-weight: 500;
	line-height: 1.1;
	color: inherit;
	text-wrap: balance;
}

.bm-brands-main h1 {
	font-size: var(--bm-fs-h1);
}

.bm-brands-main h2 {
	font-size: var(--bm-fs-h2);
}

.bm-brands-main p {
	font-size: var(--bm-fs-text);
	line-height: 1.75;
}

/* Matches the shared .bm-eyebrow: amber on light sections, gold on dark. */
.bm-brands-main .bm-brands-eyebrow {
	margin: 0 0 14px;
	color: var(--wp--preset--color--amber-deep);
	font-family: var(--wp--preset--font-family--manrope);
	font-size: var(--bm-fs-text);
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

.bm-brands-main .bm-brands-hero .bm-brands-eyebrow {
	color: var(--wp--preset--color--gold);
}

/* Hero ---------------------------------------------------------------------- */

.bm-brands-hero {
	background: var(--wp--preset--color--charcoal);
	color: var(--wp--preset--color--ivory);
}

.bm-brands-hero__grid {
	display: grid;
	grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
	align-items: end;
	gap: clamp(24px, 5vw, 80px);
}

.bm-brands-hero h1 {
	max-width: 16ch;
}

.bm-brands-main .bm-brands-hero__intro {
	max-width: 30rem;
	padding-left: 20px;
	border-left: 1px solid var(--bm-gold-rule);
	color: rgba(245, 240, 230, 0.78);
	font-size: var(--bm-fs-card);
	line-height: 1.6;
}

/* Directory ----------------------------------------------------------------- */

.bm-brands-directory-section {
	background: var(--wp--preset--color--sand);
}

.bm-brands-directory__head {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 28rem);
	align-items: end;
	gap: clamp(20px, 5vw, 80px);
	margin-bottom: clamp(24px, 3vw, 40px) !important;
}

.bm-brands-main .bm-brands-directory__intro {
	margin: 0;
	color: var(--wp--preset--color--ink-muted);
}

.bm-brands-directory .wp-block-term-template {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0;
	margin: 0;
	padding: 0;
	border-top: 1px solid rgba(37, 29, 24, 0.16);
	border-left: 1px solid rgba(37, 29, 24, 0.16);
	list-style: none;
	counter-reset: bm-brand-directory;
}

/* Rules sit on the cards so empty cells in a partial last row show the section background. */
.bm-brands-directory .wp-block-term {
	position: relative;
	min-width: 0;
	display: flex;
	flex-direction: column;
	padding: clamp(18px, 2vw, 28px);
	border-right: 1px solid rgba(37, 29, 24, 0.16);
	border-bottom: 1px solid rgba(37, 29, 24, 0.16);
	background: var(--wp--preset--color--ivory);
	counter-increment: bm-brand-directory;
}

.bm-brands-directory .wp-block-term::before {
	content: counter(bm-brand-directory, decimal-leading-zero);
	margin-bottom: 14px;
	color: var(--wp--preset--color--amber-deep);
	font-family: var(--wp--preset--font-family--manrope);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.16em;
	line-height: 1;
}

.bm-brand-card {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 18px;
}

.bm-brands-main .bm-brand-card__name {
	font-size: var(--bm-fs-h3);
	line-height: 1.15;
}

.bm-brand-card__name a {
	color: inherit;
	text-decoration: none;
}

/* Whole card is the link target. */
.bm-brand-card__name a::after {
	position: absolute;
	inset: 0;
	content: "";
}

.bm-brand-card__meta {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding-top: 12px;
	border-top: 1px solid rgba(37, 29, 24, 0.16);
}

.bm-brands-main .bm-brand-card__count-label,
.bm-brands-main .bm-brand-card__count {
	margin: 0;
	color: var(--wp--preset--color--ink-muted);
	font-family: var(--wp--preset--font-family--manrope);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

.bm-brands-main .bm-brand-card__count {
	color: var(--wp--preset--color--amber-deep);
	font-size: 12px;
	font-weight: 700;
}

/* Instant colour change on hover/focus; no transition (owner direction: no animation). */
.bm-brands-directory .wp-block-term:hover,
.bm-brands-directory .wp-block-term:focus-within {
	background: var(--wp--preset--color--espresso);
	color: var(--wp--preset--color--ivory);
}

.bm-brands-directory .wp-block-term:hover::before,
.bm-brands-directory .wp-block-term:focus-within::before,
.bm-brands-directory .wp-block-term:hover .bm-brand-card__count,
.bm-brands-directory .wp-block-term:focus-within .bm-brand-card__count {
	color: var(--wp--preset--color--gold);
}

.bm-brands-directory .wp-block-term:hover .bm-brand-card__count-label,
.bm-brands-directory .wp-block-term:focus-within .bm-brand-card__count-label {
	color: rgba(245, 240, 230, 0.72);
}

.bm-brands-directory .wp-block-term:hover .bm-brand-card__meta,
.bm-brands-directory .wp-block-term:focus-within .bm-brand-card__meta {
	border-color: rgba(245, 240, 230, 0.24);
}

.bm-brands-directory .wp-block-term:focus-within {
	outline: 2px solid var(--wp--preset--color--gold);
	outline-offset: -4px;
}

.bm-brands-directory .wp-block-term :focus-visible {
	outline: none;
}

.bm-brands-main .bm-brands-empty {
	display: none;
	max-width: 40rem;
	padding: 24px;
	border: 1px solid rgba(37, 29, 24, 0.16);
	background: var(--wp--preset--color--ivory);
}

.bm-brands-directory:not(:has(.wp-block-term)) + .bm-brands-empty {
	display: block;
}

.bm-brands-main .bm-brands-notice {
	margin-top: 24px;
	color: var(--wp--preset--color--ink-muted);
	font-size: 12px;
	line-height: 1.6;
}

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

@media (max-width: 900px) {
	.bm-brands-directory .wp-block-term-template {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 781px) {
	.bm-brands-hero__grid,
	.bm-brands-directory__head {
		grid-template-columns: minmax(0, 1fr);
	}

	.bm-brands-hero__grid {
		align-items: start;
	}
}

@media (max-width: 479px) {
	.bm-brands-directory .wp-block-term-template {
		grid-template-columns: minmax(0, 1fr);
	}
}
