/* TBT Poll — the [tbt_poll] shortcode.

   Lesson world: white page, whitespace for structure, no card. Tablet and
   desktop only; light only. Hub tokens only, no colour of its own: the
   question badge takes the lesson's domain colour, everything that
   interacts is TBT Blue. The one exception is the results "prism": each
   answer's bar colour (--c) is computed in poll.js. Design:
   docs/prototypes/poll.html, poll-0.3.0.html. */

.tbtpl {
	--tbtpl-look: var(--tbt-blue);
	--tbtpl-bar: color-mix(in srgb, var(--tbt-blue) 22%, var(--tbt-surface));
	max-width: 1080px;
	color: var(--tbt-ink);
	font: 400 16px/1.5 var(--tbt-font-ui);
}
.tbtpl[data-domain="gi"] { --tbtpl-look: var(--tbt-gi); }
.tbtpl[data-domain="pd"] { --tbtpl-look: var(--tbt-pd); }
.tbtpl[data-domain="le"] { --tbtpl-look: var(--tbt-le); }

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

.tbtpl form {
	margin: 0;
}

/* ---------- Question ---------- */

.tbtpl .tbtpl-q {
	min-width: 0;
	margin: 0 0 var(--tbt-s7);
	padding: 0;
	border: 0;
}

.tbtpl .tbtpl-head {
	display: grid;
	grid-template-columns: 32px 1fr;
	gap: 14px;
	align-items: start;
	width: 100%;
	margin: 0 0 20px;
	padding: 0;
	float: none;
	border: 0;
}

.tbtpl .tbtpl-n {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	margin-top: 1px;
	border-radius: var(--tbt-s2);
	background: var(--tbtpl-look);
	color: var(--tbt-surface);
	font: 700 16px/1 var(--tbt-font-ui);
}

.tbtpl .tbtpl-qt {
	color: var(--tbt-ink);
	font: 700 22px/1.35 var(--tbt-font-content);
}

/* Multi-choice: the title and the hint under it. */
.tbtpl .tbtpl-qc {
	display: block;
}

.tbtpl .tbtpl-qc .tbtpl-qt {
	display: block;
}

.tbtpl .tbtpl-hint {
	display: block;
	margin-top: 6px;
	color: var(--tbt-muted);
	font: 500 15px/1.4 var(--tbt-font-ui);
}

.tbtpl .tbtpl-hint .tbtpl-count {
	color: var(--tbt-blue);
	font-weight: 600;
}

/* ---------- Vote state ---------- */

.tbtpl .tbtpl-opts {
	display: grid;
	gap: 10px;
	padding-left: 46px;
}

.tbtpl .tbtpl-opt {
	position: relative;
	display: grid;
	grid-template-columns: 24px 1fr;
	gap: var(--tbt-s3);
	align-items: start;
	margin: 0;
	padding: 14px 18px;
	border: 1px solid var(--tbt-border);
	border-radius: var(--tbt-radius-control);
	color: var(--tbt-ink);
	font: 400 17px/1.5 var(--tbt-font-content);
	cursor: pointer;
	transition: background .15s, border-color .15s, opacity .15s;
}

.tbtpl .tbtpl-opt:hover,
.tbtpl .tbtpl-opt:has(input:checked) {
	border-color: var(--tbt-blue);
	background: var(--tbt-selected-bg);
}

.tbtpl .tbtpl-opt input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.tbtpl .tbtpl-opt:has(input:focus-visible) {
	box-shadow: var(--tbt-focus-ring);
}

.tbtpl .tbtpl-l {
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	margin-top: 2px;
	border: 2px solid var(--tbt-border);
	border-radius: 50%;
	color: var(--tbt-muted);
	font: 700 12px/1 var(--tbt-font-ui);
	transition: background .15s, border-color .15s, color .15s;
}

.tbtpl .tbtpl-opt:has(input:checked) .tbtpl-l {
	border-color: var(--tbt-blue);
	background: var(--tbt-blue);
	color: var(--tbt-surface);
}

/* Multi-choice answers have square markers. */
.tbtpl .tbtpl-q.is-multi .tbtpl-l {
	border-radius: 6px;
}

/* "Choose up to N" reached: the rest rest until one is unticked. */
.tbtpl .tbtpl-opt:has(input:disabled) {
	opacity: .45;
	cursor: not-allowed;
}

.tbtpl .tbtpl-opt:has(input:disabled):hover {
	border-color: var(--tbt-border);
	background: transparent;
}

.tbtpl .tbtpl-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 20px;
	padding-left: 46px;
}

.tbtpl .tbtpl-vote {
	height: 48px;
	margin: 0;
	padding: 0 var(--tbt-s6);
	border: 0;
	border-radius: var(--tbt-radius-control);
	background: var(--tbt-blue);
	box-shadow: none;
	color: var(--tbt-surface);
	font: 700 15px/1 var(--tbt-font-ui);
	letter-spacing: .04em;
	text-transform: uppercase;
	text-shadow: none;
	cursor: pointer;
	transition: background .15s, transform .15s;
}

