/**
 * 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 {
	--vps-white:        #ffffff;
	--vps-gray-50:      #f9fafb;
	--vps-gray-100:     #f3f4f6;
	--vps-gray-200:     #e5e7eb;
	--vps-gray-500:     #6b7280;
	--vps-gray-700:     #374151;
	--vps-gray-900:     #111827;
	--vps-accent:       #222222;   /* matches theme primary */
	--vps-accent-hover: #444444;
	--vps-radius:       8px;
	--vps-shadow:       0 4px 24px rgba(0, 0, 0, 0.12);
	--vps-shadow-sm:    0 1px 4px rgba(0, 0, 0, 0.08);
	--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__text {
	margin: 0;
	color: var(--vps-gray-700);
}

.vps-consent-banner__policy-link {
	margin-left: 4px;
	color: var(--vps-gray-900);
	text-decoration: underline;
}

.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: same scoped override as the modal footer fix.
 * Two-class specificity (0,2,0) beats both the --accept variant (0,1,0) and
 * any theme-level `button {}` reset (0,0,1) that would make white text on a
 * transparent/white background invisible until hover.
 */
.vps-consent-banner__actions .vps-consent-btn {
	background: var(--vps-white);
	color: var(--vps-gray-900);
	border-color: var(--vps-gray-900);
}

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

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

/*
 * All consent buttons share identical height (38px) and border-radius.
 * border: 2px solid is declared on the base so border-box sizing is identical
 * across all variants — no variant should change the border width.
 */
.vps-consent-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 38px;
	padding: 0 18px;
	border: 2px solid transparent;
	border-radius: var(--vps-radius);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	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);
}

/* Accept — filled, theme 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);
}

/* Reject — outlined dark */
.vps-consent-btn--reject {
	background: var(--vps-white);
	color: var(--vps-gray-900);
	border-color: var(--vps-gray-900);
}
.vps-consent-btn--reject:hover {
	background: var(--vps-gray-100);
}

/* Secondary — subtle outlined (modal "Accept all" shortcut) */
.vps-consent-btn--secondary {
	background: var(--vps-gray-50);
	color: var(--vps-gray-900);
	border-color: var(--vps-gray-200);
}
.vps-consent-btn--secondary:hover {
	background: var(--vps-gray-100);
}

/* Manage — de-emphasised outlined, same height as the others */
.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-gray-50);
	border-color: var(--vps-gray-500);
	color: var(--vps-gray-900);
}

.vps-consent-btn:focus-visible {
	outline: 3px solid #005fcc;
	outline-offset: 2px;
}

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

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

.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: 6px;
	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 #005fcc;
	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-gray-900);
	text-decoration: underline;
}

/* ── 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: #2ea44f;
	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-accent);
}

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

.vps-consent-toggle:focus-visible {
	outline: 3px solid #005fcc;
	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);
}

/*
 * All three footer buttons share identical styling regardless of their variant
 * class. The two-class selector (0,2,0) outranks both the variant rules (0,1,0)
 * and any theme-level `button {}` resets (0,0,1) that could make the --accept
 * white text invisible against a transparent or white background.
 */
.vps-consent-modal__footer .vps-consent-btn {
	background: var(--vps-white);
	color: var(--vps-gray-900);
	border-color: var(--vps-gray-900);
}

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

/* ── 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 #005fcc;
	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;
	}
}
