/* VETEFITS — email-subscription dialog
 *
 * Loaded only on pages that actually print the dialog (see
 * theme/vetefits/inc/email-optin.php), so the twenty-one pages' first paint is
 * untouched by it.
 *
 * IT IS NOT A GENERIC MODAL. Two things about this site's readers drove every
 * measurement below, and neither is a preference:
 *
 *   The audience skews older and includes disabled veterans. So the controls
 *   are the same size as the ones on /register/ — a 52px field, a 26px
 *   checkbox in a 44px row, a 56px button — rather than the smaller, tidier
 *   ones a marketing modal usually gets. The close button is a 48px square,
 *   not a 16px glyph in the corner.
 *
 *   Text can be at 200%. Every length that governs the box is in rem so it
 *   grows with the text instead of clipping it, the card's width is capped
 *   with min() so it can never exceed the viewport, and the card scrolls
 *   inside itself rather than pushing the page sideways. At 320px and 200%
 *   zoom this is a full-height sheet with everything reachable, which is the
 *   only honest outcome at that size.
 *
 * Palette and type come from theme.json's presets — no new colors, and no
 * font this site does not already use.
 */

/* THIS RULE IS LOad-BEARING. Do not merge it into the block below.
 *
 * The container ships with the `hidden` attribute, and the browser's own
 * stylesheet hides it with `[hidden] { display: none }`. That rule is in the
 * USER-AGENT origin, so any author rule beats it — including the
 * `display: flex` below, which is a plain class selector.
 *
 * The result, found on production by tools/qa/email-optin-live.mjs: `hidden`
 * was true, the script had never run, and the dialog was nonetheless painted on
 * every page at every load — no focus management, no Escape handler, no timing,
 * just a subscription form sitting over the article. Exactly the behavior the
 * timing rules exist to prevent, arrived at through CSS.
 *
 * So the author origin has to hide it too, and `!important` is here because the
 * rule it is overriding is the one immediately below it in the same file.
 */
.vf-optin[hidden] {
	display: none !important;
}

.vf-optin {
	position: fixed;
	inset: 0;
	z-index: 9000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	/* The dialog is taller than a phone at 200% text. Scrolling the container,
	 * not the page behind it, is what keeps the submit button reachable. */
	overflow-y: auto;
	overscroll-behavior: contain;
}

.vf-optin__scrim {
	position: fixed;
	inset: 0;
	background: rgba(4, 18, 42, .62);
	/* Below the dialog, above everything else. */
	z-index: 0;
}

