/*
 * Scoped styling for the survey fill-out plugin (#4). Everything is
 * namespaced under .tx-pegasussurvey so it cannot bleed into unrelated
 * page content - reuses the template's existing Bootstrap/radio-checkbox
 * components (Agentur-Doku projekte/whitelabel-typo3/uxConcept-umfrage.md:
 * "Kein eigenes Grid/CSS-Framework"),
 * this file only adds the handful of rules the template doesn't already
 * provide for this use case.
 */

/* #18: bound to the site's theme color instead of a hardcoded hex, so the
   button stays mandant-correct across whitelabels. --themecolor is the CSS
   custom property page.typoscript writes site-wide from the TypoScript
   constant `themeColor` (= getEnv(THEME_MAIN_COLOR), see
   pegasus_distribution/Configuration/TypoScript/Default/Page/{constants,page}
   .typoscript) - the same variable every other pegasus_distribution
   stylesheet already themes off of (style-vars.css etc.), so this follows
   the established pattern rather than inventing a new one. `, #148F77`
   fallback (old hardcoded value) matches the same defensive pattern already
   used for this var elsewhere (bs-switches.css) in case the property is
   ever unset. Class name kept as "-teal" to keep the diff surgical (rename
   is cosmetic, not part of this fix). Albatros' value (#1E3970) is ~11:1
   against white text, well past WCAG AA's 4.5:1. */