.tbtpl .tbtpl-vote:hover:not(:disabled) {
	background: var(--tbt-blue-dark);
	transform: translateY(-1px);
}

.tbtpl .tbtpl-vote:focus-visible {
	outline: none;
	box-shadow: var(--tbt-focus-ring);
}

.tbtpl .tbtpl-vote:disabled {
	opacity: .5;
	cursor: not-allowed;
}

.tbtpl .tbtpl-left {
	color: var(--tbt-muted);
	font-size: 15px;
}

.tbtpl .tbtpl-error {
	flex-basis: 100%;
	margin: 0;
	color: var(--tbt-error);
	font-size: 15px;
}

/* ---------- Results state ---------- */

.tbtpl .tbtpl-res {
	display: grid;
	gap: 18px;
	padding-left: 46px;
}

.tbtpl .tbtpl-r {
	display: grid;
	gap: var(--tbt-s2);
}

.tbtpl .tbtpl-rl {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: var(--tbt-s4);
	align-items: baseline;
	font: 400 17px/1.5 var(--tbt-font-content);
}

.tbtpl .tbtpl-rl b {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-right: var(--tbt-s1);
	color: var(--tbt-muted);
	font-weight: 500;
}

/* The answer's prism swatch, matching its bar. */
.tbtpl .tbtpl-rl b::before {
	content: "";
	width: 10px;
	height: 10px;
	border-radius: 3px;
	background: var(--c, transparent);
}

.tbtpl .tbtpl-pct {
	min-width: 44px;
	color: var(--tbt-muted);
	font: 700 16px/1 var(--tbt-font-ui);
	font-variant-numeric: tabular-nums;
	text-align: right;
}

.tbtpl .tbtpl-track {
	height: 12px;
	overflow: hidden;
	border-radius: 6px;
	background: var(--tbt-input);
}

.tbtpl .tbtpl-fill {
	width: 0;
	height: 100%;
	border-radius: 6px;
	background: var(--c, var(--tbtpl-bar));
	transition: width .7s cubic-bezier(.2, .7, .2, 1);
}

/* "Yours" is the pill and an ink figure; the bar keeps its colour. */
.tbtpl .tbtpl-r.is-mine .tbtpl-pct {
	color: var(--tbt-ink);
}

/* Under multi-choice results: why the total passes 100%. */
.tbtpl .tbtpl-note {
	margin: 2px 0 0;
	color: var(--tbt-muted);
	font: 400 14px/1.45 var(--tbt-font-ui);
}

.tbtpl .tbtpl-mine {
	display: inline-flex;
	align-items: center;
	gap: var(--tbt-s1);
	margin-left: var(--tbt-s2);
	padding: var(--tbt-s1) 10px;
	border-radius: var(--tbt-radius-pill);
	background: var(--tbt-selected-bg);
	color: var(--tbt-blue);
	font: 600 13px/1 var(--tbt-font-ui);
	white-space: nowrap;
	vertical-align: 2px;
}

.tbtpl .tbtpl-sum {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--tbt-s4);
	margin-top: calc(-1 * var(--tbt-s4));
	padding: 20px 0 0 46px;
}

.tbtpl .tbtpl-total {
	font: 700 18px/1.3 var(--tbt-font-ui);
}

.tbtpl .tbtpl-pts {
	display: inline-flex;
	align-items: center;
	gap: var(--tbt-s2);
	padding: var(--tbt-s3) var(--tbt-s4);
	border-radius: var(--tbt-radius-control);
	background: var(--tbt-success-bg);
	color: var(--tbt-success);
	font: 600 15px/1 var(--tbt-font-ui);
}

/* Guest: secondary, sentence case. */
.tbtpl .tbtpl-login {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 48px;
	padding: 0 var(--tbt-s5);
	border: 1px solid var(--tbt-border);
	border-radius: var(--tbt-radius-control);
	background: var(--tbt-surface);
	color: var(--tbt-blue-dark);
	font: 600 15px/1 var(--tbt-font-ui);
	text-decoration: none;
	transition: background .15s;
}

.tbtpl .tbtpl-login:hover {
	background: var(--tbt-selected-bg);
	color: var(--tbt-blue-dark);
}

.tbtpl .tbtpl-login:focus-visible {
	outline: none;
	box-shadow: var(--tbt-focus-ring);
}

.tbtpl .tbtpl-muted,
.tbtpl-notice {
	color: var(--tbt-muted);
}

@media (prefers-reduced-motion: reduce) {
	.tbtpl *,
	.tbtpl .tbtpl-fill {
		transition: none !important;
	}
}
