/**
 * ClickVault — front-end styles.
 *
 * Neutral, modern, accessible. No external fonts. Primary accent ~#2563eb to
 * match the magic-link email. Uses CSS custom properties for easy theming and
 * respects prefers-reduced-motion / focus-visible for accessibility.
 *
 * @package ClickVault
 */

/* Brand-themeable custom properties live on :root so the Branding page's
   injected `:root{…}` block (added after this stylesheet via
   wp_add_inline_style) can override them, and so the admin preview can scope
   overrides to a single element. Defaults match the magic-link email. */
:root {
	--cv-primary: #2563eb;
	--cv-primary-hover: #1d4ed8;
	--cv-primary-active: #1e40af;
	--cv-text: #111827;
	--cv-muted: #6b7280;
	--cv-border: #e5e7eb;
	--cv-surface: #fff;
	--cv-surface-alt: #f9fafb;
	--cv-radius: 12px;
	--cv-button-bg: #2563eb;
	--cv-button-text: #fff;
	--cv-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--cv-font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--cv-success-bg: #ecfdf5;
	--cv-success-fg: #047857;
	--cv-success-border: #a7f3d0;
	--cv-error-bg: #fef2f2;
	--cv-error-fg: #b91c1c;
	--cv-error-border: #fecaca;
	--cv-info-bg: #eff6ff;
	--cv-info-fg: #1e40af;
	--cv-info-border: #bfdbfe;
	--cv-shadow: 0 1px 2px rgba( 16, 24, 40, 0.05 ), 0 8px 24px rgba( 16, 24, 40, 0.08 );
}

/* ------------------------------------------------------------------ *
 * Preview: a teaser of the article with a soft "more below" fade.
 * ------------------------------------------------------------------ */
.clickvault-preview {
	position: relative;
	max-height: 22em;
	overflow: hidden;
	color: var(--cv-text);
	-webkit-mask-image: linear-gradient( to bottom, #000 60%, transparent 100% );
	        mask-image: linear-gradient( to bottom, #000 60%, transparent 100% );
}

/* Progressive-enhancement gradient overlay for browsers without mask support. */
.clickvault-preview::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 8em;
	background: linear-gradient( to bottom, rgba( 255, 255, 255, 0 ), var(--cv-surface) 92% );
	pointer-events: none;
}

.clickvault-preview > p {
	margin: 0 0 1em;
	line-height: 1.7;
}

/* ------------------------------------------------------------------ *
 * Gate card.
 * ------------------------------------------------------------------ */
.clickvault-gate {
	margin: 1.5rem auto 2rem;
	max-width: 36rem;
	box-sizing: border-box;
	font-family: var(--cv-font-body);
	color: var(--cv-text);
}

.clickvault-gate *,
.clickvault-gate *::before,
.clickvault-gate *::after {
	box-sizing: border-box;
}

.clickvault-gate__inner {
	background: var(--cv-surface);
	border: 1px solid var(--cv-border);
	border-radius: var(--cv-radius);
	box-shadow: var(--cv-shadow);
	padding: clamp( 1.25rem, 4vw, 2rem );
	text-align: center;
}

.clickvault-gate__title {
	margin: 0 0 0.5rem;
	font-family: var(--cv-font-heading);
	font-size: 1.375rem;
	line-height: 1.25;
	font-weight: 700;
	color: var(--cv-text);
}

.clickvault-gate__desc {
	margin: 0 0 1.25rem;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--cv-muted);
}

/* ------------------------------------------------------------------ *
 * Form fields.
 * ------------------------------------------------------------------ */
.clickvault-form {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	margin: 0 auto;
	text-align: left;
}

.clickvault-field {
	display: block;
}

/* Visible field label: a placeholder alone disappears on focus, so a persistent
 * label keeps the field identifiable (WCAG 2.5.3 / 3.3.2). */
.clickvault-field__label {
	display: block;
	margin-bottom: 0.3rem;
	font-size: 0.85em;
	font-weight: 600;
	line-height: 1.3;
}

.clickvault-form input[type="text"],
.clickvault-form input[type="email"] {
	width: 100%;
	padding: 0.7rem 0.9rem;
	font-size: 1rem;
	line-height: 1.4;
	color: var(--cv-text);
	background: var(--cv-surface);
	border: 1px solid var(--cv-border);
	border-radius: 8px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	-webkit-appearance: none;
	   -moz-appearance: none;
	        appearance: none;
}

.clickvault-form input[type="text"]::placeholder,
.clickvault-form input[type="email"]::placeholder {
	color: #9ca3af;
}

.clickvault-form input[type="text"]:focus,
.clickvault-form input[type="email"]:focus {
	outline: none;
	border-color: var(--cv-primary);
	box-shadow: 0 0 0 3px rgba( 37, 99, 235, 0.18 );
}

/* Visible focus for keyboard users across all interactive elements. */
.clickvault-form input:focus-visible,
.clickvault-consent input:focus-visible,
.clickvault-submit:focus-visible,
.clickvault-download-button:focus-visible {
	outline: 2px solid var(--cv-primary);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * Consent checkbox (small, inline).
 * ------------------------------------------------------------------ */
.clickvault-consent {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--cv-muted);
}

.clickvault-consent input[type="checkbox"] {
	flex: 0 0 auto;
	margin-top: 0.15rem;
	width: 1rem;
	height: 1rem;
	accent-color: var(--cv-primary);
}

