/* ============================================================================
   ALPHA PEPTIDES — 21+ SITE-ENTRY AGE GATE   (owner: tuju-woo / P5)

   Every value below is MEASURED from the source, not designed:
   `source-cdp/age-gate-raw.json` -> the bespoke `apx-age-gate-css` layer and
   `age-gate-custom-inline-css` (`--ag-background-color: rgba(0,0,0,0.1)`,
   `--ag-blur: 8px`), cross-checked against `_shots/agegate-{1440,820,390}.png`.

   ⛔ The backdrop's `backdrop-filter: blur(8px)` is the exact reason CDP
      `Page.captureScreenshot` with `fromSurface:False` HANGS FOREVER on this
      design and poisons the websocket. Use `fromSurface:True` + a 45 s timeout.

   SELF-CONTAINED ON PURPOSE. An entry overlay must never depend on a utility
   class or a token that might not be present — it is the first thing a visitor
   sees and a missing `z-index` or backdrop makes the whole site unusable. Every
   `var()` below therefore carries a literal fallback, and nothing is scoped to
   `body.ap-stg` (the source's own badge CSS was scoped to a staging body class
   and rendered unstyled anywhere else — recon's trap #1).
   ========================================================================= */

/* --------------------------------------------------------------------------
   Scroll lock. Added to <html> by the boot script in `inc/ap-agegate.php`
   BEFORE first paint, removed on accept — and auto-released after 6s if the
   gate never mounts, so a failed script degrades to "no gate", never to a
   page that cannot be scrolled.
   -------------------------------------------------------------------------- */
html.ap-ag-lock,
html.ap-ag-lock body {
	overflow: hidden !important;
	overscroll-behavior: none;
}

/* --------------------------------------------------------------------------
   Overlay shell  (source: .age-gate__wrapper)
   -------------------------------------------------------------------------- */
.ap-ag-wrap {
	position: fixed;
	inset: 0;
	z-index: 10000;            /* source: --ag-form-z-index. The cart drawer is
	                              10020 and the dose sheet 10030, both ABOVE —
	                              same as the source. Neither can be opened
	                              while the gate is up: the backdrop eats the
	                              click, and the gate is removed from the DOM on
	                              accept, so it can never trap one later. */
	display: flex;
	width: 100%;
	box-sizing: border-box;
	padding: 28px 20px;
	overflow-y: auto;
	text-align: center;
	opacity: 0;
	transition: opacity .22s ease;
}

.ap-ag-wrap.is-open { opacity: 1; }

.ap-ag-wrap * { box-sizing: border-box; }

/* The blur layer. `rgba(0,0,0,0.1)` + `blur(8px)` means the page stays VISIBLE
   behind the gate — that is the source's deliberate design, and it is why
   there is nothing to hide before the gate mounts. */
