/*
 * Fancy Consent — default styles.
 *
 * Plain and neutral, and built to be restyled from a theme without fighting:
 *
 * - Every rule is a single class, so the defaults hold against a theme's
 *   element styles (h2, ul, label) but give way to any theme selector with two
 *   classes — scope an override under .fancy-consent-notice or
 *   .fancy-consent-dialog and it wins, whichever stylesheet loads first.
 * - Colours, radii and fonts read custom properties with the defaults as
 *   fallbacks, so a theme sets only the ones it wants, anywhere it likes:
 *
 *     :root { --fancy-consent-accent: #0a7; --fancy-consent-radius: 0; }
 *
 * - The notice and the dialog have their own sets (--fancy-consent-notice-*,
 *   --fancy-consent-dialog-*), which fall back to the shared ones.
 *
 * The full list is in the README. To drop these entirely and style from
 * scratch: add_filter( 'fancy_consent_styles', '__return_false' ).
 */

/* The one !important: whatever display a theme gives the notice or dialog,
   it must not show while it's meant to be hidden. */
.fancy-consent-notice[hidden],
.fancy-consent-dialog:not([open]) {
	display: none !important;
}

/* ==========================================================================
   Notice
   ========================================================================== */

.fancy-consent-notice {
	position: fixed;
	z-index: var(--fancy-consent-z-index, 9999);
	right: var(--fancy-consent-notice-inset, 20px);
	bottom: var(--fancy-consent-notice-inset, 20px);
	left: var(--fancy-consent-notice-inset, 20px);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 20px;
	max-width: var(--fancy-consent-notice-max-width, max-content);
	margin-inline: auto;
	padding: var(--fancy-consent-notice-padding, 16px 20px);
	border: var(--fancy-consent-notice-border, 1px solid var(--fancy-consent-border, #dcdcde));
	border-radius: var(--fancy-consent-notice-radius, var(--fancy-consent-radius, 4px));
	background: var(--fancy-consent-notice-bg, var(--fancy-consent-bg, #fff));
	box-shadow: var(--fancy-consent-notice-shadow, var(--fancy-consent-shadow, 0 4px 16px rgb(0 0 0 / 12%)));
	color: var(--fancy-consent-notice-color, var(--fancy-consent-color, #1e1e1e));
	font: 14px/1.5 var(--fancy-consent-font, inherit);
}

.fancy-consent-text {
	display: flex;
	flex: 1 1 280px;
	align-items: baseline;
	gap: 10px;
	margin: 0;
}

/* An empty hook before the message: off by default. Give it a display, size
   and background to use it as a dot, an icon, etc. */
.fancy-consent-marker {
	display: none;
	flex: 0 0 auto;
}

/* ==========================================================================
   Shared: links, actions and buttons
   ========================================================================== */

.fancy-consent-notice a,
.fancy-consent-dialog a {
	color: inherit;
	text-decoration: underline;
}

.fancy-consent-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.fancy-consent-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px 16px;
	border: 1px solid var(--fancy-consent-accent, #2271b1);
	border-radius: var(--fancy-consent-button-radius, var(--fancy-consent-radius, 4px));
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
}

/* Accept is filled; Reject and Save are outlined at the same size, so neither
   choice is the easier one to make. */
.fancy-consent-button--accept {
	background: var(--fancy-consent-accent, #2271b1);
	color: var(--fancy-consent-accent-color, #fff);
}

.fancy-consent-button:hover {
	filter: brightness(0.9);
}

.fancy-consent-link {
	padding: 8px 4px;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.fancy-consent-button:focus-visible,
.fancy-consent-link:focus-visible,
.fancy-consent-close:focus-visible {
	outline: 2px solid var(--fancy-consent-focus, var(--fancy-consent-accent, #2271b1));
	outline-offset: 2px;
}

/* ==========================================================================
   Dialog
   ========================================================================== */

/* The <dialog> carries no padding — the panel inside it does — so a click on
   the dialog element itself is always the backdrop, which closes it. */
.fancy-consent-dialog {
	width: min(var(--fancy-consent-dialog-width, 560px), calc(100% - 40px));
	max-width: none;
	max-height: calc(100vh - 40px);
	padding: 0;
	border: var(--fancy-consent-dialog-border, 1px solid var(--fancy-consent-border, #dcdcde));
	border-radius: var(--fancy-consent-dialog-radius, var(--fancy-consent-radius, 4px));
	background: var(--fancy-consent-dialog-bg, var(--fancy-consent-bg, #fff));
	box-shadow: var(--fancy-consent-dialog-shadow, var(--fancy-consent-shadow, 0 4px 16px rgb(0 0 0 / 12%)));
	color: var(--fancy-consent-dialog-color, var(--fancy-consent-color, #1e1e1e));
	font: 14px/1.5 var(--fancy-consent-font, inherit);
}

.fancy-consent-dialog::backdrop {
	background: var(--fancy-consent-backdrop, rgb(0 0 0 / 50%));
}

.fancy-consent-panel {
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding: var(--fancy-consent-dialog-padding, 24px);
}

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

.fancy-consent-heading {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.fancy-consent-title {
	margin: 0;
	font-family: var(--fancy-consent-heading-font, inherit);
	font-size: 20px;
	font-weight: 600;
	line-height: 1.2;
}

.fancy-consent-intro {
	margin: 0;
}

.fancy-consent-close {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: var(--fancy-consent-button-radius, var(--fancy-consent-radius, 4px));
	background: none;
	color: inherit;
	cursor: pointer;
}

.fancy-consent-close::before {
	content: "\00d7";
	font-size: 24px;
	line-height: 1;
}

/* ==========================================================================
   Categories
   ========================================================================== */

.fancy-consent-categories {
	margin: 0;
	padding: 0;
	list-style: none;
}

.fancy-consent-category {
	border-top: 1px solid var(--fancy-consent-dialog-rule, var(--fancy-consent-border, #dcdcde));
}

.fancy-consent-toggle {
	position: relative;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding-block: 14px;
	cursor: pointer;
}

.fancy-consent-toggle:has(.fancy-consent-input:disabled) {
	cursor: default;
}

.fancy-consent-details {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.fancy-consent-label {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	font-weight: 600;
}

.fancy-consent-badge {
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--fancy-consent-badge-bg, #f0f0f1);
	color: var(--fancy-consent-badge-color, inherit);
	font-size: 11px;
	font-weight: 600;
}

.fancy-consent-description {
	font-size: 13px;
	color: var(--fancy-consent-dialog-muted, inherit);
	opacity: var(--fancy-consent-description-opacity, 0.8);
}

/* The real checkbox stays focusable and in the accessibility tree; the switch
   beside it is drawn from its state. */
.fancy-consent-toggle .fancy-consent-input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
}

.fancy-consent-switch {
	position: relative;
	flex: 0 0 auto;
	width: 40px;
	height: 24px;
	border-radius: 999px;
	background: var(--fancy-consent-switch-off, #c3c4c7);
	transition: background 0.2s ease;
}

.fancy-consent-switch::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--fancy-consent-knob, #fff);
	box-shadow: 0 1px 2px rgb(0 0 0 / 20%);
	transition: transform 0.2s ease, background 0.2s ease;
}

.fancy-consent-input:checked + .fancy-consent-switch {
	background: var(--fancy-consent-switch-on, var(--fancy-consent-accent, #2271b1));
}

.fancy-consent-input:checked + .fancy-consent-switch::after {
	background: var(--fancy-consent-knob-on, var(--fancy-consent-knob, #fff));
	transform: translateX(16px);
}

.fancy-consent-input:disabled + .fancy-consent-switch {
	opacity: 0.55;
}

.fancy-consent-input:focus-visible + .fancy-consent-switch {
	outline: 2px solid var(--fancy-consent-focus, var(--fancy-consent-accent, #2271b1));
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

	.fancy-consent-switch,
	.fancy-consent-switch::after {
		transition: none;
	}
}
