/* =============================================================================
   High Tech Health — Sale details popup
   -----------------------------------------------------------------------------
   See inc/sale-modal.php and PROMO-BAR.md. Loaded on every page while the
   popup is switched on; the <dialog> is closed (display:none) until opened.

   Everything is scoped under #sale-details so Jevelin's global h2/h3/p/ul/a/
   button rules can't reach in, and nothing here can reach out. The fonts are
   the design system's, fetched by the popup's script on first open — Georgia
   and Helvetica/Arial stand in for the moment before they arrive.
   ========================================================================== */

html.hth-sale-lock { overflow: hidden; }

#sale-details {
	--s-sand: #EDE7DD; --s-shell: #F7F4EF; --s-white: #fff;
	--s-ink: #23303C; --s-ink-2: #3B4C5B; --s-ink-3: #556372;
	--s-azure-ink: #1F6C97; --s-azure-lift: #6FB9E0;
	--s-line: rgba(35,48,60,.14);
	--s-display: "Fraunces", Georgia, "Times New Roman", serif;
	--s-body: "DM Sans", "Helvetica Neue", Arial, sans-serif;

	/* Top band — Ink by default, overridden per colour below */
	--s-head-bg:
		radial-gradient(120% 90% at 50% 0%, rgba(111,185,224,.22) 0%, rgba(111,185,224,0) 60%),
		radial-gradient(80% 60% at 85% 110%, rgba(214,160,104,.28) 0%, rgba(214,160,104,0) 70%),
		#23303C;
	--s-head-fg: #fff;
	--s-eyebrow: #6FB9E0;
	--s-muted: rgba(255,255,255,.72);
	--s-card-line: rgba(255,255,255,.16);
	--s-card-bg: rgba(255,255,255,.04);
	--s-close-bg: rgba(255,255,255,.08);
	--s-close-bg-h: rgba(255,255,255,.18);
	--s-focus: #6FB9E0;
}
#sale-details.hth-sale--azure {
	--s-head-bg:
		radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.16) 0%, rgba(255,255,255,0) 60%),
		radial-gradient(80% 60% at 85% 110%, rgba(35,48,60,.35) 0%, rgba(35,48,60,0) 70%),
		#1F6C97;
	--s-eyebrow: #D4ECF8;
	--s-muted: rgba(255,255,255,.78);
	--s-card-line: rgba(255,255,255,.24);
	--s-card-bg: rgba(255,255,255,.07);
	--s-focus: #fff;
}
#sale-details.hth-sale--sand {
	--s-head-bg:
		radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,.55) 0%, rgba(255,255,255,0) 60%),
		#EDE7DD;
	--s-head-fg: #23303C;
	--s-eyebrow: #1F6C97;
	--s-muted: #556372;
	--s-card-line: rgba(35,48,60,.16);
	--s-card-bg: rgba(255,255,255,.45);
	--s-close-bg: rgba(35,48,60,.07);
	--s-close-bg-h: rgba(35,48,60,.14);
	--s-focus: #1F6C97;
}


/* ---- The dialog -------------------------------------------------------- */
#sale-details {
	position: fixed;
	inset: 0;
	width: min(640px, calc(100vw - 32px));
	max-width: none;
	height: -moz-fit-content;
	height: fit-content;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 20px;
	overflow: hidden;
	background: var(--s-shell);
	color: var(--s-ink-2);
	box-shadow: 0 30px 80px rgba(20,28,36,.35), 0 2px 8px rgba(20,28,36,.12);
	font-family: var(--s-body);
	font-size: 16px;
	line-height: 1.5;
	text-align: left;
	letter-spacing: normal;
	text-transform: none;
}
#sale-details:not([open]) { display: none; }
#sale-details::backdrop {
	background: rgba(20,28,36,.55);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}
#sale-details[open] { animation: hth-sale-in .32s cubic-bezier(.2,.8,.2,1); }
#sale-details[open]::backdrop { animation: hth-sale-fade .32s ease; }
@keyframes hth-sale-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes hth-sale-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
	#sale-details[open], #sale-details[open]::backdrop { animation: none; }
}

/* Browsers without <dialog>.showModal() (very old Safari) */
#sale-details.hth-sale--fallback {
	z-index: 2147483000;
	box-shadow: 0 0 0 100vmax rgba(20,28,36,.55), 0 30px 80px rgba(20,28,36,.35);
}

/* ---- Reset: keep the parent theme's globals out ------------------------ */
#sale-details *,
#sale-details *::before,
#sale-details *::after { box-sizing: border-box; }
#sale-details h2,
#sale-details h3,
#sale-details p,
#sale-details ul,
#sale-details li {
	margin: 0; padding: 0; border: 0; background: none;
	letter-spacing: normal; text-transform: none; text-shadow: none;
}
#sale-details li::before,
#sale-details li::after { content: none; }
#sale-details svg { display: block; flex: none; }
#sale-details a { box-shadow: none; }

