/**
 * FON Survey Agent — front end.
 *
 * Palette matches fon_mail_palette() in the branded-mail mu-plugin, so a survey
 * page and the receipt it sends look like the same organisation.
 *
 * Everything is scoped under .fon-sv. The theme owns the page; this owns the
 * survey and nothing else.
 */

.fon-sv {
	--fon-sv-navy: #0a1530;
	--fon-sv-navy-2: #16224a;
	--fon-sv-gold: #c9a961;
	--fon-sv-gold-d: #b08d3f;
	--fon-sv-ivory: #f4efe6;
	--fon-sv-paper: #fff;
	--fon-sv-ink: #0c1430;
	--fon-sv-ink-2: #2b3554;
	--fon-sv-muted: #6b7493;
	--fon-sv-rule: #e3ddd0;

	margin: 2rem 0;
	color: var(--fon-sv-ink);
}

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

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

.fon-sv-form {
	background: var(--fon-sv-paper);
	border: 1px solid var(--fon-sv-rule);
	border-top: 3px solid var(--fon-sv-gold);
	border-radius: 2px;
	padding: 1.75rem;
}

@media (max-width: 600px) {
	.fon-sv-form {
		padding: 1.25rem;
	}
}

.fon-sv-intro {
	margin-bottom: 1.5rem;
	padding-bottom: 1.25rem;
	border-bottom: 1px solid var(--fon-sv-rule);
	color: var(--fon-sv-ink-2);
}

.fon-sv-questions {
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: fon-sv-q;
}

.fon-sv-q {
	margin: 0 0 1.75rem;
	padding: 0;
	list-style: none;
}

.fon-sv-q-email {
	margin-top: 2rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--fon-sv-rule);
}

.fon-sv-label,
.fon-sv legend.fon-sv-label {
	display: block;
	font-weight: 600;
	font-size: 1.02rem;
	line-height: 1.45;
	margin-bottom: .35rem;
	padding: 0;
	color: var(--fon-sv-ink);
}

/* The counter goes on the legend/label rather than the list item, so the
   number sits with the question text and wraps with it. */
.fon-sv-questions > .fon-sv-q .fon-sv-label::before {
	counter-increment: fon-sv-q;
	content: counter(fon-sv-q) ". ";
	color: var(--fon-sv-gold-d);
	font-weight: 700;
}

.fon-sv-req {
	color: var(--fon-sv-gold-d);
}

.fon-sv-help,
.fon-sv-hint {
	margin: 0 0 .6rem;
	font-size: .88rem;
	line-height: 1.5;
	color: var(--fon-sv-muted);
}

.fon-sv-group {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0; /* Firefox gives fieldsets a min-width that breaks flex children. */
}

/* --- choice lists --- */

.fon-sv-options {
	list-style: none;
	margin: 0;
	padding: 0;
}

.fon-sv-options li {
	margin: 0 0 .3rem;
	padding: 0;
	list-style: none;
}

.fon-sv-options label {
	display: flex;
	align-items: flex-start;
	gap: .6rem;
	padding: .55rem .7rem;
	border: 1px solid var(--fon-sv-rule);
	border-radius: 2px;
	cursor: pointer;
	line-height: 1.45;
	background: var(--fon-sv-paper);
	transition: border-color .12s ease, background-color .12s ease;
}

.fon-sv-options label:hover {
	border-color: var(--fon-sv-gold);
	background: #fdfbf7;
}

.fon-sv-options input {
	margin: .2rem 0 0;
	flex: 0 0 auto;
	accent-color: var(--fon-sv-navy);
}

/* Focus has to be visible on the box, not just the hidden-ish native control. */
.fon-sv-options label:focus-within {
	outline: 2px solid var(--fon-sv-navy);
	outline-offset: 1px;
}

/* --- scale --- */

.fon-sv-scale {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
}

.fon-sv-scale-item {
	flex: 1 1 2.75rem;
	min-width: 2.75rem;
	text-align: center;
	border: 1px solid var(--fon-sv-rule);
	border-radius: 2px;
	padding: .55rem .25rem;
	cursor: pointer;
	background: var(--fon-sv-paper);
	transition: border-color .12s ease, background-color .12s ease;
}

.fon-sv-scale-item:hover {
	border-color: var(--fon-sv-gold);
}

.fon-sv-scale-item:focus-within {
	outline: 2px solid var(--fon-sv-navy);
	outline-offset: 1px;
}

/* The radio itself is hidden, so :checked has to change something obvious —
   and it changes background AND border AND weight, never colour alone. */
.fon-sv-scale-item input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.fon-sv-scale-num {
	display: block;
	font-weight: 600;
	font-size: 1rem;
	line-height: 1.2;
	padding: .1rem 0;
	border-radius: 2px;
}

/* Adjacent-sibling, not :has(). The radio is visually hidden, so if the
   checked state failed to render the control would be unusable — and :has()
   is unsupported in Firefox before 121. This selector works everywhere. */
