/*
 * WCIT Surveys — front-end styles.
 *
 * SCOPING RULE: every selector starts with .wcit-survey. Never style html, body, or bare elements.
 * tests/bin/check-css-scope.php enforces this.
 */

.wcit-survey {
	--wcs-accent: #FF6600;        /* WCIT orange: focus ring, selected-state border (non-text accents) */
	--wcs-accent-dark: #CC5200;   /* checked radio/checkbox fill (non-text, 4.4:1 against white) */
	--wcs-accent-light: #FF8533;  /* submit button hover / active (navy text on it: 6.5:1) */
	--wcs-accent-tint: #FFF1E6;   /* selected-choice fill */
	--wcs-secondary: #23828C;     /* WCIT teal: section headings, links */
	--wcs-secondary-dark: #196370;
	--wcs-ink: #1A2335;           /* WCIT navy: question text */
	--wcs-text: #1A1A18;
	--wcs-muted: #6B6A64;         /* help text: 5.4:1 on white */
	--wcs-border: #D5D3CC;
	--wcs-control-border: #767570; /* input outlines: 4.6:1 on white, meets 3:1 for UI components */
	--wcs-surface: #FFFFFF;
	--wcs-error: #B42318;

	box-sizing: border-box;
	max-width: 720px;
	margin: 0 0 1.5em;
	padding: 0;
	color: var(--wcs-text);
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.5;
	text-align: left;
}

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

.wcit-survey p {
	margin: 0 0 0.75em;
	padding: 0;
}

.wcit-survey a {
	color: var(--wcs-secondary-dark);
	text-decoration: underline;
}

.wcit-survey a:hover {
	color: var(--wcs-ink);
}

/* ---------- Headings and intro ---------- */

.wcit-survey .wcit-survey__title {
	margin: 0 0 0.5em;
	padding: 0;
	color: var(--wcs-ink);
	font-family: inherit;
	font-size: 1.75em;
	font-weight: 700;
	line-height: 1.25;
}

.wcit-survey .wcit-survey__intro {
	margin: 0 0 1.25em;
}

.wcit-survey .wcit-survey__note {
	margin: 0 0 1.25em;
	color: var(--wcs-muted);
	font-size: 0.9375em;
}

.wcit-survey .wcit-survey__section {
	margin: 2em 0 0;
	padding: 1.25em 0 0;
	border-top: 3px solid var(--wcs-secondary);
}

.wcit-survey .wcit-survey__section-title {
	margin: 0 0 0.5em;
	padding: 0;
	color: var(--wcs-secondary-dark);
	font-family: inherit;
	font-size: 1.3em;
	font-weight: 700;
	line-height: 1.3;
}

.wcit-survey .wcit-survey__section-body {
	color: var(--wcs-text);
}

/* ---------- Questions ---------- */

.wcit-survey .wcit-survey__q {
	display: block;
	min-width: 0;
	margin: 0;
	padding: 1.25em 0;
	border: 0;
	border-bottom: 1px solid var(--wcs-border);
	border-radius: 0;
	background: transparent;
	box-shadow: none;
}

.wcit-survey .wcit-survey__identity .wcit-survey__q:first-child {
	padding-top: 0.25em;
}

.wcit-survey .wcit-survey__q--invalid {
	padding-left: 1em;
	border-left: 4px solid var(--wcs-error);
}

.wcit-survey .wcit-survey__label {
	display: block;
	float: none;
	width: auto;
	max-width: 100%;
	margin: 0 0 0.5em;
	padding: 0;
	border: 0;
	color: var(--wcs-ink);
	font-family: inherit;
	font-size: 1.0625em;
	font-weight: 600;
	line-height: 1.4;
	white-space: normal;
}

.wcit-survey .wcit-survey__req {
	color: var(--wcs-muted);
	font-size: 0.875em;
	font-weight: 400;
	white-space: nowrap;
}

.wcit-survey .wcit-survey__help {
	margin: -0.25em 0 0.625em;
	color: var(--wcs-muted);
	font-size: 0.9375em;
}

.wcit-survey .wcit-survey__error {
	margin: 0 0 0.625em;
	color: var(--wcs-error);
	font-weight: 700;
}

