/**
 * Cybercoop - Questionario HR
 * Frontend styles.
 *
 * Everything is scoped under .cq-wrap so the plugin never leaks into the
 * theme. Typography is inherited on purpose: the form should look like it
 * belongs to cybercoop.it, not like a third party widget.
 */

.cq-wrap {
	--cq-accent: #0b5fff;
	--cq-ink: #16202c;
	--cq-muted: #5d6b7a;
	--cq-line: #d8dfe7;
	--cq-surface: #ffffff;
	--cq-soft: #f5f7fa;
	--cq-error: #b3261e;
	--cq-radius: 10px;

	box-sizing: border-box;
	color: var(--cq-ink);
	font-family: inherit;
	font-size: 1rem;
	line-height: 1.55;
	max-width: 780px;
	margin: 0 auto;
}

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

/* Visually hidden but readable by screen readers. */
.cq-wrap .cq-sr,
.cq-wrap .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.cq-wrap .cq-hp {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------------------------------------------------------------- Header */

.cq-wrap .cq-title {
	font-size: 1.5rem;
	line-height: 1.25;
	margin: 0 0 0.5em;
}

.cq-wrap .cq-intro {
	color: var(--cq-muted);
	margin: 0 0 1.75em;
	max-width: 65ch;
}

/* -------------------------------------------------------------- Progress */

.cq-wrap .cq-progress {
	margin: 0 0 1.75em;
}

.cq-wrap .cq-progress__bar {
	background: var(--cq-line);
	border-radius: 99px;
	height: 6px;
	overflow: hidden;
}

.cq-wrap .cq-progress__fill {
	background: var(--cq-accent);
	border-radius: 99px;
	display: block;
	height: 100%;
	transition: width 0.25s ease;
}

.cq-wrap .cq-progress__label {
	color: var(--cq-muted);
	font-size: 0.875rem;
	margin: 0.5em 0 0;
}

/* ----------------------------------------------------------------- Steps */

.cq-wrap .cq-step {
	border: 0;
	margin: 0 0 2em;
	padding: 0;
}

.cq-wrap.cq-is-wizard .cq-step {
	display: none;
}

.cq-wrap.cq-is-wizard .cq-step.cq-step--active {
	display: block;
}

.cq-wrap .cq-step__header {
	border-bottom: 2px solid var(--cq-accent);
	margin: 0 0 1.5em;
	padding: 0 0 0.75em;
}

.cq-wrap .cq-step__title {
	font-size: 1.2rem;
	line-height: 1.3;
	margin: 0;
}

.cq-wrap .cq-step__desc {
	color: var(--cq-muted);
	font-size: 0.9375rem;
	margin: 0.4em 0 0;
}

/* ---------------------------------------------------------------- Fields */

.cq-wrap .cq-field {
	margin: 0 0 1.75em;
}

.cq-wrap .cq-field[hidden] {
	display: none;
}

.cq-wrap .cq-fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

.cq-wrap .cq-label,
.cq-wrap legend.cq-label {
	display: block;
	float: none;
	font-weight: 600;
	margin: 0 0 0.6em;
	padding: 0;
	width: 100%;
}

.cq-wrap .cq-req {
	color: var(--cq-error);
	font-weight: 700;
}

.cq-wrap .cq-help {
	color: var(--cq-muted);
	font-size: 0.875rem;
	margin: -0.3em 0 0.8em;
}

/* Instruction derived from the question's own rules (max 3 answers, etc). */
.cq-wrap .cq-hint {
	color: var(--cq-muted);
	font-size: 0.875rem;
	font-style: italic;
	margin: -0.3em 0 0.8em;
}

.cq-wrap .cq-counter {
	color: var(--cq-muted);
	font-size: 0.8125rem;
	margin: 0.6em 0 0;
}

.cq-wrap .cq-counter--full {
	color: var(--cq-ink);
	font-weight: 600;
}

/* Options: the whole row is the target, not just the little circle. */

.cq-wrap .cq-options {
	display: grid;
	gap: 0.5em;
}

.cq-wrap .cq-option {
	position: relative;
}

.cq-wrap .cq-option input {
	position: absolute;
	left: 0.9em;
	top: 50%;
	transform: translateY(-50%);
	margin: 0;
	width: 1.15em;
	height: 1.15em;
	accent-color: var(--cq-accent);
}

.cq-wrap .cq-option label {
	background: var(--cq-surface);
	border: 1px solid var(--cq-line);
	border-radius: var(--cq-radius);
	cursor: pointer;
	display: block;
	font-weight: 400;
	line-height: 1.4;
	margin: 0;
	padding: 0.75em 1em 0.75em 3em;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cq-wrap .cq-option label:hover {
	border-color: var(--cq-accent);
	background: var(--cq-soft);
}

.cq-wrap .cq-option input:checked + label {
	border-color: var(--cq-accent);
	box-shadow: inset 0 0 0 1px var(--cq-accent);
	background: var(--cq-soft);
	font-weight: 600;
}

.cq-wrap .cq-option input:focus-visible + label,
.cq-wrap .cq-option input:focus + label {
	outline: 3px solid var(--cq-accent);
	outline-offset: 2px;
}

/* Locked once the answer limit is reached: dimmed, but still readable. */
.cq-wrap .cq-option label.cq-option--locked {
	background: var(--cq-soft);
	color: var(--cq-muted);
	cursor: not-allowed;
	opacity: 0.65;
}

.cq-wrap .cq-option label.cq-option--locked:hover {
	border-color: var(--cq-line);
	background: var(--cq-soft);
}

/* Answers that exclude all the others sit slightly apart. */
.cq-wrap .cq-option--exclusive {
	margin-top: 0.35em;
}

.cq-wrap .cq-option--exclusive label {
	border-style: dashed;
}

.cq-wrap .cq-other {
	margin-top: 0.6em;
}

.cq-wrap .cq-other[hidden] {
	display: none;
}

/* ------------------------------------------------------------ 1-5 scale */

.cq-wrap .cq-scale {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75em;
}

.cq-wrap .cq-scale__label {
	color: var(--cq-muted);
	font-size: 0.875rem;
	flex: 0 0 auto;
}

.cq-wrap .cq-scale__items {
	display: flex;
	flex: 1 1 auto;
	gap: 0.4em;
	min-width: 220px;
}

.cq-wrap .cq-scale__item {
	flex: 1 1 0;
	position: relative;
}

.cq-wrap .cq-scale__item input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.cq-wrap .cq-scale__item label {
	align-items: center;
	background: var(--cq-surface);
	border: 1px solid var(--cq-line);
	border-radius: var(--cq-radius);
	cursor: pointer;
	display: flex;
	font-weight: 600;
	justify-content: center;
	margin: 0;
	min-height: 3rem;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cq-wrap .cq-scale__item label:hover {
	border-color: var(--cq-accent);
}

.cq-wrap .cq-scale__item input:checked + label {
	background: var(--cq-accent);
	border-color: var(--cq-accent);
	color: #fff;
}

.cq-wrap .cq-scale__item input:focus-visible + label,
.cq-wrap .cq-scale__item input:focus + label {
	outline: 3px solid var(--cq-accent);
	outline-offset: 2px;
}

/* Scale with a label on every point: a five column grid that stacks on
   narrow screens, so the wording stays readable instead of being squeezed. */

.cq-wrap .cq-scale--labelled {
	display: block;
}

.cq-wrap .cq-scale--labelled .cq-scale__items {
	display: grid;
	gap: 0.5em;
	grid-template-columns: repeat(5, 1fr);
	min-width: 0;
}

.cq-wrap .cq-scale--labelled .cq-scale__item label {
	align-items: center;
	flex-direction: column;
	gap: 0.35em;
	justify-content: flex-start;
	min-height: 0;
	padding: 0.85em 0.6em;
	text-align: center;
}

.cq-wrap .cq-scale--labelled .cq-scale__num {
	align-items: center;
	background: var(--cq-soft);
	border-radius: 50%;
	display: inline-flex;
	font-size: 0.9375rem;
	height: 2rem;
	justify-content: center;
	width: 2rem;
}

.cq-wrap .cq-scale--labelled .cq-scale__text {
	font-size: 0.8125rem;
	font-weight: 400;
	line-height: 1.3;
}

.cq-wrap .cq-scale--labelled input:checked + label .cq-scale__num {
	background: #fff;
	color: var(--cq-accent);
}

@media (max-width: 640px) {
	.cq-wrap .cq-scale--labelled .cq-scale__items {
		grid-template-columns: 1fr;
	}

	.cq-wrap .cq-scale--labelled .cq-scale__item label {
		flex-direction: row;
		gap: 0.75em;
		justify-content: flex-start;
		text-align: left;
	}

	.cq-wrap .cq-scale--labelled .cq-scale__num {
		flex: 0 0 auto;
	}
}

/* ----------------------------------------------------------- Text inputs */

.cq-wrap .cq-input {
	background: var(--cq-surface);
	border: 1px solid var(--cq-line);
	border-radius: var(--cq-radius);
	color: var(--cq-ink);
	display: block;
	font: inherit;
	line-height: 1.5;
	padding: 0.7em 0.9em;
	width: 100%;
	max-width: 100%;
}

.cq-wrap .cq-input:focus {
	border-color: var(--cq-accent);
	outline: 3px solid var(--cq-accent);
	outline-offset: 1px;
}

.cq-wrap .cq-textarea {
	min-height: 7em;
	resize: vertical;
}

/* -------------------------------------------------------------- Consent */

.cq-wrap .cq-consent {
	align-items: flex-start;
	display: flex;
	gap: 0.7em;
}

.cq-wrap .cq-consent input {
	flex: 0 0 auto;
	margin: 0.25em 0 0;
	width: 1.2em;
	height: 1.2em;
	accent-color: var(--cq-accent);
}

.cq-wrap .cq-consent label {
	font-weight: 400;
	line-height: 1.5;
	margin: 0;
}

/* --------------------------------------------------------------- Errors */

.cq-wrap .cq-error {
	color: var(--cq-error);
	font-size: 0.875rem;
	font-weight: 600;
	margin: 0.5em 0 0;
}

.cq-wrap .cq-error[hidden] {
	display: none;
}

.cq-wrap .cq-field--error .cq-option label,
.cq-wrap .cq-field--error .cq-input {
	border-color: var(--cq-error);
}

.cq-wrap .cq-field--error {
	border-left: 3px solid var(--cq-error);
	padding-left: 1em;
}

.cq-wrap .cq-alert {
	border-radius: var(--cq-radius);
	margin: 0 0 1.5em;
	padding: 0.9em 1.1em;
}

.cq-wrap .cq-alert[hidden] {
	display: none;
}

.cq-wrap .cq-alert--error {
	background: #fdecea;
	border: 1px solid #f0b4ae;
	color: var(--cq-error);
	font-weight: 600;
}

/* ----------------------------------------------------------- Navigation */

.cq-wrap .cq-note {
	background: var(--cq-soft);
	border-left: 3px solid var(--cq-line);
	color: var(--cq-muted);
	font-size: 0.875rem;
	margin: 1.5em 0 0;
	padding: 0.75em 1em;
}

.cq-wrap .cq-nav {
	align-items: center;
	border-top: 1px solid var(--cq-line);
	display: flex;
	flex-wrap: wrap;
	gap: 0.75em;
	margin-top: 2em;
	padding-top: 1.5em;
}

.cq-wrap .cq-btn {
	border: 1px solid transparent;
	border-radius: var(--cq-radius);
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	min-height: 3rem;
	padding: 0.8em 1.6em;
	transition: opacity 0.15s ease;
}

.cq-wrap .cq-btn[hidden] {
	display: none;
}

.cq-wrap .cq-btn:focus-visible,
.cq-wrap .cq-btn:focus {
	outline: 3px solid var(--cq-accent);
	outline-offset: 2px;
}

.cq-wrap .cq-btn--primary {
	background: var(--cq-accent);
	color: #fff;
	margin-left: auto;
}

.cq-wrap .cq-btn--primary:hover {
	opacity: 0.88;
}

.cq-wrap .cq-btn--ghost {
	background: transparent;
	border-color: var(--cq-line);
	color: var(--cq-ink);
}

.cq-wrap .cq-btn--ghost:hover {
	border-color: var(--cq-accent);
}

.cq-wrap .cq-btn[disabled] {
	cursor: progress;
	opacity: 0.6;
}

/* -------------------------------------------------------------- Success */

.cq-wrap .cq-success {
	background: var(--cq-soft);
	border: 1px solid var(--cq-line);
	border-left: 4px solid var(--cq-accent);
	border-radius: var(--cq-radius);
	padding: 2em 1.75em;
	text-align: center;
}

.cq-wrap .cq-success[hidden] {
	display: none;
}

.cq-wrap .cq-success__icon {
	background: var(--cq-accent);
	border-radius: 50%;
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	height: 3rem;
	width: 3rem;
	margin-bottom: 0.6em;
}

.cq-wrap .cq-success p {
	font-size: 1.0625rem;
	margin: 0;
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 600px) {
	.cq-wrap .cq-scale {
		align-items: stretch;
		flex-direction: column;
		gap: 0.4em;
	}

	.cq-wrap .cq-scale__items {
		min-width: 0;
	}

	.cq-wrap .cq-nav {
		flex-direction: column-reverse;
		align-items: stretch;
	}

	.cq-wrap .cq-btn {
		margin-left: 0;
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cq-wrap * {
		transition: none !important;
		animation: none !important;
	}
}

/* High contrast / forced colors: never rely on colour alone. */
@media (forced-colors: active) {
	.cq-wrap .cq-option input:checked + label,
	.cq-wrap .cq-scale__item input:checked + label {
		border: 3px solid;
	}
}
