/**
 * Application form styles.
 *
 * Inherits the theme's tokens (--navy, --accent, --rule …). If the plugin is
 * used without the Sully theme, these fallbacks keep it legible rather than
 * unstyled — it is a whitelabel plugin, so it cannot assume its host.
 */
.sully-form {
	--sf-navy: var(--navy, #0A1428);
	--sf-accent: var(--accent, #F5B517);
	--sf-rule: var(--rule, #D3DCE6);
	--sf-dim: var(--text-dim, #46566E);
	max-width: 52rem;
	margin: 0 auto;
}

.sully-section {
	border: 1px solid var(--sf-rule);
	border-radius: 3px;
	padding: 1.5rem;
	margin: 0 0 1.25rem;
}
.sully-section legend {
	font-family: var(--font-display, inherit);
	font-weight: 700;
	text-transform: uppercase;
	font-size: 1.1rem;
	padding: 0 .5rem;
	color: var(--sf-navy);
}
.sully-optional {
	font-family: system-ui, sans-serif;
	font-weight: 400;
	text-transform: none;
	font-size: .78rem;
	color: var(--sf-dim);
	margin-left: .4rem;
}

.sully-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	gap: 1rem;
}
.sully-field { display: flex; flex-direction: column; gap: .35rem; }
.sully-field--textarea, .sully-field--file { grid-column: 1 / -1; }

.sully-field label {
	font-size: .85rem;
	font-weight: 600;
	color: var(--sf-navy);
	display: flex;
	align-items: center;
	gap: .4rem;
	flex-wrap: wrap;
}
.sully-req { color: #B23F32; }

/* Tells the applicant which fields get sealed. This is a trust signal —
   people hesitate at the SSN box, and saying what happens to it helps. */
.sully-sealed {
	font-size: .62rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .08em;
	background: var(--sf-navy);
	color: var(--sf-accent);
	padding: .12rem .35rem;
	border-radius: 2px;
}

.sully-form input,
.sully-form select,
.sully-form textarea {
	font: inherit;
	padding: .65rem .7rem;
	border: 1px solid var(--sf-rule);
	border-radius: 3px;
	background: #fff;
	color: inherit;
	width: 100%;
}
.sully-form input:focus-visible,
.sully-form select:focus-visible,
.sully-form textarea:focus-visible {
	outline: 3px solid var(--sf-accent);
	outline-offset: 1px;
	border-color: var(--sf-navy);
}
.sully-form input[aria-invalid="true"] { border-color: #B23F32; }

/* ---------- required-field errors (see validate() in form.js) ----------
   The field is marked in place and the submit is blocked, instead of a round
   trip to a server error page. */
.sully-field.has-error input,
.sully-field.has-error select,
.sully-field.has-error textarea { border-color: #B23F32; }
.sully-sig.has-error { border-color: #B23F32; border-style: solid; }
.sully-check.has-error { outline: 2px solid #B23F32; outline-offset: .35rem; border-radius: 2px; }
.sully-error-msg {
	display: block;
	color: #B23F32;
	font-size: .78rem;
	font-weight: 600;
	margin: .1rem 0 0;
}

.sully-help { font-size: .78rem; color: var(--sf-dim); margin: 0; }

/* Cloudflare Turnstile sits above the submit button, full row. */
.sully-field--turnstile { grid-column: 1 / -1; margin: .25rem 0 1rem; gap: .5rem; }
.sully-field--turnstile.has-error .cf-turnstile { outline: 2px solid #B23F32; outline-offset: 4px; border-radius: 4px; }

.sully-consent__text {
	font-size: .82rem;
	line-height: 1.5;
	color: var(--sf-dim);
	background: var(--paper-2, #EFF3F7);
	border-left: 3px solid var(--sf-accent);
	padding: .8rem 1rem;
	margin: 0 0 .75rem;
	max-height: 11rem;
	overflow-y: auto;
}
.sully-check {
	display: flex;
	gap: .6rem;
	align-items: flex-start;
	margin: 0 0 1.25rem;
	font-size: .9rem;
}
.sully-check input { width: auto; margin-top: .2em; flex: none; }

.sully-privacy { font-size: .82rem; color: var(--sf-dim); margin: 0 0 1rem; }
.sully-footnote { font-size: .75rem; color: var(--sf-dim); text-align: center; margin-top: .75rem; }

/* Honeypot: off-screen rather than display:none, which some bots detect. */
.sully-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.sully-form--down {
	border: 2px solid #B23F32;
	border-radius: 3px;
	padding: 1.5rem;
	text-align: center;
}

/* Post-submit confirmation, shown in place of the form on the same page. */
.sully-form--thanks {
	border: 2px solid var(--go, #1F7A52);
	border-radius: 3px;
	padding: 1.75rem;
}
.sully-form--thanks h2 { margin-top: 0; }

@media (max-width: 40rem) {
	.sully-grid { grid-template-columns: 1fr; }
	.sully-section { padding: 1rem; }
}

/* ---------- signature pad ----------
   Sized so a finger has room. The baseline and the × are the affordance that
   makes it read as "sign here" without instructions. */
.sully-field--signature { grid-column: 1 / -1; }

.sully-sig {
	position: relative;
	border: 2px dashed var(--sf-rule);
	border-radius: 4px;
	background: #fff;
	transition: border-color .15s ease;
}
.sully-sig.is-signed { border-style: solid; border-color: var(--go, #1F7A52); }

.sully-sig__pad {
	display: block;
	width: 100%;
	height: 11rem;
	/* Stops the browser scrolling the page while a finger draws. */
	touch-action: none;
	cursor: crosshair;
	border-radius: 3px;
}
.sully-sig__pad:focus-visible { outline: 3px solid var(--sf-accent); outline-offset: -3px; }

/* Baseline sits under the canvas, not in it, so it never lands in the export. */
.sully-sig__base {
	position: absolute;
	left: 1.5rem;
	right: 1.5rem;
	bottom: 3.2rem;
	border-bottom: 1px solid var(--sf-rule);
	pointer-events: none;
	display: flex;
	align-items: flex-end;
}
.sully-sig__x { color: var(--sf-rule); font-size: 1.4rem; line-height: 1; transform: translateY(.35rem); }

.sully-sig__bar {
	display: flex;
	justify-content: space-between;
	gap: .5rem;
	padding: .5rem;
	border-top: 1px solid var(--sf-rule);
	flex-wrap: wrap;
}
.sully-sig__btn {
	background: none;
	border: 0;
	padding: .35rem .5rem;
	font: inherit;
	font-size: .82rem;
	color: var(--sf-dim);
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: .15em;
}
.sully-sig__btn:hover { color: var(--sf-navy); }

/* Typed fallback: hide the pad, keep the name field doing the work. */
.sully-sig.is-typed .sully-sig__pad,
.sully-sig.is-typed .sully-sig__base { display: none; }
.sully-sig.is-typed::after {
	content: 'Signing by typing your name below.';
	display: block;
	padding: 1.5rem;
	text-align: center;
	color: var(--sf-dim);
	font-size: .9rem;
}

/* ---------- conditional fields ----------
   A .sully-field is display:flex, which overrides the bare `hidden` attribute
   (that only sets display:none at low specificity). This makes hidden win. */
.sully-field[hidden] { display: none; }

/* A field that has just appeared gets a brief highlight so it is noticed. */
.sully-field.is-revealed { animation: sully-reveal .4s ease; }
@keyframes sully-reveal {
	from { background: rgba(245, 181, 23, .14); }
	to   { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
	.sully-field.is-revealed { animation: none; }
}