.wcit-survey .wcit-survey__error::before {
	content: "! ";
}

.wcit-survey .wcit-survey__error[hidden] {
	display: none;
}

/* ---------- Text inputs, selects, textareas ---------- */

.wcit-survey .wcit-survey__input,
.wcit-survey .wcit-survey__select,
.wcit-survey .wcit-survey__textarea {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	min-height: 44px;
	margin: 0;
	padding: 0.5em 0.75em;
	border: 2px solid var(--wcs-control-border);
	border-radius: 4px;
	background: var(--wcs-surface);
	box-shadow: none;
	color: var(--wcs-text);
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.5;
	-webkit-appearance: none;
	appearance: none;
}

.wcit-survey .wcit-survey__textarea {
	min-height: 8em;
	resize: vertical;
}

.wcit-survey .wcit-survey__input--number {
	max-width: 14em;
}

.wcit-survey .wcit-survey__select {
	padding-right: 2.5em;
	background-image: linear-gradient(45deg, transparent 50%, var(--wcs-ink) 50%), linear-gradient(135deg, var(--wcs-ink) 50%, transparent 50%);
	background-position: calc(100% - 1.15em) 55%, calc(100% - 0.8em) 55%;
	background-size: 0.35em 0.35em, 0.35em 0.35em;
	background-repeat: no-repeat;
}

.wcit-survey .wcit-survey__input::placeholder,
.wcit-survey .wcit-survey__textarea::placeholder {
	color: var(--wcs-muted);
	opacity: 1;
}

.wcit-survey .wcit-survey__q--invalid .wcit-survey__input,
.wcit-survey .wcit-survey__q--invalid .wcit-survey__select,
.wcit-survey .wcit-survey__q--invalid .wcit-survey__textarea {
	border-color: var(--wcs-error);
}

/* ---------- Radio buttons and checkboxes ---------- */

.wcit-survey .wcit-survey__choices {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}

.wcit-survey .wcit-survey__choice {
	display: flex;
	align-items: center;
	gap: 0.75em;
	min-height: 44px;
	margin: 0;
	padding: 0.5em 0.75em;
	border: 1px solid var(--wcs-border);
	border-radius: 4px;
	background: var(--wcs-surface);
	color: var(--wcs-text);
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.4;
	cursor: pointer;
}

.wcit-survey .wcit-survey__choice:hover {
	border-color: var(--wcs-control-border);
}

.wcit-survey .wcit-survey__choice:has(.wcit-survey__control:checked) {
	border-color: var(--wcs-accent);
	background: var(--wcs-accent-tint);
}

.wcit-survey .wcit-survey__control {
	position: relative;
	flex: 0 0 auto;
	width: 1.375em;
	height: 1.375em;
	margin: 0;
	padding: 0;
	border: 2px solid var(--wcs-control-border);
	border-radius: 4px;
	background: var(--wcs-surface);
	box-shadow: none;
	cursor: pointer;
	vertical-align: middle;
	-webkit-appearance: none;
	appearance: none;
}

.wcit-survey .wcit-survey__control[type="radio"] {
	border-radius: 50%;
}

.wcit-survey .wcit-survey__control:checked {
	border-color: var(--wcs-accent-dark);
	background: var(--wcs-accent-dark);
}

/* Radio: white inner dot on a filled circle. */
.wcit-survey .wcit-survey__control[type="radio"]:checked::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0.5em;
	height: 0.5em;
	border-radius: 50%;
	background: var(--wcs-surface);
	transform: translate(-50%, -50%);
}

/* Checkbox: white tick on a filled square. */
.wcit-survey .wcit-survey__control[type="checkbox"]:checked::after {
	content: "";
	position: absolute;
	top: 45%;
	left: 50%;
	width: 0.35em;
	height: 0.7em;
	border: solid var(--wcs-surface);
	border-width: 0 0.15em 0.15em 0;
	transform: translate(-50%, -50%) rotate(45deg);
}

.wcit-survey .wcit-survey__choice-text {
	flex: 1 1 auto;
	min-width: 0;
}

.wcit-survey .wcit-survey__control:checked + .wcit-survey__choice-text {
	font-weight: 600;
}

