/* =============================================================================
   ADMIN — answer options drag-and-drop table (SurveyQuestionForm)
   ============================================================================= */

/* Add answer option button spacing */
#survey-question-options-wrapper > .fieldset-wrapper > input[type="submit"] {
  margin-top: 0.75rem;
}

/* Keep textareas readable inside the table */
#survey-question-options-wrapper textarea {
  min-width: 180px;
}

/* =============================================================================
   SURVEY — layout
   The take form is aimed at older drivers: large, high-contrast text and
   generous click targets. The text stays at 18px (the theme body is 16px);
   headings, colours and the column follow the vias theme. The section and the
   centred col-lg-8 come from paragraph--survey.html.twig (vias theme).
   ============================================================================= */

.survey-form {
  --survey-ok: #1e7b3c;
  --survey-ok-subtle: #e6f4ea;
  --survey-warning: #b4530a;
  --survey-warning-subtle: #fdf0e3;
  --survey-danger: #c0262d;
  --survey-danger-subtle: #fbe7e8;
  /* vias tokens: $color-neutral-lighter, $color-neutral, $color-neutral-lightest. */
  --survey-border: #cccccc;
  --survey-muted: #757575;
  --survey-track: #eeeeee;

  font-size: 1.125rem;
  line-height: 1.5;
}

/* Scrolled to after an Ajax step (survey.js), below the sticky header. */
.survey-form-wrapper {
  scroll-margin-top: 7rem;
}

.survey-form [tabindex="-1"]:focus {
  outline: none;
}

/* Messages added by an Ajax step, above the form: within the column. */
.survey-form-wrapper .vias-messages {
  max-width: none;
  padding-inline: 0;
  margin: 0 0 2rem;
}

/* Introduction before the first question: rich text with the .text-paragraph
   styles of the theme (h2/h3 sizes, light #444 text), at the 18px of the form. */
.survey-intro {
  margin-bottom: 2rem;
}

/* Ajax throbber next to the buttons. */
.survey-actions .ajax-progress {
  align-self: center;
}

