/* components/feature-tiles/feature-tiles.css
 *
 * 2–5 large tiles in a single row that stacks on mobile. Each tile has its own
 * background type (image / preset / solid color) and its own content block
 * (optional icon + eyebrow + heading + text + buttons). Used as the
 * dual-audience row replacement on the Lakai home page but generic for any
 * 2-to-5-way feature group.
 *
 * Every selector is scoped under `.mvc-feature-tiles` per
 * feedback_variant_css_scoping so layout variants don't leak into other
 * components. Background-preset paint comes from bg-presets.css (the
 * `[data-bg-preset]` selectors are global), this file only defines the tile
 * shell + content layout + per-tile-bg-type adjustments.
 */

.mvc-feature-tiles__header {
	margin-block-end: var(--space-8);
}

/* ── Grid shell ─────────────────────────────────────────────────────────── */

.mvc-feature-tiles__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-5);
}

/* Tablet: 2-col grid, last tile spans both columns when count is odd (3 or 5)
   so the row reads visually balanced. */
@media (min-width: 640px) {
	.mvc-feature-tiles__grid {
		grid-template-columns: 1fr 1fr;
		gap: var(--space-6);
	}

	.mvc-feature-tiles__grid[data-count="3"] > .mvc-feature-tiles__tile:nth-child(3),
	.mvc-feature-tiles__grid[data-count="5"] > .mvc-feature-tiles__tile:nth-child(5) {
		grid-column: 1 / -1;
	}
}

/* Desktop: lay out N tiles in N equal columns (up to 5). */
@media (min-width: 1024px) {
	.mvc-feature-tiles__grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
	.mvc-feature-tiles__grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
	.mvc-feature-tiles__grid[data-count="4"] { grid-template-columns: repeat(4, 1fr); }
	.mvc-feature-tiles__grid[data-count="5"] { grid-template-columns: repeat(5, 1fr); }

	/* Undo the odd-count span override from the tablet breakpoint. */
	.mvc-feature-tiles__grid[data-count="3"] > .mvc-feature-tiles__tile:nth-child(3),
	.mvc-feature-tiles__grid[data-count="5"] > .mvc-feature-tiles__tile:nth-child(5) {
		grid-column: auto;
	}
}

/* "Two-up feature" layout — first tile gets ~60% width and full height on
   desktop, the rest stack on the right. Only meaningful when count >= 3. */
@media (min-width: 1024px) {
	.mvc-feature-tiles--layout-two-up-feature .mvc-feature-tiles__grid[data-count="3"] {
		grid-template-columns: 1.6fr 1fr;
		grid-template-rows: 1fr 1fr;
	}
	.mvc-feature-tiles--layout-two-up-feature .mvc-feature-tiles__grid[data-count="3"] > .mvc-feature-tiles__tile:nth-child(1) {
		grid-row: 1 / span 2;
	}

	.mvc-feature-tiles--layout-two-up-feature .mvc-feature-tiles__grid[data-count="4"] {
		grid-template-columns: 1.6fr 1fr 1fr;
		grid-template-rows: 1fr 1fr;
	}
	.mvc-feature-tiles--layout-two-up-feature .mvc-feature-tiles__grid[data-count="4"] > .mvc-feature-tiles__tile:nth-child(1) {
		grid-row: 1 / span 2;
	}

	.mvc-feature-tiles--layout-two-up-feature .mvc-feature-tiles__grid[data-count="5"] {
		grid-template-columns: 1.6fr 1fr 1fr;
		grid-template-rows: 1fr 1fr;
	}
	.mvc-feature-tiles--layout-two-up-feature .mvc-feature-tiles__grid[data-count="5"] > .mvc-feature-tiles__tile:nth-child(1) {
		grid-row: 1 / span 2;
	}
}

/* ── Tile shell ─────────────────────────────────────────────────────────── */

.mvc-feature-tiles__tile {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	overflow: hidden;
	border-radius: var(--radius-lg, 12px);
	border: var(--mvc-ft-border, 0 solid transparent);
	padding: var(--space-6);
	min-height: 320px;
	color: var(--color-text, inherit);
	background: var(--mvc-ft-bg, var(--color-surface, transparent));
	text-decoration: none;
	transition: transform 240ms ease, box-shadow 240ms ease;
}