.wcit-survey .wcit-survey__other {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}

.wcit-survey .wcit-survey__other-text {
	margin-left: 2.875em;
	width: calc(100% - 2.875em);
}

/* ---------- Rating scale ---------- */

.wcit-survey .wcit-survey__scale {
	display: grid;
	grid-template-columns: repeat(var(--wcs-points, 5), minmax(0, 1fr));
	gap: 0.5em;
}

.wcit-survey .wcit-survey__point {
	display: block;
	position: relative;
	margin: 0;
	padding: 0;
	cursor: pointer;
}

/* The native radio is visually hidden but remains focusable and operable. */
.wcit-survey .wcit-survey__point-input {
	position: absolute;
	top: 0;
	left: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	border: 0;
	opacity: 0;
	-webkit-appearance: none;
	appearance: none;
}

.wcit-survey .wcit-survey__point-box {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 0.25em;
	height: 100%;
	min-width: 44px;
	min-height: 44px;
	padding: 0.5em 0.25em;
	border: 2px solid var(--wcs-border);
	border-radius: 6px;
	background: var(--wcs-surface);
	color: var(--wcs-text);
	text-align: center;
}

.wcit-survey .wcit-survey__point:hover .wcit-survey__point-box {
	border-color: var(--wcs-control-border);
}

.wcit-survey .wcit-survey__point-num {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2em;
	height: 2em;
	border: 2px solid var(--wcs-control-border);
	border-radius: 50%;
	color: var(--wcs-ink);
	font-weight: 700;
	line-height: 1;
}

