/**
 * VPS Consent — frontend styles
 *
 * Design targets:
 *  - WCAG 2.1 Level AA colour contrast throughout.
 *  - Accessible focus indicators (WCAG SC 1.4.11, 3:1 non-text contrast).
 *  - prefers-reduced-motion: removes transitions and slide animations.
 *  - Mobile-first responsive layout.
 *  - No colour used as the sole differentiator between Accept and Reject.
 */

/* ── Reset ──────────────────────────────────────────────────────────────── */

.vps-consent-banner *,
.vps-consent-modal *,
.vps-consent-overlay,
.vps-consent-reopen {
	box-sizing: border-box;
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
	/* Remapped to the serp-shop theme palette (theme assets/css/tokens.css).
	   The --vps-gray-* names are kept so existing rules need no edit — their
	   values now track the theme's neutral scale. */
	--vps-white:        #ffffff;
	--vps-gray-50:      #F7F8FA;   /* theme --color-bg */
	--vps-gray-100:     #EEF1F5;   /* theme --color-bg-alt */
	--vps-gray-200:     #E2E8F0;   /* theme --color-border */
	--vps-gray-500:     #718096;   /* theme --color-text-light */
	--vps-gray-700:     #2D3748;   /* theme --color-text-main */
	--vps-gray-900:     #1B2A4A;   /* theme --color-secondary (headings) */

	--vps-primary:      #0B7A75;   /* theme --color-primary (teal) — secondary action, toggles, focus, links */
	--vps-primary-dark: #085E5A;   /* theme --color-primary-dark */
	--vps-accent:       #E8653A;   /* theme --color-accent (orange) — primary CTA */
	--vps-accent-hover: #D4552D;   /* theme --color-accent-hover */

	--vps-radius:       12px;      /* theme --radius (cards / modal / banner corners) */
	--vps-radius-sm:    8px;       /* theme --radius-sm */
	--vps-btn-radius:   4px;       /* theme .btn */

	--vps-shadow:       0 10px 30px rgba(0, 0, 0, 0.12);  /* theme --shadow-lg */
	--vps-shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);  /* theme --shadow-sm */
	--vps-shadow-md:    0 4px 12px rgba(0, 0, 0, 0.1);    /* theme --shadow-md */

	--vps-transition:   0.2s ease;

	--vps-z-banner:     9998;
	--vps-z-overlay:    9999;
	--vps-z-modal:      10000;
	--vps-z-reopen:     9997;
}

/* ── Screen-reader only ─────────────────────────────────────────────────── */

.vps-consent-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ── Banner ─────────────────────────────────────────────────────────────── */

.vps-consent-banner {
	position: fixed;
	z-index: var(--vps-z-banner);
	background: var(--vps-white);
	box-shadow: var(--vps-shadow);
	font-family: inherit;
	font-size: 14px;
	line-height: 1.5;
	color: var(--vps-gray-900);
}

.vps-consent-banner--hidden {
	display: none;
}

.vps-consent-banner--bottom-bar {
	bottom: 0;
	left: 0;
	right: 0;
	border-top: 1px solid var(--vps-gray-200);
}

.vps-consent-banner--bottom-left {
	bottom: 16px;
	left: 16px;
	width: 100%;
	max-width: 400px;
	border-radius: var(--vps-radius);
	border: 1px solid var(--vps-gray-200);
}

.vps-consent-banner--bottom-right {
	bottom: 16px;
	right: 16px;
	width: 100%;
	max-width: 400px;
	border-radius: var(--vps-radius);
	border: 1px solid var(--vps-gray-200);
}

.vps-consent-banner--center-modal {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 90%;
	max-width: 540px;
	border-radius: var(--vps-radius);
	border: 1px solid var(--vps-gray-200);
}

.vps-consent-banner__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	max-width: 1280px;
	margin: 0 auto;
}

.vps-consent-banner__body {
	flex: 1;
	min-width: 0;
}

.vps-consent-banner__title {
	margin: 0 0 4px;
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--vps-gray-900);
}

.vps-consent-banner__text {
	margin: 0;
	color: var(--vps-gray-700);
}

.vps-consent-banner__policy-link {
	margin-left: 4px;
	color: var(--vps-primary);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.vps-consent-banner__policy-link:hover,
.vps-consent-banner__policy-link:focus {
	text-decoration: none;
}

.vps-consent-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	flex-shrink: 0;
}

/*
 * Banner buttons carry their own variant colours (see Buttons below): Accept =
 * orange CTA, Reject = teal action, Manage = outline. The previous blanket
 * flattening override has been removed so the branded variants render.
 */

/* ── Buttons ─────────────────────────────────────────────────────────────── */

