/**
 * JG Website Manager — cookie consent banner and preferences centre.
 *
 * Colours come from custom properties set on #jgwm-cc:
 * --jgwm-cc-bg, --jgwm-cc-text, --jgwm-cc-accent, --jgwm-cc-accent-text.
 *
 * @since 1.16.0
 */

.jgwm-cc {
	--jgwm-cc-bg: #ffffff;
	--jgwm-cc-text: #1d2327;
	--jgwm-cc-accent: #1776a6;
	--jgwm-cc-accent-text: #ffffff;
	--jgwm-cc-radius: 14px;
	/* Derived shades, calculated in PHP from the three colours above. */
	--jgwm-cc-muted: #5b5f64;
	--jgwm-cc-line: #dddedf;
	--jgwm-cc-soft: #f4f4f4;
	--jgwm-cc-track: #bbbcbe;
	--jgwm-cc-accent-soft: #dcebf2;
	--jgwm-cc-accent-tint: #e8f1f6;
	--jgwm-cc-accent-hover: #14648d;
	--jgwm-cc-shadow: 0 18px 50px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.55;
	color: var(--jgwm-cc-text);
	-webkit-font-smoothing: antialiased;
}

.jgwm-cc[hidden],
.jgwm-cc [hidden] {
	display: none !important;
}

.jgwm-cc *,
.jgwm-cc *::before,
.jgwm-cc *::after {
	box-sizing: border-box;
}

/* ---------- Banner ---------- */

.jgwm-cc__banner {
	position: fixed;
	z-index: 2147483000;
	background: var(--jgwm-cc-bg);
	color: var(--jgwm-cc-text);
	box-shadow: var(--jgwm-cc-shadow);
	padding: 22px 24px;
	animation: jgwm-cc-rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.jgwm-cc__banner:focus {
	outline: none;
}

.jgwm-cc--box-left .jgwm-cc__banner,
.jgwm-cc--box-right .jgwm-cc__banner {
	bottom: 20px;
	width: min(420px, calc(100vw - 32px));
	border-radius: var(--jgwm-cc-radius);
	border: 1px solid var(--jgwm-cc-line);
}

.jgwm-cc--box-left .jgwm-cc__banner {
	left: 20px;
}

.jgwm-cc--box-right .jgwm-cc__banner {
	right: 20px;
}

.jgwm-cc--bar-bottom .jgwm-cc__banner {
	left: 0;
	right: 0;
	bottom: 0;
	border-top: 1px solid var(--jgwm-cc-line);
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas: "head actions" "text actions";
	column-gap: 32px;
	align-items: center;
	padding: 18px max(24px, calc((100vw - 1240px) / 2));
}

.jgwm-cc--bar-bottom .jgwm-cc__head {
	grid-area: head;
}

.jgwm-cc--bar-bottom .jgwm-cc__text {
	grid-area: text;
	margin-bottom: 0;
	padding-left: 52px;
}

.jgwm-cc--bar-bottom .jgwm-cc__actions {
	grid-area: actions;
	flex-direction: column;
	min-width: 210px;
}

.jgwm-cc--bar-bottom .jgwm-cc__actions .jgwm-cc__btn {
	flex: 0 0 auto;
}

.jgwm-cc--centre .jgwm-cc__banner {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: min(520px, calc(100vw - 32px));
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	border-radius: var(--jgwm-cc-radius);
	padding: 28px;
	animation: jgwm-cc-fade 0.25s ease-out;
}

.jgwm-cc__head {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 10px;
}

.jgwm-cc__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--jgwm-cc-accent-soft);
	color: var(--jgwm-cc-accent);
}

.jgwm-cc .jgwm-cc__title {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
	color: var(--jgwm-cc-text);
}

.jgwm-cc__text {
	margin-bottom: 18px;
	color: var(--jgwm-cc-muted);
	font-size: 14px;
}

.jgwm-cc__text p {
	margin: 0 0 8px;
	padding: 0;
	font-size: inherit;
	color: inherit;
}

.jgwm-cc__text p:last-child {
	margin-bottom: 0;
}

