/**
 * Custom Elementor Product Grid — Quick-Add drawer chrome.
 * The drawer is appended once to <body> by product-quickview.js, so these
 * rules deliberately live outside the .cepg-products scope. Slides in from
 * the right on desktop/tablet (internally scrollable, footer pinned); on
 * mobile it's a bottom sheet that opens compact (50vh) and snaps taller
 * (85vh, product-flavour-grid.js's .is-flavour-expanded) once the shopper
 * taps open the Flavour Grid.
 */

.cepg-modal {
	/*
	 * Reusing Product_Card::render_badges()/render_add_to_cart() inside the
	 * drawer means this must mirror every custom property .cepg-products
	 * defines in product-grid.css — the drawer renders outside that scope.
	 */
	--cepg-orange: #ff6b00;
	--cepg-obsidian: #0d0f12;
	--cepg-dark: #3f3f46;
	--cepg-muted: #71717a;
	--cepg-border: #e5e7eb;
	--cepg-surface: #ffffff;
	--cepg-neutral: #f4f5f7;
	--cepg-tile: #f7f7f8;
	--cepg-font: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	font-family: var(--cepg-font);
}

.cepg-modal.is-open {
	display: block;
}

.cepg-modal * {
	box-sizing: border-box;
}

.cepg-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(13, 15, 18, 0.55);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.cepg-modal.is-open .cepg-modal__overlay {
	opacity: 1;
}

/*
 * Fixed to the viewport's right edge, top-aligned — a slide-out drawer, not
 * a centered dialog. translateX, not display, drives the open/close motion
 * so it's an actual slide rather than a cut. No bottom:0 (deliberately, like
 * the mobile bottom sheet below): pinning both top and bottom forced an
 * exact 100vh height regardless of content, and since every child down to
 * .cepg-quickview > .cepg-variations is flex:1 1 auto, a product with a
 * short attribute list stretched to fill that fixed height anyway, leaving
 * a large dead gap above the footer instead of the footer sitting right
 * after the content. max-height + overflow:hidden here is what still caps a
 * genuinely tall product's drawer at the viewport edge and hands scrolling
 * to .cepg-quickview's own middle section — see the "Content" block below —
 * so the footer (price/Add to Cart/Visit Product Page) stays pinned in view
 * instead of scrolling away, but only once content actually needs it.
 */
.cepg-modal__panel {
	position: fixed;
	top: 0;
	right: 0;
	z-index: 1;
	width: min(440px, 92vw);
	max-width: 100%;
	max-height: 100vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--cepg-drawer-bg, var(--cepg-surface));
	box-shadow: -24px 0 64px rgba(13, 15, 18, 0.18);
	transform: translateX(100%);
	transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.cepg-modal.is-open .cepg-modal__panel {
	transform: translateX(0);
}

/*
 * Desktop/tablet: the drawer always fills the full viewport height rather
 * than hugging its content — explicit merchant choice, since a
 * content-sized panel for a short product left a lot of unused screen and
 * made a long flavour list feel cramped even with its own internal scroll.
 * .cepg-quickview > .cepg-variations (flex: 1 1 auto; min-height: 0;
 * overflow-y: auto — see below) is what actually absorbs the extra height,
 * so header/footer stay their natural size and the middle content area
 * grows or scrolls to fill whatever's left.
 */
@media (min-width: 641px) {
	.cepg-modal__panel {
		height: 100vh;
	}
}

/*
 * Bottom sheet below the drawer's own comfortable width threshold. No
 * explicit height is set — only max-height — so the panel already hugs its
 * actual content (product details, size pills, flavour pills/collapsed
 * preview, Add to Cart, Visit Product Page) rather than forcing a fixed
 * viewport fraction; max-height is purely a safety ceiling so it can never
 * eat the whole screen. Raised from 50vh to 62vh: 50vh was tuned before a
 * Size row existed alongside Flavours, and with both present the content
 * no longer fit, forcing the merchant-reported internal scroll before a
 * shopper could see the Add to Cart button at all. Tapping the flavour
 * preview open (product-flavour-grid.js adds .is-flavour-expanded to
 * .cepg-modal) snaps it to 85vh so the live search + full grid has room.
 */
