/* Build Freedom Summit - sponsor logo grid.
   No JS. Auto-fit grid, so it reflows without breakpoint juggling. */

.bfs-sponsors {
	--bfs-cols: 0;
	--bfs-min: 180px;
	--bfs-frame-h: 96px;
	--bfs-inset: 28px;
	--bfs-pad: 14px 16px;
	--bfs-gap: 22px;
	--bfs-border: #e3e8ef;
	--bfs-name: #5a6472;

	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(var(--bfs-min), 1fr));
	gap: var(--bfs-gap);
	align-items: start;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* An explicit columns="" wins on wide screens, still collapses when narrow. */
@media (min-width: 768px) {
	.bfs-sponsors[style*="--bfs-cols"]:not([style*="--bfs-cols:0"]) {
		grid-template-columns: repeat(var(--bfs-cols), minmax(0, 1fr));
	}
}

.bfs-sponsors--small  { --bfs-min: 150px; --bfs-pad: 11px 13px; --bfs-gap: 16px; --bfs-frame-h: 76px; --bfs-inset: 22px; }
.bfs-sponsors--medium { --bfs-min: 180px; }
.bfs-sponsors--large  { --bfs-min: 230px; --bfs-pad: 18px 22px; --bfs-frame-h: 124px; --bfs-inset: 36px; }

/* One per row on genuinely small phones so logos never get squeezed. */
@media (max-width: 419px) {
	.bfs-sponsors { grid-template-columns: 1fr; --bfs-min: 0; }
}

.bfs-sponsors__heading {
	margin: 0 0 18px;
}

.bfs-sponsors__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.bfs-sponsors__link {
	display: flex;
	flex-direction: column;
	gap: 10px;
	text-decoration: none;
	color: inherit;
}

/* Identical frame for every logo. Without a fixed shape a 6:1 wordmark and a
   1:1 badge land at completely different optical sizes and the grid looks
   ragged, which is the whole thing a logo wall is meant to avoid. */
.bfs-sponsors__frame {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: var(--bfs-frame-h);
	background: #fff;
	border: 1px solid var(--bfs-border);
	border-radius: 3px;
	box-sizing: border-box;
	overflow: hidden;
}

/* Both dimensions are definite: a percentage width against a known column,
   and a pixel height derived from the frame token. Percentages resolved
   against an aspect-ratio box silently fall back to the image's intrinsic
   height, which is what made tall logos burst out of the frame. */
/* Specificity is deliberate. A bare .bfs-sponsors__logo (0,1,0) loses to
   theme rules like `.something img` (0,1,1), which silently drops the height
   and lets tall logos size to their intrinsic height instead. Three classes
   clears that without resorting to !important. */
.bfs-sponsors .bfs-sponsors__frame .bfs-sponsors__logo {
	display: block;
	width: 100%;
	height: calc(var(--bfs-frame-h) - var(--bfs-inset));
	max-width: 100%;
	object-fit: contain;
	object-position: center;
}

.bfs-sponsors__fallback {
	padding: var(--bfs-pad);
	font-size: 0.9em;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	color: var(--bfs-name);
}

.bfs-sponsors__name {
	display: block;
	font-size: 0.85em;
	line-height: 1.35;
	text-align: center;
	color: var(--bfs-name);
	overflow-wrap: break-word;
}

@media (hover: hover) {
	.bfs-sponsors__frame {
		transition: border-color 150ms ease, box-shadow 150ms ease;
	}
	a.bfs-sponsors__link:hover .bfs-sponsors__frame {
		border-color: #c3d0e2;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
	}
	a.bfs-sponsors__link:hover .bfs-sponsors__name {
		color: #355e93;
	}
}

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

a.bfs-sponsors__link:focus-visible .bfs-sponsors__frame {
	outline: 2px solid #355e93;
	outline-offset: 3px;
}