#sale-details .hth-sale__scroll {
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow: auto;
	overscroll-behavior: contain;
	outline: none;
}


/* ---- Top band ---------------------------------------------------------- */
#sale-details .hth-sale__head {
	position: relative;
	padding: 44px 48px 40px;
	background: var(--s-head-bg);
	color: var(--s-head-fg);
	text-align: center;
}
#sale-details .hth-sale__close {
	position: absolute; top: 14px; right: 14px;
	width: 40px; height: 40px; min-width: 0; margin: 0; padding: 0;
	border: 0; border-radius: 50%;
	background: var(--s-close-bg); color: var(--s-head-fg);
	font: 300 26px/40px var(--s-body);
	text-align: center; box-shadow: none; cursor: pointer;
	-webkit-appearance: none; appearance: none;
	transition: background .15s;
}
#sale-details .hth-sale__close:hover { background: var(--s-close-bg-h); }
#sale-details .hth-sale__close:focus-visible,
#sale-details .hth-sale__head a:focus-visible { outline: 2px solid var(--s-focus); outline-offset: 3px; }

#sale-details .hth-sale__eyebrow {
	margin: 0 0 14px;
	color: var(--s-eyebrow);
	font: 600 12px/1.4 var(--s-body);
	letter-spacing: .16em;
	text-transform: uppercase;
}
#sale-details .hth-sale__title {
	color: inherit;
	font: 300 44px/1.08 var(--s-display);
	font-variation-settings: "opsz" 144;
	letter-spacing: -.01em;
}
#sale-details .hth-sale__title em { font-style: italic; font-weight: inherit; }

#sale-details .hth-sale__offers {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 14px;
	margin: 30px 0 0;
}
#sale-details .hth-sale__offers--n1 { grid-template-columns: minmax(0, 280px); justify-content: center; }
#sale-details .hth-sale__offers--n3 { grid-template-columns: repeat(3, 1fr); }
#sale-details .hth-sale__offer {
	padding: 20px 16px 18px;
	border: 1px solid var(--s-card-line);
	border-radius: 14px;
	background: var(--s-card-bg);
}
#sale-details .hth-sale__amt {
	display: block;
	color: inherit;
	font: 300 46px/1 var(--s-display);
	font-variation-settings: "opsz" 144;
	letter-spacing: -.02em;
}
#sale-details .hth-sale__offers--n3 .hth-sale__amt { font-size: 38px; }
#sale-details .hth-sale__amt sup {
	position: relative; top: .35em;
	margin-right: 2px;
	font-size: .45em; line-height: 0; vertical-align: top;
}
#sale-details .hth-sale__unit {
	display: block; margin-top: 6px;
	color: var(--s-muted);
	font: 500 13px/1.3 var(--s-body);
	letter-spacing: .06em; text-transform: uppercase;
}
#sale-details .hth-sale__series {
	display: block; margin-top: 10px;
	color: inherit;
	font: 400 15px/1.3 var(--s-body);
}


/* ---- Body -------------------------------------------------------------- */
#sale-details .hth-sale__body {
	display: flex;
	flex-direction: column;
	padding: 30px 48px 36px;
}
#sale-details .hth-sale__body > :first-child { margin-top: 0; }

#sale-details .hth-sale__perks {
	display: flex; flex-wrap: wrap; justify-content: center;
	gap: 10px 26px;
	list-style: none;
}
#sale-details .hth-sale__perks li {
	display: flex; align-items: center; gap: 8px;
	color: var(--s-ink);
	font: 500 15px/1.4 var(--s-body);
}
#sale-details .hth-sale__perks svg { flex: none; color: var(--s-azure-ink); }
/* A word mark (NEW, BONUS…) in place of the checkmark. */
#sale-details .hth-sale__badge {
	flex: none;
	padding: 4px 8px 3px;
	border-radius: 999px;
	background: var(--s-azure-ink);
	color: var(--s-white);
	font: 600 11px/1.2 var(--s-body);
	letter-spacing: .08em;
	text-transform: uppercase;
	white-space: nowrap;
}

#sale-details .hth-sale__hl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 16px;
	margin-top: 28px;
	padding: 22px 22px 20px;
	border: 1px solid var(--s-line);
	border-radius: 14px;
	background: var(--s-white);
}
#sale-details .hth-sale__hl--noicon { grid-template-columns: 1fr; }
/* "Show the box" unticked: the same text with no border, fill or padding, so it
   runs to the body's margins. Two classes so the phone rule below can't put
   the padding back. */
