/*
 * Decision runtime styles.
 *
 * The default look follows Tablio, which is the Codivra UI reference
 * (codivra/brand/DESIGN-SYSTEM.md): Inter, quiet paper surfaces, strong
 * headings with tight tracking, 1px controls, separation before elevation,
 * and one button system — filled ink for the action the page is asking for,
 * outlined for the alternative. Colour is minimal and never the only thing
 * carrying a meaning.
 *
 * Every value hangs off an --osd-* custom property, so a host theme restyles
 * the form by redefining those rather than by out-specifying these rules.
 * A form design (inc/design.php) layers per-block rules on top of this.
 *
 * Three themes, set by data-theme on the root: the default card, `light`
 * (no card — the form sits directly on the page) and `auto` (the default,
 * inverted under prefers-color-scheme: dark).
 */

.osd {
	--osd-paper: #f7f7f4;
	--osd-paper-deep: #eeeeea;
	--osd-surface: #fff;
	--osd-ink: #151518;
	--osd-muted: #606066;
	--osd-line: #dcdcd7;
	--osd-field-line: #cfcfca;
	--osd-accent: #3157e8;
	--osd-accent-hover: #2447c7;
	--osd-soft: #dfe5ff;

	/* 14px is the Codivra radius for a large container; controls take 1px. */
	--osd-radius: 14px;
	--osd-radius-sm: 1px;
	--osd-shadow: 0 10px 28px rgb(0 27 68 / 0.045);
	--osd-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	--osd-font: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;

	position: relative;
	container-type: inline-size;
	max-width: 640px;
	margin-inline: auto;
	font-family: var(--osd-font);
	font-size: 16px;
	line-height: 1.5;
	color: var(--osd-ink);
	text-align: initial;
	-webkit-font-smoothing: antialiased;
}

/* No card: the form sits on whatever the page already is. */
.osd[data-theme="light"] {
	--osd-surface: transparent;
	--osd-shadow: none;
	--osd-radius: 0;
}

.osd[data-theme="light"] .osd-card {
	border-color: transparent;
	padding-inline: 0;
}

@media (prefers-color-scheme: dark) {
	.osd[data-theme="auto"] {
		--osd-paper: #111217;
		--osd-paper-deep: #1a1b21;
		--osd-surface: #16171d;
		--osd-ink: #f2f2f4;
		--osd-muted: #9b9ba4;
		--osd-line: #2c2d35;
		--osd-field-line: #3a3b45;
		--osd-accent: #7d96ff;
		--osd-accent-hover: #9aadff;
		--osd-soft: #232640;
		--osd-shadow: 0 10px 28px rgb(0 0 0 / 0.4);
	}
}

/* The standalone page: the runtime owns the whole viewport band. */
.osd-page {
	padding: clamp(2rem, 6vw, 4rem) var(--gutter, 1.25rem) clamp(3rem, 8vw, 5rem);
	background: var(--osd-paper);
}

.osd * {
	box-sizing: border-box;
}

.osd .osd-shell {
	position: relative;
	z-index: 1;
}

/* ------------------------------------------------------------------- shell */

