/**
 * QWX Kiosk Mode — Contact Form 7 kiosk styling.
 * Loaded on every kiosk page; harmless if CF7 isn't present (the
 * selectors simply match nothing, and the thank-you banner never shows
 * since wpcf7mailsent never fires).
 */

:root {
	/* Semantic action colors, used consistently across every kiosk
	 * button regardless of which UI element it lives in (footer bar,
	 * nudge overlay, CF7 submit). Reset/"start again" actions are
	 * destructive (they discard whatever's been entered) and are red so
	 * a visitor pauses before tapping one by accident; resuming/
	 * continuing is the safe default action and is blue; submitting the
	 * form is the affirmative, "go" action and is green. */
	--qwx-color-danger: #e0383e;
	--qwx-color-danger-active: #c52f34;
	--qwx-color-safe: #0a84ff;
	--qwx-color-safe-active: #0670d8;
	--qwx-color-go: #1fae5c;
	--qwx-color-go-active: #18914c;
}

.qwx-kiosk-thank-you {
	position: fixed;
	inset: 0;
	z-index: 999998; /* Below the hint overlay (999999), above page content. */
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(255, 255, 255, 0.97);
	animation: qwx-kiosk-thank-you-fade-in 0.25s ease-out;
}

.qwx-kiosk-thank-you[hidden] {
	display: none;
}

.qwx-kiosk-thank-you-card {
	text-align: center;
	max-width: 420px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.qwx-kiosk-thank-you-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 88px;
	height: 88px;
	border-radius: 50%;
	background: var(--qwx-color-go);
	color: #fff;
	font-size: 44px;
	line-height: 1;
	margin-bottom: 24px;
	animation: qwx-kiosk-thank-you-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

.qwx-kiosk-thank-you-message {
	margin: 0 0 8px;
	font-size: 32px;
	font-weight: 700;
	color: #1d1d1f;
}

.qwx-kiosk-thank-you-submessage {
	margin: 0;
	font-size: 18px;
	color: #515154;
}

@keyframes qwx-kiosk-thank-you-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes qwx-kiosk-thank-you-pop {
	0% { transform: scale(0.6); opacity: 0; }
	100% { transform: scale(1); opacity: 1; }
}

/*
 * CF7 prints its own (much smaller) response message in
 * .wpcf7-response-output once a submission completes. With the prominent
 * banner above taking over the whole screen, showing both at once would
 * be confusing — so the default message is hidden on kiosk pages only
 * while a form has just been sent. CF7 adds the "sent" status class to
 * the <form> itself, so this only ever hides the *success* message,
 * never validation/error messages a visitor still needs to see and act
 * on before resubmitting.
 */
.wpcf7-form.sent .wpcf7-response-output {
	display: none !important;
}

/*
 * Small, persistent "time until reset" countdown. Deliberately low-key —
 * it's a quiet status indicator, not something meant to draw attention.
 * Sits in the top-right corner rather than the bottom, since the bottom
 * of the screen now belongs to the footer bar (§5.4) when that's
 * enabled — sitting above the nudge overlay (999995) so it stays legible
 * and accurate even while that overlay's dimmed backdrop is up, per
 * design, but below the thank-you banner (999998), which should always
 * be able to fully cover it during a submission.
 */
.qwx-kiosk-idle-countdown {
	position: fixed;
	right: 12px;
	top: 12px;
	z-index: 999997;
	padding: 4px 10px;
	background: rgba(0, 0, 0, 0.55);
	color: rgba(255, 255, 255, 0.85);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
	border-radius: 6px;
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
}

.qwx-kiosk-idle-countdown[hidden] {
	display: none;
}

/*
 * "Are you still there?" nudge overlay. Dims the page behind it (the
 * persistent footer bar, if enabled, stays visible underneath — see
 * .qwx-kiosk-footer-bar below — and the idle countdown pill stays above
 * it entirely, per design).
 */
.qwx-kiosk-nudge-overlay {
	position: fixed;
	inset: 0;
	z-index: 999995;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.55);
	animation: qwx-kiosk-thank-you-fade-in 0.2s ease-out;
}

