/*
 * Anmeldung / Anfrage forms.
 *
 * Set in Open Sans rather than the theme's DIN Alternate: DIN Alternate ships
 * here as a single bold weight, and a form of bold 17px labels and bold input
 * text is unreadable. See the typography note in BRAND.md.
 */
.ieo-form-section {
	margin-top: 20px;
	font-family: 'Open Sans', sans-serif;
}

/* --- Collapsed opener ----------------------------------------------------
 *
 * A Lehrgang page carries both an Anmeldung and an Anfrage. Fully expanded
 * that is two long forms stacked, and the page reads as paperwork rather than
 * an invitation. Collapsed, the two sit side by side as a choice — commit, or
 * just ask — and each still looks like a button, which is the point: this had
 * to stay a call to action, not become a FAQ list.
 */
.ieo-form-details {
	border-radius: 10px;
	border: 2px solid transparent;
	background-color: #fafafa;
	overflow: hidden;
	transition: border-color 0.2s ease, background-color 0.2s ease;
}

/*
 * The accent is present at rest, not held back until hover.
 *
 * On the workshop pages this block sits in the middle of the page as the call
 * to action rather than at the foot of it, and a grey panel with an invisible
 * border reads there as a disclosure widget — something to skip — rather than
 * an invitation. It also waited for a hover that a touch device never sends.
 *
 * Hover still has somewhere to go: the tint clears to white and the border
 * steps to its darker ink (the rules below, which come later and win on source
 * order at equal specificity).
 */
.ieo-form-details:has(.ieo-form-summary--anmeldung) {
	background-color: #f1f9f6;
	border-color: #a9dccd;
}

.ieo-form-details:has(.ieo-form-summary--anfrage) {
	background-color: #fffcec;
	border-color: var(--brand-yellow);
}

.ieo-form-summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 20px;
	cursor: pointer;
	list-style: none;
	min-height: var(--tap);
}

/* The default triangle, in both engines. Replaced by our own chevron. */
.ieo-form-summary::-webkit-details-marker {
	display: none;
}

.ieo-form-summary::marker {
	content: '';
}

.ieo-form-summary-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.ieo-form-summary-title {
	font-family: 'DIN Alternate Bold', 'Helvetica Neue', Helvetica, sans-serif;
	font-size: clamp(19px, 1vw + 14px, 24px);
	color: #1c1c1c;
	line-height: 1.2;
}

.ieo-form-summary-blurb {
	font-size: 13.5px;
	line-height: 1.4;
	color: #5a5a5a;
}

.ieo-form-summary-marker {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	font-size: 13px;
	transition: transform 0.25s ease, background-color 0.2s ease;
}

.ieo-form-details[open] .ieo-form-summary-marker {
	transform: rotate(180deg);
}

/* Anmeldung is the committing action and gets the solid treatment; Anfrage is
   the lighter alternative beside it. */
.ieo-form-summary--anmeldung .ieo-form-summary-marker {
	background-color: var(--brand-teal-ink);
	color: #fff;
}

.ieo-form-summary--anfrage .ieo-form-summary-marker {
	background-color: var(--brand-yellow);
	color: #40391a;
}

/*
 * Two boxes sit side by side here, and both halves of this used to leave one of
 * them lit up when nothing was happening inside it.
 *
 * `:hover` is gated behind `hover: hover` because a touch browser applies hover
 * to whatever was tapped last and holds it there until something else is
 * tapped. On a phone that meant opening one form left it highlighted for good,
 * and opening the other moved the highlight across — the two appeared to trade
 * a highlight back and forth.
 *
 * `:focus-within` did the same thing with a mouse: clicking a <summary> focuses
 * it, so the box stayed lit long after the pointer had left. `:has(:focus-
 * visible)` keeps what the highlight is actually for — a keyboard user still
 * sees which box they are in, and a text field matches :focus-visible however
 * it was focused, so a form being filled in still reads as active — while a
 * plain click on the summary no longer marks the box indefinitely.
 *
 * These stay *after* the at-rest accent rules above: specificity is equal, so
 * source order is what lets hover clear the tint to white.
 */
@media (hover: hover) {
	.ieo-form-details:hover {
		background-color: #fff;
	}

	.ieo-form-details:has(.ieo-form-summary--anmeldung):hover {
		border-color: var(--brand-teal-ink);
	}

	.ieo-form-details:has(.ieo-form-summary--anfrage):hover {
		border-color: var(--brand-yellow-rule);
	}
}