.jgwm-cc a,
.jgwm-cc a:visited {
	color: var(--jgwm-cc-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.jgwm-cc a:hover {
	text-decoration-thickness: 2px;
}

/* ---------- Buttons ---------- */

.jgwm-cc__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.jgwm-cc__actions .jgwm-cc__btn--solid {
	flex: 1 1 140px;
}

.jgwm-cc__actions .jgwm-cc__btn--text {
	flex: 1 1 100%;
}

.jgwm-cc .jgwm-cc__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin: 0;
	padding: 10px 18px;
	border: 2px solid var(--jgwm-cc-accent);
	border-radius: 999px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-transform: none;
	letter-spacing: normal;
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.jgwm-cc .jgwm-cc__btn:active {
	transform: translateY(1px);
}

.jgwm-cc .jgwm-cc__btn:focus-visible,
.jgwm-cc .jgwm-cc__close:focus-visible,
.jgwm-cc .jgwm-cc__float:focus-visible,
.jgwm-cc .jgwm-cc__switch input:focus-visible + .jgwm-cc__slider,
.jgwm-cc summary:focus-visible {
	outline: 3px solid var(--jgwm-cc-accent);
	outline-offset: 2px;
}

.jgwm-cc .jgwm-cc__btn--solid {
	background: var(--jgwm-cc-accent);
	color: var(--jgwm-cc-accent-text);
}

.jgwm-cc .jgwm-cc__btn--solid:hover {
	background: var(--jgwm-cc-accent-hover);
	border-color: var(--jgwm-cc-accent-hover);
	color: var(--jgwm-cc-accent-text);
}

.jgwm-cc .jgwm-cc__btn--outline {
	background: transparent;
	color: var(--jgwm-cc-accent);
}

.jgwm-cc .jgwm-cc__btn--outline:hover {
	background: var(--jgwm-cc-accent-tint);
	color: var(--jgwm-cc-accent);
}

.jgwm-cc .jgwm-cc__btn--text {
	min-height: 36px;
	padding: 6px 10px;
	border-color: transparent;
	background: transparent;
	color: var(--jgwm-cc-text);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.jgwm-cc .jgwm-cc__btn--text:hover {
	background: var(--jgwm-cc-soft);
	color: var(--jgwm-cc-text);
}

/* ---------- Overlay ---------- */

.jgwm-cc__overlay {
	position: fixed;
	inset: 0;
	z-index: 2147482999;
	background: rgba(15, 18, 22, 0.55);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	animation: jgwm-cc-fade 0.2s ease-out;
}

/* ---------- Preferences centre ---------- */

.jgwm-cc__prefs {
	position: fixed;
	z-index: 2147483001;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	width: min(640px, calc(100vw - 24px));
	max-height: min(760px, calc(100vh - 24px));
	background: var(--jgwm-cc-bg);
	color: var(--jgwm-cc-text);
	border-radius: var(--jgwm-cc-radius);
	box-shadow: var(--jgwm-cc-shadow);
	overflow: hidden;
	animation: jgwm-cc-fade 0.2s ease-out;
}

.jgwm-cc__prefs:focus {
	outline: none;
}

.jgwm-cc__prefs-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 20px 24px;
	border-bottom: 1px solid var(--jgwm-cc-line);
}

.jgwm-cc .jgwm-cc__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--jgwm-cc-text);
	cursor: pointer;
}

.jgwm-cc .jgwm-cc__close:hover {
	background: var(--jgwm-cc-soft);
}

.jgwm-cc__prefs-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 24px 8px;
}

.jgwm-cc__intro {
	margin: 0 0 16px;
	color: var(--jgwm-cc-muted);
	font-size: 14px;
}

.jgwm-cc__notice {
	margin: 0 0 16px;
	padding: 10px 14px;
	border-radius: 10px;
	background: var(--jgwm-cc-accent-tint);
	font-size: 13px;
}

.jgwm-cc__cat {
	margin: 0 0 12px;
	padding: 16px 18px;
	border: 1px solid var(--jgwm-cc-line);
	border-radius: 12px;
	background: var(--jgwm-cc-soft);
}

.jgwm-cc__cat-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.jgwm-cc .jgwm-cc__cat-title {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	text-transform: none;
	letter-spacing: normal;
	color: var(--jgwm-cc-text);
}

.jgwm-cc__cat-desc {
	margin: 6px 0 0;
	color: var(--jgwm-cc-muted);
	font-size: 14px;
}

.jgwm-cc__always {
	flex: 0 0 auto;
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--jgwm-cc-accent-soft);
	color: var(--jgwm-cc-text);
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
}

/* Switch */
.jgwm-cc__switch {
	position: relative;
	flex: 0 0 auto;
	display: inline-block;
	width: 50px;
	height: 28px;
	margin: 0;
	cursor: pointer;
}

.jgwm-cc .jgwm-cc__switch input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
	z-index: 1;
}

.jgwm-cc__slider {
	position: absolute;
	inset: 0;
	border-radius: 999px;
	background: var(--jgwm-cc-track);
	transition: background-color 0.2s ease;
}

.jgwm-cc__slider::before {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s ease;
}

.jgwm-cc__switch input:checked + .jgwm-cc__slider {
	background: var(--jgwm-cc-accent);
}

.jgwm-cc__switch input:checked + .jgwm-cc__slider::before {
	transform: translateX(22px);
}

/* Cookie table */
.jgwm-cc__details {
	margin-top: 10px;
}

.jgwm-cc__details summary {
	display: inline-block;
	cursor: pointer;
	color: var(--jgwm-cc-accent);
	font-size: 13px;
	font-weight: 600;
	list-style: none;
	border-radius: 4px;
}

.jgwm-cc__details summary::-webkit-details-marker {
	display: none;
}