#sale-details .hth-sale__hl.hth-sale__hl--plain {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
}
#sale-details .hth-sale__icon {
	display: grid; place-items: center;
	width: 44px; height: 44px;
	border-radius: 50%;
	background: var(--s-sand);
	color: var(--s-ink);
}
#sale-details .hth-sale__hl-title {
	margin: 2px 0 6px;
	color: var(--s-ink);
	font: 400 22px/1.2 var(--s-display);
}
#sale-details .hth-sale__hl-title em { font-style: italic; }
#sale-details .hth-sale__hl-text {
	color: var(--s-ink-2);
	font: 400 15px/1.6 var(--s-body);
}
/* Tags allowed in the highlight text (see hth_sale_kses()). */
#sale-details .hth-sale__hl-text strong,
#sale-details .hth-sale__hl-text b { color: var(--s-ink); font-weight: 600; }
#sale-details .hth-sale__hl-text em,
#sale-details .hth-sale__hl-text i { font-style: italic; }
#sale-details .hth-sale__hl-text a {
	color: var(--s-azure-ink);
	font-weight: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}
#sale-details .hth-sale__hl-text a:hover { color: var(--s-ink); }
#sale-details .hth-sale__hl-strong {
	margin-top: 10px;
	color: var(--s-ink);
	font: 500 15px/1.6 var(--s-body);
}

#sale-details .hth-sale__cta {
	display: flex; flex-direction: column; align-items: center;
	gap: 14px;
	margin-top: 28px;
}
#sale-details .hth-sale__btn {
	display: inline-flex; align-items: center; gap: 10px;
	padding: 15px 34px;
	border: 0; border-radius: 999px;
	background: var(--s-ink); color: #fff;
	font: 600 16px/1 var(--s-body);
	letter-spacing: .01em;
	text-decoration: none;
	transition: transform .15s, background .15s;
}
#sale-details .hth-sale__btn:hover,
#sale-details .hth-sale__btn:focus { background: #2d3d4c; color: #fff; text-decoration: none; }
#sale-details .hth-sale__btn:hover { transform: translateY(-1px); }
#sale-details .hth-sale__btn svg { transition: transform .15s; }
#sale-details .hth-sale__btn:hover svg { transform: translateX(3px); }
#sale-details .hth-sale__link {
	color: var(--s-azure-ink);
	font: 500 14px/1.4 var(--s-body);
	text-decoration: underline;
	text-underline-offset: 3px;
}
#sale-details .hth-sale__link:hover { color: var(--s-ink); }
#sale-details .hth-sale__body a:focus-visible { outline: 2px solid var(--s-azure-ink); outline-offset: 3px; }

#sale-details .hth-sale__fine {
	margin-top: 22px;
	color: var(--s-ink-3);
	font: 400 12px/1.5 var(--s-body);
	text-align: center;
}


/* ---- Phones ------------------------------------------------------------ */
@media (max-width: 560px) {
	#sale-details { border-radius: 16px; }
	#sale-details .hth-sale__head { padding: 60px 20px 26px; }
	#sale-details .hth-sale__title { font-size: 34px; }
	#sale-details .hth-sale__offers { gap: 10px; margin-top: 22px; }
	#sale-details .hth-sale__offer { padding: 16px 10px 14px; }
	#sale-details .hth-sale__amt { font-size: 36px; }
	#sale-details .hth-sale__unit { font-size: 11px; }
	#sale-details .hth-sale__series { font-size: 14px; }
	/* Three offers stay side by side, just smaller — stacking them pushes
	   everything else below the fold. */
	#sale-details .hth-sale__offers--n3 { gap: 8px; }
	#sale-details .hth-sale__offers--n3 .hth-sale__offer { padding: 14px 6px 12px; }
	#sale-details .hth-sale__offers--n3 .hth-sale__amt { font-size: 28px; }
	#sale-details .hth-sale__offers--n3 .hth-sale__unit { font-size: 10px; }
	#sale-details .hth-sale__offers--n3 .hth-sale__series { margin-top: 8px; font-size: 12px; }
	#sale-details .hth-sale__body { padding: 24px 20px 28px; }
	#sale-details .hth-sale__perks { flex-direction: column; align-items: flex-start; width: max-content; max-width: 100%; margin-left: auto; margin-right: auto; }
	#sale-details .hth-sale__hl { grid-template-columns: 1fr; padding: 20px; }
	#sale-details .hth-sale__btn { width: 100%; justify-content: center; }

	/* The button stays in reach: it sticks to the bottom of the popup. */
	#sale-details .hth-sale__body:has(.hth-sale__cta) { padding-bottom: 0; }
	#sale-details .hth-sale__cta {
		order: 1;
		position: sticky; bottom: 0;
		gap: 10px;
		margin: 22px -20px 0;
		padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
		border-top: 1px solid var(--s-line);
		background: var(--s-shell);
		box-shadow: 0 -10px 20px rgba(247,244,239,.9);
	}
	#sale-details .hth-sale__fine { margin-top: 20px; }
}
