/* CRC Blueprint Research — the one-to-one request form
 *
 * Loaded only on a page that renders [crc_consult_form].
 *
 * The people filling this in are often exhausted, sometimes on chemotherapy
 * with the neuropathy that brings, and frequently doing it on a phone in a
 * waiting room. So: one column always, 16px minimum type so iOS does not zoom
 * on focus, 44px minimum targets, real labels above real fields, and no
 * placeholder standing in for a label. Nothing here animates.
 *
 * Colours come from the same custom properties as the article styles, which the
 * theme redefines to its navy and orange. Both schemes are declared because the
 * theme decides which one applies.
 */

.crcbp-consult {
	--crcbp-consult-field: #fff;
	--crcbp-consult-text: #1a1a1a;
	--crcbp-consult-border: var(--crcbp-line, #dfe3e6);

	/* Light, whatever the reader's operating system prefers.
	 *
	 * This form is not free to follow the OS. The theme it appears in is
	 * light-only by deliberate design — it re-pins every colour to its light
	 * value inside its own `prefers-color-scheme: dark` block, so the page is
	 * on warm paper for everybody. A field that went dark on its own therefore
	 * had a dark background and, because the text colour came from the theme
	 * and stayed dark, dark text on it. Black on black, only for readers whose
	 * machine is set to dark mode.
	 *
	 * `color-scheme: light` is the other half, and the half that CSS alone
	 * cannot reach: it tells the browser to paint the parts it owns — the open
	 * dropdown list, the date picker, checkboxes and radios, the scrollbar
	 * inside a long select — in light too. Without it the select looks right
	 * until it is opened, and then the list of time zones comes up black.
	 *
	 * The field colours below are literal rather than inherited for the same
	 * reason: they must not be able to drift out of step with each other. A
	 * dark theme embedding this form can set the two custom properties above. */
	color-scheme: light;

	margin: 2rem 0;
	max-width: 42rem;
}

/* --- Grouping ---------------------------------------------------------- */

/* Fieldsets rather than headings and divs. A screen reader announces the legend
   with every field inside it, so "Documents, reports you would like me to read"
   arrives as one thought instead of two unrelated ones. */
.crcbp-consult__set {
	margin: 0 0 2rem;
	padding: 1.5rem;
	border: 1px solid var(--crcbp-consult-border);
	border-radius: 3px;
	background: var(--crcbp-panel, #f7f9f9);
}

.crcbp-consult__legend {
	padding: 0 0.5rem;
	margin-left: -0.5rem;
	font-weight: 700;
	font-size: 1.25rem;
	line-height: 1.3;
	color: var(--crcbp-teal, #0f6f6c);
}

/* Radios and checkboxes get their own nested fieldset so the question reads as
   a question rather than as a label orphaned above three controls. */
.crcbp-consult__subset {
	margin: 0 0 1.5rem;
	padding: 0;
	border: 0;
}

.crcbp-consult__subset legend {
	padding: 0;
	margin-bottom: 0.5rem;
	font-weight: 600;
	color: var(--crcbp-ink, #1d2327);
}

/* --- Fields ------------------------------------------------------------ */

.crcbp-consult__field {
	display: flex;
	flex-direction: column;
	margin: 0 0 1.5rem;
}

.crcbp-consult__field > label {
	margin-bottom: 0.4rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--crcbp-ink, #1d2327);
}

.crcbp-consult__req {
	color: var(--crcbp-amber, #b8500f);
	font-weight: 700;
}

.crcbp-consult input[type="text"],
.crcbp-consult input[type="email"],
.crcbp-consult input[type="date"],
.crcbp-consult select,
.crcbp-consult textarea {
	width: 100%;
	min-height: 2.75rem;
	padding: 0.65rem 0.75rem;
	/* Never below 16px. Safari on iOS zooms the whole page when a smaller
	   field takes focus, and the reader then has to pinch back out to find
	   the next question. */
	font-size: 1rem;
	font-family: inherit;
	line-height: 1.5;
	color: var(--crcbp-consult-text);
	background: var(--crcbp-consult-field);
	border: 1px solid var(--crcbp-consult-border);
	border-radius: 3px;
	/* Without this a select and a text input in the same column are different
	   widths on Safari, and the form looks broken rather than styled. */
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
}

/* The arrow the appearance reset above removed. Drawn rather than an image so
   it costs no request and inherits nothing that can break. */
.crcbp-consult select {
	padding-right: 2.25rem;
	background-image: linear-gradient( 45deg, transparent 50%, currentColor 50% ),
		linear-gradient( 135deg, currentColor 50%, transparent 50% );
	background-position: right 1.1rem top 50%, right 0.75rem top 50%;
	background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
	background-repeat: no-repeat;
}

.crcbp-consult textarea {
	min-height: 7rem;
	resize: vertical;
}

.crcbp-consult input[type="file"] {
	padding: 0.75rem;
	font-size: 1rem;
	color: var(--crcbp-consult-text);
	background: var(--crcbp-consult-field);
	border: 1px dashed var(--crcbp-consult-border);
	border-radius: 3px;
}

.crcbp-consult__hint {
	margin-top: 0.4rem;
	font-size: 0.9rem;
	line-height: 1.5;
	color: var(--crcbp-muted, #5c6670);
}

/* The two dates sit side by side where there is room, because they are one
   question asked twice, and stack below that. */
.crcbp-consult__pair {
	display: grid;
	gap: 0 1rem;
	grid-template-columns: 1fr;
}

@media ( min-width: 34rem ) {
	.crcbp-consult__pair {
		grid-template-columns: 1fr 1fr;
	}
}

/* --- Choices ----------------------------------------------------------- */

/* The whole row is the label, so the tap target is the line of text rather
   than a 13px circle — which matters on a phone, and matters more to hands
   that are not steady. */
.crcbp-consult__choice {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	min-height: 2.75rem;
	padding: 0.35rem 0;
	line-height: 1.5;
	cursor: pointer;
}

.crcbp-consult__choice input {
	width: 1.15rem;
	height: 1.15rem;
	margin: 0.3rem 0 0;
	flex: none;
	accent-color: var(--crcbp-teal, #0f6f6c);
}

/* The four things that can be asked for.
 *
 * Each is a card rather than a line, because each carries a name and a
 * sentence explaining it, and a checkbox list where the labels wrap into each
 * other is unreadable at exactly the moment it matters most. The whole card is
 * the label, so the target is the card.
 *
 * They are deliberately not visually ranked by weight or colour. The order and
 * the numbering carry that, and shading the expensive one differently would be
 * a nudge rather than information. */
.crcbp-consult__services {
	margin-bottom: 1.75rem;
}

.crcbp-consult__hint--lead {
	display: block;
	margin: 0 0 0.9rem;
}

.crcbp-consult__service {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	margin-bottom: 0.65rem;
	padding: 0.9rem 1rem;
	color: var(--crcbp-consult-text);
	background: var(--crcbp-consult-field);
	border: 1px solid var(--crcbp-consult-border);
	border-radius: 3px;
	cursor: pointer;
}

.crcbp-consult__service input {
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.15rem 0 0;
	flex: none;
	accent-color: var(--crcbp-teal, #0f6f6c);
}

/* Checking one should be visible without hunting for the tick, since these are
   the answers a person changes their mind about most. */
.crcbp-consult__service:has( input:checked ) {
	border-color: var(--crcbp-teal, #0f6f6c);
	box-shadow: inset 3px 0 0 var(--crcbp-teal, #0f6f6c);
}

.crcbp-consult__service-name {
	display: block;
	font-weight: 600;
	line-height: 1.45;
	color: var(--crcbp-consult-text);
}

.crcbp-consult__service-note {
	display: block;
	margin-top: 0.3rem;
	font-size: 0.9rem;
	line-height: 1.5;
	color: var(--crcbp-muted, #5c6670);
}

.crcbp-consult__consent {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	margin-bottom: 1.25rem;
	padding: 0.85rem 1rem;
	line-height: 1.6;
	color: var(--crcbp-consult-text);
	background: var(--crcbp-consult-field);
	border: 1px solid var(--crcbp-consult-border);
	border-radius: 3px;
	cursor: pointer;
}

.crcbp-consult__consent input {
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.2rem 0 0;
	flex: none;
	accent-color: var(--crcbp-teal, #0f6f6c);
}

/* --- Sending ----------------------------------------------------------- */

.crcbp-consult__actions {
	margin: 0 0 1rem;
}

/* The button's orange is its own value rather than the shared --crcbp-amber.
 *
 * White on the theme's burnt orange (#D87F4A) is 2.98:1. WCAG AA wants 4.5:1
 * for text this size — 17px at weight 600 is not "large text", which needs
 * 18.66px bold or 24px normal — so the label on the one control that submits
 * the form was the least legible text on the page, for readers who are tired
 * and often reading on a phone in a waiting room.
 *
 * #B45E2C is the same hue carried far enough down to clear the threshold at
 * 4.59:1. The shared property is left alone: it is correct everywhere else,
 * where the orange sits behind nothing or behind dark text. */
.crcbp-consult button[type="submit"] {
	min-height: 3.25rem;
	padding: 0.85rem 1.75rem;
	font-family: inherit;
	font-size: 1.0625rem;
	font-weight: 600;
	color: #fff;
	background: #b45e2c;
	border: 0;
	border-radius: 3px;
	cursor: pointer;
}

.crcbp-consult button[type="submit"]:hover {
	background: #9e4a1c;
}

.crcbp-consult__note {
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--crcbp-muted, #5c6670);
}

/* --- Outcomes ---------------------------------------------------------- */

/* Both are announced (role status / role alert), so they have to be visible as
   well as legible. The left border carries no meaning on its own: each one is
   introduced by its own words. */
.crcbp-consult__ok,
.crcbp-consult__error {
	margin: 0 0 2rem;
	padding: 1.25rem 1.5rem;
	color: var(--crcbp-consult-text);
	background: var(--crcbp-consult-field);
	border: 1px solid var(--crcbp-consult-border);
	border-left: 4px solid;
	border-radius: 3px;
	line-height: 1.6;
}

.crcbp-consult__ok {
	border-left-color: #27ae60;
}

.crcbp-consult__ok h2 {
	margin: 0 0 0.75rem;
	font-size: 1.35rem;
	line-height: 1.3;
}

.crcbp-consult__ok p:last-child,
.crcbp-consult__error p:last-child {
	margin-bottom: 0;
}

.crcbp-consult__error {
	border-left-color: #c0392b;
}

/* Generous, visible focus, matching the theme's. A keyboard user working down
   a form this long must always know where they are. */
.crcbp-consult :where( input, select, textarea, button ):focus-visible {
	outline: 3px solid var(--crcbp-amber, #b8500f);
	outline-offset: 2px;
}