.wcit-survey .wcit-survey__point-label {
	font-size: 0.875em;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.wcit-survey .wcit-survey__point-input:checked + .wcit-survey__point-box {
	border-color: var(--wcs-accent);
	background: var(--wcs-accent-tint);
	box-shadow: inset 0 0 0 1px var(--wcs-accent);
}

.wcit-survey .wcit-survey__point-input:checked + .wcit-survey__point-box .wcit-survey__point-num {
	border-color: var(--wcs-accent-dark);
	background: var(--wcs-accent-dark);
	color: var(--wcs-surface);
}

.wcit-survey .wcit-survey__point-input:checked + .wcit-survey__point-box .wcit-survey__point-label {
	font-weight: 700;
}

.wcit-survey .wcit-survey__na {
	margin-top: 0.5em;
}

/* ---------- Focus ---------- */

.wcit-survey .wcit-survey__input:focus,
.wcit-survey .wcit-survey__select:focus,
.wcit-survey .wcit-survey__textarea:focus,
.wcit-survey .wcit-survey__control:focus,
.wcit-survey .wcit-survey__submit:focus {
	outline: 2px solid var(--wcs-accent);
	outline-offset: 2px;
	box-shadow: none;
}

.wcit-survey .wcit-survey__input:focus:not(:focus-visible),
.wcit-survey .wcit-survey__control:focus:not(:focus-visible),
.wcit-survey .wcit-survey__submit:focus:not(:focus-visible) {
	outline: none;
}

.wcit-survey .wcit-survey__input:focus-visible,
.wcit-survey .wcit-survey__select:focus-visible,
.wcit-survey .wcit-survey__textarea:focus-visible,
.wcit-survey .wcit-survey__control:focus-visible,
.wcit-survey .wcit-survey__submit:focus-visible {
	outline: 2px solid var(--wcs-accent);
	outline-offset: 2px;
}

.wcit-survey .wcit-survey__point-input:focus + .wcit-survey__point-box {
	outline: 2px solid var(--wcs-accent);
	outline-offset: 2px;
}

.wcit-survey .wcit-survey__point-input:focus:not(:focus-visible) + .wcit-survey__point-box {
	outline: none;
}

.wcit-survey .wcit-survey__summary:focus,
.wcit-survey .wcit-survey__thanks:focus,
.wcit-survey .wcit-survey__closed:focus {
	outline: 2px solid var(--wcs-accent);
	outline-offset: 4px;
}

/* ---------- Error summary ---------- */

.wcit-survey .wcit-survey__summary {
	margin: 0 0 1.5em;
	padding: 1em 1.25em;
	border: 3px solid var(--wcs-error);
	border-radius: 4px;
	background: var(--wcs-surface);
}

.wcit-survey .wcit-survey__summary[hidden] {
	display: none;
}

.wcit-survey .wcit-survey__summary-title {
	margin: 0 0 0.5em;
	padding: 0;
	color: var(--wcs-error);
	font-family: inherit;
	font-size: 1.125em;
	font-weight: 700;
	line-height: 1.3;
}

.wcit-survey .wcit-survey__summary-list {
	margin: 0;
	padding: 0 0 0 1.25em;
	list-style: disc;
}

.wcit-survey .wcit-survey__summary-list li {
	margin: 0 0 0.25em;
	padding: 0;
	color: var(--wcs-error);
}

.wcit-survey .wcit-survey__summary-list a {
	color: var(--wcs-error);
	font-weight: 700;
	text-decoration: underline;
}

/* ---------- Submit ---------- */

.wcit-survey .wcit-survey__actions {
	margin: 1.5em 0 0;
}

.wcit-survey .wcit-survey__submit {
	display: inline-block;
	min-height: 48px;
	margin: 0;
	padding: 0.75em 1.75em;
	border: 2px solid var(--wcs-accent);
	border-radius: 4px;
	/* Navy text on WCIT orange is 5.3:1. White on orange fails WCAG AA, so it is not used. */
	background: var(--wcs-accent);
	box-shadow: none;
	color: var(--wcs-ink);
	font-family: inherit;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
}

.wcit-survey .wcit-survey__submit:hover,
.wcit-survey .wcit-survey__submit:active {
	border-color: var(--wcs-ink);
	background: var(--wcs-accent-light);
	color: var(--wcs-ink);
}

.wcit-survey .wcit-survey__submit::after,
.wcit-survey .wcit-survey__submit::before {
	content: none;
	display: none;
}

.wcit-survey .wcit-survey__submit[disabled] {
	cursor: progress;
	opacity: 0.75;
}

/* ---------- Thank-you / closed / notices ---------- */

.wcit-survey .wcit-survey__thanks,
.wcit-survey .wcit-survey__closed {
	padding: 1.25em 1.5em;
	border-left: 4px solid var(--wcs-secondary);
	background: var(--wcs-surface);
	color: var(--wcs-ink);
	font-size: 1.0625em;
}

.wcit-survey .wcit-survey__thanks p:last-child,
.wcit-survey .wcit-survey__closed p:last-child,
.wcit-survey .wcit-survey__intro p:last-child,
.wcit-survey .wcit-survey__section-body p:last-child {
	margin-bottom: 0;
}

.wcit-survey .wcit-survey__reveal {
	animation: wcs-reveal 0.3s ease-out;
}

@keyframes wcs-reveal {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.wcit-survey .wcit-survey__draft-note,
.wcit-survey.wcit-survey--notice {
	padding: 0.5em 0.75em;
	border: 1px dashed var(--wcs-muted, #6B6A64);
	color: var(--wcs-muted, #6B6A64);
	font-size: 0.875em;
}

/* ---------- Utilities ---------- */

.wcit-survey .wcit-survey__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

/* Honeypot: off-screen rather than display:none, which some bots detect. */
.wcit-survey .wcit-survey__hp {
	position: absolute;
	left: -10000px;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Small screens: stack the rating scale with labels beside the radio ---------- */

@media (max-width: 599px) {
	.wcit-survey .wcit-survey__scale {
		grid-template-columns: 1fr;
	}

	.wcit-survey .wcit-survey__point-box {
		flex-direction: row;
		justify-content: flex-start;
		gap: 0.75em;
		padding: 0.375em 0.75em;
		text-align: left;
	}

	.wcit-survey .wcit-survey__point-label {
		font-size: 1em;
	}

	.wcit-survey .wcit-survey__title {
		font-size: 1.5em;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wcit-survey .wcit-survey__reveal {
		animation: none;
	}
}

@media (forced-colors: active) {
	.wcit-survey .wcit-survey__point-input:checked + .wcit-survey__point-box {
		border-width: 4px;
		border-color: Highlight;
	}

	.wcit-survey .wcit-survey__control:checked {
		background: Highlight;
	}
}