@media (max-width: 640px) {
	.cepg-modal__panel {
		top: auto;
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		max-height: 62vh;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -16px 48px rgba(13, 15, 18, 0.22);
		transform: translateY(100%);
		transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.3s ease;
	}

	.cepg-modal.is-open .cepg-modal__panel {
		transform: translateY(0);
	}

	.cepg-modal.is-flavour-expanded .cepg-modal__panel {
		max-height: 85vh;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cepg-modal__overlay,
	.cepg-modal__panel {
		transition: none;
	}
}

/*
 * Swipe-down-to-close affordance — a decorative grab bar on the bottom
 * sheet, and the actual drag surface product-quickview.js's
 * bindSwipeToClose() listens on. Desktop/tablet never shows it: the drawer
 * isn't a bottom sheet there, so there's nothing to swipe closed.
 */
.cepg-modal__drag-handle {
	display: none;
}

@media (max-width: 640px) {
	.cepg-modal__drag-handle {
		position: sticky;
		top: 0;
		z-index: 2;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 28px;
		background: var(--cepg-drawer-bg, var(--cepg-surface));
		touch-action: none;
	}

	.cepg-modal__drag-handle::before {
		content: "";
		width: 40px;
		height: 4px;
		background: var(--cepg-drag-bar-color, #d4d4d8);
		border-radius: 2px;
	}
}

.cepg-modal__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: transparent;
	border: none;
	color: var(--cepg-obsidian);
	cursor: pointer;
}

.cepg-modal__close:hover,
.cepg-modal__close:focus-visible {
	color: var(--cepg-orange);
}

.cepg-modal__close svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: var(--cepg-close-icon-weight, 2px);
	stroke-linecap: round;
}

/* Clears the drag handle bar, which occupies the top ~28px on mobile. */
@media (max-width: 640px) {
	.cepg-modal__close {
		top: 26px;
	}
}

.cepg-modal__body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 200px;
	overflow: hidden;
}

.cepg-modal__loading,
.cepg-modal__error {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	padding: 40px;
	color: var(--cepg-muted);
	font-size: 14px;
	text-align: center;
}

/* ------------------------------------------------------------ Content */

.cepg-quickview {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	gap: 18px;
	padding: var(--cepg-drawer-padding, 24px 20px 20px);
	overflow: hidden;
}

/*
 * The one scrollable region: header/divider/footer stay fixed in place
 * (flex: 0 0 auto, below), while the attribute pickers — potentially tall
 * with a large Flavour Grid — scroll independently in the space between
 * them. min-height: 0 is what actually lets a flex child shrink below its
 * content size enough for overflow-y: auto to engage at all.
 */