.jgwm-cc__details summary::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	margin: 0 8px 2px 2px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(-45deg);
	transition: transform 0.15s ease;
}

.jgwm-cc__details[open] summary::before {
	transform: rotate(45deg);
}

.jgwm-cc__table-wrap {
	margin-top: 10px;
	overflow-x: auto;
}

.jgwm-cc .jgwm-cc__table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	border: 0;
	font-size: 12.5px;
	background: var(--jgwm-cc-bg);
}

.jgwm-cc .jgwm-cc__table th,
.jgwm-cc .jgwm-cc__table td {
	padding: 7px 9px;
	border: 0;
	border-bottom: 1px solid var(--jgwm-cc-line);
	text-align: left;
	vertical-align: top;
	color: var(--jgwm-cc-text);
}

.jgwm-cc .jgwm-cc__table th {
	font-weight: 700;
	white-space: nowrap;
}

.jgwm-cc .jgwm-cc__table code {
	padding: 0;
	background: none;
	font-size: 12px;
	word-break: break-all;
}

.jgwm-cc__more {
	margin: 8px 0 12px;
	font-size: 14px;
}

.jgwm-cc__prefs-foot {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 16px 24px;
	border-top: 1px solid var(--jgwm-cc-line);
	background: var(--jgwm-cc-bg);
}

.jgwm-cc__prefs-foot .jgwm-cc__btn {
	flex: 1 1 150px;
}

/* ---------- Floating settings button ---------- */

.jgwm-cc .jgwm-cc__float {
	position: fixed;
	z-index: 2147482998;
	bottom: 18px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--jgwm-cc-line);
	border-radius: 50%;
	background: var(--jgwm-cc-bg);
	color: var(--jgwm-cc-accent);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
	cursor: pointer;
	opacity: 0.9;
	transition: transform 0.15s ease, opacity 0.15s ease;
	animation: jgwm-cc-fade 0.3s ease-out;
}

.jgwm-cc .jgwm-cc__float:hover {
	opacity: 1;
	transform: scale(1.06);
}

.jgwm-cc--side-left .jgwm-cc__float {
	left: 18px;
}

.jgwm-cc--side-right .jgwm-cc__float {
	right: 18px;
}

/* Shortcode button and cookie list */
.jgwm-cc-link-button {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.jgwm-cc-list__table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.5em;
}

.jgwm-cc-list__table th,
.jgwm-cc-list__table td {
	padding: 8px 10px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	text-align: left;
	vertical-align: top;
}

/* ---------- Small screens ---------- */

@media (max-width: 782px) {
	.jgwm-cc--bar-bottom .jgwm-cc__banner {
		display: block;
		padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
	}

	.jgwm-cc--bar-bottom .jgwm-cc__text {
		padding-left: 0;
		margin-bottom: 16px;
	}

	.jgwm-cc--bar-bottom .jgwm-cc__actions {
		flex-direction: row;
		min-width: 0;
	}

	.jgwm-cc--bar-bottom .jgwm-cc__actions .jgwm-cc__btn--solid {
		flex: 1 1 140px;
	}
}

@media (max-width: 520px) {
	.jgwm-cc--box-left .jgwm-cc__banner,
	.jgwm-cc--box-right .jgwm-cc__banner {
		left: 8px;
		right: 8px;
		bottom: 8px;
		width: auto;
		padding: 18px;
	}

	.jgwm-cc__banner {
		max-height: calc(100vh - 16px);
		overflow-y: auto;
	}

	.jgwm-cc__prefs {
		top: auto;
		bottom: 0;
		left: 0;
		transform: none;
		width: 100%;
		max-height: 92vh;
		border-radius: var(--jgwm-cc-radius) var(--jgwm-cc-radius) 0 0;
		animation: jgwm-cc-rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
	}

	.jgwm-cc__prefs-head,
	.jgwm-cc__prefs-body,
	.jgwm-cc__prefs-foot {
		padding-left: 18px;
		padding-right: 18px;
	}

	.jgwm-cc__prefs-foot {
		padding-bottom: calc(16px + env(safe-area-inset-bottom));
	}

	.jgwm-cc__actions .jgwm-cc__btn--solid,
	.jgwm-cc__prefs-foot .jgwm-cc__btn {
		flex-basis: 100%;
	}
}

/* ---------- Motion ---------- */

@keyframes jgwm-cc-rise {
	from {
		opacity: 0;
		translate: 0 24px;
	}
	to {
		opacity: 1;
		translate: 0 0;
	}
}

@keyframes jgwm-cc-fade {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jgwm-cc *,
	.jgwm-cc *::before,
	.jgwm-cc *::after {
		animation: none !important;
		transition: none !important;
	}
}

@media print {
	.jgwm-cc {
		display: none !important;
	}
}

/* Stop the page scrolling behind an open modal. */
html.jgwm-cc-locked,
html.jgwm-cc-locked body {
	overflow: hidden;
}