.tx-pegasussurvey .btn-primary-teal {
	background-color: var(--themecolor, #148F77);
	border-color: var(--themecolor, #148F77);
	color: #fff;
}
/* Hover/focus darkens via an inset overlay rather than `filter: brightness()`
   on the whole element - a whole-element filter also dims the white label
   text and Bootstrap's focus box-shadow (Codex review #18: reduces contrast
   and hides the keyboard focus ring). The overlay only darkens the
   background, so the text stays crisp - contrast can only improve, never
   worsen, versus the unhovered state. */
.tx-pegasussurvey .btn-primary-teal:hover,
.tx-pegasussurvey .btn-primary-teal:focus {
	background-color: var(--themecolor, #148F77);
	border-color: var(--themecolor, #148F77);
	box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.15);
	color: #fff;
}
/* :focus alone (not :hover) re-adds bootstrap.css' outer focus ring
   (`.btn:focus { box-shadow: 0 0 0 .2rem rgba(0,123,255,.25) }`) - our rule
   above is more specific and would otherwise silently drop it, leaving
   keyboard users without a visible focus indicator (WCAG 2.2 AA). */
.tx-pegasussurvey .btn-primary-teal:focus {
	box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.15), 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Quirin acceptance #15 Bug-Loop #1, Finding 1 (Major): the template's
   generic `.btn` class carries no min-height, so the wizard nav buttons
   (Weiter/Zurück/Absenden, `.survey-submit-wrap button`) measured 38px on
   mobile - below the required >=44px touch target (uxConcept-umfrage-
   wizard.md §5/§6, WCAG 2.5.8). Scoped to `.btn` in general (not just
   `.survey-submit-wrap button`) so the success-state "Zurück zur
   Startseite" link (#15 AC10, also a `.btn`) gets the same target size for
   free instead of needing a duplicate rule. inline-flex+center (not just
   min-height) so the label stays vertically centred in the taller box
   instead of sticking to the top. */
.tx-pegasussurvey .btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
}

/* radio-checkbox.css hides the native input (opacity:0) and defines no
   focus state at all - without this, keyboard users tabbing through
   options get no visible focus indicator (WCAG 2.2 AA). */
.tx-pegasussurvey .radio-style:focus-visible + .radio-style-1-label:before,
.tx-pegasussurvey .checkbox-style:focus-visible + .checkbox-style-1-label:before {
	outline: 2px solid #148F77;
	outline-offset: 2px;
}

/* Generous, thumb-friendly touch target: the *label* (not just the visual
   circle/box) is the clickable area (native <label for>), so it is sized
   to >=44px rather than the small decorative marker. */
.tx-pegasussurvey .radio-style-1-label,
.tx-pegasussurvey .checkbox-style-1-label {
	display: flex;
	align-items: center;
	min-height: 44px;
	margin: 0;
	padding: 4px 4px 4px 0;
}

.tx-pegasussurvey .question-option {
	margin-bottom: 4px;
}

.tx-pegasussurvey fieldset.question {
	border: 0;
	padding: 0;
	margin: 0 0 1.5rem;
}

.tx-pegasussurvey fieldset.question legend {
	font-weight: 600;
	padding: 0;
	margin-bottom: .5rem;
	font-size: inherit;
}

.tx-pegasussurvey .question__scale-hint {
	font-weight: 400;
	font-size: .85em;
	color: #6c757d;
}

.tx-pegasussurvey .question__help {
	font-size: .9em;
	color: #6c757d;
	margin-bottom: .5rem;
}

.tx-pegasussurvey .question__error {
	color: #dc3545;
	font-size: .9em;
	margin: .25rem 0 0;
}

.tx-pegasussurvey .question__error--empty {
	display: none;
}

.tx-pegasussurvey .question--error .form-control,
.tx-pegasussurvey .question--error input.radio-style + .radio-style-1-label:before,
.tx-pegasussurvey .question--error input.checkbox-style + .checkbox-style-1-label:before {
	border-color: #dc3545;
}

/* Likert: vertical stack on mobile (default), horizontal row on desktop.
   flex-wrap lets long custom labels (Uma: "Edge - lange Optionslabels")
   wrap onto a second line instead of being force-fit into one row. */
.tx-pegasussurvey .likert-options {
	display: flex;
	flex-direction: column;
}

@media (min-width: 768px) {
	.tx-pegasussurvey .likert-options {
		flex-direction: row;
		flex-wrap: wrap;
		gap: .5rem 1rem;
	}

	.tx-pegasussurvey .likert-options .likert-option {
		flex: 1 1 110px;
		min-width: 110px;
	}
}

/* #13: the radio input and its label are siblings, not parent/child - the
   radio isn't part of the label's own box, so centering text *inside* the
   label alone can't keep the circle aligned with it. Making each option its
   own centered column keeps the radio's horizontal center locked to the
   label's, at every viewport (not just desktop), and keeps it locked even
   when a longer label wraps onto 2-3 lines - the label stretches to the
   column's full (consistent) width via align-self so wrapped lines all
   center on that same shared axis, instead of each label shrink-wrapping to
   its own text width. */
.tx-pegasussurvey .likert-options .likert-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .35rem;
}

.tx-pegasussurvey .likert-options .likert-option .radio-style-1-label {
	display: block;
	align-self: stretch;
	text-align: center;
	min-height: 0;
}

/* #14: binary single-choice questions (Ja/Nein) - stacked on mobile/tablet
   (<768px, matches the Likert breakpoint above for one consistent rule of
   thumb across the survey), side by side from 768px up. Tab/Arrow-Key order
   is unaffected - this only changes the visual flow direction, not the DOM
   order the options are already in.
   #17 (ADR 0003 §3): renamed from the original --binary to the canonical
   --horizontal - it is now also reachable via an explicit redakteur
   "horizontal" override, not just the auto+2-options heuristic. Same rule,
   same class contract, just no longer implying "only for binary questions". */
.tx-pegasussurvey .question-options--horizontal {
	display: flex;
	flex-direction: column;
	gap: .5rem;
}

@media (min-width: 768px) {
	.tx-pegasussurvey .question-options--horizontal {
		flex-direction: row;
		gap: 1.5rem;
	}

	.tx-pegasussurvey .question-options--horizontal .question-option {
		margin-bottom: 0;
	}
}

/* Error summary box (aria-live region, hidden until populated by JS or
   rendered server-side for the no-JS/422 case). */
.tx-pegasussurvey .survey-error-summary {
	border: 1px solid #dc3545;
	background: #fdecea;
	color: #842029;
	padding: .75rem 1rem;
	margin-bottom: 1.5rem;
	border-radius: 4px;
}
.tx-pegasussurvey .survey-error-summary[hidden] {
	display: none;
}

/* Progress bar text stays visible (not just the colour-coded fill). */
.tx-pegasussurvey .survey-progress-text {
	font-size: .85em;
	margin: .25rem 0 1rem;
}

/* #15 wizard: sticky top on mobile so the "Seite X von N"-indicator stays in
   view while scrolling the (now shorter, per-page) question list - matches
   the sticky nav footer below (Agentur-Doku
   projekte/whitelabel-typo3/uxConcept-umfrage-wizard.md §5).
   Desktop stays static in the content flow (§3.4 wireframe). */
.tx-pegasussurvey .survey-progress-wizard {
	margin-bottom: 1.5rem;
}
@media (max-width: 767.98px) {
	.tx-pegasussurvey .survey-progress-wizard {
		position: sticky;
		top: 0;
		background: #fff;
		padding: .5rem 0;
		z-index: 2;
	}
}

/* #15 wizard page heading - the `.focus()` target after Weiter/Zurück
   (uxConcept-umfrage-wizard.md §6 "Fokus-Management"). tabindex=-1 keeps it
   out of the normal Tab order but it still needs a visible ring once
   programmatically focused. */
.tx-pegasussurvey .survey-page__title {
	margin: 0 0 1rem;
}
.tx-pegasussurvey .survey-page__title:focus-visible {
	outline: 2px solid #148F77;
	outline-offset: 2px;
}
/* bugfix/survey-empty-page-title: no "Seite N" text fallback anymore - a
   Block without a title renders an empty heading (still needed as the focus
   target above). Collapse its margin so no visible gap is left behind, but
   keep a 1-line min-height so the :focus-visible ring above still has a
   real box to draw around instead of collapsing to a zero-size point. */
.tx-pegasussurvey .survey-page__title--empty {
	margin: 0;
	min-height: 1.5em;
}

.tx-pegasussurvey .survey-session-hint {
	font-size: .85em;
	color: #6c757d;
	margin: 1rem 0 0;
}

/* #15 wizard nav: "‹ Vorherige Seite" left, Weiter/Absenden right. The
   submit button's auto margin (not `justify-content: space-between` on the
   container) is deliberate - with the prev button `hidden` on page 1
   (removed from flex flow), `space-between` would collapse to a single
   left-aligned item; `margin-left: auto` on the submit button keeps it
   pinned to the right in both cases (uxConcept-umfrage-wizard.md §4 "Erste
   Seite: kein Zurück ... Weiter rechtsbündig"). */
.tx-pegasussurvey .survey-submit-wrap {
	display: flex;
	align-items: center;
	gap: 1rem;
}
.tx-pegasussurvey .survey-submit-wrap [data-survey-submit] {
	margin-left: auto;
}

/* Sticky submit button on mobile (thumb zone), static on desktop. */
@media (max-width: 767.98px) {
	.tx-pegasussurvey .survey-submit-wrap {
		position: sticky;
		bottom: 0;
		background: #fff;
		padding: .75rem 0;
		z-index: 2;
	}
}

/* Fill uses the site's theme color instead of Bootstrap's hardcoded default
   blue (`.progress-bar { background-color: #007bff }` in
   pegasus_distribution/bootstrap.css). Same --themecolor + `, #148F77`
   fallback pattern as .btn-primary-teal above - established mechanism,
   nothing new invented here. */
.tx-pegasussurvey .progress-bar {
	background-color: var(--themecolor, #148F77);
}

@media (prefers-reduced-motion: reduce) {
	.tx-pegasussurvey .progress-bar {
		transition: none;
	}
}
