/**
 * Cookie banner — front-end styles.
 *
 * Every visual decision is driven by a --hwpm-* custom property. The settings
 * page emits an inline :root block (HWPM_Design::inline_css) that overrides the
 * defaults below, so this file doubles as the "factory settings" source.
 *
 * Sizes inside the banner are in `em` on purpose: --hwpm-font-size scales the
 * whole component from one number.
 */
:root {
	--hwpm-primary: #38494B;
	--hwpm-primary-text: #F4F1EA;
	--hwpm-accent: #E16A54;
	--hwpm-bg: #F4F1EA;
	--hwpm-surface: #FBFAF9;
	--hwpm-text: #2D2828;
	--hwpm-text-muted: #8C8C85;
	--hwpm-border: #38494B;

	--hwpm-radius: 8px;
	--hwpm-btn-radius: 8px;
	--hwpm-font-size: 16px;
	--hwpm-card-width: 560px;
	--hwpm-bar-width: 1152px;
	--hwpm-edge: 20px;

	--hwpm-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
	--hwpm-shadow-up: 0 -8px 32px rgba(0, 0, 0, 0.12);
	--hwpm-overlay-color: #000000;
	--hwpm-overlay-opacity: 50%;
	--hwpm-z: 30000;
}

/* ——————————————————————————————— Root & layout ——————————————————————————— */

.hwpm-banner-root {
	font-size: var(--hwpm-font-size);

	/* Derived values follow --hwpm-border / --hwpm-primary automatically.
	   They are declared here, not on :root, because a custom property's var()
	   references are substituted on the element that declares it — declaring
	   them at :root would freeze them to the stylesheet defaults whenever the
	   base tokens are overridden further down the tree (which is exactly what
	   the settings-page preview does on the stage element). */
	--hwpm-border-soft: color-mix(in srgb, var(--hwpm-border) 20%, transparent);
	--hwpm-border-softer: color-mix(in srgb, var(--hwpm-border) 12%, transparent);
	--hwpm-focus-ring: color-mix(in srgb, var(--hwpm-primary) 30%, transparent);
	--hwpm-hover-wash: color-mix(in srgb, var(--hwpm-primary) 8%, transparent);
	--hwpm-overlay: color-mix(in srgb, var(--hwpm-overlay-color) var(--hwpm-overlay-opacity), transparent);
}

.hwpm-banner-root:not([hidden]) {
	position: fixed;
	z-index: var(--hwpm-z);
	font-family: inherit;
}

/* public.js focuses the root (tabindex="-1") so screen-reader and keyboard users
   land on the pending choice. The root is not a tab stop, and it spans the full
   viewport width in most layouts, so its focus ring would just draw a stray line
   across the page. The buttons inside keep their own :focus-visible ring. */
.hwpm-banner-root:focus {
	outline: none;
}

/* Optional dimmed backdrop. Always viewport-sized, whatever the layout is.
   `pointer-events: auto` is explicit because the card layout sets `none` on the
   root — without it the backdrop would dim the page but still let clicks
   through, which is not what enabling a backdrop means. `z-index: -1` keeps it
   behind the banner's own buttons inside the root's stacking context. */
.hwpm-banner-root--overlay:not([hidden])::before {
	content: '';
	position: fixed;
	inset: 0;
	background: var(--hwpm-overlay);
	pointer-events: auto;
	z-index: -1;
}

/* Full-width bar --------------------------------------------------------- */
.hwpm-banner-root--bar:not([hidden]) {
	inset-inline: 0;
}

.hwpm-banner-root--bar.hwpm-banner-root--pos-bottom:not([hidden]) {
	bottom: 0;
}

.hwpm-banner-root--bar.hwpm-banner-root--pos-top:not([hidden]) {
	top: 0;
}

/* Floating card ---------------------------------------------------------- */
.hwpm-banner-root--card:not([hidden]) {
	inset-inline: 0;
	display: flex;
	padding: var(--hwpm-edge);
	pointer-events: none;
}

.hwpm-banner-root--card.hwpm-banner-root--pos-bottom-start:not([hidden]),
.hwpm-banner-root--card.hwpm-banner-root--pos-bottom-center:not([hidden]),
.hwpm-banner-root--card.hwpm-banner-root--pos-bottom-end:not([hidden]) {
	bottom: 0;
	align-items: flex-end;
}

.hwpm-banner-root--card.hwpm-banner-root--pos-top-center:not([hidden]) {
	top: 0;
	align-items: flex-start;
}

/* `dir="rtl"` on the root makes flex-start the right-hand side. */
.hwpm-banner-root--pos-bottom-start { justify-content: flex-start; }
.hwpm-banner-root--pos-bottom-center,
.hwpm-banner-root--pos-top-center { justify-content: center; }
.hwpm-banner-root--pos-bottom-end { justify-content: flex-end; }

/* Centred modal ---------------------------------------------------------- */
.hwpm-banner-root--modal:not([hidden]) {
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--hwpm-edge);
	overflow: auto;
}

/* ——————————————————————————————— Banner box —————————————————————————————— */

.hwpm-banner {
	background: var(--hwpm-bg);
	color: var(--hwpm-text);
	direction: rtl;
	text-align: right;
}

.hwpm-banner-root--bar .hwpm-banner {
	box-shadow: var(--hwpm-shadow-up);
	border-block-start: 1px solid var(--hwpm-border-soft);
}

