/*
 * RoofPilot homeowner form — chunk 1.
 * Single brand hook: --brand-color. Later chunks inject the contractor's
 * color into this one variable; everything accent-colored reads from it.
 */
:root {
	--brand-color: #2563eb; /* neutral professional blue (default) */
	--brand-color-dark: #1e4fd1;
	--text: #1f2937;
	--text-muted: #6b7280;
	--border: #d1d5db;
	--border-focus: var(--brand-color);
	--error: #dc2626;
	/* Banner shades of --error: the tint is the fill, the deep shade is the
	 * text — plain --error on the tint lands at 4.4:1, just under AA. */
	--error-bg: #fef2f2;
	--error-text: #991b1b;
	--bg: #f3f4f6;
	--card-bg: #ffffff;
	--radius: 10px;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	padding: 24px 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--text);
	background: var(--bg);
	line-height: 1.5;
}

.card {
	max-width: 520px;
	margin: 0 auto;
	background: var(--card-bg);
	border-radius: var(--radius);
	padding: 28px 24px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.04);
}

h1 {
	font-size: 1.5rem;
	margin: 0 0 8px;
	line-height: 1.25;
}

.subhead {
	margin: 0 0 24px;
	color: var(--text-muted);
}

/* Honeypot — visually removed but still in the DOM/tab-excluded. Deliberately
 * NOT display:none and NOT type=hidden so naive bots still fill it. */
.hp-field {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
}

/* ---- Embedded mode ----
 * Set by form.js only when the form runs inside an embed.js iframe (&embed=1).
 * The contractor's page supplies the background and the width, so we drop ours
 * and let the card fill the frame. The card itself stays a visible panel — a
 * border instead of the shadow, which is what read as a bolted-on widget — so
 * the estimate still looks anchored rather than like loose text on their page.
 * Standalone loads never match these rules. */
.embedded body {
	padding: 0 8px;
	background: transparent;
}

.embedded .card {
	max-width: none;
	margin: 8px 0;
	border: 1px solid var(--border);
	box-shadow: none;
}

/* ---- Fields ---- */
.field {
	margin-bottom: 18px;
}

label {
	display: block;
	font-weight: 600;
	font-size: 0.95rem;
	margin-bottom: 6px;
}

.optional {
	font-weight: 400;
	color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
	width: 100%;
	padding: 11px 12px;
	font-size: 1rem;
	font-family: inherit;
	color: var(--text);
	background: #fff;
	border: 1px solid var(--border);
	border-radius: 8px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--border-focus);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
	resize: vertical;
}

input.invalid,
select.invalid {
	border-color: var(--error);
}

/* A rejected address focuses its own field, so the ring has to agree with the
 * red border instead of overlaying it with the brand blue. */