.fon-sv-scale-item input:checked + .fon-sv-scale-num {
	background: var(--fon-sv-navy);
	color: #fff;
	box-shadow: 0 0 0 .35rem var(--fon-sv-navy);
}

/* Enhancement where supported: the whole tile picks up the selected state. */
.fon-sv-scale-item:has(input:checked) {
	background: var(--fon-sv-navy);
	border-color: var(--fon-sv-navy);
}

.fon-sv-scale-item:has(input:checked) .fon-sv-scale-num {
	box-shadow: none;
}

.fon-sv-scale-ends {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin: .4rem 0 0;
	font-size: .8rem;
	color: var(--fon-sv-muted);
}

/* --- text inputs --- */

.fon-sv input[type="text"],
.fon-sv input[type="email"],
.fon-sv textarea {
	width: 100%;
	padding: .6rem .7rem;
	border: 1px solid var(--fon-sv-rule);
	border-radius: 2px;
	font: inherit;
	font-size: 1rem;
	color: var(--fon-sv-ink);
	background: var(--fon-sv-paper);
}

.fon-sv input[type="text"]:focus,
.fon-sv input[type="email"]:focus,
.fon-sv textarea:focus {
	outline: 2px solid var(--fon-sv-navy);
	outline-offset: 1px;
	border-color: var(--fon-sv-navy);
}

.fon-sv textarea {
	resize: vertical;
	min-height: 6rem;
}

/* --- honeypot ---
   Off-canvas rather than display:none. Some bots skip fields that are
   display:none, and the point is that they fill it in. */
.fon-sv-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

/* --- buttons --- */

.fon-sv-submit {
	margin-top: 1.75rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--fon-sv-rule);
}

.fon-sv-button {
	display: inline-block;
	background: var(--fon-sv-navy);
	color: #fff;
	border: 1px solid var(--fon-sv-navy);
	border-radius: 2px;
	padding: .8rem 1.8rem;
	font: inherit;
	font-size: .95rem;
	font-weight: 600;
	letter-spacing: .02em;
	cursor: pointer;
	text-decoration: none;
	transition: background-color .12s ease;
}

.fon-sv-button:hover,
.fon-sv-button:focus {
	background: var(--fon-sv-navy-2);
	color: #fff;
}

.fon-sv-button:focus-visible {
	outline: 2px solid var(--fon-sv-gold-d);
	outline-offset: 2px;
}

.fon-sv-button[disabled],
.fon-sv-button.is-busy {
	opacity: .6;
	cursor: progress;
}

.fon-sv-button-quiet {
	background: transparent;
	color: var(--fon-sv-navy);
	border-color: var(--fon-sv-rule);
}

.fon-sv-button-quiet:hover,
.fon-sv-button-quiet:focus {
	background: var(--fon-sv-ivory);
	color: var(--fon-sv-navy);
	border-color: var(--fon-sv-gold);
}

.fon-sv-legal {
	margin: 1rem 0 0;
	font-size: .78rem;
	color: var(--fon-sv-muted);
}

.fon-sv-legal a {
	color: var(--fon-sv-muted);
}

/* --- messages --- */

.fon-sv-errors {
	margin: 0 0 1.5rem;
	padding: 1rem 1.1rem;
	background: #fdf3f3;
	border-left: 4px solid #b32d2e;
	color: #7a1f20;
}

.fon-sv-errors p {
	margin: 0 0 .4rem;
}

.fon-sv-errors ul {
	margin: 0;
	padding-left: 1.2rem;
}

.fon-sv-note,
.fon-sv-thanks {
	background: var(--fon-sv-ivory);
	border-left: 4px solid var(--fon-sv-gold);
	padding: 1.5rem 1.75rem;
}

.fon-sv-note-locked {
	border-left-color: var(--fon-sv-navy);
}

.fon-sv-thanks p:first-child {
	margin-top: 0;
}

.fon-sv-thanks p:last-child {
	margin-bottom: 0;
}

/* --- results --- */

.fon-sv-results-head {
	padding-bottom: 1rem;
	margin-bottom: 1.5rem;
	border-bottom: 2px solid var(--fon-sv-gold);
}

.fon-sv-bignum {
	margin: 0;
	font-size: 2.4rem;
	line-height: 1.1;
	font-weight: 700;
	color: var(--fon-sv-navy);
}

.fon-sv-bignum span {
	font-size: .95rem;
	font-weight: 400;
	color: var(--fon-sv-muted);
	letter-spacing: .04em;
	text-transform: uppercase;
}

.fon-sv-note-small {
	margin: .4rem 0 0;
	font-size: .85rem;
	color: var(--fon-sv-muted);
}

.fon-sv-result {
	margin: 0 0 2rem;
	padding: 0 0 1.5rem;
	border-bottom: 1px solid var(--fon-sv-rule);
}

.fon-sv-result:last-of-type {
	border-bottom: 0;
}

.fon-sv-result-q {
	margin: 0 0 .3rem;
	font-size: 1.05rem;
	line-height: 1.4;
	color: var(--fon-sv-ink);
}