/* Larger, easier-to-hit consent control on touch / small screens (WCAG 2.5.5). */
@media ( max-width: 600px ) {
	.clickvault-consent {
		gap: 0.65rem;
	}

	.clickvault-consent input[type="checkbox"] {
		width: 1.35rem;
		height: 1.35rem;
		margin-top: 0.1rem;
	}
}

.clickvault-consent a {
	color: var(--cv-primary);
	text-decoration: underline;
}

/* ------------------------------------------------------------------ *
 * Submit button (prominent, with hover/disabled states).
 * ------------------------------------------------------------------ */
.clickvault-submit {
	display: inline-block;
	width: 100%;
	margin-top: 0.25rem;
	padding: 0.8rem 1.25rem;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.2;
	color: var(--cv-button-text);
	background: var(--cv-button-bg);
	border: 1px solid transparent;
	border-radius: var(--cv-radius);
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.clickvault-submit:hover {
	filter: brightness( 0.95 );
}

.clickvault-submit:active {
	filter: brightness( 0.9 );
	transform: translateY( 1px );
}

.clickvault-submit:disabled,
.clickvault-submit[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
	filter: none;
	transform: none;
}

/* In-flight spinner: hide the label and show a spinner while the request runs.
 * The status message ("Sending…") carries the textual cue, so the reduced-motion
 * fallback simply drops the spinner and keeps the label. */
.clickvault-submit.is-loading {
	position: relative;
	color: transparent;
}

.clickvault-submit.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 1.1em;
	height: 1.1em;
	margin: -0.55em 0 0 -0.55em;

	/* Use the button's own text colour (set to contrast with its background by the
	 * branding system) so the spinner is visible on light and dark buttons alike. */
	border: 2px solid var(--cv-button-text, #fff);
	border-top-color: transparent;
	border-radius: 50%;
	animation: clickvault-spin 0.6s linear infinite;
}

@keyframes clickvault-spin {
	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.clickvault-submit.is-loading {
		color: inherit;
	}

	.clickvault-submit.is-loading::after {
		display: none;
		animation: none;
	}
}

/* ------------------------------------------------------------------ *
 * Status message (success / error variants toggled by JS).
 * ------------------------------------------------------------------ */
.clickvault-gate__message {
	margin: 1rem 0 0;
	font-size: 0.9375rem;
	line-height: 1.5;
	min-height: 1.25em;
}

.clickvault-gate__message:empty {
	margin: 0;
	min-height: 0;
}

.clickvault-gate__message.is-success {
	padding: 0.75rem 1rem;
	border-radius: 8px;
	color: var(--cv-success-fg);
	background: var(--cv-success-bg);
	border: 1px solid var(--cv-success-border);
}

.clickvault-gate__message.is-error {
	padding: 0.75rem 1rem;
	border-radius: 8px;
	color: var(--cv-error-fg);
	background: var(--cv-error-bg);
	border: 1px solid var(--cv-error-border);
}

.clickvault-gate__message.is-info {
	padding: 0.75rem 1rem;
	border-radius: 8px;
	color: var(--cv-info-fg);
	background: var(--cv-info-bg);
	border: 1px solid var(--cv-info-border);
}

/* ------------------------------------------------------------------ *
 * Download CTA (download mode, unlocked state).
 * ------------------------------------------------------------------ */
.clickvault-download {
	margin: 1.5rem auto 2rem;
	max-width: 36rem;
	text-align: center;
}

.clickvault-download--missing p {
	padding: 0.75rem 1rem;
	border-radius: 8px;
	color: var(--cv-error-fg);
	background: var(--cv-error-bg);
	border: 1px solid var(--cv-error-border);
}

.clickvault-download-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.85rem 1.5rem;
	font-size: 1.0625rem;
	font-weight: 600;
	line-height: 1.2;
	color: var(--cv-button-text);
	text-decoration: none;
	background: var(--cv-button-bg);
	border: 1px solid transparent;
	border-radius: var(--cv-radius);
	box-shadow: var(--cv-shadow);
	transition: filter 0.15s ease, transform 0.05s ease;
}

.clickvault-download-button:hover,
.clickvault-download-button:focus {
	color: var(--cv-button-text);
	filter: brightness( 0.95 );
}

.clickvault-download-button:active {
	filter: brightness( 0.9 );
	transform: translateY( 1px );
}

/* ------------------------------------------------------------------ *
 * Admin / editor notice.
 * ------------------------------------------------------------------ */
.clickvault-admin-notice {
	padding: 10px 14px;
	margin: 0 0 16px;
	border-left: 4px solid var(--cv-primary);
	border-radius: 4px;
	background: #eff4ff;
	color: #1e3a8a;
	font-size: 13px;
	line-height: 1.5;
}

/* ------------------------------------------------------------------ *
 * Responsive.
 * ------------------------------------------------------------------ */
@media ( max-width: 480px ) {
	.clickvault-gate__inner {
		padding: 1.25rem;
	}

	.clickvault-gate__title {
		font-size: 1.25rem;
	}
}

/* ------------------------------------------------------------------ *
 * Reduced motion: disable transitions/transforms.
 * ------------------------------------------------------------------ */
@media ( prefers-reduced-motion: reduce ) {
	.clickvault-submit,
	.clickvault-download-button,
	.clickvault-form input[type="text"],
	.clickvault-form input[type="email"] {
		transition: none;
	}

	.clickvault-submit:active,
	.clickvault-download-button:active {
		transform: none;
	}
}