/* Per-tile radius override (data-radius set by feature-tiles.php from the
   tile_radius field). Lets editors round a tile that pulls up into the next
   section, or square one off to sit flush. */
.mvc-feature-tiles__tile[data-radius="none"] { border-radius: 0; }
.mvc-feature-tiles__tile[data-radius="sm"]   { border-radius: var(--radius-sm, 4px); }
.mvc-feature-tiles__tile[data-radius="md"]   { border-radius: var(--radius-md, 8px); }
.mvc-feature-tiles__tile[data-radius="lg"]   { border-radius: var(--radius-lg, 12px); }
.mvc-feature-tiles__tile[data-radius="xl"]   { border-radius: var(--radius-xl, 20px); }
.mvc-feature-tiles__tile[data-radius="full"] { border-radius: var(--radius-full, 9999px); }

.mvc-feature-tiles__tile[data-min-height="sm"],
.mvc-feature-tiles[data-min-height="sm"] .mvc-feature-tiles__tile { min-height: 240px; }
.mvc-feature-tiles[data-min-height="md"] .mvc-feature-tiles__tile { min-height: 320px; }
.mvc-feature-tiles[data-min-height="lg"] .mvc-feature-tiles__tile { min-height: 420px; }
.mvc-feature-tiles[data-min-height="xl"] .mvc-feature-tiles__tile { min-height: 520px; }

/* Custom text color override (per-tile color picker). */
.mvc-feature-tiles__tile[style*="--mvc-ft-fg"] {
	color: var(--mvc-ft-fg);
}
.mvc-feature-tiles__tile[style*="--mvc-ft-fg"] .mvc-feature-tiles__heading,
.mvc-feature-tiles__tile[style*="--mvc-ft-fg"] .mvc-feature-tiles__eyebrow,
.mvc-feature-tiles__tile[style*="--mvc-ft-fg"] .mvc-feature-tiles__text {
	color: var(--mvc-ft-fg);
}

/* Content vertical alignment within the tile. */
.mvc-feature-tiles[data-content-pos="top"] .mvc-feature-tiles__tile    { justify-content: flex-start; }
.mvc-feature-tiles[data-content-pos="center"] .mvc-feature-tiles__tile { justify-content: center; }
.mvc-feature-tiles[data-content-pos="bottom"] .mvc-feature-tiles__tile { justify-content: flex-end; }

/* Text alignment. */
.mvc-feature-tiles--align-center .mvc-feature-tiles__tile {
	text-align: center;
	align-items: center;
}
.mvc-feature-tiles--align-center .mvc-feature-tiles__inner {
	align-items: center;
}
.mvc-feature-tiles--align-center .mvc-feature-tiles__body {
	align-items: center;
}
.mvc-feature-tiles--align-center .mvc-feature-tiles__buttons {
	justify-content: center;
}

/* Linked tile (whole-card link) — subtle lift on hover. */
.mvc-feature-tiles__tile--linked {
	cursor: pointer;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.mvc-feature-tiles__tile--linked:hover {
		transform: translateY(-4px);
		box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.25);
	}
	.mvc-feature-tiles__tile--linked:hover .mvc-feature-tiles__bg-img {
		transform: scale(1.04);
	}
}

.mvc-feature-tiles__tile:focus-visible {
	outline: 2px solid var(--color-accent, currentColor);
	outline-offset: 3px;
}

/* ── Background variants ────────────────────────────────────────────────── */

/* Image background — fills the tile, with content positioned over a gradient
   overlay so type stays readable regardless of the photo. */
.mvc-feature-tiles__bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	overflow: hidden;
}

.mvc-feature-tiles__bg-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 480ms ease;
}

.mvc-feature-tiles__bg-overlay {
	position: absolute;
	inset: 0;
	/* --mvc-ft-overlay is set inline (0..0.80) and is a FLAT darken across the
	   whole image so the editor's slider matches its label. Falls back to 0.4
	   when no inline value is set. Per-content-pos rules below ADD a secondary
	   gradient on top of this flat darken when text needs extra contrast on a
	   specific edge. */
	--mvc-ft-overlay: 0.4;
	background: rgba(0, 0, 0, var(--mvc-ft-overlay));
	pointer-events: none;
}

