/*
 * Coastal Supply — Money Saving Deals block.
 *
 * Layout: full-width tinted band with an inner grid of deal cards. Card
 * uses a 3D-flip pattern so the front face (price/copy/CTA) can flip
 * around to reveal a barcode/QR image on the back. Backface visibility
 * is hidden on each face so the inactive side doesn't bleed through.
 *
 * Background tint comes from the editor via a CSS custom property
 * (--coastal-deals-bg) set inline on the section, defaulting to the
 * brand light blue used elsewhere on the site.
 */

.coastal-deals {
	--coastal-deals-bg: #DCE9F580;
	--coastal-deals-card-bg: #ffffff;
	--coastal-deals-card-radius: 16px;
	--coastal-deals-card-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
	--coastal-deals-text: #1f2937;
	--coastal-deals-muted: #6b7280;
	--coastal-deals-brand: #2c2c75;
	--coastal-deals-grid-gap: 24px;
	--coastal-deals-cols: 4;
	--coastal-deals-section-py: 64px;

	width: 100%;
	background-color: var(--coastal-deals-bg);
	color: var(--coastal-deals-text);
	padding-top: var(--coastal-deals-section-py);
	padding-bottom: var(--coastal-deals-section-py);
	font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.coastal-deals--padding-compact {
	--coastal-deals-section-py: 40px;
}

.coastal-deals--padding-spacious {
	--coastal-deals-section-py: 96px;
}

.coastal-deals--cols-3 {
	--coastal-deals-cols: 3;
}

.coastal-deals--cols-4 {
	--coastal-deals-cols: 4;
}

/*
 * Inner caps the content to 1440px so the tinted background bleeds full
 * width while text/cards align with the rest of the site (header, hero,
 * stats strip, etc). `!important` on max-width + the chained
 * `.coastal-deals .coastal-deals__inner` specificity (0,2,0) is required
 * to beat Astra's page-builder layout rule at (0,4,0):
 *
 *   .ast-page-builder-template .entry-content[data-ast-blocks-layout]
 *     > *:not(.wp-block-group):where(...) > *
 *
 * which otherwise constrains every grandchild of `.entry-content` to the
 * customizer's heading-width value. Same trick used by hero-banner and
 * stats-strip blocks.
 */
.coastal-deals .coastal-deals__inner {
	box-sizing: border-box;
	width: 100%;
	max-width: 1440px !important;
	margin-inline: auto;
	padding: 0 45px;
}

@media (max-width: 768px) {
	.coastal-deals .coastal-deals__inner {
		padding: 0 24px;
	}
}

/* ── Header ─────────────────────────────────────────────────────────── */

.coastal-deals__header {
	text-align: center;
	margin-bottom: 32px;
}

.coastal-deals__eyebrow {
	margin: 0 0 8px;
	font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--coastal-deals-brand);
}

.coastal-deals__heading {
	margin: 0 0 12px;
	font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-weight: 800;
	font-size: clamp(28px, 3vw, 40px);
	line-height: 1.15;
	color: var(--coastal-deals-brand);
}

.coastal-deals__subheading {
	margin: 0 auto;
	max-width: 760px;
	font-size: 16px;
	line-height: 1.5;
	color: var(--coastal-deals-muted);
}

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

.coastal-deals__grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(var(--coastal-deals-cols), minmax(0, 1fr));
	gap: var(--coastal-deals-grid-gap);
}

.coastal-deals__card-wrap {
	margin: 0;
	padding: 0;
	min-width: 0;
}