.osd .osd-eyebrow {
	display: flex;
	align-items: center;
	gap: 9px;
	margin: 0 0 10px;
	color: var(--osd-accent-hover);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.osd .osd-mark {
	width: 10px;
	height: 10px;
	flex: 0 0 10px;
	border: 2px solid currentcolor;
	border-radius: 50%;
}

/* These are h2/h3: a theme rule naming the tag beats an inherited family,
   so each heading states the form's font rather than assuming it. */
.osd .osd-headline {
	margin: 0 0 28px;
	color: var(--osd-ink);
	font-family: inherit;
	font-size: clamp(1.75rem, 3.6vw, 2.5rem);
	font-weight: 800;
	line-height: 1.08;
	letter-spacing: -0.032em;
	text-wrap: balance;
}

.osd .osd-progress {
	height: 3px;
	margin-bottom: 14px;
	border-radius: 999px;
	background: var(--osd-line);
	overflow: hidden;
}

.osd .osd-progress-fill {
	width: 0;
	height: 100%;
	border-radius: 999px;
	background: var(--osd-accent);
	transition: width 300ms var(--osd-ease);
}

.osd .osd-trail {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	min-height: 28px;
	margin-bottom: 20px;
}

.osd .osd-chip {
	padding: 5px 10px;
	border: 1px solid var(--osd-field-line);
	border-radius: var(--osd-radius-sm);
	background: var(--osd-surface);
	color: var(--osd-muted);
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition:
		border-color 150ms var(--osd-ease),
		color 150ms var(--osd-ease);

	&:hover {
		border-color: var(--osd-ink);
		color: var(--osd-ink);
	}

	/* Quiet: a breadcrumb should not out-shout the question it belongs to. */
	&.is-current {
		border-color: transparent;
		background: var(--osd-paper-deep);
		color: var(--osd-ink);
		cursor: default;
	}

	&.is-current:hover {
		border-color: transparent;
		color: var(--osd-ink);
	}
}

/* ------------------------------------------------------------------- card */

.osd .osd-card {
	padding: clamp(1.5rem, 4vw, 2rem);
	border: 1px solid var(--osd-line);
	border-radius: var(--osd-radius);
	background: var(--osd-surface);
	box-shadow: var(--osd-shadow);
	animation: osd-rise 260ms var(--osd-ease) both;
}

/* Inactive cards stay in the HTML for indexing; only the current one is shown. */
.osd .osd-card[hidden] {
	display: none !important;
}

@keyframes osd-rise {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.osd .osd-step {
	margin: 0 0 10px;
	color: var(--osd-muted);
	font-size: 11px;
	font-weight: 650;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.osd .osd-question {
	margin: 0 0 20px;
	color: var(--osd-ink);
	font-family: inherit;
	font-size: clamp(1.25rem, 2.4vw, 1.5rem);
	font-weight: 650;
	line-height: 1.3;
	letter-spacing: -0.012em;
	text-wrap: balance;

	&:focus-visible {
		outline: 2px solid var(--osd-accent);
		outline-offset: 3px;
	}
}

.osd .osd-help {
	margin: -12px 0 20px;
	color: var(--osd-muted);
	font-size: 14px;
	line-height: 1.55;
}

.osd .osd-answers {
	display: grid;
	gap: 8px;

	&.is-grid {
		grid-template-columns: 1fr 1fr;
	}

	&.is-list {
		grid-template-columns: 1fr;
	}
}

@container (max-width: 460px) {
	.osd-answers.is-grid {
		grid-template-columns: 1fr;
	}
}

/*
 * Every answer is a peer, so they are all the same plain outlined control.
 *
 * The tone still rides along as .is-yes / .is-no, but nothing here paints
 * it: a coloured edge in the base stylesheet is one more thing a design has
 * to fight, and the answers already say which is which in words.
 */
.osd .osd-answer {
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: 13px 15px;
	border: 1px solid var(--osd-field-line);
	border-radius: var(--osd-radius-sm);
	background: var(--osd-surface);
	color: var(--osd-ink);
	font: inherit;
	font-size: 15px;
	font-weight: 650;
	text-align: left;
	cursor: pointer;
	transition: ease all .3s;

	&:active:not(:disabled) {
		transform: none;
	}

	&:focus-visible {
		outline: 2px solid var(--osd-accent);
		outline-offset: 3px;
	}

	/* A dangling answer: the graph has nowhere to send it yet. */
	&:disabled {
		color: var(--osd-muted);
		cursor: not-allowed;
	}
}

.osd .osd-answer-note {
	color: var(--osd-muted);
	font-size: 13px;
	font-weight: 400;
}

/* ----------------------------------------------------------------- footer */

.osd .osd-footer {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	min-height: 20px;
	margin-top: 16px;
}

/* A link is a link: no frame, no fill, no lift. */
.osd .osd-back {
	padding: 0;
	border: none;
	background: none;
	color: var(--osd-accent);
	font: inherit;
	font-size: 14px;
	font-weight: 650;
	cursor: pointer;
	transition: ease all .3s;

	&:hover {
		color: var(--osd-accent-hover);
	}
}

.osd .osd-restart {
	margin-left: auto;
	padding: 0 14px;
	height: 36px;
	border: 1px solid var(--osd-field-line);
	border-radius: var(--osd-radius-sm);
	background: var(--osd-surface);
	color: var(--osd-ink);
	font: inherit;
	font-size: 13px;
	font-weight: 650;
	cursor: pointer;
	transition: ease all .3s;

	&:hover {
		border-color: var(--osd-ink);
		transform: translateY(-1px);
	}
}

/* ----------------------------------------------------------------- result */

.osd .osd-card.is-result {
	animation: osd-rise 300ms var(--osd-ease) both;
}

.osd .osd-badge {
	display: inline-flex;
	margin-bottom: 14px;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--osd-soft);
	color: var(--osd-accent-hover);
	font-size: 12px;
	font-weight: 600;
}

.osd .osd-result-image {
	display: block;
	width: 100%;
	max-width: 320px;
	height: auto;
	margin: 0 0 18px;
	border: 1px solid var(--osd-line);
	border-radius: var(--osd-radius-sm);
}

.osd .osd-result-name {
	margin: 0 0 8px;
	color: var(--osd-ink);
	font-family: inherit;
	font-size: clamp(1.5rem, 3vw, 2rem);
	font-weight: 700;
	line-height: 1.12;
	letter-spacing: -0.025em;
	text-wrap: balance;

	&:focus-visible {
		outline: 2px solid var(--osd-accent);
		outline-offset: 3px;
	}
}

.osd .osd-result-summary {
	max-width: 46ch;
	margin: 0 0 18px;
	color: var(--osd-muted);
	font-size: 16px;
	line-height: 1.5;
}

.osd .osd-result-body {
	max-width: 60ch;
	margin: 0 0 20px;
	font-size: 15px;
	line-height: 1.6;

	& a {
		color: var(--osd-accent);
	}

	& p:last-child {
		margin-bottom: 0;
	}
}

/* The action the card is asking for, so it is the filled one. */
.osd .osd-cta {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 20px;
	border: 1px solid var(--osd-ink);
	border-radius: var(--osd-radius-sm);
	background: var(--osd-ink);
	color: #fff;
	font-size: 14px;
	font-weight: 650;
	text-decoration: none;
	transition:
		background-color 180ms var(--osd-ease),
		border-color 180ms var(--osd-ease),
		transform 180ms var(--osd-ease);

	&:hover {
		border-color: var(--osd-accent);
		background: var(--osd-accent);
		color: #fff;
		transform: translateY(-1px);
	}

	&:focus-visible {
		outline: 2px solid var(--osd-accent);
		outline-offset: 3px;
	}
}

/* ------------------------------------------------------- design additions */

/* Free blocks a design can drop in anywhere. */
.osd .osd-b-heading {
	margin: 0 0 10px;
	color: var(--osd-ink);
	font-family: inherit;
	font-weight: 700;
	letter-spacing: -0.015em;
	line-height: 1.25;
}

.osd .osd-b-text {
	margin: 0 0 14px;
	color: var(--osd-muted);
	font-size: 15px;
	line-height: 1.55;
}

.osd .osd-b-divider {
	height: 0;
	margin: 18px 0;
	border: 0;
	border-top: 1px solid var(--osd-line);
}

.osd .osd-b-picture {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: var(--osd-radius-sm);
}

.osd .osd-noscript,
.osd .osd-placeholder {
	margin-top: 14px;
	padding: 10px 12px;
	border: 1px dashed var(--osd-field-line);
	border-radius: var(--osd-radius-sm);
	color: var(--osd-muted);
	font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
	.osd-card {
		animation: none;
	}

	.osd-progress-fill {
		transition: none;
	}

	.osd-answer:hover:not(:disabled),
	.osd-restart:hover,
	.osd-cta:hover {
		transform: none;
	}
}
