/*
 * WM Cookies: layout only. Colours, borders and type come from the theme; the :where()
 * selectors keep this file's specificity at zero so any theme rule wins. The background and
 * text colours below are the browser's own (Canvas, CanvasText), so the banner stays readable
 * until the theme styles it.
 */

/* Banner: fixed at the bottom, never covering more than half the screen, clear of the
   phone's rounded corners and home bar. */
:where(.wmcookies-banner) {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 99990;
	box-sizing: border-box;
	max-height: 50vh;
	max-height: 50dvh;
	overflow-y: auto;
	padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	background-color: Canvas;
	color: CanvasText;
}

:where(.wmcookies-banner-inner) {
	display: grid;
	gap: 16px;
	max-width: 1200px;
	margin: 0 auto;
}

@media (min-width: 1280px) {
	:where(.wmcookies-banner-inner) {
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		gap: 32px;
	}
}

:where(.wmcookies-title) {
	margin: 0 0 4px;
	font-size: 1.125em;
}

:where(.wmcookies-text, .wmcookies-panel-text) {
	margin: 0;
}

/* The same size for every choice: side by side when they fit, else one per line. */
:where(.wmcookies-buttons) {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 10em), 1fr));
	gap: 8px 12px;
}

@media (min-width: 1280px) {
	:where(.wmcookies-banner .wmcookies-buttons) {
		grid-template-columns: none;
		grid-auto-columns: 1fr;
		grid-auto-flow: column;
	}
}

:where(.wmcookies-button) {
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	font: inherit;
	cursor: pointer;
}

/* Room at the end of the page while the banner is shown (its height is set by the script). */
:where(.wmcookies-spacer) {
	display: block;
}

/* Cookie settings: a dialog over a dimmed page. */
:where(.wmcookies-panel) {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	background-color: rgb(0 0 0 / 0.5);
}

:where(.wmcookies-panel):focus {
	outline: none;
}

:where(.wmcookies-panel-box) {
	box-sizing: border-box;
	width: 100%;
	max-width: 640px;
	max-height: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 24px;
	background-color: Canvas;
	color: CanvasText;
}

:where(.wmcookies-panel-open) {
	overflow: hidden;
}

:where(.wmcookies-panel-header) {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 12px;
}

:where(.wmcookies-panel-title) {
	margin: 0;
}

:where(.wmcookies-close) {
	flex: none;
	min-width: 44px;
	min-height: 44px;
	margin: -10px -10px 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 1.75em;
	line-height: 1;
	cursor: pointer;
}

/* One block per category: title and switch on one line, the description and the cookies
   under them. */
:where(.wmcookies-category) {
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid;
	border-top-color: color-mix(in srgb, currentColor 20%, transparent);
}

:where(.wmcookies-category-header) {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

:where(.wmcookies-category-title) {
	margin: 0;
	font-size: 1em;
}

:where(.wmcookies-category-title label) {
	cursor: pointer;
}

:where(.wmcookies-category-description) {
	margin: 6px 0 0;
}

:where(.wmcookies-switch) {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 10px;
}

/* A switch drawn in the text colour: the knob is on the right when the category is on. */
:where(.wmcookies-switch-input) {
	box-sizing: border-box;
	width: 2.75em;
	height: 1.5em;
	margin: 0;
	border: 2px solid currentColor;
	border-radius: 999px;
	background: radial-gradient(circle, currentColor 0.4em, transparent calc(0.4em + 1px)) no-repeat left 0.05em center / 1.25em 1.25em;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
}

:where(.wmcookies-switch-input:checked) {
	background-position: right 0.05em center;
}

:where(.wmcookies-switch-input:disabled) {
	opacity: 0.6;
	cursor: default;
}

:where(.wmcookies-details) {
	margin-top: 8px;
}

:where(.wmcookies-details summary) {
	cursor: pointer;
}

:where(.wmcookies-cookies) {
	margin: 8px 0 0;
	padding: 0;
	list-style: none;
}

:where(.wmcookies-cookie) {
	padding: 8px 0;
}

:where(.wmcookies-cookie-name) {
	display: block;
	font-weight: bold;
	overflow-wrap: anywhere;
}

:where(.wmcookies-cookie-info) {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 2px 12px;
	margin: 4px 0 0;
	font-size: 0.875em;
}

:where(.wmcookies-cookie-info dd) {
	margin: 0;
}

:where(.wmcookies-panel-buttons) {
	margin-top: 24px;
}

:where(.wmcookies-consent-id) {
	margin: 16px 0 0;
	font-size: 0.875em;
	overflow-wrap: anywhere;
}

/* "Manage cookies": reads like a link until the theme styles it. */
:where(.wmcookies-manage) {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

/* Cookie table of the cookie policy page: scrolls sideways on narrow screens. */
:where(.wmcookies-table-wrap) {
	overflow-x: auto;
}

:where(.wmcookies-table) {
	width: 100%;
	border-collapse: collapse;
}

:where(.wmcookies-table th, .wmcookies-table td) {
	padding: 8px 12px 8px 0;
	text-align: start;
	vertical-align: top;
}

:where(.wmcookies-table-name) {
	overflow-wrap: anywhere;
}

/* Placeholder of a video, a map or another embed that waits for its category: the service,
   what "Show" does, "Show" and "Cookie settings". It takes the width and proportions of the
   frame (set by the script) and grows when its text needs more room. */
:where(.wmcookies-placeholder) {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 24px 16px;
	border: 1px solid;
	border-color: color-mix(in srgb, currentColor 25%, transparent);
	background-color: color-mix(in srgb, currentColor 6%, transparent);
	text-align: center;
}

/* Over the area of a frame laid over other content: scrolls when the text does not fit. */
:where(.wmcookies-placeholder--cover) {
	position: absolute;
	inset: 0;
	z-index: 1;
	justify-content: safe center;
	width: auto;
	overflow: auto;
}

/* Above an embed's own text (a quote, a link), which stays. */
:where(.wmcookies-placeholder--embed) {
	margin-bottom: 12px;
}

:where(.wmcookies-placeholder-name) {
	margin: 0;
	font-weight: bold;
}

:where(.wmcookies-placeholder-text, .wmcookies-placeholder-note) {
	max-width: 36em;
	margin: 0;
}

:where(.wmcookies-placeholder-note) {
	font-size: 0.875em;
}

:where(.wmcookies-placeholder-buttons) {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 12px;
	margin-top: 8px;
}

:where(.wmcookies-placeholder .wmcookies-button) {
	width: auto;
}

/* Announcements for screen readers ("Your cookie choices have been saved."). */
.wmcookies-status {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.wmcookies-banner[hidden],
.wmcookies-spacer[hidden],
.wmcookies-panel[hidden],
.wmcookies-panel [hidden],
.wmcookies-held {
	display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
	:where(.wmcookies-banner) {
		animation: wmcookies-in 0.3s ease-out;
	}

	:where(.wmcookies-switch-input) {
		transition: background-position 0.15s;
	}
}

@keyframes wmcookies-in {
	from {
		transform: translateY(100%);
	}
}