.qwx-kiosk-nudge-overlay[hidden] {
	display: none;
}

.qwx-kiosk-nudge-card {
	text-align: center;
	max-width: 380px;
	width: 100%;
	background: #fff;
	border-radius: 16px;
	padding: 28px 24px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.qwx-kiosk-nudge-card h2 {
	margin: 0 0 8px;
	font-size: 22px;
	font-weight: 700;
	color: #1d1d1f;
}

.qwx-kiosk-nudge-message {
	margin: 0 0 4px;
	font-size: 15px;
	color: #515154;
}

.qwx-kiosk-nudge-countdown {
	margin: 0 0 20px;
	font-size: 36px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: #1d1d1f;
}

.qwx-kiosk-nudge-buttons {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.qwx-kiosk-nudge-resume-button,
.qwx-kiosk-nudge-reset-button {
	appearance: none;
	border: none;
	border-radius: 10px;
	padding: 14px 20px;
	font-size: 16px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
}

.qwx-kiosk-nudge-resume-button {
	background: var(--qwx-color-safe);
	color: #fff;
}

.qwx-kiosk-nudge-resume-button:active {
	background: var(--qwx-color-safe-active);
}

.qwx-kiosk-nudge-reset-button {
	background: var(--qwx-color-danger);
	color: #fff;
}

.qwx-kiosk-nudge-reset-button:active {
	background: var(--qwx-color-danger-active);
}

/*
 * Persistent full-width footer bar.
 *
 * The bar's markup is no longer printed by this plugin — the site owner
 * adds it directly to the kiosk page (typically inside the CF7 form
 * itself, right after the visible fields). In the CF7 form editor this
 * usually means wrapping the reset and submit form-tags together on one
 * line inside the div, e.g.:
 *
 *   <div id="qwx-kiosk-footer-bar" class="qwx-kiosk-footer-bar">
 *     [reset "Start again"] [submit "Submit"]
 *   </div>
 *
 * CF7 always wraps form-tags in a paragraph when you do this, so what
 * actually reaches the browser looks like:
 *
 *   <div id="qwx-kiosk-footer-bar" class="qwx-kiosk-footer-bar">
 *     <p>
 *       <input type="reset" value="Start again" class="wpcf7-reset">
 *       <input type="submit" value="Submit" class="wpcf7-form-control wpcf7-submit">
 *       <span class="wpcf7-spinner"></span>
 *     </p>
 *   </div>
 *
 * i.e. the bar's only direct child is that <p>, not the buttons
 * themselves. The rule just below handles this by making *any* direct
 * child of the bar (the <p>, or the buttons themselves if you skip the
 * wrapper and place them straight inside the div) a flex row, with
 * reset, the spinner, and submit each given an explicit `order` (0, 1,
 * 2) so reset sits leftmost and the spinner + submit pair is pushed to
 * the right via `margin-right: auto` on reset — see the comment on that
 * rule for why this is used instead of `justify-content: space-between`.
 * The spinner CF7 adds next to the submit button mid-submission is,
 * inside the footer bar specifically, visually reordered to sit just
 * *before* the submit button rather than after it — see the dedicated
 * `.qwx-kiosk-footer-bar .wpcf7-spinner` rule further down for why, and
 * for why this doesn't conflict with the `margin-right: auto` rule just
 * mentioned.
 *
 * The color/shape styling for CF7's specific `.wpcf7-reset` /
 * `.wpcf7-submit` classes (so they read as "destructive" vs.
 * "affirmative" — see the rules just below) is a separate, independent
 * concern from this positioning. A native type="reset" input clears the
 * form on click with no JS required; this plugin's own script (see
 * assets/js/cf7-kiosk.js) just listens for the form's resulting
 * "reset" event afterward to keep the idle timer and nudge overlay in
 * sync.
 *
 * Only takes effect once the "Show footer bar" admin setting is on for
 * this kiosk, which adds the qwx-kiosk-footer-bar-active class to <body>
 * (see QWX_Kiosk_CF7::maybe_add_footer_bar_body_class()) — so adding the
 * div without enabling the setting renders it inline, unstyled, rather
 * than fixed to the viewport. Sits below the nudge overlay's dimmed
 * backdrop and below the idle countdown pill, but above ordinary page
 * content — always visible, including while the nudge overlay is up.
 *
 * Left/right padding comes from the active block theme's own
 * --wp--style--root--padding-left/right custom properties (this plugin
 * requires a block theme — see DOCUMENTATION.md — so these are reliably
 * present whenever a kiosk page actually renders) rather than a fixed
 * pixel value picked here. Themes typically define these as a fluid
 * clamp() that's small-to-none on phones and grows on wider screens,
 * which is exactly "no extra margin on phone/tablet, more breathing
 * room on desktop" — already solved at the theme level, so there's
 * nothing to duplicate or keep in sync with a separate breakpoint of
 * this plugin's own invention. The 16px fallback only matters if a
 * theme doesn't set these variables at all, which would be unusual for
 * a current block theme.
 */
body.qwx-kiosk-footer-bar-active .qwx-kiosk-footer-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999990;
	padding-top: 10px;
	padding-bottom: 10px;
	padding-left: var( --wp--style--root--padding-left, 16px );
	padding-right: var( --wp--style--root--padding-right, 16px );
	background: rgba(255, 255, 255, 0.97);
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

/*
 * The actual left-reset/right-submit layout happens on whichever
 * element is the bar's direct child — almost always the <p> CF7 wraps
 * the reset/submit form-tags in (see the markup note above), but this
 * also matches the buttons themselves if no such wrapper is present, so
 * both markup shapes lay out identically. Resets the <p>'s default
 * margin so it doesn't add extra space on top of the bar's own padding.
 *
 * Deliberately *not* using `justify-content: space-between` here: CF7
 * also inserts a spinner element next to the submit button while a
 * submission is in flight (see markup note above), which would make
 * this a 3-item row — and space-between distributes evenly across
 * however many items are present, so with 3 items the *spinner* would
 * end up pinned to the right edge instead of the submit button, with
 * submit stranded in the middle. `margin-right: auto` on the reset
 * button instead opens all the free space immediately after it — so
 * reset sits at the left edge, and the spinner + submit button are
 * pushed over to the right edge *together*, with only this row's
 * regular `gap` between the two of them, rather than each fixed-gap
 * pair fighting over a single pool of flexible space placed in the
 * wrong slot (an earlier version of this rule put the auto margin on
 * submit instead, which absorbed all the free space immediately before
 * *it* specifically, stranding the spinner hard up against reset with
 * only the row's small fixed gap separating them — exactly backwards).
 * Reset, spinner, and submit each carry an explicit `order` value (0,
 * 1, 2 respectively — see their own rules below) precisely so this
 * sequence is pinned and doesn't depend on CF7's DOM order or any
 * implicit default.
 */
.qwx-kiosk-footer-bar > * {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 auto;
	width: 100%;
	max-width: min( 100%, var( --wp--style--global--content-size, 640px ) );
}

/*
 * Caps how far apart reset and submit can spread on a very wide screen
 * — without this, the row's width: 100% above would let the
 * margin-right: auto gap (see the comment below, on the reset rule
 * itself) grow to the full width of the bar minus the bar's own
 * left/right padding, leaving the two buttons stranded far apart on a
 * desktop monitor. var(--wp--style--global--content-size) is the
 * active block theme's own readable-content width — the same cap a
 * theme already applies to ordinary text content — so the row settles
 * to a sensible width without this plugin guessing at one of its own.
 * min(100%, …) keeps it from ever exceeding the bar's actual available
 * width on a narrow screen, where the theme's content-size could
 * otherwise be wider than the viewport itself; margin: 0 auto centers
 * the row once it's narrower than the bar. The 640px fallback only
 * matters if the active theme doesn't define this variable.
 */
.qwx-kiosk-footer-bar .wpcf7-submit {
	order: 2;
}

/*
 * Contact Form 7's native reset input, restyled to match this plugin's
 * other destructive/"start again" buttons (nudge overlay's reset button,
 * etc.) — red, so a visitor pauses before tapping it by accident. Scoped
 * to inside the footer bar only, so a reset input used elsewhere in the
 * form (if any) is unaffected. order: 0 makes explicit what the
 * reset/spinner/submit ordering actually depends on now — see the
 * dedicated spinner rule further down for why an implicit default no
 * longer works here. margin-right: auto is the layout mechanism
 * described in the comment above this row's own rule — it's grouped
 * here rather than split into its own rule since it's conceptually
 * part of "how reset behaves in this row", same as its order value.
 */
.qwx-kiosk-footer-bar .wpcf7-reset {
	order: 0;
	margin-right: auto;
	appearance: none;
	border: none;
	border-radius: 10px;
	padding: 14px 28px;
	background: var(--qwx-color-danger);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	cursor: pointer;
}

.qwx-kiosk-footer-bar .wpcf7-reset:active {
	background: var(--qwx-color-danger-active);
}

/*
 * Contact Form 7's own submit button, restyled to match the visual
 * language of this plugin's reset/resume buttons — same shape, weight,
 * and sizing — but in green, the "go"/affirmative action color. Targets
 * CF7's default markup directly:
 *   <input type="submit" class="wpcf7-form-control wpcf7-submit
 *     has-spinner" value="Submit">
 * Scoped to kiosk pages only (this file is only enqueued there), so a
 * site's normal contact page elsewhere is unaffected.
 */
.wpcf7-form .wpcf7-submit {
	appearance: none;
	border: none;
	border-radius: 10px;
	padding: 14px 28px;
	background: var(--qwx-color-go);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	cursor: pointer;
}

.wpcf7-form .wpcf7-submit:active {
	background: var(--qwx-color-go-active);
}

/*
 * CF7 inserts a small spinner element immediately after the submit
 * button while an AJAX submission is in flight (only visible once the
 * "submitting" status class is added to the form). CF7's own default
 * styling keeps the spinner's layout box reserved at all times via
 * `visibility: hidden` (rather than `display: none`) even when it's
 * not spinning — specifically so the button doesn't shift size/position
 * the moment a submission starts. Left to its default size/position
 * here — only nudged slightly to sit comfortably next to the now-larger,
 * more padded button above rather than hugging its edge. (Inside the
 * footer bar specifically, this is overridden below — see the next
 * rule — so the spinner there has no permanently-reserved empty space
 * sitting to the right of the button.)
 */
.wpcf7-form .wpcf7-spinner {
	margin-left: 10px;
	vertical-align: middle;
}

/*
 * Inside the footer bar, move the spinner to visually render *before*
 * the submit button instead of after it. `order: 1` only works because
 * the spinner's immediate parent there is the flex row set up by
 * `.qwx-kiosk-footer-bar > *` further up this file — it has no effect
 * (and isn't applied) anywhere else CF7's spinner might appear on the
 * page, where it stays in its normal after-the-button position. This
 * is a *visual* reorder only, not a DOM change, so CF7's own JS — which
 * toggles the spinner's visibility based on the form's actual markup,
 * not how it's laid out on screen — is unaffected.
 *
 * The value has to be 1, not -1: `order` ranks every flex item by an
 * absolute ordinal, not "one slot earlier than whatever it would
 * otherwise sit next to" — reset and submit are explicitly 0 and 2
 * (see their own rules above), so -1 would put the spinner *before*
 * reset, at the very front of the whole row, rather than between the
 * two buttons where it belongs. 1 sits in the gap between them.
 *
 * The margin also moves, from the spinner's left side to its right:
 * the reserved gap needs to sit between the spinner and the button it
 * now visually precedes, not on the outside, where it would just
 * recreate the exact "permanent empty space" problem on the opposite
 * side instead.
 */
.qwx-kiosk-footer-bar .wpcf7-spinner {
	order: 1;
	margin-left: 0;
	margin-right: 10px;
}