.hwpm-banner-root--bar.hwpm-banner-root--pos-top .hwpm-banner {
	box-shadow: var(--hwpm-shadow);
	border-block-start: 0;
	border-block-end: 1px solid var(--hwpm-border-soft);
}

.hwpm-banner-root--card .hwpm-banner,
.hwpm-banner-root--modal .hwpm-banner {
	pointer-events: auto;
	width: var(--hwpm-card-width);
	max-width: 100%;
	max-height: 85vh;
	overflow-y: auto;
	border: 1px solid var(--hwpm-border-soft);
	border-radius: var(--hwpm-radius);
	box-shadow: var(--hwpm-shadow);
}

.hwpm-banner__inner {
	max-width: var(--hwpm-bar-width);
	margin: 0 auto;
	padding: 1.25em 1.25em 1.5em;
}

.hwpm-banner-root--card .hwpm-banner__inner,
.hwpm-banner-root--modal .hwpm-banner__inner {
	max-width: none;
}

.hwpm-banner__title {
	margin: 0 0 0.4em;
	font-size: 1.25em;
	font-weight: 700;
	color: var(--hwpm-primary);
	line-height: 1.3;
}

.hwpm-banner__text {
	margin: 0 0 1em;
	font-size: 1em;
	line-height: 1.6;
	color: var(--hwpm-text);
}

.hwpm-banner__text a {
	color: var(--hwpm-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.hwpm-banner__text a:hover,
.hwpm-banner__text a:focus {
	text-decoration-thickness: 2px;
}

.hwpm-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	justify-content: flex-start;
	align-items: center;
}

/* ——————————————————————————————— Buttons ————————————————————————————————— */

.hwpm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.5em 1.25em;
	font-family: inherit;
	font-size: 1em;
	font-weight: 600;
	border-radius: var(--hwpm-btn-radius);
	border: 2px solid transparent;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.hwpm-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--hwpm-focus-ring);
}

.hwpm-btn--primary {
	background: var(--hwpm-primary);
	color: var(--hwpm-primary-text);
	border-color: var(--hwpm-primary);
}

.hwpm-btn--primary:hover {
	filter: brightness(1.08);
}

.hwpm-btn--secondary {
	background: transparent;
	color: var(--hwpm-primary);
	border-color: var(--hwpm-primary);
}

.hwpm-btn--secondary:hover {
	background: var(--hwpm-hover-wash);
}

.hwpm-btn--ghost {
	background: transparent;
	color: var(--hwpm-text-muted);
	border-color: transparent;
	text-decoration: underline;
	min-height: auto;
	padding: 0.35em 0.5em;
}

.hwpm-btn--ghost:hover {
	color: var(--hwpm-primary);
}

/* ——————————————————————————— Preferences panel ——————————————————————————— */

.hwpm-banner__panel {
	margin-top: 1em;
	padding-top: 1em;
	border-top: 1px solid var(--hwpm-border-softer);
}

.hwpm-banner__fieldset {
	border: 0;
	margin: 0;
	padding: 0;
}

.hwpm-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;
}

.hwpm-cat {
	margin-bottom: 1em;
	padding: 0.75em 1em;
	background: var(--hwpm-surface);
	border-radius: var(--hwpm-radius);
	border: 1px solid var(--hwpm-border-softer);
}

.hwpm-cat__label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.25em;
	color: var(--hwpm-primary);
}

.hwpm-cat__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	font-weight: 600;
	cursor: pointer;
	color: var(--hwpm-text);
}

.hwpm-cat__desc {
	margin: 0.35em 0 0;
	font-size: 0.875em;
	color: var(--hwpm-text-muted);
	line-height: 1.5;
}

.hwpm-cat__desc a {
	color: var(--hwpm-accent);
}

.hwpm-banner__save {
	margin-top: 0.5em;
}

@media (min-width: 768px) {
	.hwpm-banner-root--bar .hwpm-banner__actions {
		justify-content: flex-end;
		flex-direction: row-reverse;
	}
}

/* ————————————————————— Simple mode (one line + 2 buttons) ————————————————— */

.hwpm-banner__inner--simple {
	padding: 0.875em 1em 1em;
}

.hwpm-banner__simple-row {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 0.65em;
	flex-wrap: wrap;
}

.hwpm-banner__text--simple {
	flex: 1 1 180px;
	margin: 0;
	font-size: 0.9375em;
	line-height: 1.55;
	color: var(--hwpm-text);
	min-width: 0;
}

.hwpm-banner__text--simple a {
	color: var(--hwpm-accent);
}

.hwpm-banner__actions--simple {
	display: flex;
	flex-direction: row-reverse;
	flex-wrap: nowrap;
	gap: 0.5em;
	align-items: center;
	flex-shrink: 0;
	margin-inline-start: auto;
}

/* Compact buttons — colours still come from --primary / --secondary. */
.hwpm-btn--simple,
.hwpm-btn--simple-primary {
	min-height: 40px;
	padding: 0.4em 1.15em;
	font-size: 0.9375em;
}

@media (max-width: 480px) {
	.hwpm-banner-root--card:not([hidden]),
	.hwpm-banner-root--modal:not([hidden]) {
		padding-inline: 0.75em;
	}

	.hwpm-banner-root--card .hwpm-banner,
	.hwpm-banner-root--modal .hwpm-banner {
		max-width: 100%;
	}

	.hwpm-banner__actions--simple {
		width: 100%;
		justify-content: stretch;
		margin-inline-start: 0;
	}

	.hwpm-banner__actions--simple .hwpm-btn {
		flex: 1;
	}
}