input.invalid:focus,
select.invalid:focus {
	border-color: var(--error);
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* ---- Address autocomplete ----
 * The dropdown is absolutely positioned so opening it doesn't shove the rest
 * of the form down. Embedded, that means it can hang past the card's bottom
 * edge — form.js measures the open list and reports the taller height, so the
 * iframe grows to fit instead of clipping it. Nothing here sets overflow on an
 * ancestor, which would clip it before the frame ever got the chance. */
.autocomplete {
	position: relative;
}

.suggestions {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	z-index: 30;
	margin: 0;
	padding: 4px 0;
	list-style: none;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	max-height: 260px;
	overflow-y: auto;
}

.suggestions[hidden] {
	display: none;
}

.suggestion {
	padding: 10px 12px;
	font-size: 0.95rem;
	line-height: 1.35;
	cursor: pointer;
}

/* Hover and keyboard focus have to look identical — arrowing down the list is
 * the only feedback a keyboard user gets that the highlight moved. */
.suggestion:hover,
.suggestion.active {
	background: var(--bg);
}

.suggestion.active {
	box-shadow: inset 2px 0 0 var(--brand-color);
}

.field-hint {
	font-size: 0.83rem;
	color: var(--text-muted);
	margin: 5px 0 0;
}

/* Louder than .field-hint: this reports a change made to a field the
 * homeowner had already filled in, so it has to actually get noticed. */
.field-note {
	font-size: 0.83rem;
	font-weight: 600;
	color: var(--brand-color);
	margin: 5px 0 0;
}

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

/* Announced to screen readers, invisible to everyone else. */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Auto-filled "Austin, TX" line under the ZIP field. */
.city-preview {
	font-size: 0.83rem;
	color: var(--text-muted);
	margin: 5px 0 0;
	min-height: 0;
}

.city-preview:empty {
	display: none;
}

small.error {
	display: none;
	color: var(--error);
	font-size: 0.83rem;
	margin-top: 5px;
}

small.error.show {
	display: block;
}

/* ---- Checkbox ---- */
.checkbox-field {
	margin-top: 4px;
}

.checkbox {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-weight: 400;
	cursor: pointer;
}

.checkbox input {
	margin-top: 3px;
	width: 18px;
	height: 18px;
	accent-color: var(--brand-color);
	flex-shrink: 0;
}

/* ---- Submit ---- */
.submit-btn {
	width: 100%;
	padding: 14px 16px;
	font-size: 1.05rem;
	font-weight: 600;
	color: #fff;
	background: var(--brand-color);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	margin-top: 8px;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.submit-btn:hover:not(:disabled) {
	background: var(--brand-color-dark);
}

.submit-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Server-side errors (bad address, capacity, security check). An alert box,
 * not a footnote — a small centred line under the button was routinely missed
 * in live testing. Left-aligned body text on a red tint, with a heavy left
 * rule, so it reads as a block that happened to the submission.
 *
 * It now sits directly above the submit button. The top margin collapses with
 * the preceding .field's 18px, so the banner keeps normal field spacing above
 * it; the bottom margin has to beat the button's own 8px top margin to leave a
 * visible gap between the message and the button it belongs to. */
.form-error {
	color: var(--error-text);
	font-size: 1rem;
	line-height: 1.45;
	text-align: left;
	background: var(--error-bg);
	border: 1px solid var(--error);
	border-left: 4px solid var(--error);
	border-radius: 8px;
	padding: 12px 14px;
	margin: 0 0 14px;
}

.consent {
	font-size: 0.8rem;
	color: var(--text-muted);
	margin: 16px 0 0;
	text-align: center;
}

.consent a {
	color: var(--brand-color);
}

/* ---- Loading view ---- */
#loading-view {
	text-align: center;
	padding: 48px 16px;
}

.spinner {
	width: 44px;
	height: 44px;
	margin: 0 auto 20px;
	border: 4px solid rgba(37, 99, 235, 0.2);
	border-top-color: var(--brand-color);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.loading-text {
	font-size: 1.05rem;
	color: var(--text-muted);
}

/* ---- Result view ---- */
#result-view {
	text-align: center;
	padding: 8px 4px;
}

.result-label {
	font-size: 1rem;
	color: var(--text-muted);
	margin: 0 0 12px;
}

.price {
	/* Fluid so a full range ("$11,269 – $13,773") stays on one line on a 360px
	 * phone, while desktop keeps the original 2.25rem anchor. */
	font-size: clamp(1.5rem, 7.5vw, 2.25rem);
	font-weight: 700;
	color: var(--brand-color);
	margin: 0 0 12px;
	line-height: 1.15;
}

.result-note {
	font-size: 0.95rem;
	color: var(--text-muted);
	margin: 0 0 20px;
}

.measured-address {
	font-size: 0.85rem;
	color: var(--text-muted);
	margin: 0;
}

/* Rough-estimate disclaimer shown above the price. */
.rough-warning {
	background: #fef9c3;
	border: 1px solid #facc15;
	border-radius: 8px;
	padding: 12px 16px;
	font-size: 0.92rem;
	color: #854d0e;
	margin: 0 0 20px;
	text-align: left;
}

/* "Request a call" — an <a> dressed as the submit button. */
a.request-call-btn {
	display: block;
	margin-top: 24px;
	text-align: center;
	text-decoration: none;
}

/* display:block above would defeat the [hidden] attribute without this. */
a.request-call-btn[hidden] {
	display: none;
}

.out-of-area {
	font-size: 1.1rem;
	color: var(--text);
	padding: 24px 8px;
	margin: 0;
}
