/**
 * Earthonic Category Grid - frontend styles
 * All selectors are scoped under .ecg-grid-wrap and prefixed with "ecg-"
 * to avoid colliding with theme or other plugin CSS.
 *
 * Three stacked sections, each its own row (30px gap between them, from
 * .ecg-grid-wrap's flex gap):
 *   .ecg-hero-grid   - the fixed Televisions / Cooling / Mobile Accessories bento.
 *   .ecg-bottom-grid - the fixed Audio / Smart Essentials / Cables & More row.
 *   .ecg-extra-grid  - categories added later from the widget's "Additional
 *                      Categories" repeater; always rendered below
 *                      .ecg-bottom-grid, sharing its exact styling.
 */

.ecg-grid-wrap {
	--ecg-gap: 30px;
	--ecg-radius: 14px;
	box-sizing: border-box;
}
.ecg-grid-wrap *,
.ecg-grid-wrap *::before,
.ecg-grid-wrap *::after {
	box-sizing: inherit;
}

.ecg-grid-wrap {
	display: flex;
	flex-direction: column;
	gap: var(--ecg-gap);
}

.ecg-hero-grid,
.ecg-bottom-grid,
.ecg-extra-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--ecg-gap);
}

.ecg-tile {
	position: relative;
	display: block;
	border-radius: var(--ecg-radius);
	overflow: hidden;
	aspect-ratio: 4 / 3;
	text-decoration: none;
	isolation: isolate;
	outline-offset: 3px;
}
.ecg-tile:focus-visible {
	outline: 3px solid #2b6cb0;
}
.ecg-tile img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
	border: 0;
}
.ecg-tile:hover img,
.ecg-tile:focus-visible img {
	transform: scale(1.05);
}
.ecg-tile::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.3) 42%, rgba(0, 0, 0, 0) 68%);
	z-index: 1;
	pointer-events: none;
}
.ecg-tile-content {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	padding: clamp(18px, 3vw, 34px);
	color: #fff;
}
.ecg-tile-content h3 {
	font-size: clamp(20px, 2.4vw, 30px);
	font-weight: 800;
	letter-spacing: -0.01em;
	line-height: 1.15;
	margin: 0 0 8px;
	color: #fff;
}
.ecg-tile-content p {
	font-size: clamp(13px, 1.1vw, 15px);
	line-height: 1.4;
	color: rgba(255, 255, 255, 0.88);
	max-width: 32ch;
	margin: 0 0 14px;
}
.ecg-tile-cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13.5px;
	font-weight: 600;
	color: #fff;
}
.ecg-tile-cta .ecg-rule {
	position: relative;
	padding-bottom: 2px;
}
.ecg-tile-cta .ecg-rule::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 1px;
	background: rgba(255, 255, 255, 0.9);
	transform-origin: left;
	transition: transform 0.3s ease;
}
.ecg-tile:hover .ecg-tile-cta .ecg-rule::after {
	transform: scaleX(1.15);
}
.ecg-tile-cta svg {
	width: 14px;
	height: 14px;
	transition: transform 0.3s ease;
	flex: none;
}
.ecg-tile:hover .ecg-tile-cta svg {
	transform: translateX(3px);
}

.ecg-tile--tv .ecg-tile-content h3 {
	font-size: clamp(24px, 3vw, 38px);
}

/* Tablet: hero = TV full width, Cooling/Mobile Accessories 50/50 below it.
   Bottom row is a flexible auto-fit grid, not locked to 3 tiles. */
@media (min-width: 768px) {
	.ecg-hero-grid {
		grid-template-columns: 1fr 1fr;
		grid-template-areas:
			"tv tv"
			"cooling mobile";
	}
	.ecg-tile--tv {
		grid-area: tv;
		aspect-ratio: 21 / 9;
	}
	.ecg-tile--cooling {
		grid-area: cooling;
	}
	.ecg-tile--mobile {
		grid-area: mobile;
	}

	.ecg-bottom-grid,
	.ecg-extra-grid {
		grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	}
}

/* Desktop and up: bento hero, Televisions = 75% width and full stacked
   height; Cooling and Mobile Accessories share the remaining 25%, stacked,
   each the same height as a bottom-row tile. Bottom row keeps the auto-fit
   technique so extra categories added later reflow without CSS changes. */
@media (min-width: 1024px) {
	.ecg-hero-grid {
		grid-template-columns: 3fr 1fr;
		grid-template-areas: none;
		grid-template-rows: repeat(2, minmax(240px, 1fr));
	}
	.ecg-tile--tv {
		grid-column: 1 / 2;
		grid-row: 1 / 3;
		aspect-ratio: auto;
	}
	.ecg-tile--cooling {
		grid-column: 2 / 3;
		grid-row: 1 / 2;
		aspect-ratio: auto;
	}
	.ecg-tile--mobile {
		grid-column: 2 / 3;
		grid-row: 2 / 3;
		aspect-ratio: auto;
	}

	.ecg-bottom-grid,
	.ecg-extra-grid {
		grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
		grid-auto-rows: minmax(240px, 1fr);
	}
}

@media (min-width: 1536px) {
	.ecg-hero-grid {
		grid-template-rows: repeat(2, minmax(280px, 1fr));
	}
	.ecg-bottom-grid,
	.ecg-extra-grid {
		grid-auto-rows: minmax(280px, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ecg-tile img,
	.ecg-tile-cta .ecg-rule::after,
	.ecg-tile-cta svg {
		transition: none !important;
	}
}