/*
 * Buttons match the serp-shop button system (theme assets/css/components.css):
 * 44px min-height, 4px radius, 1px border, 600 weight, .9375rem. border-box
 * sizing (set in the reset) keeps all variants identical regardless of border.
 *
 * Visual hierarchy / GDPR balance: Accept (orange) and Reject (teal) are both
 * filled and equal weight — colour is never the sole differentiator and neither
 * choice is visually suppressed. Manage is a de-emphasised outline (it opens
 * options rather than recording a decision).
 */
.vps-consent-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.75rem 1.25rem;
	border: 1px solid transparent;
	border-radius: var(--vps-btn-radius);
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
	-webkit-appearance: none;
	transition: background var(--vps-transition), color var(--vps-transition), border-color var(--vps-transition), transform var(--vps-transition), box-shadow var(--vps-transition);
}

/* Accept / Save — primary CTA, theme accent (orange). Matches .btn--primary. */
.vps-consent-btn--accept {
	background: var(--vps-accent);
	color: var(--vps-white);
	border-color: var(--vps-accent);
}
.vps-consent-btn--accept:hover {
	background: var(--vps-accent-hover);
	border-color: var(--vps-accent-hover);
	transform: translateY(-1px);
	box-shadow: var(--vps-shadow-md);
}

/* Reject — secondary action, theme primary (teal). Matches .btn--secondary. */
.vps-consent-btn--reject {
	background: var(--vps-primary);
	color: var(--vps-white);
	border-color: var(--vps-primary);
}
.vps-consent-btn--reject:hover {
	background: var(--vps-primary-dark);
	border-color: var(--vps-primary-dark);
}

/* Secondary — modal "Accept all" shortcut. Teal, equal weight to Reject all. */
.vps-consent-btn--secondary {
	background: var(--vps-primary);
	color: var(--vps-white);
	border-color: var(--vps-primary);
}
.vps-consent-btn--secondary:hover {
	background: var(--vps-primary-dark);
	border-color: var(--vps-primary-dark);
}

/* Manage — de-emphasised outline. Matches .btn--outline. */
.vps-consent-btn--manage {
	background: var(--vps-white);
	color: var(--vps-gray-700);
	border-color: var(--vps-gray-200);
}
.vps-consent-btn--manage:hover {
	background: var(--vps-white);
	border-color: var(--vps-primary);
	color: var(--vps-primary);
}

/*
 * Focus indicator is keyboard-only. The banner auto-focuses "Accept all" on open
 * (consent.js showBanner), so a :focus-visible ring would otherwise render a teal
 * outline on the orange CTA on load — reading as an unwanted double border.
 * Suppressing plain :focus keeps the CTA a clean solid button for mouse /
 * programmatic focus; the :focus-visible rule restores the ring for keyboard users.
 */
.vps-consent-btn:focus {
	outline: none;
}

.vps-consent-btn:focus-visible {
	outline: 3px solid var(--vps-primary);
	outline-offset: 2px;
}

/* Per request: no focus-visible outline on the Accept-all / primary orange CTA
 * (banner "Accept all cookies" + modal "Save preferences"). */
.vps-consent-btn--accept:focus-visible {
	outline: none;
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */

.vps-consent-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: var(--vps-z-overlay);
	background: rgba(0, 0, 0, 0.4);
}

.vps-consent-overlay--visible {
	display: block;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */

.vps-consent-modal {
	display: none;
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: var(--vps-z-modal);
	width: 90%;
	max-width: 640px;
	max-height: 90vh;
	background: var(--vps-white);
	border-radius: var(--vps-radius);
	box-shadow: var(--vps-shadow);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.vps-consent-modal--open {
	display: block;
}

.vps-consent-no-scroll {
	overflow: hidden;
}

.vps-consent-modal__inner {
	padding: 24px;
}

.vps-consent-modal__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

.vps-consent-modal__title {
	font-size: 18px;
	font-weight: 700;
	margin: 0;
	color: var(--vps-gray-900);
}

.vps-consent-modal__close {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: none;
	border: 2px solid transparent;
	border-radius: var(--vps-radius-sm);
	cursor: pointer;
	color: var(--vps-gray-500);
	padding: 0;
	transition: color var(--vps-transition), background var(--vps-transition);
}

.vps-consent-modal__close:hover {
	color: var(--vps-gray-900);
	background: var(--vps-gray-100);
}

.vps-consent-modal__close:focus-visible {
	outline: 3px solid var(--vps-primary);
	outline-offset: 2px;
}

.vps-consent-modal__intro {
	font-size: 13px;
	color: var(--vps-gray-700);
	margin: 0 0 20px;
}

.vps-consent-modal__intro a {
	color: var(--vps-primary);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* ── Category rows ───────────────────────────────────────────────────────── */

.vps-consent-modal__categories {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--vps-gray-200);
	border-radius: var(--vps-radius);
	overflow: hidden;
}

.vps-consent-modal__category {
	border-bottom: 1px solid var(--vps-gray-200);
	background: var(--vps-white);
}

.vps-consent-modal__category:last-child {
	border-bottom: none;
}

.vps-consent-modal__category-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 16px;
}

.vps-consent-modal__category-info {
	flex: 1;
	min-width: 0;
}

.vps-consent-modal__category-title {
	font-size: 14px;
	font-weight: 600;
	margin: 0 0 4px;
	color: var(--vps-gray-900);
}

.vps-consent-modal__category-title label {
	cursor: pointer;
}

.vps-consent-modal__category-desc {
	font-size: 13px;
	color: var(--vps-gray-500);
	margin: 0 0 4px;
}

.vps-consent-modal__legal-basis {
	font-size: 11px;
	color: var(--vps-gray-500);
	margin: 0;
	font-style: italic;
}

/* ── Native checkboxes ───────────────────────────────────────────────────── */

.vps-consent-modal__toggle-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}