.cepg-quickview > .cepg-variations {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

/*
 * Image left, title/price right — kept identical on mobile and desktop (no
 * breakpoint override): a compact thumbnail beside the text reads sleeker
 * than a large hero image stacked above a centered title, and stays
 * consistent rather than reflowing at 640px.
 */
.cepg-quickview__header {
	flex: 0 0 auto;
	display: flex;
	gap: 14px;
	align-items: center;
	padding-right: 30px; /* clear of the absolutely-positioned close button */
}

.cepg-quickview__thumb {
	flex: 0 0 auto;
	width: 76px;
	height: 76px;
	object-fit: contain;
	/* Was 8% — that much inset padding made the product look small/"zoomed
	 * out" inside its own box, on top of whatever margin the photo itself
	 * already has. Trimmed down so the product actually fills the frame. */
	padding: 3%;
	background: var(--cepg-tile);
	border-radius: 10px;
	/* Blends a white product-photo backdrop into the grey tile. */
	mix-blend-mode: multiply;
}

.cepg-quickview__heading {
	display: flex;
	flex-direction: column;
	gap: var(--cepg-title-price-gap, 6px);
	min-width: 0;
}

.cepg-quickview__title {
	margin: 0;
	color: var(--cepg-obsidian);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.35;
}

.cepg-quickview__price {
	font-size: 18px;
}

.cepg-quickview__divider {
	flex: 0 0 auto;
	width: 100%;
	height: 0;
	margin: 0;
	border: 0;
	border-top: 1px solid var(--cepg-border);
}

.cepg-quickview__footer {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding-top: 4px;
}

.cepg-quickview__cta-row {
	display: flex;
	width: 100%;
}

.cepg-quickview__cta-row .cepg-add {
	flex: 0 1 var(--cepg-btn-width, 100%);
	width: var(--cepg-btn-width, 100%);
}

.cepg-quickview__permalink {
	color: var(--cepg-permalink-color, var(--cepg-muted));
	font-family: var(--cepg-permalink-font-family, var(--cepg-font));
	font-size: var(--cepg-permalink-font-size, 13px);
	font-weight: var(--cepg-permalink-font-weight, 400);
	text-decoration: var(--cepg-permalink-decoration, underline);
	text-underline-offset: 2px;
}

.cepg-quickview__permalink:hover,
.cepg-quickview__permalink:focus-visible {
	color: var(--cepg-obsidian);
}

/* Bigger, easier drag target for swipe-to-close on phones. */
@media (max-width: 640px) {
	.cepg-modal__drag-handle { height: 44px; }
}

/* ------------------------------------------------ Flavour list = product page style */

.cepg-modal .cepg-flavour-grid.rf-fl-big { position: static; }
.cepg-modal .rf-fl-head { display: none; }

/* >8 in stock: trigger field + full "Choose your flavour" panel over the drawer */
.cepg-modal .cepg-flavour-grid[data-rf-fl] .cepg-flavour-grid__preview {
	min-height: 52px;
	height: auto;
	padding: 13px 16px;
	background: #fff;
	border: 1px solid var(--cepg-orange);
	border-radius: 12px;
	font-size: 15px;
	font-weight: 400;
}
.cepg-modal .rf-fl-big.is-expanded .cepg-flavour-grid__panel {
	display: flex !important;
	flex-direction: column;
	position: absolute;
	inset: 0;
	z-index: 5;
	margin: 0;
	padding: 24px 24px 16px;
	background: #fff;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}
.cepg-modal .rf-fl-big.is-expanded .rf-fl-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}
.cepg-modal .rf-fl-head strong { font-size: 22px; font-weight: 500; color: #101214; }
.cepg-modal .rf-fl-head button { font-size: 28px; line-height: 1; background: none; border: 0; padding: 4px 8px; cursor: pointer; color: #101214; }
.cepg-modal .rf-fl-big.is-expanded [data-cepg-flavour-grid-search] {
	display: block;
	width: 100%;
	padding: 11px 14px;
	border: 1px solid #e0e2e5;
	border-radius: 10px;
	font-size: 16px;
	margin-bottom: 8px;
}
.cepg-modal .rf-fl-big.is-expanded .cepg-flavour-grid__scroll { flex: 1; min-height: 0; overflow-y: auto !important; max-height: none !important; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill-group { display: block !important; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill {
	display: flex !important;
	flex-direction: row !important;
	align-items: center !important;
	justify-content: flex-start !important;
	gap: 12px;
	width: 100%;
	min-height: 56px !important;
	padding: 10px 8px !important;
	border: 0 !important;
	border-bottom: 1px solid #eee !important;
	border-radius: 8px !important;
	background: #fff !important;
	box-shadow: none !important;
	outline: 0;
	font-size: 15px;
	text-align: left !important;
	white-space: normal;
}
.cepg-modal .rf-fl-big.is-expanded .cepg-pill.is-active,
.cepg-modal .rf-fl-big.is-expanded .cepg-pill[aria-pressed="true"],
.cepg-modal .rf-fl-big.is-expanded .cepg-pill:hover:not(.is-disabled) { border-bottom: 1px solid #ff6b00 !important; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill.is-disabled { opacity: .55; }

/* <=8 in stock: inline two-column tiles, including sold-out options */
.cepg-modal .rf-fl-inline .cepg-flavour-grid__preview,
.cepg-modal .rf-fl-inline [data-cepg-flavour-grid-search] { display: none !important; }
.cepg-modal .rf-fl-inline .cepg-flavour-grid__panel { display: block !important; position: static; border: 0; box-shadow: none; padding: 0; background: none; max-height: none; }
.cepg-modal .rf-fl-inline .cepg-flavour-grid__scroll { max-height: none !important; overflow: visible !important; padding: 0; }
.cepg-modal .rf-fl-inline .cepg-pill-group { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cepg-modal .rf-fl-inline .cepg-pill {
	display: flex !important;
	flex-direction: row !important;
	align-items: center !important;
	justify-content: flex-start !important;
	gap: 11px;
	width: auto;
	min-height: 56px !important;
	padding: 12px 14px !important;
	border: 1px solid #e2e2e6 !important;
	border-radius: 12px !important;
	background: #fff !important;
	box-shadow: none !important;
	outline: 0;
	font-size: 15px;
	line-height: 1.3;
	text-align: left !important;
	white-space: normal;
}
.cepg-modal .rf-fl-inline .cepg-pill.is-active,
.cepg-modal .rf-fl-inline .cepg-pill[aria-pressed="true"],
.cepg-modal .rf-fl-inline .cepg-pill:hover:not(.is-disabled) { border-color: #ff6b00 !important; }

/* shared: dark text in every state, round swatch, plain label, Notify me on the right */
.cepg-modal .rf-fl-big.is-expanded .cepg-pill,
.cepg-modal .rf-fl-big.is-expanded .cepg-pill *,
.cepg-modal .rf-fl-inline .cepg-pill,
.cepg-modal .rf-fl-inline .cepg-pill * { color: #101214 !important; font-weight: 400 !important; text-decoration: none !important; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill .cepg-swatch,
.cepg-modal .rf-fl-inline .cepg-pill .cepg-swatch { width: 26px !important; height: 26px !important; border-radius: 50%; flex: none !important; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill .cepg-pill__label,
.cepg-modal .rf-fl-inline .cepg-pill .cepg-pill__label { flex: 1; margin: 0; font-size: 15px !important; line-height: 1.3 !important; text-align: left; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill:not(.is-disabled) .cepg-pill__notify,
.cepg-modal .rf-fl-inline .cepg-pill:not(.is-disabled) .cepg-pill__notify { display: none !important; }
.cepg-modal .rf-fl-big.is-expanded .cepg-pill__notify,
.cepg-modal .rf-fl-inline .cepg-pill__notify { position: static; margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }

@media (max-width: 640px) {
	.cepg-modal .rf-fl-big.is-expanded .cepg-flavour-grid__panel { padding: 20px 20px 24px; }
	/* the list panel is absolutely positioned, so the sheet needs a real height while it is open */
	.cepg-modal.is-flavour-expanded .cepg-modal__panel { height: 82dvh; max-height: 82dvh; }
}

/* Bestselling flavours row (same look as the product page) */
.cepg-modal .rf-fl-picks { margin: 0 0 14px; }
.cepg-modal .rf-fl-picks__title { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 500; margin-bottom: 12px; color: #101214; }
.cepg-modal .rf-fl-picks__title button { font-size: 13px; font-weight: 400; color: #a54400; text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.cepg-modal .rf-fl-picks__row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cepg-modal .rf-fl-pick {
	display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left;
	min-height: 102px; padding: 12px 10px; overflow: hidden; cursor: pointer;
	background: #fff !important; border: 1px solid #e2e2e6 !important; border-radius: 11px; box-shadow: none !important;
	font: 400 14px/1.35 inherit; font-family: inherit; color: #101214 !important; white-space: normal;
}
.cepg-modal .rf-fl-pick span { color: #101214 !important; font-weight: 400 !important; }
.cepg-modal .rf-fl-pick .cepg-swatch { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.cepg-modal .rf-fl-pick span:last-child { display: block; max-width: 100%; overflow-wrap: anywhere; hyphens: auto; }
.cepg-modal .rf-fl-pick:hover, .cepg-modal .rf-fl-pick:focus-visible, .cepg-modal .rf-fl-pick[aria-pressed="true"] { border-color: #ff6b00 !important; outline: 0; }
@media (max-width: 640px) { .cepg-modal .rf-fl-pick { font-size: 13px; min-height: 110px; padding: 11px 9px; } }