.fon-sv-caption {
	margin: 0 0 .9rem;
	font-size: .82rem;
	color: var(--fon-sv-muted);
}

.fon-sv-private {
	margin: 0;
	font-size: .9rem;
	color: var(--fon-sv-muted);
	font-style: italic;
}

/* --- bar chart --- */

.fon-sv-bars {
	list-style: none;
	margin: 0;
	padding: 0;
}

.fon-sv-bar-row {
	display: grid;
	grid-template-columns: minmax(6rem, 14rem) 1fr auto;
	align-items: center;
	gap: .75rem;
	margin: 0 0 .45rem;
	padding: 0;
	list-style: none;
	font-size: .9rem;
	line-height: 1.4;
}

@media (max-width: 600px) {
	.fon-sv-bar-row {
		grid-template-columns: 1fr auto;
	}
	.fon-sv-bar-label {
		grid-column: 1 / -1;
	}
}

.fon-sv-bar-label {
	color: var(--fon-sv-ink-2);
	overflow-wrap: break-word;
}

.fon-sv-bar-track {
	display: block;
	background: var(--fon-sv-ivory);
	border-radius: 1px;
	height: 1.15rem;
	min-width: 2rem;
	overflow: hidden;
}

.fon-sv-bar-fill {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, var(--fon-sv-navy), var(--fon-sv-navy-2));
	border-radius: 1px;
	min-width: 2px;
}

.fon-sv-bar-value {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
	color: var(--fon-sv-muted);
	font-size: .85rem;
}

/* --- scale strip --- */

.fon-sv-strip-wrap {
	max-width: 32rem;
}

.fon-sv-strip {
	display: block;
	width: 100%;
	height: 4.5rem;
	overflow: visible;
}

.fon-sv-strip-bar {
	fill: var(--fon-sv-navy);
}

.fon-sv-strip-empty {
	fill: var(--fon-sv-rule);
}

.fon-sv-strip-tick {
	fill: var(--fon-sv-muted);
	font-size: 6px;
	font-family: inherit;
}

.fon-sv-strip-text {
	margin: .4rem 0 0;
	font-size: .8rem;
	color: var(--fon-sv-muted);
	line-height: 1.6;
}

/* --- index cards --- */

.fon-sv-cards {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
	gap: 1.25rem;
}

.fon-sv-card {
	list-style: none;
	margin: 0;
	padding: 1.35rem 1.5rem;
	background: var(--fon-sv-paper);
	border: 1px solid var(--fon-sv-rule);
	border-top: 3px solid var(--fon-sv-gold);
	border-radius: 2px;
	display: flex;
	flex-direction: column;
}

.fon-sv-card-title {
	margin: 0 0 .5rem;
	font-size: 1.1rem;
	line-height: 1.35;
}

.fon-sv-card-title a {
	color: var(--fon-sv-navy);
	text-decoration: none;
}

.fon-sv-card-title a:hover {
	color: var(--fon-sv-gold-d);
}

.fon-sv-card-meta {
	margin: 0 0 .6rem;
	font-size: .8rem;
	color: var(--fon-sv-muted);
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
	align-items: center;
}

.fon-sv-card-text {
	margin: 0 0 1rem;
	font-size: .92rem;
	line-height: 1.55;
	color: var(--fon-sv-ink-2);
	flex: 1 1 auto;
}

.fon-sv-card-actions {
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
}

.fon-sv-tag {
	display: inline-block;
	padding: .1rem .5rem;
	border-radius: 999px;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	border: 1px solid;
}

.fon-sv-tag-open {
	color: #1c6b34;
	border-color: #a7dcae;
	background: #edfaef;
}

.fon-sv-tag-closed {
	color: var(--fon-sv-muted);
	border-color: var(--fon-sv-rule);
	background: var(--fon-sv-ivory);
}

.fon-sv-tag-done {
	color: var(--fon-sv-gold-d);
	border-color: var(--fon-sv-gold);
	background: #fdfaf3;
}

/* --- sample data ---
   Amber rather than the house navy/gold, deliberately: this is the one label
   on the page that must not read as decoration. */

.fon-sv-tag-demo {
	color: #8a5300;
	border-color: #f0c26a;
	background: #fdf4e3;
}

.fon-sv-demo-notice {
	margin: 0 0 1.5rem;
	padding: .9rem 1.1rem;
	background: #fdf4e3;
	border: 1px solid #f0c26a;
	border-left: 4px solid #d18b1e;
	border-radius: 2px;
	color: #6b4405;
	font-size: .92rem;
	line-height: 1.55;
}

.fon-sv-demo-notice p {
	margin: 0;
}

.fon-sv-demo-notice strong {
	color: #8a5300;
}

.fon-sv-back {
	margin: 1.5rem 0 0;
}

/* Respect a reduced-motion preference: nothing here needs to animate. */
@media (prefers-reduced-motion: reduce) {
	.fon-sv * {
		transition: none !important;
	}
}