.vps-consent-modal__always-active {
	font-size: 11px;
	font-weight: 600;
	color: #38A169;
	white-space: nowrap;
}

/*
 * Native checkbox — browser renders the control.
 * accent-color tints the checkbox fill to the theme primary when checked.
 * No appearance overrides: accessible in all contexts, including high-contrast mode.
 */
.vps-consent-toggle {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	cursor: pointer;
	accent-color: var(--vps-primary);
}

.vps-consent-toggle:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.vps-consent-toggle:focus-visible {
	outline: 3px solid var(--vps-primary);
	outline-offset: 2px;
}

/* ── Cookie table ────────────────────────────────────────────────────────── */

.vps-consent-cookie-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--vps-gray-50);
	border-top: 1px solid var(--vps-gray-200);
}

.vps-consent-cookie-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
	color: var(--vps-gray-700);
}

.vps-consent-cookie-table th {
	text-align: left;
	padding: 8px 12px;
	font-weight: 600;
	color: var(--vps-gray-900);
	background: var(--vps-gray-100);
	border-bottom: 1px solid var(--vps-gray-200);
	white-space: nowrap;
}

.vps-consent-cookie-table td {
	padding: 8px 12px;
	border-bottom: 1px solid var(--vps-gray-200);
	vertical-align: top;
}

.vps-consent-cookie-table tbody tr:last-child td {
	border-bottom: none;
}

.vps-consent-cookie-table code {
	font-size: 11px;
	background: var(--vps-gray-200);
	padding: 1px 4px;
	border-radius: 3px;
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ── Modal footer ────────────────────────────────────────────────────────── */

.vps-consent-modal__footer {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--vps-gray-200);
}

/*
 * Footer buttons use their variant colours: Save = orange CTA (--accept),
 * Accept all / Reject all = teal (--secondary / --reject), equal weight. The
 * previous blanket flattening override has been removed.
 */

/* ── Re-open button (persistent footer) ─────────────────────────────────── */

.vps-consent-reopen {
	position: fixed;
	bottom: 16px;
	left: 16px;
	z-index: var(--vps-z-reopen);
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background: var(--vps-white);
	color: var(--vps-gray-700);
	border: 1px solid var(--vps-gray-200);
	border-radius: 20px;
	font-family: inherit;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	box-shadow: var(--vps-shadow-sm);
	transition: background var(--vps-transition), box-shadow var(--vps-transition);
}

.vps-consent-reopen:hover {
	background: var(--vps-gray-50);
	box-shadow: var(--vps-shadow);
}

.vps-consent-reopen:focus-visible {
	outline: 3px solid var(--vps-primary);
	outline-offset: 2px;
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.vps-consent-banner,
	.vps-consent-modal,
	.vps-consent-overlay,
	.vps-consent-btn,
	.vps-consent-modal__close,
	.vps-consent-reopen {
		transition: none;
	}
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
	.vps-consent-banner__inner {
		flex-direction: column;
		align-items: stretch;
	}

	.vps-consent-banner__actions {
		flex-direction: column;
	}

	.vps-consent-btn {
		width: 100%;
		justify-content: center;
	}

	.vps-consent-modal__inner {
		padding: 16px;
	}

	.vps-consent-modal__footer {
		flex-direction: column;
	}

	.vps-consent-reopen {
		bottom: 8px;
		left: 8px;
	}

	.vps-consent-banner--bottom-left,
	.vps-consent-banner--bottom-right {
		left: 0;
		right: 0;
		bottom: 0;
		max-width: 100%;
		border-radius: 0;
	}
}