.ieo-form-details:has(:focus-visible) {
	background-color: #fff;
}

.ieo-form-details:has(.ieo-form-summary--anmeldung):has(:focus-visible) {
	border-color: var(--brand-teal-ink);
}

.ieo-form-details:has(.ieo-form-summary--anfrage):has(:focus-visible) {
	border-color: var(--brand-yellow-rule);
}

.ieo-form-summary:focus-visible {
	outline: 3px solid var(--brand-teal-ink);
	outline-offset: -3px;
	border-radius: 8px;
}

.ieo-form-body {
	padding: 4px 20px 22px;
	border-top: 1px solid #e6e6e6;
	margin-top: 2px;
}

/*
 * The two openers stack, tightly, so they read as one pair of choices.
 *
 * Floating them side by side was tried and abandoned: an opened form needs the
 * full width for its field grid, so the pair had to un-float on open, and a
 * float that changes with state is a reflow bug waiting to happen. Stacked
 * costs about 80px and behaves identically everywhere.
 */
.ieo-form-section + .ieo-form-section {
	margin-top: 12px;
}

/* The pair as a whole is separated from the page content above it. */
.ieo-form-section:not(.ieo-form-section + .ieo-form-section) {
	margin-top: 40px;
	padding-top: 28px;
	border-top: 2px solid var(--brand-yellow);
}

/*
 * The closing counterpart, for a block that sits *inside* the page rather than
 * at the end of it — the workshop pages put the Anfrage straight after the
 * intro, so the page resumes underneath and needs the same separation it got
 * above. `:has(+ *)` is what keeps this off the Lehrgang pages, where the forms
 * are last and a trailing rule would read as a stray line.
 */
.ieo-form-section:not(:has(+ .ieo-form-section)):has(+ *) {
	margin-bottom: 40px;
	padding-bottom: 28px;
	border-bottom: 2px solid var(--brand-yellow);
}

@media (prefers-reduced-motion: reduce) {
	.ieo-form-details,
	.ieo-form-summary-marker {
		transition: none;
	}
}

/* --- Field grid ----------------------------------------------------------
 * Fractional widths so a postcode does not get the same room as a street.
 * They collapse to one column on narrow screens, where side-by-side fields
 * are always too tight to type in.
 */
.ieo-form-grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 16px 18px;
}

.ieo-field--full { grid-column: span 6; }
.ieo-field--half { grid-column: span 3; }
.ieo-field--third { grid-column: span 2; }

@media (max-width: 640px) {
	.ieo-field--full,
	.ieo-field--half,
	.ieo-field--third {
		grid-column: span 6;
	}
}

/*
 * A run of fields under a heading — the Rechnungsadresse (inc/forms.php,
 * ieo_form_groups()). Set off by a hairline and a heading rather than a box:
 * the form already sits in a tinted panel, and a box inside it would be one
 * frame too many. The grids before and after it are separate grids, so they
 * get the grid's own row gap between them.
 */
.ieo-form-grid + .ieo-form-grid,
.ieo-form-group + .ieo-form-grid {
	margin-top: 16px;
}

.ieo-form-group {
	min-width: 0;
	margin: 24px 0 0;
	padding: 18px 0 0;
	border: 0;
	border-top: 1px solid #dcdcdc;
}

/* Floated, so it takes its place in the flow below the rule instead of
   sitting on it — the one reliable way to place a legend in every engine. */
.ieo-form-group-legend {
	float: left;
	width: 100%;
	margin: 0;
	padding: 0;
	font-family: 'DIN Alternate Bold', 'Helvetica Neue', Helvetica, sans-serif;
	font-size: 18px;
	line-height: 1.25;
	color: #1c1c1c;
}

.ieo-form-group-hint {
	clear: both;
	margin: 0;
	padding-top: 4px;
	font-size: 13.5px;
	line-height: 1.45;
	color: #5a5a5a;
}

.ieo-form-group > .ieo-form-grid {
	clear: both;
	margin-top: 14px;
}

.ieo-field label {
	display: block;
	font-size: 14px;
	font-weight: 600;
	color: #2b2b2b;
	margin-bottom: 5px;
}

.ieo-field-optional {
	font-weight: 400;
	color: #6f6f6f;
	font-size: 13px;
}