.ap-ag-backdrop {
	position: fixed;
	inset: 0;
	z-index: 1;
	width: 100%;
	background: rgba(0, 0, 0, 0.1);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

/* --------------------------------------------------------------------------
   The 560px measure  (source: .age-gate)

   `margin: auto`, NOT `align-items: center`. A centred flex item gets its TOP
   clipped once the panel is taller than the viewport and there is then no way
   to scroll up to it; `margin: auto` never does. The source's own override
   says exactly this — keep it.
   -------------------------------------------------------------------------- */
.ap-ag {
	position: relative;
	z-index: 2;
	margin: auto;
	width: 100%;
	max-width: 560px;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
}

/* --------------------------------------------------------------------------
   The card  (source: .age-gate__form)
   -------------------------------------------------------------------------- */
/* ⚠ `display: flex` is LOAD-BEARING, not styling. The source's card is a flex
   column (the plugin's `.age-gate__form`), and flex containers do NOT collapse
   adjacent sibling margins. Measured over CDP against the live source: as a
   plain block our card came out 578.7px tall against the source's 649.2px, and
   30px of that difference was margin collapsing between `__remember-wrapper`
   and `__errors` alone. Every per-element margin below is the source's own
   number only BECAUSE they stack here instead of collapsing.

   `line-height: 1.65` is the base the source's card inherits from the theme
   underneath it, and it is what makes the CTA 56px rather than 52px, the
   decline link 24.8 rather than 19.3, and the logo's line box 63.5 rather than
   59.8. All three were measured, not guessed. */
.ap-ag__form,
.ap-ag__denied {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 32px 34px 26px;
	border: 0;
	border-top: 7px solid #102b64;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 30px 80px rgba(6, 15, 32, .28);
	font-family: var(--ap-font, 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
	font-size: 16px;
	line-height: 1.65;
	text-align: center;
}

/* The decline view swaps with the form. Declared explicitly rather than relying
   on the UA's `[hidden] { display: none }`, which any later sheet can beat. */
.ap-ag__form[hidden],
.ap-ag__denied[hidden] { display: none !important; }

/* ---- logo: capped at 156px, centred ---- */
.ap-ag__heading {
	margin: 0 0 12px;
	text-align: center;
}

.ap-ag__logo-link {
	display: inline-block;
	line-height: 0;
}

.ap-ag__logo {
	display: block;
	max-width: 156px;
	width: 100%;
	height: auto;
	margin: 0 auto;
}

/* ---- headline / sub ---- */
.ap-ag__headline {
	margin: 0 0 8px;
	color: #0B1322;
	font-size: 26px;
	font-weight: 900;
	line-height: 1.15;
	letter-spacing: .02em;
	text-transform: uppercase;
	text-align: center;
}

.ap-ag__subheadline {
	margin: 0 0 20px;
	color: #5b6678;
	font-size: 16px;
	line-height: 1.45;
	text-align: center;
}

/* --------------------------------------------------------------------------
   The TWO confirmations  (source: .apx-ag-checks / .apx-ag-check)
   -------------------------------------------------------------------------- */
.ap-ag__checks {
	display: grid;
	gap: 10px;
	/* 24px top = the gap the source's empty `.age-gate__challenge` <p> leaves
	   behind (its `:empty` rule never matches because that element contains
	   whitespace). Reproduced as geometry rather than by shipping a junk
	   element. 18px bottom is the source's own. */
	margin: 24px 0 18px;
	text-align: left;
}

.ap-ag__check {
	display: grid;
	grid-template-columns: 22px minmax(0, 1fr);
	gap: 14px;
	align-items: start;
	margin: 0;
	padding: 14px 16px;
	border: 1px solid #e3e8f0;
	border-radius: 11px;
	background: #fff;
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease;
}

.ap-ag__check:hover { border-color: #c3d3ee; }

.ap-ag__check.is-checked {
	border-color: #2563EB;
	background: #f6f9ff;
}

.ap-ag__check input[type="checkbox"] {
	width: 22px;
	height: 22px;
	margin: 1px 0 0;
	accent-color: #2563EB;
	cursor: pointer;
}

.ap-ag__check span {
	min-width: 0;
	color: #1a2537;
	font-size: 15.5px;
	line-height: 1.5;
}

.ap-ag__check strong {
	color: #102b64;
	font-weight: 800;
}

/* --------------------------------------------------------------------------
   Buttons — primary above, decline underneath

   DOM order here is already yes-then-no, so tab order matches reading order.
   The source emits them the other way round and flips with `order: 1 / 2`,
   which leaves a keyboard user reaching "I don't meet these requirements"
   first. Visually identical.
   -------------------------------------------------------------------------- */
.ap-ag__buttons {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 14px;
	margin: 0;
}

.ap-ag__submit--yes {
	width: 100%;
	min-height: 52px;
	padding: 14px 20px;
	border: 0;
	border-radius: 10px;
	background: #2563EB;
	color: #fff;
	font-family: inherit;
	font-size: 17px;
	font-weight: 800;
	/* ⚠ Buttons do NOT inherit line-height from their container, so this has to
	   be restated even though the card already declares 1.65. It is what makes
	   the rendered CTA 56px (17 x 1.65 = 28px line box + 2 x 14px padding)
	   rather than the 52px `min-height` — measured against the live source,
	   which renders 56. */
	line-height: 1.65;
	letter-spacing: .01em;
	cursor: pointer;
	transition: background .15s ease, opacity .15s ease;
}

.ap-ag__submit--yes:hover:not([disabled]) { background: #1d4fd7; }

.ap-ag__submit--yes[disabled] {
	background: #c9d6ee;
	cursor: not-allowed;
}

.ap-ag__submit--no {
	align-self: center;
	min-height: 0;
	padding: 0;
	border: 0;
	background: none;
	color: #3c4757;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.65;   /* same non-inheritance as above: source renders 24.8px */
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.ap-ag__submit--no:hover { color: #0B1322; }

/* ---- Remember me (checked by default, below the decline link) ---- */
.ap-ag__remember-wrapper {
	/* 16px above = the source's `.age-gate__fields` bottom margin; 16px below
	   = `.age-gate__remember-wrapper`'s own. They stack (flex column). */
	margin: 16px 0;
	text-align: center;
}

.ap-ag__remember {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.ap-ag__remember-field {
	width: 13px;
	height: 13px;
	margin: 0;
	accent-color: #2563EB;
	cursor: pointer;
}

.ap-ag__remember-text {
	margin-left: 5px;
	color: #3c4757;
	font-size: 14.4px;   /* the source's .9rem */
	font-weight: 400;
}

/* ---- error region (empty until a guard fires) ---- */
.ap-ag__errors {
	/* The 14px stays even when empty — the source's override sets it
	   unconditionally and the flex column does not collapse it away, so the
	   gap below "Remember me" is part of the measured design. */
	margin-top: 14px;
	color: #dc2626;
	font-size: 14px;
	line-height: 1.45;
	text-align: center;
}

/* ---- fine print ---- */
.ap-ag__fine { margin: 18px 0 0; }

.ap-ag__fine p {
	margin: 0;
	color: #8b95a6;
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
}

/* --------------------------------------------------------------------------
   <= 560px  (source's own breakpoint and values)
   -------------------------------------------------------------------------- */
@media (max-width: 560px) {
	.ap-ag__form,
	.ap-ag__denied {
		padding: 28px 20px 24px;
		border-radius: 14px;
	}
	.ap-ag__headline { font-size: 21px; }
	.ap-ag__subheadline {
		font-size: 15px;
		margin-bottom: 20px;
	}
	.ap-ag__check {
		padding: 14px 15px;
		gap: 12px;
	}
	.ap-ag__check span { font-size: 14.5px; }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.ap-ag-wrap,
	.ap-ag__check,
	.ap-ag__submit--yes {
		transition: none;
	}
}