@media (max-width: 992px) {
	.coastal-deals__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 540px) {
	.coastal-deals__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ── Card flip stage ────────────────────────────────────────────────── */

/*
 * Card uses a CSS-Grid "stack" so both faces share the same single grid
 * cell — the cell sizes itself to the larger face (always the front, since
 * the back is just an image), and the back face overlays it without ever
 * affecting layout. Avoids the "absolute + min-height + overflow: hidden"
 * trio that was clipping CTAs when content didn't fit a guessed height.
 */
.coastal-deals__card {
	position: relative;
	height: 100%;
	perspective: 1400px;
}

.coastal-deals__card-inner {
	position: relative;
	display: grid;
	grid-template-areas: "stack";
	grid-template-columns: 1fr;
	grid-template-rows: 1fr;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	transition: transform 600ms cubic-bezier(0.65, 0.05, 0.36, 1);
}

.coastal-deals__card.is-flipped .coastal-deals__card-inner {
	transform: rotateY(180deg);
}

.coastal-deals__face {
	grid-area: stack;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 20px;
	background: var(--coastal-deals-card-bg);
	border-radius: var(--coastal-deals-card-radius);
	box-shadow: var(--coastal-deals-card-shadow);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	overflow: hidden;
}

.coastal-deals__face--front {
	transform: rotateY(0deg);
}

.coastal-deals__face--back {
	transform: rotateY(180deg);
	align-items: center;
	justify-content: center;
	text-align: center;
	gap: 16px;
}

/* No-flip cards: drop preserve-3d so non-flipping cards don't render in
   3D space (some browsers anti-alias differently inside preserve-3d). */
.coastal-deals__card:not(.coastal-deals__card--flippable) .coastal-deals__card-inner {
	transform-style: flat;
}

/* ── Front face content ─────────────────────────────────────────────── */

.coastal-deals__badge {
	position: absolute;
	top: 14px;
	left: 14px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 999px;
	font-family: "Manrope", system-ui, sans-serif;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #fff;
	z-index: 1;
}

.coastal-deals__badge--accent {
	background: var(--coastal-deals-brand);
}

.coastal-deals__badge--urgent {
	background: #c0392b;
}

.coastal-deals__badge--neutral {
	background: #6b7280;
}

/*
 * Image lives in a fixed-height slot so every product photo — landscape
 * hose, square box, tall jug — visually occupies the same vertical space.
 * `object-fit: contain` keeps the original aspect ratio inside that slot
 * (white space around small images, scaled-down for tall ones).
 */
.coastal-deals__media {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 180px;
	margin-bottom: 4px;
}

.coastal-deals__media img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.coastal-deals__media--placeholder {
	background: linear-gradient(135deg, #eef2f8 0%, #dbe6f3 100%);
	border-radius: 8px;
}

@media (max-width: 540px) {
	.coastal-deals__media {
		height: 200px;
	}
}

/*
 * Price row reserves a fixed vertical band so single-line price layouts
 * (sale + regular on one row) and stacked layouts (bundle headline +
 * disclaimer) produce the same card height.
 */
.coastal-deals__price-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px 8px;
	margin-top: 4px;
	min-height: 44px;
}

.coastal-deals__price-row--bundle {
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
}

.coastal-deals__price-sale,
.coastal-deals__price-bundle {
	font-family: "Manrope", system-ui, sans-serif;
	font-weight: 800;
	font-size: 22px;
	line-height: 1.1;
	color: var(--coastal-deals-text);
}

.coastal-deals__price-regular {
	font-family: "Manrope", system-ui, sans-serif;
	font-size: 14px;
	font-weight: 600;
	color: var(--coastal-deals-muted);
}

.coastal-deals__price-regular--strike {
	text-decoration: line-through;
}

.coastal-deals__price-disclaimer {
	font-size: 12px;
	color: var(--coastal-deals-muted);
	font-style: italic;
}

.coastal-deals__unit {
	margin-left: 1px;
	font-size: 0.65em;
	font-weight: 600;
	color: inherit;
	opacity: 0.85;
}

/*
 * Name is clamped to two lines so a one-word product and a long
 * descriptor occupy the same vertical space. The reserved min-height
 * stops short names from collapsing the row above the SKU.
 */
.coastal-deals__name {
	margin: 6px 0 0;
	font-family: "Manrope", system-ui, sans-serif;
	font-weight: 700;
	font-size: 15px;
	line-height: 1.35;
	color: var(--coastal-deals-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(1.35em * 2);
}

/* SKU min-height keeps the slot reserved when a card has no SKU
   so the CTA row aligns across the grid. */
.coastal-deals__sku {
	margin: 0 0 8px;
	font-size: 12px;
	font-weight: 500;
	color: var(--coastal-deals-muted);
	letter-spacing: 0.02em;
	min-height: 1em;
}

/* CTA at the bottom-center of the card */
.coastal-deals__cta {
	margin-top: auto;
	align-self: center;
	min-height: 40px;
	padding: 8px 22px;
	font-size: 14px;
}

.coastal-deals__cta.is-disabled,
.coastal-deals__cta[disabled] {
	cursor: not-allowed;
	opacity: 0.6;
	pointer-events: none;
}

.coastal-deals__card--expired {
	opacity: 0.92;
}

.coastal-deals__card--expired .coastal-deals__media img {
	filter: grayscale(40%);
}

/* ── Back face (reveal) ─────────────────────────────────────────────── */

.coastal-deals__reveal-media {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 240px;
	margin: 0 auto;
	padding: 12px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
}

.coastal-deals__reveal-media img {
	width: 100%;
	height: auto;
	display: block;
}

.coastal-deals__reveal-name {
	margin: 0;
	font-family: "Manrope", system-ui, sans-serif;
	font-weight: 700;
	font-size: 14px;
	color: var(--coastal-deals-text);
}

.coastal-deals__back {
	min-height: 36px;
	padding: 6px 18px;
	font-size: 13px;
}

/* ── View-all CTA ───────────────────────────────────────────────────── */

.coastal-deals__view-all-wrap {
	display: flex;
	justify-content: center;
	margin-top: 32px;
}

/* ── Editor placeholder grid ────────────────────────────────────────── */

.coastal-deals__grid--placeholder .coastal-deals__card--placeholder {
	min-height: 320px;
	border: 1px dashed #c7d3e3;
	background: rgba(255, 255, 255, 0.6);
	box-shadow: none;
}

.coastal-deals__grid--placeholder .coastal-deals__name {
	color: var(--coastal-deals-muted);
}

/* ── Reduced motion ─────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.coastal-deals__card-inner {
		transition: none;
	}
}
