/*
 * Cookie Consent Manager — frontend styles
 *
 * Design plan (revised)
 * ----------------------
 * Matches the requested UX: the initial consent prompt and the preference
 * center are both centered popup cards over a dimmed backdrop, not a bottom
 * bar or a side drawer. "Customise" swaps the small popup for a larger one
 * with an accordion of categories, mirroring a two-step dialog rather than
 * two separate surfaces.
 *
 * Color:  --ccm-c-surface #FFFFFF / #15171C (dark)
 *         --ccm-c-ink     #14171C / #F3F4F6 (dark)
 *         --ccm-c-muted   #5B6472 / #9AA3B2 (dark)
 *         --ccm-c-line    #E7E9ED / #262A33 (dark)
 *         --ccm-c-accent  admin-configurable, default #2540C7
 *         --ccm-c-positive #1F9D66 used for "Always Active" label + on-toggle
 * Type:   System UI stack, one scale.
 * Layout: Non-modal "bar"/"top" banners stay fixed at the page edge with no
 *         backdrop (unchanged). The "modal" banner layout, and the
 *         preference-center popup regardless of banner layout, render as a
 *         centered card over a shared dim overlay.
 */

:host {
	--ccm-c-surface: #ffffff;
	--ccm-c-surface-alt: #f6f7f9;
	--ccm-c-ink: #14171c;
	--ccm-c-muted: #5b6472;
	--ccm-c-line: #e7e9ed;
	--ccm-c-accent: #2540c7;
	--ccm-c-accent-ink: #ffffff;
	--ccm-c-positive: #1f9d66;
	--ccm-radius: 12px;
	--ccm-radius-sm: 8px;
	--ccm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--ccm-shadow: 0 20px 60px rgba(20, 23, 28, 0.22);
	--ccm-z: 999999;
	all: initial;
	font-family: var(--ccm-font);
	color: var(--ccm-c-ink);
	-webkit-font-smoothing: antialiased;
}

