/*
 * seamlessmd/logo-row — horizontal band of partner / customer / integration /
 * certification logos.
 *
 * Variants mostly differ in default heading + vertical spacing.
 */

.seamlessmd-logo-row {
	--seamlessmd-logo-row-height: 38px;
	padding-block: var(--seamlessmd-section-pad);
	color: var(--seamlessmd-text, #1a2540);
	background-color: transparent;
}

.seamlessmd-logo-row--variant-customers {
	/* Source `.logo_section_wrap` uses 2rem block padding (not 3rem). */
	padding-block: 2rem;
}

/* Heading on the `customers` variant matches the source's `.logo_title`
 * rule: uppercase H3-style, 1.2rem, weight 700, dark text, no letter-spacing,
 * 1.4rem padding-bottom. Overrides the muted small-caption default that the
 * generic `.seamlessmd-logo-row__heading` rule sets further down. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-customers .seamlessmd-logo-row__heading {
	/* Source uses Nunito Sans on `body` and `.logo_title` inherits — match it
	 * explicitly here so the heading reads the same as on seamless.md
	 * regardless of our theme's Inter default. The font is already
	 * preconnected + loaded via the Google Fonts link in <head>. */
	font-family: "Nunito Sans", system-ui, -apple-system, sans-serif;
	font-size: 1.2rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0;
	color: var(--seamlessmd-text, #1a2540);
	margin: 0;
}

.seamlessmd-logo-row--variant-integrations {
	padding-block: var(--seamlessmd-space-10, 4rem);
	background-color: var(--seamlessmd-surface-alt, #f4f7fb);
}

.seamlessmd-logo-row--variant-certifications {
	padding-block: var(--seamlessmd-space-6, 1.75rem);
}

/* ---------- customer-strip variant ----------
 *
 * Under-hero "Partnered with leading health systems..." band used on
 * customers / specialty / product / care-plan-library pages. Differs from
 * the legacy `customers` variant by:
 *   - Tighter vertical padding (target: ~3rem block, not 4rem)
 *   - H3 heading by default (not the small `<p>` caption)
 *   - Explicit CSS-grid column count driven by `--seamlessmd-logo-row-columns`
 *     so 6 logos lay out as 6 even cells, not centered/wrapped flex.
 */
.seamlessmd-logo-row--variant-customer-strip {
	padding-block: var(--seamlessmd-space-6, 1.75rem);
}

/* Heading: target renders an H3 ("heading accent logo-space customers") that
 * is darker + larger than the legacy `<p>` caption. Override the generic
 * caption styling for the H3 inside customer-strip only. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-customer-strip .seamlessmd-logo-row__heading {
	font-size: clamp(1.25rem, 2vw, 1.75rem);
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--seamlessmd-heading, #1e2a5c);
	margin: 0 0 var(--seamlessmd-space-6, 1.75rem);
}

/* Grid mode: only the customer-strip variant uses CSS grid. Legacy variants
 * (`customers`, `integrations`, `certifications`) keep their existing
 * `flex-wrap` layout — render.php emits `--seamlessmd-logo-row-columns` only
 * when `columns !== 'auto'`, but even when it did, those variants don't read
 * the var (no grid rule below them). No regression to existing instances.
 */
.seamlessmd-logo-row--variant-customer-strip .seamlessmd-logo-row__list {
	/* Default to 6 columns if no explicit value (covers the 6-logo common case
	 * — Atrium, UAB, William Osler, etc.). The render-emitted var overrides. */
	display: grid;
	grid-template-columns: repeat(var(--seamlessmd-logo-row-columns, 6), minmax(0, 1fr));
	align-items: center;
	justify-items: center;
	column-gap: var(--seamlessmd-logo-row-gap, 2.5rem);
	row-gap: var(--seamlessmd-logo-row-gap, 2.5rem);
}

@media (max-width: 991px) {
	.seamlessmd-logo-row--variant-customer-strip .seamlessmd-logo-row__list {
		/* Tablet: collapse to 4 columns regardless of desktop column count. */
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.seamlessmd-logo-row--variant-customer-strip .seamlessmd-logo-row__list {
		/* Mobile: 2 columns keeps logos legible at common phone widths. */
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: var(--seamlessmd-space-4, 1rem);
		row-gap: var(--seamlessmd-space-5, 1.25rem);
	}
}

/* ---------- compact-strip variant ----------
 *
 * Under-hero "trusted organizations" band from the Home design: ONE pale-blue
 * rounded strip holding up to four organization logos plus one optional
 * trailing text item ("and more" / "والمزيد"), with a small decorative dash
 * centred above the strip. No heading, no border, no shadow — the strip is the
 * whole section, and it must read as one unified surface rather than five
 * separate cards.
 *
 * Reference geometry (Home Option 2, 550 px wide, scaled to the 1216 px
 * container content box at ≥1280 px viewports):
 *   strip height ≈ 9%  of strip width  → ~110 px
 *   inline padding ≈ 5.5% of strip width → ~64 px
 *   logo height   ≈ 3.8% of strip width → ~46 px  (editor-driven `logoHeight`)
 *   gaps between the five items are EQUAL, and the outer items sit flush with
 *   the strip's inline padding — i.e. `justify-content: space-between`, not an
 *   equal-column grid (the logos have very different natural widths).
 *
 * Cascade note: `assets/css/seamlessmd-theme.css` is enqueued AFTER this file
 * and carries `.seamlessmd-logo-row` (0,1,0 — padding-block + background),
 * `.seamlessmd-logo-row__list` (0,1,0), `.seamlessmd-logo-row
 * .seamlessmd-logo-row__item` (0,2,0) and `.seamlessmd-logo-row
 * .seamlessmd-logo-row__logo` (0,2,0). At an equal specificity the later file
 * wins, so every rule below is escalated to 0,2,0 / 0,3,0 through the doubled
 * `.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip` root. That
 * makes the variant win on specificity instead of on load order — which is
 * also what keeps the block-editor canvas (different stylesheet stack) in
 * agreement with the frontend.
 */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip {
	/* Block-local tokens. Brand colours belong in global tokens, but the
	 * palette has no blue — the accent below mirrors the value the completed
	 * Home hero already uses, so both read as the same accent. If a global
	 * blue token lands, these two definitions collapse into it. */
	--seamlessmd-strip-surface: #edf4ff;
	--seamlessmd-strip-ink: var(--seamlessmd-text, #1e2a5c);
	--seamlessmd-strip-radius: 16px;

	/* ~44 px at 1440 — matches the reference's gap to the hero above and to
	 * the next section below. Beats theme.css's generic
	 * `clamp(1rem, 3.45vh, 3.5rem)` on specificity. */
	padding-block: clamp(1.5rem, 3.2vw, 2.75rem);

	/* theme.css paints `background: var(--seamlessmd-surface)` (white) on
	 * every logo-row section. This variant's surface is the strip itself, so
	 * the section stays transparent and sits on whatever the page uses. */
	background: transparent;
}

/* The strip itself is the `<ul>`, so it spans the container's content box and
 * its inline edges line up with the hero copy above it. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__list {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	/* Equal-width logo cells + a natural-width trailing text item. `flex: 1 1 0`
	 * on the logo items shares the row's inline space evenly, so every logo
	 * renders inside an identical bounding box regardless of its natural aspect
	 * ratio — matching the "same size" requirement from the design review. Gap
	 * stays wired to the editor's `logoGap` field. */
	justify-content: stretch;
	gap: var(--seamlessmd-logo-row-gap, 2rem);
	padding-block: clamp(1.125rem, 2.2vw, 2rem);
	padding-inline: clamp(1.25rem, 4.5vw, 4rem);
	border-radius: var(--seamlessmd-strip-radius);
	background: var(--seamlessmd-strip-surface);
}

/* Each logo cell takes an equal share of the row's inline space. `min-inline-size: 0`
 * cancels the flex default of `min-width: auto`, which would otherwise let a wide
 * logo push the strip past the container and open a document-level horizontal scrollbar. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__item {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 0;
	min-inline-size: 0;
}

/* The trailing text is the one item that must never grow or shrink — "and more"
 * should sit at its natural width at the end of the row, not consume a full logo
 * cell. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__item--text {
	flex: 0 0 auto;
}

/* Link/span wrapper stretches to fill its cell so the `<img>` inside can use
 * `inline-size: 100%` and get a proper bounding box for `object-fit: contain`. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__item:not(.seamlessmd-logo-row__item--text) .seamlessmd-logo-row__link {
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 100%;
	block-size: var(--seamlessmd-logo-row-height, 46px);
}

.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__trailing {
	font-size: clamp(0.9375rem, 1.15vw, 1.0625rem);
	font-weight: 600;
	line-height: 1.2;
	color: var(--seamlessmd-strip-ink);
	white-space: nowrap;
}

/* One consistent visual bounding box for logos of wildly different natural
 * dimensions. Both `block-size` and `inline-size` are fixed to the parent cell,
 * and `object-fit: contain` letterboxes the pixel content inside — a wide
 * logo (UAB) hits the width limit first, a narrow logo (Catholic Health) hits
 * the height limit first, but each occupies the SAME cell size on screen.
 * That is what "make all logo sizes exactly the same" means for a strip of
 * logos with mixed natural aspect ratios. */
.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__logo {
	block-size: var(--seamlessmd-logo-row-height, 46px);
	inline-size: 100%;
	object-fit: contain;
	display: block;
}

@media (max-width: 991px) {
	/* Tablet: wrap into balanced rows rather than squeezing five items onto
	 * one line. `space-between` would strand a lone item on the last row, so
	 * centre instead once wrapping is possible. */
	.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__list {
		flex-wrap: wrap;
		justify-content: center;
		column-gap: clamp(1.5rem, 4vw, 2.5rem);
		row-gap: clamp(1rem, 3vw, 1.75rem);
	}
}

@media (max-width: 600px) {
	/* Mobile: a plain 2-column grid keeps every logo legible and cannot
	 * overflow the document. Design review flagged the previous mobile
	 * layout as visually unbalanced — "and more" stranded alone in the
	 * first column of a third row, big empty band inside the pale-blue
	 * strip, and the strip itself carrying wide vertical padding. Cuts:
	 *   - Strip padding-block is dropped to keep the strip tight around
	 *     its 2x2 logo grid, with just enough breathing room for "and more".
	 *   - "and more" span 2 columns and centre-align so it reads as a
	 *     caption below the grid, not a stranded logo cell.
	 *   - `align-content: center` keeps the grid vertically centred inside
	 *     the strip whatever the exact row heights work out to. */
	/* Trim the surrounding section padding on mobile too — desktop's ~44px
	 * cadence reads as a huge dead band on a phone. Scoped to compact-strip
	 * so other logo-row variants are unaffected. */
	.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip {
		padding-block: 1rem;
	}

	.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__list {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: var(--seamlessmd-space-4, 1rem);
		row-gap: var(--seamlessmd-space-5, 1.25rem);
		padding-block: 1.25rem;
		padding-inline: var(--seamlessmd-space-5, 1.25rem);
	}

	.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__item--text {
		grid-column: 1 / -1;
		justify-content: center;
		padding-block-start: 0.25rem;
	}

	.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__item:not(.seamlessmd-logo-row__item--text) .seamlessmd-logo-row__link {
		/* The desktop rule pins the link box to 46px tall; on mobile the
		 * logo height clamp below can drop to 26px, so let the link box
		 * follow the logo instead of pinning it. */
		block-size: auto;
	}

	.seamlessmd-logo-row.seamlessmd-logo-row--variant-compact-strip .seamlessmd-logo-row__logo {
		block-size: clamp(26px, 8vw, var(--seamlessmd-logo-row-height, 46px));
	}
}

/* Inner wrapper carries the shared `.seamlessmd-container` class in render.php — that gives it max-width + responsive horizontal gutter. */

/* ---------- Header ---------- */

.seamlessmd-logo-row__header {
	text-align: center;
	margin-bottom: 2rem;
}

.seamlessmd-logo-row__eyebrow {
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--seamlessmd-primary, #2563eb);
	margin: 0 0 var(--seamlessmd-space-2, 0.5rem);
}

.seamlessmd-logo-row__heading {
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--seamlessmd-muted, #5a6475);
	margin: 0;
}

/* ---------- Per-heading-tag visual scale ----------
 *
 * Previously: regardless of the editor's `headingLevel` choice (h2 / h3 / h4
 * / p), the heading rendered with the same small-caption style above (or
 * the variant override for customer-strip). Selecting a different tag had
 * no visible effect.
 *
 * Fix: when an editor picks an explicit heading level, the tag-qualified
 * selectors below take over with appropriately scaled typography. `<p>`
 * keeps the small caption (legacy default). `<h3>` defers to the
 * `customer-strip` rule for backwards compatibility (it lives BEFORE this
 * block in the cascade but has equal/higher specificity within its
 * variant). `<h1>` is hero-scale for new "section-header" use cases like
 * the careers page logo-row. `color: inherit` makes the heading follow
 * the section's `color:` (driven by the `textColor` attr) so light text
 * works on dark backgrounds. */

/* Specificity note: the customer-strip variant rule above is
 * `.logo-row.logo-row--variant-customer-strip .__heading` = (0,3,0).
 * We need the per-tag rules to beat that even when the variant is
 * customer-strip, so each selector below is (0,3,1) via the
 * `.logo-row.logo-row` double-class trick. */

/* `text-transform: none` resets the bundled `seamlessmd-theme.css` rule
 * (.seamlessmd-logo-row__heading at (0,1,0)) which paints uppercase by
 * default for the legacy customers-strip layout. The per-tag rules below
 * are at (0,3,1) so they win on cascade. `text-align: center` is
 * preserved across all tags so the header stays centered above the row. */

.seamlessmd-logo-row.seamlessmd-logo-row h1.seamlessmd-logo-row__heading {
	font-size: clamp(2rem, 4vw, 3.5rem);
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.1;
	text-transform: none;
	text-align: center;
	color: inherit;
	margin: 0 0 var(--seamlessmd-space-6, 1.75rem);
}

.seamlessmd-logo-row.seamlessmd-logo-row h2.seamlessmd-logo-row__heading {
	font-size: clamp(1.625rem, 3vw, 2.5rem);
	font-weight: 700;
	letter-spacing: -0.015em;
	line-height: 1.15;
	text-transform: none;
	text-align: center;
	color: inherit;
	margin: 0 0 var(--seamlessmd-space-6, 1.75rem);
}

.seamlessmd-logo-row.seamlessmd-logo-row h4.seamlessmd-logo-row__heading {
	font-size: clamp(1.125rem, 1.5vw, 1.375rem);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.25;
	text-transform: none;
	text-align: center;
	color: inherit;
	margin: 0 0 var(--seamlessmd-space-5, 1.25rem);
}

/* ---------- List ---------- */

.seamlessmd-logo-row__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	/* Gap is editor-driven via the `logoGap` block attribute (px); render.php
	 * emits `--seamlessmd-logo-row-gap` inline on the section. The fallback
	 * (4rem ≈ 64px) matches the schema default so unset blocks still look
	 * the same as before this attribute existed. */
	gap: var(--seamlessmd-logo-row-gap, 4rem);
}

/* The `.seamlessmd-logo-row` parent on `__item` and `__logo` rules below
 * is required to outrank the WP editor canvas's
 * `.editor-styles-wrapper img { max-width: 100%; height: auto }` rule.
 * Without it, the WP-core editor rule pinned logos at their natural
 * width inside the block-editor preview iframe (specificity tie at
 * 0,1,1, last-loaded wins). The parent raises us to 0,2,0 which beats
 * it cleanly in both editor + frontend. */
.seamlessmd-logo-row .seamlessmd-logo-row__item {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.seamlessmd-logo-row .seamlessmd-logo-row__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: inherit;
	text-decoration: none;
}

/* ---------- Logo image ---------- */

.seamlessmd-logo-row .seamlessmd-logo-row__logo {
	/* Height is the sole size driver; width follows the logo's natural
	 * aspect ratio. `max-width: none` cancels the WP editor canvas's
	 * `max-width: 100%` so wide logos at large heights render at full
	 * natural width instead of being squashed to the column. */
	height: var(--seamlessmd-logo-row-height, 40px);
	width: auto;
	max-width: none;
	object-fit: contain;
	display: block;
	transition: filter 250ms ease, opacity 250ms ease, transform 250ms ease;
}

.seamlessmd-logo-row.seamlessmd-logo-row--grayscale .seamlessmd-logo-row__logo {
	filter: grayscale(100%);
	opacity: 0.7;
}

.seamlessmd-logo-row.seamlessmd-logo-row--grayscale .seamlessmd-logo-row__link:hover .seamlessmd-logo-row__logo,
.seamlessmd-logo-row.seamlessmd-logo-row--grayscale .seamlessmd-logo-row__link:focus-visible .seamlessmd-logo-row__logo {
	filter: grayscale(0%);
	opacity: 1;
}

.seamlessmd-logo-row a.seamlessmd-logo-row__link:hover .seamlessmd-logo-row__logo,
.seamlessmd-logo-row a.seamlessmd-logo-row__link:focus-visible .seamlessmd-logo-row__logo {
	transform: translateY(-1px);
}

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


/* ---------- Empty state (editor only) ---------- */

.seamlessmd-logo-row__empty {
	padding: var(--seamlessmd-space-6, 1.75rem);
	text-align: center;
}

/* ---------- Specialty-page "fill viewport" opt-in ----------
 *
 * Opt-in via the `fillViewport` block attribute (toggle in the editor's
 * Layout panel). When true AND the band sits on a specialty CPT page
 * (`body.page-spec-<slug>` added by `seamlessmd_body_classes()`) AND the
 * variant is `customers`, stretch the band so hero + band together fill
 * the first viewport.
 *
 * Math: `100vh − 80px − 70vh`
 *   - 80px  ≈ site header (`--seamlessmd-header-height` = 72px, with an 8px
 *             buffer for the header's bottom border + visual breathing room)
 *   - 70vh  = hero use-case pinned height (blocks/hero-banner/style.css)
 *
 * `min-height` (not fixed height) so content longer than the calc still
 * renders without clipping. Flex-center vertically inside that band.
 */
.seamlessmd-logo-row--variant-customers.seamlessmd-logo-row--fill-viewport {
	min-height: calc(100vh - 80px - 70vh);
	display: flex;
	flex-direction: column;
	justify-content: center;
}