.ieo-field input[type="text"],
.ieo-field input[type="email"],
.ieo-field input[type="tel"],
.ieo-field textarea {
	width: 100%;
	box-sizing: border-box;
	/* 16px minimum: anything smaller makes iOS Safari zoom the page on focus. */
	font-size: 16px;
	font-family: inherit;
	padding: 11px 13px;
	border: 1.5px solid #c8c8c8;
	border-radius: 5px;
	background-color: #fff;
	color: #1c1c1c;
	min-height: var(--tap);
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ieo-field textarea {
	resize: vertical;
	line-height: 1.5;
}

.ieo-field input:focus,
.ieo-field textarea:focus {
	outline: none;
	border-color: var(--brand-teal-ink);
	box-shadow: 0 0 0 3px rgba(1, 184, 173, 0.22);
}

/* Errors are marked by colour *and* a heavier border, so the state does not
   depend on colour vision alone. The message underneath is the real signal. */
.ieo-field.is-invalid input,
.ieo-field.is-invalid textarea {
	border-color: #b32d2e;
	border-width: 2px;
}

.ieo-field-error {
	margin: 5px 0 0;
	font-size: 13px;
	font-weight: 600;
	color: #b32d2e;
}

/* --- Consent ------------------------------------------------------------ */
.ieo-field--consent {
	margin-top: 20px;
}

.ieo-consent {
	display: flex;
	align-items: flex-start;
	gap: 11px;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	color: #2b2b2b;
	cursor: pointer;
}

.ieo-consent input[type="checkbox"] {
	flex: none;
	width: 19px;
	height: 19px;
	margin: 2px 0 0;
	accent-color: var(--brand-teal-ink);
	cursor: pointer;
}

.ieo-consent a {
	color: var(--brand-teal-ink);
	font-weight: 600;
}

/* --- Submit ------------------------------------------------------------- */
.ieo-form-submit {
	margin-top: 24px;
	padding: 13px 30px;
	border: none;
	border-radius: 999px;
	background-color: var(--brand-teal-ink);
	color: #fff;
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.3px;
	cursor: pointer;
	min-height: var(--tap);
	box-shadow: 0 2px 10px rgba(5, 138, 110, 0.28);
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.ieo-form-submit:hover,
.ieo-form-submit:focus-visible {
	background-color: #04705a;
	transform: translateY(-1px);
}

.ieo-form-submit:focus-visible {
	outline: 3px solid var(--brand-teal-ink);
	outline-offset: 3px;
}

/* --- Result banners ----------------------------------------------------- */
/*
 * These used to carry a 5px coloured left border. Two reasons it is gone: it is
 * a tired pattern, and it was doing a job an icon does better. The state still
 * must not rest on colour alone (WCAG 1.4.1), so it is now carried by a leading
 * glyph plus the wording itself, with the tint and a hairline border as
 * reinforcement rather than as the signal.
 */
.ieo-form-success,
.ieo-form-errors {
	padding: 15px 18px;
	border-radius: 6px;
	border: 1px solid;
	font-size: 15px;
	line-height: 1.5;
	margin-bottom: 20px;
}

.ieo-form-success {
	background-color: #eef8f4;
	border-color: #b6ded1;
	color: #16493c;
}

.ieo-form-errors {
	background-color: #fdefee;
	border-color: #eec4c2;
	color: #6d1a1b;
}

.ieo-form-success p,
.ieo-form-errors p {
	margin: 0;
}

/* The glyph is decorative reinforcement — the message text already states the
   outcome, so it is not announced separately. */
.ieo-form-success p:first-child::before,
.ieo-form-errors p:first-child::before {
	margin-right: 9px;
	font-weight: 700;
}

.ieo-form-success p:first-child::before {
	content: '\2713';
	color: var(--brand-teal-ink);
}

.ieo-form-errors p:first-child::before {
	content: '\0021';
	color: #b32d2e;
}

.ieo-form-errors ul {
	margin: 8px 0 0;
	padding-left: 20px;
}

/*
 * Honeypot.
 *
 * Positioned off-screen rather than display:none or hidden — a bot that reads
 * CSS skips fields it can see are hidden, and fills in ones it cannot.
 */
.ieo-form-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.ieo-field input,
	.ieo-field textarea,
	.ieo-form-submit {
		transition: none;
	}
	.ieo-form-submit:hover {
		transform: none;
	}
}