/* Progress bar */
.survey-progress {
  height: 8px;
  background-color: var(--survey-track);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.survey-progress__bar {
  height: 100%;
  background-color: var(--bs-primary, #51deb8);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Step indicator */
.survey-step-indicator {
  text-align: center;
  color: var(--survey-muted);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

/* Question title: an h2 at the size of the theme h4 (32px); line height and
   letter spacing come from the theme headings. */
.survey-question__title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 2rem;
}

/* =============================================================================
   Answer option cards (questions and personal info)
   ============================================================================= */

.survey-options {
  margin-bottom: 2rem;
}

/* Drop the margins of the theme fieldset wrappers around the radios. */
.survey-options .fieldgroup,
.survey-options .fieldgroup > .mb-3 {
  margin-bottom: 0 !important;
}

.survey-options .form-radios {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.survey-options--grid .form-radios {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.survey-options .form-check {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  border: 2px solid var(--survey-border);
  border-radius: var(--bs-border-radius-sm, 0.25rem);
  padding: 0.75rem 1.25rem;
  margin: 0;
  background-color: #fff;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.survey-options .form-check:hover {
  border-color: var(--bs-primary, #51deb8);
  background-color: rgba(81, 222, 184, 0.1);
}

/* Keyboard focus on the visually hidden radio. */
.survey-options .form-check:focus-within {
  outline: 3px solid var(--bs-secondary, #3c5196);
  outline-offset: 2px;
}

.survey-options .form-check.is-selected {
  background-color: rgba(81, 222, 184, 0.25);
  border-color: var(--bs-primary, #51deb8);
  font-weight: 600;
}

/* Visually hide the radio input — the card is the click target */
.survey-options .form-check-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.survey-options .form-check-label {
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1.35;
  margin: 0;
}

/* The question is the title of the page step: its legend is only for screen
   readers (the theme does not hide it for #title_display invisible). */
.survey-options--question .fieldset-legend {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* Inline error above the answers of an unanswered question. The summary at
   the top of the page links to it. */
.survey-options .invalid-feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--survey-danger);
}

.survey-options .invalid-feedback::before {
  content: "";
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 0a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15H9v-2h2v2Zm0-4H9V5h2v6Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Unanswered question: red cards instead of the red labels of Bootstrap. */
.survey-options .form-check:has(.is-invalid) {
  border-color: var(--survey-danger);
}

.survey-options .form-check-input.is-invalid ~ .form-check-label {
  color: inherit;
}

/* Error message of an unanswered question. */
.survey-form .invalid-feedback,
.survey-form .form-item--error-message {
  font-size: 1rem;
  text-align: center;
}

/* =============================================================================
   Navigation buttons
   ============================================================================= */

.survey-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 0;
}

/* Theme buttons (padding, radius), at the 18px of the form. */
.survey-actions .btn {
  --bs-btn-font-size: 1.125rem;
}

/* The theme gives every submit button btn-primary; "Back" also gets
   btn-outline-secondary (SurveyTakeForm), the secondary button of the site.
   That class sets no background, so drop the one of btn-primary. */
.survey-form .survey-actions .survey-btn--back.btn {
  --bs-btn-bg: transparent;
}

@media (max-width: 575.98px) {
  .survey-actions .btn {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* =============================================================================
   Personal info step
   ============================================================================= */

.survey-personal-info__title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.survey-personal-info__description {
  text-align: center;
  color: var(--survey-muted);
  margin-bottom: 2.5rem;
}

.survey-personal-info__group {
  margin-bottom: 2.5rem;
}

/* Question of a group: the fieldset legend or the field label. */
.survey-personal-info__group .fieldset-legend,
.survey-personal-info__field .form-label {
  display: block;
  width: 100%;
  margin-bottom: 0 !important;
  padding-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

.survey-personal-info__group .fieldset-legend label {
  margin: 0;
  font: inherit;
}

.survey-personal-info__field {
  text-align: center;
}

.survey-form .survey-personal-info__text-input.form-control {
  max-width: 14rem;
  min-height: 3.5rem;
  margin: 0 auto;
  font-size: 1.125rem;
  text-align: center;
}

/* =============================================================================
   Results step
   ============================================================================= */

.survey-results__title {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Score summary box */
.survey-results__score {
  border-radius: 0.5rem;
  padding: 1.5rem 2rem;
  text-align: center;
  margin-bottom: 3rem;
  color: #fff;
}

.survey-results__score--ok {
  background-color: var(--survey-ok);
}

.survey-results__score--warning {
  background-color: var(--survey-warning);
}

.survey-results__score--danger {
  background-color: var(--survey-danger);
}

/* The label of the range: "OK!", "LET OP!", "STOP!". */
.survey-results__score-intro {
  margin: 0 0 0.25rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
}

.survey-results__score-text {
  font-size: 1.25rem;
  margin: 0;
}

/* Score range interpretation grid */
.survey-results__ranges-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 1.25rem;
}

.survey-results__range-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}

/* Inactive ranges are light; the range of the score is solid. */
.survey-results__range {
  border-radius: 0.5rem;
  border-top: 6px solid;
  padding: 1.25rem;
  color: var(--bs-body-color, #000);
}

.survey-results__range--ok {
  border-color: var(--survey-ok);
  background-color: var(--survey-ok-subtle);
}

.survey-results__range--warning {
  border-color: var(--survey-warning);
  background-color: var(--survey-warning-subtle);
}

.survey-results__range--danger {
  border-color: var(--survey-danger);
  background-color: var(--survey-danger-subtle);
}

.survey-results__range.is-active {
  color: #fff;
}

.survey-results__range--ok.is-active {
  background-color: var(--survey-ok);
}

.survey-results__range--warning.is-active {
  background-color: var(--survey-warning);
}

.survey-results__range--danger.is-active {
  background-color: var(--survey-danger);
}

.survey-results__range-label {
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}

.survey-results__range-description {
  font-size: 1rem;
  margin: 0;
  line-height: 1.5;
}

/* Improvement sections */
.survey-results__section {
  margin-bottom: 3rem;
}

.survey-results__section-title {
  font-size: 2rem;
  margin-bottom: 1rem;
}

/* Individual improvement item */
.survey-improvement {
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.survey-improvement--concern {
  border: 2px solid var(--survey-danger);
}

.survey-improvement--attention {
  border: 2px solid var(--survey-warning);
}

.survey-improvement summary,
.survey-improvement > div:not(.survey-improvement__body) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  list-style: none;
  cursor: pointer;
}

.survey-improvement--concern summary,
.survey-improvement--concern > div:not(.survey-improvement__body) {
  background-color: var(--survey-danger);
  color: #fff;
}

.survey-improvement--attention summary,
.survey-improvement--attention > div:not(.survey-improvement__body) {
  background-color: var(--survey-warning);
  color: #fff;
}

.survey-improvement summary::-webkit-details-marker {
  display: none;
}

.survey-improvement summary:focus-visible {
  outline: 3px solid var(--bs-secondary, #3c5196);
  outline-offset: -3px;
}

.survey-improvement__question-label {
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.35;
  margin: 0 0 0.25rem;
}

.survey-improvement__answer-label {
  font-size: 1rem;
  margin: 0;
}

/* Toggle link texts */
.survey-improvement__toggle-read { display: inline; }
.survey-improvement__toggle-close { display: none; }

.survey-improvement[open] .survey-improvement__toggle-read { display: none; }
.survey-improvement[open] .survey-improvement__toggle-close { display: inline; }

.survey-improvement__toggle-btn {
  white-space: nowrap;
  font-size: 1rem;
  text-decoration: underline;
  flex-shrink: 0;
}

/* Improvement suggestion body: rich text with the .text-paragraph styles of
   the theme (SurveyTakeForm), at the 18px of the form. */
.survey-improvement__body {
  padding: 1.25rem 1.5rem;
  background-color: #fff;
  font-size: 1.125rem;
  line-height: 1.6;
}

.survey-improvement__body h3 {
  font-size: 1.25rem;
  margin-top: 1.25rem;
}

.survey-improvement__body > :last-child {
  margin-bottom: 0;
}

.survey-results__restart {
  margin: 0;
  text-align: center;
  font-size: 1.125rem;
}

@media (max-width: 575.98px) {
  .survey-improvement summary,
  .survey-improvement > div:not(.survey-improvement__body) {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .survey-results__score {
    padding: 1.25rem 1rem;
  }
}
