/*
 * Choice Option for Bricks. Self-contained: only .cob classes, no shared stylesheet.
 * Colours, radius and spacing are CSS variables, so they are easy to override.
 *
 * Appearance (class on the card root, set by the Tick box look setting):
 *   .cob--styled   our own tick box / option button
 *   .cob--browser  the browser's own input
 *   .cob--pure     the Pure Form skin draws the box; browser input if the skin is off
 *   .cob--auto     Pure Form when the skin is active (data-cob-skin="pure", set by choice-option-form.js), else styled
 */
.cob {
	--cob-accent: #1d1d1f;
	--cob-border: #d2d2d7;
	--cob-bg: #fff;
	--cob-selected-bg: #fff;
	--cob-heading-bg: #f5f5f7;
	--cob-heading-ink: #1d1d1f;
	--cob-ink: #1d1d1f;
	--cob-muted: #6e6e73;
	--cob-radius: 24px;
	--cob-pad: 1.5rem;
	position: relative;
	display: block;
	width: 100%;
	box-sizing: border-box;
}
.cob *,
.cob *::before,
.cob *::after {
	box-sizing: border-box;
}

/* The real input stays in the page for forms, keyboards and screen readers. */
.cob__input {
	position: absolute;
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

.cob__card {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	color: var(--cob-ink);
	background: var(--cob-bg);
	border: 1px solid var(--cob-border);
	border-radius: var(--cob-radius);
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.cob:not(.cob--disabled) .cob__card:not(:has(.cob__input:checked)):hover {
	border-color: #86868b;
}
.cob__card:has(.cob__input:checked) {
	background: var(--cob-selected-bg);
	border-color: var(--cob-accent);
	box-shadow: 0 0 0 1px var(--cob-accent);
}
.cob__card:has(.cob__input:focus-visible) {
	outline: 2px solid var(--cob-accent);
	outline-offset: 3px;
}
.cob--disabled .cob__card {
	opacity: 0.55;
	cursor: not-allowed;
}

/* Heading strip */
.cob__heading {
	padding: 0.75rem var(--cob-pad);
	font-weight: 600;
	font-size: 0.9375em;
	line-height: 1.3;
	text-align: center;
	color: var(--cob-heading-ink);
	background: var(--cob-heading-bg);
}

/* Body */
.cob__body {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: var(--cob-pad);
}
.cob__main {
	flex: 1 1 auto;
	min-width: 0;
}
.cob__row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}
.cob__label {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0;
	color: var(--cob-ink);
	font-weight: 600;
	font-size: 1.125em;
	line-height: 1.3;
	cursor: pointer;
}
.cob--disabled .cob__label {
	cursor: not-allowed;
}

/* Styled tick box / option button */
.cob__indicator {
	display: grid;
	flex: none;
	place-items: center;
	width: 1.5rem;
	height: 1.5rem;
	color: #fff;
	background: var(--cob-bg);
	border: 2px solid var(--cob-border);
	border-radius: 50%;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}
.cob--checkbox .cob__indicator {
	border-radius: 6px;
}
.cob__indicator svg {
	opacity: 0;
	transition: opacity 0.12s ease;
}
.cob__card:has(.cob__input:checked) .cob__indicator {
	background: var(--cob-accent);
	border-color: var(--cob-accent);
}
.cob__card:has(.cob__input:checked) .cob__indicator svg {
	opacity: 1;
}

/*
 * Styled: the Pure Form skin must not add a second box. Its selectors are very specific, so these few
 * rules need !important to win when a styled option sits inside a form wrapper.
 */
.cob--styled .cob__label::before,
.cob--styled .cob__label::after {
	content: none !important;
	display: none !important;
}
.cob--styled .cob__label {
	padding: 0 !important;
}

/* Pure Form: our own box steps aside and the skin draws its box on the label. */
:is(.cob--pure:not([data-cob-skin="none"]), .cob--auto[data-cob-skin="pure"]) .cob__label {
	display: block;
}

/* Browser appearance (also what Pure Form shows when the skin is off): the native input is shown. */
:is(.cob--browser, .cob--pure[data-cob-skin="none"]) .cob__input {
	position: static !important;
	flex: none;
	width: 1.125rem !important;
	height: 1.125rem !important;
	margin: 0 !important;
	overflow: visible !important;
	clip: auto !important;
	opacity: 1;
	pointer-events: auto;
	accent-color: var(--cob-accent);
}
:is(.cob--browser, .cob--pure) .cob__indicator {
	display: none;
}
.cob--auto[data-cob-skin="pure"] .cob__indicator {
	display: none;
}
.cob--browser .cob__label {
	padding: 0 !important;
}
.cob--browser .cob__label::before,
.cob--browser .cob__label::after {
	content: none !important;
	display: none !important;
}

/* Side text */
.cob__aside {
	flex: none;
	text-align: right;
	font-weight: 600;
	font-size: 1.125em;
	line-height: 1.3;
	white-space: nowrap;
}
.cob__aside :where(s, del) {
	display: block;
	font-weight: 400;
	font-size: 0.875em;
	color: var(--cob-muted);
}

/* Rich content */
.cob__content {
	margin-top: 0.75rem;
	color: var(--cob-muted);
	font-size: 0.9375em;
	line-height: 1.5;
}
.cob__content > :first-child {
	margin-top: 0;
}
.cob__content > :last-child {
	margin-bottom: 0;
}
.cob__content :where(p, ul, ol) {
	margin: 0.5em 0;
}

/* Optional ticks for bulleted lists */
.cob--ticks .cob__content ul {
	padding: 0;
	list-style: none;
}
.cob--ticks .cob__content ul li {
	position: relative;
	padding-left: 1.75rem;
	margin: 0.4em 0;
}
.cob--ticks .cob__content ul li::before {
	content: "";
	position: absolute;
	top: 0.3em;
	left: 0;
	width: 1em;
	height: 1em;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%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 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Clickable parent (on by default): an empty label is stretched over the whole card. */
.cob__hit {
	position: absolute;
	inset: 0;
	z-index: 1;
	margin: 0;
	padding: 0;
	cursor: pointer;
}
.cob--disabled .cob__hit {
	cursor: not-allowed;
}
/* Links, buttons and fields inside the content or side text stay above the stretched area. */
.cob :where(.cob__content, .cob__aside) :where(a, button, input, select, textarea, summary, label, [role="button"], [tabindex]) {
	position: relative;
	z-index: 2;
}

@media (max-width: 480px) {
	.cob__body {
		flex-wrap: wrap;
	}
	.cob__aside {
		text-align: left;
		white-space: normal;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cob__card,
	.cob__indicator,
	.cob__indicator svg {
		transition: none;
	}
}