.vf-optin__dialog {
	position: relative;
	z-index: 1;
	/* min() rather than a bare max-width: at 320px with a 1rem gutter either
	 * side the card must be 288px, and a fixed 30rem would be 480px at normal
	 * text and 960px at 200%. */
	width: min(30rem, 100%);
	max-height: 100%;
	overflow-y: auto;
	background: var(--wp--preset--color--paper, #faf7f2);
	color: var(--wp--preset--color--contrast, #16202e);
	border-radius: 10px;
	border-top: 5px solid var(--wp--preset--color--gold, #e8b84b);
	box-shadow: 0 18px 48px rgba(4, 18, 42, .34);
	padding: 1.75rem 1.5rem 1.5rem;
}

/* The close control.
 *
 * Top-right, 48px square, and it is a real <button> with a visually hidden
 * name — not a bare "×", which a screen reader announces as "times" or as
 * nothing at all. It is never disabled and never hidden: a dialog you cannot
 * leave is a dark pattern, and this one appears uninvited. */
.vf-optin__close {
	position: absolute;
	top: .4rem;
	right: .4rem;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 6px;
	color: var(--wp--preset--color--contrast-2, #40506a);
	cursor: pointer;
}

.vf-optin__x { font-size: 1.75rem; line-height: 1; }
.vf-optin__close:hover { background: var(--wp--preset--color--cream, #f3ede2); color: var(--wp--preset--color--navy, #0b2545); }
.vf-optin__close:focus-visible {
	outline: 3px solid var(--wp--preset--color--navy-light, #12335e);
	outline-offset: 2px;
}

.vf-optin__eyebrow {
	margin: 0 0 .35rem;
	/* gold-text, not gold: #e8b84b on paper is about 1.7:1 and unreadable.
	 * The preset exists for exactly this. */
	color: var(--wp--preset--color--gold-text, #7d5710);
	font-size: .8125rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.vf-optin__title {
	/* The serif display face the rest of the site uses for headings. */
	font-family: var(--wp--preset--font-family--display, Georgia, serif);
	color: var(--wp--preset--color--navy, #0b2545);
	font-size: 1.625rem;
	line-height: 1.2;
	margin: 0 0 .5rem;
	/* Keeps the outline off the descenders when focus lands here after a
	 * successful subscription. */
	scroll-margin-top: 1rem;
}
.vf-optin__title:focus-visible {
	outline: 3px solid var(--wp--preset--color--navy-light, #12335e);
	outline-offset: 4px;
}

.vf-optin__lead {
	margin: 0 0 1.15rem;
	font-size: 1.0625rem;
	line-height: 1.5;
	color: var(--wp--preset--color--contrast-2, #40506a);
}

.vf-optin__field { margin: 0 0 .9rem; }

.vf-optin__label {
	display: block;
	margin-bottom: .3rem;
	font-size: 1rem;
	font-weight: 700;
	color: var(--wp--preset--color--navy, #0b2545);
}

.vf-optin__optional,
.vf-optin__required {
	font-weight: 400;
	color: var(--wp--preset--color--contrast-2, #40506a);
}

/* Same geometry as the fields on /register/. Consistency here is not tidiness:
 * somebody who has filled the registration form should not have to learn a
 * second set of controls. */
.vf-optin__input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	min-height: 52px;
	padding: .7rem .85rem;
	font-family: inherit;
	font-size: 1.0625rem;
	color: var(--wp--preset--color--contrast, #16202e);
	background: #fff;
	/* The same field-boundary token the Gravity Forms fields use, with the same
	 * literal fallback — this stylesheet is loaded on its own in the panel and
	 * must not depend on vetefits.css having defined it (#265). */
	border: 1px solid var(--vf-field-border, #6b7c93);
	border-radius: 6px;
}
.vf-optin__input:focus {
	outline: 3px solid var(--wp--preset--color--navy-light, #12335e);
	outline-offset: 1px;
	border-color: var(--wp--preset--color--navy-light, #12335e);
}
/* Never color alone: the invalid field gets a heavier border as well as a red
 * one, and the message above it says what is wrong in words. */
.vf-optin__input[aria-invalid="true"] {
	border-color: var(--wp--preset--color--red, #b22234);
	border-width: 2px;
}

/* The consent row. Unticked, always — there is no CSS or markup here that
 * could pre-tick it, and the endpoint refuses a submission without it. */
.vf-optin__consent {
	display: flex;
	align-items: flex-start;
	gap: 0;
	min-height: 44px;
	margin: .25rem 0 1.15rem;
}
.vf-optin__consent input[type="checkbox"] {
	width: 26px;
	height: 26px;
	flex: 0 0 26px;
	margin: .45rem 0 0;
	accent-color: var(--wp--preset--color--navy-light, #12335e);
}
.vf-optin__consent input[type="checkbox"]:focus-visible {
	outline: 3px solid var(--wp--preset--color--navy-light, #12335e);
	outline-offset: 2px;
}
.vf-optin__consent input[type="checkbox"][aria-invalid="true"] {
	outline: 2px solid var(--wp--preset--color--red, #b22234);
	outline-offset: 2px;
}
/* The old flex gap lives inside the label, where it accepts a pointer action
 * instead of swallowing one — the same fix issue #126 made on the real forms. */
.vf-optin__consent label {
	flex: 1 1 auto;
	min-height: 44px;
	padding: .45rem .25rem .45rem .65rem;
	font-size: 1rem;
	line-height: 1.45;
	cursor: pointer;
}

.vf-optin__submit {
	display: block;
	width: 100%;
	min-height: 56px;
	padding: 1rem 1.5rem;
	font-family: inherit;
	font-size: 1.1875rem;
	font-weight: 700;
	line-height: 1.2;
	color: #fff;
	background: var(--wp--preset--color--red, #b22234);
	border: 0;
	border-radius: 6px;
	cursor: pointer;
}
.vf-optin__submit:hover { background: var(--wp--preset--color--red-deep, #8d1a29); }
.vf-optin__submit:focus-visible {
	outline: 3px solid var(--wp--preset--color--navy-light, #12335e);
	outline-offset: 3px;
}
.vf-optin__submit[disabled] { opacity: .72; cursor: progress; }

.vf-optin__fine {
	margin: .85rem 0 0;
	font-size: .9375rem;
	line-height: 1.45;
	color: var(--wp--preset--color--contrast-2, #40506a);
}
.vf-optin__fine a { color: var(--wp--preset--color--navy-light, #12335e); }

/* The error region. Border, background and words — three signals, so it does
 * not rely on color, matching the validation styling on the real forms. */
.vf-optin__error {
	margin: 0 0 .9rem;
	padding: .7rem .9rem;
	background: #fdeaec;
	border: 1px solid var(--wp--preset--color--red, #b22234);
	border-left-width: 4px;
	border-radius: 0 6px 6px 0;
	color: #7a1521;
	font-size: 1rem;
	line-height: 1.5;
}

/* Off-screen, not display:none — some form-filling bots skip what is display
 * none. aria-hidden and tabindex="-1" in the markup keep it away from anyone
 * using a keyboard or a screen reader. */
.vf-optin__trap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Room above the confirmation when a page scrolls it into view (#295). */
.vf-optin__done { text-align: center; scroll-margin-top: 1rem; }
.vf-optin__tick {
	margin: .25rem 0 .6rem;
	font-size: 2.5rem;
	line-height: 1;
	color: var(--wp--preset--color--gold-text, #7d5710);
}
.vf-optin__done .vf-optin__lead { margin-bottom: 1.35rem; }

/* Phones: a bottom sheet.
 *
 * Anchored to the bottom because that is where a thumb is, and because the
 * on-screen keyboard rises from there — a centered card gets pushed off the top
 * the moment the email field takes focus, which is the classic way a mobile
 * modal becomes unusable. `100dvh` accounts for the browser chrome that
 * appears and disappears while scrolling; the `vh` line above it is the
 * fallback for engines that do not know dvh.
 */
@media (max-width: 40rem) {
	.vf-optin {
		align-items: flex-end;
		padding: 0;
	}

	.vf-optin__dialog {
		width: 100%;
		max-height: 92vh;
		max-height: 92dvh;
		border-radius: 14px 14px 0 0;
		padding: 1.5rem 1.15rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
	}

	.vf-optin__title { font-size: 1.5rem; }
}

/* Short screens: the Subscribe button has to be on screen.
 *
 * A 320x568 phone is 568px tall and the card wanted 572. Two pixels — but the
 * two pixels were the bottom of the Subscribe button, and a subscription form
 * whose button is below the fold is a form people abandon rather than scroll.
 * Measured on production by tools/qa/email-optin-live.mjs, which is the only
 * thing that could have measured it.
 *
 * Keyed on height rather than width, because that is the constraint: a short
 * landscape phone has the same problem and is not narrow. The eyebrow is the
 * first thing to go — it is a decorative label and the heading immediately
 * under it says the same thing in more words. Nothing that carries meaning,
 * and no target size, is reduced.
 */
@media (max-height: 640px) {
	.vf-optin__dialog { padding-top: 1.15rem; }
	.vf-optin__eyebrow { display: none; }
	.vf-optin__title { font-size: 1.3rem; margin-bottom: .35rem; }
	.vf-optin__lead { font-size: 1rem; margin-bottom: .8rem; }
	.vf-optin__field { margin-bottom: .6rem; }
	.vf-optin__consent { margin: .15rem 0 .8rem; }
	.vf-optin__fine { margin-top: .6rem; }
}

/* Keep the complete submit target visible on short phones without shrinking controls. */
@media (max-width: 40rem) and (max-height: 640px) {
	.vf-optin__dialog { max-height: 96vh; max-height: 96dvh; }
}

/* Reduced motion is respected by having no motion to reduce: the dialog
 * appears, it does not slide, scale or fade. The rule below is a guard for
 * anything a future edit adds, and the transition above it is the only
 * animation in the file — 140ms on the entry, which is under the threshold at
 * which motion reads as movement. */
@media (prefers-reduced-motion: no-preference) {
	.vf-optin__dialog { animation: vf-optin-in 140ms ease-out; }
}

@keyframes vf-optin-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

/* Windows High Contrast / forced colors: the scrim disappears and the card
 * would float with no edge. A border in a system color gives it one. */
@media (forced-colors: active) {
	.vf-optin__dialog { border: 1px solid CanvasText; }
	.vf-optin__submit { border: 1px solid ButtonText; }
}

/* Footer signup: one editorial introduction and one compact form panel.
 * Scope all overrides here so the dialog and dedicated page retain their layout. */
.vf-optin-footer {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    padding: 0;
    gap: 0;
    width: calc(100% - 3rem);
    max-width: 76rem;
    margin: clamp(2rem, 5vw, 5rem) auto;
    background: var(--wp--preset--color--paper, #faf7f2);
    color: var(--wp--preset--color--contrast, #16202e);
    border: 1px solid #d6dce4;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(11, 37, 69, .06);
}
.vf-optin-footer__intro {
    padding: clamp(1.5rem, 3.5vw, 3.25rem);
    background: var(--wp--preset--color--navy, #0b2545);
    color: #fff;
    border-radius: 11px 0 0 11px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}
.vf-optin-footer__intro .vf-optin__eyebrow {
    display: block;
    color: #e8b84b;
    margin: 0 0 1.25rem;
    letter-spacing: .12em;
}
.vf-optin-footer__intro h2 {
    margin: 0 0 1rem;
    max-width: min(12ch, 100%);
    color: #fff;
    font-family: Georgia, serif;
    font-size: clamp(2rem, 3.1vw, 3rem);
    line-height: 1.12;
    letter-spacing: -.025em;
    text-wrap: balance;
}
.vf-optin-footer__intro > p:not(.vf-optin__eyebrow) {
    margin: 0;
    max-width: 38ch;
    color: #dce5ef;
    font-size: 1.0625rem;
    line-height: 1.6;
}
.vf-optin-footer__intro > .vf-optin-footer__note {
    margin-top: 1.5rem !important;
    padding-top: 1.25rem;
    border-top: 1px solid #476079;
    font-size: .9375rem !important;
}
.vf-optin-footer a.vf-optin-footer__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: .5rem;
    color: #e8b84b;
    font-size: .9375rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: .25em;
}
.vf-optin-footer__link:hover { text-decoration-thickness: 2px; }
.vf-optin-footer__link:focus-visible { outline: 3px solid #e8b84b; outline-offset: 4px; }
.vf-optin-footer__signup {
    min-width: 0;
    padding: clamp(1.5rem, 3.5vw, 3.25rem);
    align-self: center;
}
.vf-optin-footer [hidden] { display: none !important; }
.vf-optin-footer .vf-optin__form {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 1.25rem 1rem;
}
.vf-optin-footer .vf-optin__form > * { grid-column: 1 / -1; margin: 0; }
.vf-optin-footer .vf-optin__form > .vf-optin__field { grid-column: auto; min-width: 0; }
.vf-optin-footer .vf-optin__form > .vf-optin__field--email { grid-column: 1 / -1; }
.vf-optin-footer .vf-optin__label { margin: 0 0 .5rem; font-size: .9375rem; line-height: 1.5; }
.vf-optin-footer .vf-optin__optional,
.vf-optin-footer .vf-optin__required { font-size: .8125rem; }
.vf-optin-footer .vf-optin__input { box-sizing: border-box; max-width: 100%; margin: 0; }
.vf-optin-footer .vf-optin__consent { align-items: flex-start; }
.vf-optin-footer .vf-optin__consent label { font-size: .9375rem; }
.vf-optin-footer .vf-optin__fine { font-size: .875rem; line-height: 1.6; }
/* WordPress may wrap noscript in an otherwise empty paragraph. */
.vf-optin-footer > p { display: contents; }
.vf-optin-footer > p > br { display: none; }
.vf-optin-footer noscript { grid-column: 1 / -1; padding: 1rem 1.5rem; }
@media (max-width: 64rem) {
    .vf-optin-footer .vf-optin__form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 48rem) {
    .vf-optin-footer { grid-template-columns: minmax(0, 1fr); width: calc(100% - 2rem); }
    .vf-optin-footer__intro { border-radius: 11px 11px 0 0; }
    .vf-optin-footer__intro h2 { max-width: min(18ch, 100%); }
}
.vf-optin, .vf-optin *, .vf-optin-footer, .vf-optin-footer * { box-sizing: border-box; }
.vf-optin-footer, .vf-optin__dialog { overflow-wrap: anywhere; }

/* Dedicated signup card shares the existing form's accessible controls. */
.vf-optin-page {
    width: 100%;
    max-width: 38rem;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    background: #fff;
    color: #16202e;
    border: 1px solid #d6dce4;
    border-top: 4px solid #e8b84b;
    border-radius: 14px;
    overflow-wrap: anywhere;
}
.vf-optin-page, .vf-optin-page * { box-sizing: border-box; }
.vf-optin-page [hidden] { display: none !important; }
.vf-optin-page .vf-optin__input { max-width: 100%; }
a.vf-optin__submit { display: inline-block; text-align: center; text-decoration: none; }