/* Image-bg tiles default to light text on the dark overlay. */
.mvc-feature-tiles__tile--bg-image {
	color: #fff;
}
.mvc-feature-tiles__tile--bg-image .mvc-feature-tiles__heading,
.mvc-feature-tiles__tile--bg-image .mvc-feature-tiles__eyebrow,
.mvc-feature-tiles__tile--bg-image .mvc-feature-tiles__text {
	color: #fff;
}

/* Content-pos variants: the flat darken from .__bg-overlay still applies; this
   adds a SECOND gradient layer on top to deepen the side the text sits on, so
   type stays readable even with a low flat-overlay value. The secondary
   gradient's strength is half the slider value so editors don't have to fight
   the two layers stacking too dark. */
.mvc-feature-tiles[data-content-pos="bottom"] .mvc-feature-tiles__tile--bg-image .mvc-feature-tiles__bg-overlay {
	background:
		linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, calc(var(--mvc-ft-overlay) * 0.5)) 100%),
		rgba(0, 0, 0, var(--mvc-ft-overlay));
}
.mvc-feature-tiles[data-content-pos="top"] .mvc-feature-tiles__tile--bg-image .mvc-feature-tiles__bg-overlay {
	background:
		linear-gradient(0deg, transparent 50%, rgba(0, 0, 0, calc(var(--mvc-ft-overlay) * 0.5)) 100%),
		rgba(0, 0, 0, var(--mvc-ft-overlay));
}
/* Center positioning gets flat darken only — no axis to deepen. */

/* Preset bg — bg-presets.css paints the surface via the global [data-bg-preset]
   rules. Inner content stacks above. */
.mvc-feature-tiles__tile--has-preset {
	/* paint comes from bg-presets.css */
}

/* ── Inner content ──────────────────────────────────────────────────────── */

.mvc-feature-tiles__inner {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	width: 100%;
}

.mvc-feature-tiles__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: var(--radius-md, 8px);
	background: rgba(255, 255, 255, 0.12);
	color: currentColor;
}

.mvc-feature-tiles__tile--bg-preset .mvc-feature-tiles__icon,
.mvc-feature-tiles__tile--bg-color  .mvc-feature-tiles__icon {
	background: rgba(255, 255, 255, 0.18);
}

.mvc-feature-tiles__body {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}

.mvc-feature-tiles__eyebrow {
	margin: 0;
	font-size: var(--text-sm, 0.875rem);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-weight: 600;
	opacity: 0.9;
}

.mvc-feature-tiles__heading {
	margin: 0;
	font-size: clamp(1.5rem, 2.5vw, var(--text-3xl, 1.875rem));
	line-height: 1.15;
	color: inherit;
}

.mvc-feature-tiles__text {
	margin: 0;
	font-size: var(--text-base, 1rem);
	line-height: 1.55;
	opacity: 0.92;
}

.mvc-feature-tiles__text > *:last-child { margin-bottom: 0; }
.mvc-feature-tiles__text > *:first-child { margin-top: 0; }

.mvc-feature-tiles__buttons {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-3);
	margin-top: var(--space-4);
}

/* Image-bg + preset-bg tiles: prefer the inverse-style button so it reads
   against a colored / photographic background. */
.mvc-feature-tiles__tile--bg-image  .mvc-feature-tiles__buttons .mvc-btn--primary,
.mvc-feature-tiles__tile--bg-preset .mvc-feature-tiles__buttons .mvc-btn--primary {
	/* author can still choose primary; this is just a default lean — no
	   override here. The Inverse button style is a separate option in the
	   button picker for editors who want the cleaner look. */
}

/* ── Mobile tweaks ──────────────────────────────────────────────────────── */

@media (max-width: 639px) {
	.mvc-feature-tiles__tile {
		min-height: 280px;
		padding: var(--space-5);
	}
	.mvc-feature-tiles[data-min-height="lg"] .mvc-feature-tiles__tile,
	.mvc-feature-tiles[data-min-height="xl"] .mvc-feature-tiles__tile {
		min-height: 320px;
	}
	.mvc-feature-tiles__heading {
		font-size: var(--text-2xl, 1.5rem);
	}
	.mvc-feature-tiles__icon {
		width: 48px;
		height: 48px;
	}
}
