/*
 * The site's standard controls (plan Dokument\05 Development\ui-controls, Magnus 2026-10-28).
 * Loaded by mwlPageLayout after css_main and css_button, before the page's own CSS.
 *
 * Checkbox "B" (and the radio button further down): a 16px square with a 1px corner and a grey border. When checked the border turns green,
 * the box gets a faint green fill and a green tick shows inside. Same size in all places.
 *
 * The selector is kept at the weight of "input[type=checkbox]" (the :where part counts as nothing), so a page's
 * own rule such as ".x input" still wins. Pages that hide the checkbox (chips, toggles) keep doing so with
 * opacity:0; this file never sets opacity. A checkbox that draws itself (the switch on the Airports page)
 * carries the class mwl-own-box and is left alone.
 *
 * Colours: --border-check, --bg-check, --bg-check-on and --text-check-tick in css_main (light and dark).
 */

input[type="checkbox"]:where(:not(.mwl-own-box)) {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin: 3px 3px 3px 4px;
	padding: 0;
	display: inline-grid;
	place-content: center;
	vertical-align: middle;
	border: 1px solid var(--border-check);
	border-radius: 1px;
	background: var(--bg-check);
	cursor: pointer;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}

/* The tick: an SVG used as a mask, so its colour comes from the theme */
input[type="checkbox"]:where(:not(.mwl-own-box))::before {
	content: "";
	width: 14px;
	height: 14px;
	background: var(--text-check-tick);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.4l3 3 6.6-7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.4l3 3 6.6-7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	transform: scale(0);
	transition: transform 0.12s;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}

input[type="checkbox"]:where(:not(.mwl-own-box)):checked {
	border-color: var(--text-check-tick);
	background: var(--bg-check-on);
}
input[type="checkbox"]:where(:not(.mwl-own-box)):checked::before {
	transform: scale(1);
}

input[type="checkbox"]:where(:not(.mwl-own-box)):focus-visible {
	outline: 2px solid var(--border-brand);
	outline-offset: 2px;
}

/* Disabled: greyed with colours, not opacity (opacity would show the checkboxes that pages hide) */
input[type="checkbox"]:where(:not(.mwl-own-box)):disabled {
	border-color: var(--border-neutral-4);
	background: var(--bg-neutral-8);
	cursor: not-allowed;
}
input[type="checkbox"]:where(:not(.mwl-own-box)):disabled::before {
	background: var(--text-neutral-6);
}

/*
 * Radio button: the same box made round. When chosen the border turns green, the box gets the faint
 * green fill and a green dot shows. Same rules as the checkbox: page rules win, opacity is never set.
 */
input[type="radio"]:where(:not(.mwl-own-box)) {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin: 3px 3px 3px 4px;
	padding: 0;
	display: inline-grid;
	place-content: center;
	vertical-align: middle;
	border: 1px solid var(--border-check);
	border-radius: 50%;
	background: var(--bg-check);
	cursor: pointer;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}
input[type="radio"]:where(:not(.mwl-own-box))::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--text-check-tick);
	transform: scale(0);
	transition: transform 0.12s;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}
input[type="radio"]:where(:not(.mwl-own-box)):checked {
	border-color: var(--text-check-tick);
	background: var(--bg-check-on);
}
input[type="radio"]:where(:not(.mwl-own-box)):checked::before {
	transform: scale(1);
}
input[type="radio"]:where(:not(.mwl-own-box)):focus-visible {
	outline: 2px solid var(--border-brand);
	outline-offset: 2px;
}
input[type="radio"]:where(:not(.mwl-own-box)):disabled {
	border-color: var(--border-neutral-4);
	background: var(--bg-neutral-8);
	cursor: not-allowed;
}
input[type="radio"]:where(:not(.mwl-own-box)):disabled::before {
	background: var(--text-neutral-6);
}

@media (prefers-reduced-motion: reduce) {
	input[type="checkbox"]:where(:not(.mwl-own-box))::before,
	input[type="radio"]:where(:not(.mwl-own-box))::before { transition: none; }
}

/* Windows high contrast: the browser's own checkbox and radio, which follow the system colours */
@media (forced-colors: active) {
	input[type="checkbox"]:where(:not(.mwl-own-box)),
	input[type="radio"]:where(:not(.mwl-own-box)) { -webkit-appearance: auto; appearance: auto; }
	input[type="checkbox"]:where(:not(.mwl-own-box))::before,
	input[type="radio"]:where(:not(.mwl-own-box))::before { content: none; }
}