:host([data-theme="dark"]) {
	--ccm-c-surface: #15171c;
	--ccm-c-surface-alt: #1b1e25;
	--ccm-c-ink: #f3f4f6;
	--ccm-c-muted: #9aa3b2;
	--ccm-c-line: #262a33;
	--ccm-c-accent-ink: #ffffff;
	--ccm-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

* {
	box-sizing: border-box;
	font-family: inherit;
}

/*
 * Defensive resets: many WordPress themes/page builders apply global
 * skins directly to bare `button`, `a`, and `svg` elements (border,
 * padding, background, oversized icon dimensions). Because those rules
 * live in the host page's stylesheet, they can still reach INTO a light
 * DOM widget. Rendering inside a Shadow DOM (see banner.js) blocks that
 * entirely — the host page's CSS simply cannot select across the shadow
 * boundary — but these explicit resets are kept as a second line of
 * defense for any browser path that falls back to light DOM.
 */
button,
a {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	font-family: inherit;
}

button {
	font-size: 14px;
}

svg {
	display: block;
}

/* ---------- Shared dim overlay (used by modal banner + preference popup) ---------- */

.ccm-overlay {
	position: fixed;
	inset: 0;
	z-index: var(--ccm-z);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: transparent;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease, background 0.25s ease;
}

.ccm-overlay.ccm-dim {
	background: rgba(15, 17, 21, 0.5);
}

.ccm-overlay.ccm-visible {
	opacity: 1;
	pointer-events: auto;
}

/* ---------- Banner: fixed bar / top variants (unchanged placement) ---------- */

.ccm-banner {
	position: fixed;
	left: 0;
	right: 0;
	z-index: var(--ccm-z);
	background: var(--ccm-c-surface);
	color: var(--ccm-c-ink);
	box-shadow: var(--ccm-shadow);
	padding: 20px 24px;
	display: flex;
	align-items: center;
	gap: 24px;
	transform: translateY(120%);
	transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
	max-height: 90vh;
	overflow-y: auto;
}

.ccm-banner.ccm-visible {
	transform: translateY(0);
}

.ccm-banner--bottom {
	bottom: 0;
	border-top: 1px solid var(--ccm-c-line);
}

.ccm-banner--top {
	top: 0;
	bottom: auto;
	border-bottom: 1px solid var(--ccm-c-line);
	transform: translateY(-120%);
}

.ccm-banner--top.ccm-visible {
	transform: translateY(0);
}

/* ---------- Banner: centered popup variant (default, matches reference UX) ---------- */

.ccm-banner--modal {
	position: static;
	flex-direction: column;
	align-items: stretch;
	gap: 20px;
	width: min(480px, 100%);
	max-width: 480px;
	border-radius: var(--ccm-radius);
	padding: 28px 28px 24px;
	transform: translateY(24px) scale(0.98);
	opacity: 0;
	transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
}

.ccm-banner--modal.ccm-visible {
	transform: translateY(0) scale(1);
	opacity: 1;
}

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

.ccm-banner__heading {
	font-size: 20px;
	font-weight: 700;
	margin: 0 0 10px;
	letter-spacing: -0.01em;
}

.ccm-logo {
	display: block;
	max-height: 32px;
	max-width: 160px;
	width: auto;
	height: auto;
	margin: 0 0 12px;
	object-fit: contain;
}

.ccm-popup__heading-group {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.ccm-popup__heading-group .ccm-logo {
	margin: 0;
	max-height: 26px;
	max-width: 110px;
	flex-shrink: 0;
}

.ccm-banner--modal .ccm-banner__heading {
	font-size: 22px;
}

.ccm-banner__message {
	font-size: 14px;
	line-height: 1.6;
	color: var(--ccm-c-muted);
	margin: 0;
}

.ccm-banner__message a {
	color: var(--ccm-c-ink);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ccm-banner__actions {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
	flex-wrap: wrap;
}

.ccm-banner--modal .ccm-banner__actions {
	flex-wrap: nowrap;
}

.ccm-btn {
	border-radius: var(--ccm-radius-sm);
	padding: 12px 16px;
	font-weight: 600;
	border: 1.5px solid var(--ccm-c-accent);
	background: transparent;
	color: var(--ccm-c-accent);
	white-space: nowrap;
	transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
	flex: 1;
	text-align: center;
}

.ccm-btn:hover {
	opacity: 0.8;
}

.ccm-btn:focus-visible {
	outline: 2px solid var(--ccm-c-accent);
	outline-offset: 2px;
}

.ccm-btn--ghost {
	border-color: var(--ccm-c-accent);
	color: var(--ccm-c-accent);
	background: transparent;
}

.ccm-btn--primary {
	background: var(--ccm-c-accent);
	color: var(--ccm-c-accent-ink);
	border-color: var(--ccm-c-accent);
}

.ccm-banner__close {
	position: absolute;
	top: 14px;
	right: 16px;
	background: none;
	border: none;
	color: var(--ccm-c-muted);
	font-size: 20px;
	line-height: 1;
	padding: 6px;
}

.ccm-banner--modal {
	position: relative;
}

/* ---------- Persistent reopen button ---------- */

.ccm-fab {
	position: fixed;
	z-index: var(--ccm-z);
	bottom: 20px;
	left: 20px;
	width: 46px;
	height: 46px;
	border-radius: 999px;
	background: var(--ccm-c-surface);
	border: 1px solid var(--ccm-c-line);
	box-shadow: var(--ccm-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--ccm-c-ink);
}

.ccm-fab svg {
	width: 20px;
	height: 20px;
}

/* ---------- Preference center popup ---------- */

.ccm-popup {
	position: relative;
	background: var(--ccm-c-surface);
	color: var(--ccm-c-ink);
	width: min(560px, 100%);
	max-width: 560px;
	max-height: min(680px, 88vh);
	border-radius: var(--ccm-radius);
	box-shadow: var(--ccm-shadow);
	display: flex;
	flex-direction: column;
	transform: translateY(24px) scale(0.98);
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
}

.ccm-popup.ccm-visible {
	transform: translateY(0) scale(1);
	opacity: 1;
}

.ccm-popup__header {
	padding: 22px 26px 16px;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.ccm-popup__title {
	font-size: 19px;
	font-weight: 700;
	margin: 0;
	letter-spacing: -0.01em;
}

.ccm-popup__close {
	background: none;
	border: none;
	color: var(--ccm-c-muted);
	font-size: 20px;
	line-height: 1;
	padding: 4px;
	flex-shrink: 0;
}

.ccm-popup__body {
	flex: 1;
	overflow-y: auto;
	padding: 0 26px;
}

.ccm-popup__intro {
	font-size: 13.5px;
	color: var(--ccm-c-muted);
	line-height: 1.6;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--ccm-c-line);
	margin-bottom: 4px;
}

.ccm-popup__intro-toggle {
	background: none;
	border: none;
	color: var(--ccm-c-accent);
	padding: 0;
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: underline;
}

.ccm-category {
	border-bottom: 1px solid var(--ccm-c-line);
}

.ccm-category__row {
	padding: 16px 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.ccm-category__label-group {
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.ccm-category__name {
	font-size: 15px;
	font-weight: 700;
	background: none;
	border: none;
	padding: 0;
	text-align: left;
	color: var(--ccm-c-ink);
	display: flex;
	align-items: center;
	gap: 8px;
}

.ccm-category__name .ccm-chevron {
	width: 13px;
	height: 13px;
	transition: transform 0.2s ease;
	color: var(--ccm-c-muted);
	flex-shrink: 0;
}

.ccm-category__name .ccm-chevron svg {
	width: 100%;
	height: 100%;
}

.ccm-category.ccm-expanded .ccm-chevron {
	transform: rotate(90deg);
}

.ccm-category__always-active {
	font-size: 12.5px;
	color: var(--ccm-c-positive);
	font-weight: 700;
}

.ccm-category__details {
	display: none;
	padding: 0 0 16px 21px;
	font-size: 13px;
	color: var(--ccm-c-muted);
	line-height: 1.6;
}

.ccm-category.ccm-expanded .ccm-category__details {
	display: block;
}

.ccm-category__cookie-table {
	margin-top: 10px;
	border: 1px solid var(--ccm-c-line);
	border-radius: var(--ccm-radius-sm);
	overflow: hidden;
}

.ccm-category__cookie-table table {
	width: 100%;
	border-collapse: collapse;
	font-size: 11.5px;
}

.ccm-category__cookie-table th,
.ccm-category__cookie-table td {
	text-align: left;
	padding: 8px 10px;
	border-bottom: 1px solid var(--ccm-c-line);
}

.ccm-category__cookie-table tr:last-child td {
	border-bottom: none;
}

.ccm-category__cookie-table th {
	background: var(--ccm-c-surface-alt);
	font-weight: 600;
	color: var(--ccm-c-muted);
}

/* Toggle switch */

.ccm-switch {
	position: relative;
	width: 40px;
	height: 24px;
	flex-shrink: 0;
}

.ccm-switch input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.ccm-switch__track {
	position: absolute;
	inset: 0;
	background: var(--ccm-c-line);
	border-radius: 999px;
	transition: background 0.15s ease;
}

.ccm-switch__thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.15s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ccm-switch input:checked ~ .ccm-switch__track {
	background: var(--ccm-c-positive);
}

.ccm-switch input:checked ~ .ccm-switch__thumb {
	transform: translateX(16px);
}

.ccm-switch input:disabled ~ .ccm-switch__track {
	background: var(--ccm-c-positive);
	opacity: 0.5;
	cursor: not-allowed;
}

.ccm-switch input:focus-visible ~ .ccm-switch__track {
	outline: 2px solid var(--ccm-c-accent);
	outline-offset: 2px;
}

.ccm-popup__footer {
	padding: 18px 26px 22px;
	border-top: 1px solid var(--ccm-c-line);
	display: flex;
	gap: 10px;
}

.ccm-popup__links {
	padding: 0 26px 16px;
	font-size: 12px;
	display: flex;
	gap: 14px;
	color: var(--ccm-c-muted);
}

.ccm-popup__links a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

@media (max-width: 640px) {
	.ccm-overlay {
		padding: 0;
		align-items: flex-end;
	}
	.ccm-banner--modal,
	.ccm-popup {
		width: 100%;
		max-width: 100%;
		border-radius: var(--ccm-radius) var(--ccm-radius) 0 0;
		max-height: 92vh;
	}
	.ccm-banner {
		flex-direction: column;
		align-items: stretch;
		padding: 18px;
	}
	.ccm-banner__actions {
		justify-content: stretch;
	}
	.ccm-banner--modal .ccm-banner__actions {
		flex-wrap: wrap;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ccm-banner,
	.ccm-popup,
	.ccm-overlay,
	.ccm-chevron,
	.ccm-switch__thumb {
		transition: none !important;
	}
}
