/* Questionnaire wizard – REDIRECT D1.5 brand styles. */

/* Notched phones: keep chrome clear of safe areas */
body.questionnaire-wizard-page .topbar-inner {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(24px + env(safe-area-inset-right, 0px));
}

body.questionnaire-wizard-page .container {
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 800px) {
    body.questionnaire-wizard-page .topbar-inner {
        padding-top: calc(18px + env(safe-area-inset-top, 0px));
        padding-left: calc(16px + env(safe-area-inset-left, 0px));
        padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }

    body.questionnaire-wizard-page .container {
        padding-left: calc(16px + env(safe-area-inset-left, 0px));
        padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }
}

.wizard-welcome-copy #wizard-page-title {
    color: var(--teal-deep);
    font-weight: 700;
    text-align: center;
}

.wizard-page-header:not(.is-compact) {
    margin-bottom: 0;
    text-align: center;
}

.wizard-page-header:not(.is-compact) .wizard-welcome-copy {
    margin-bottom: 16px;
    text-align: center;
}

/* Compact header after leaving the welcome step */
.wizard-page-header.is-compact {
    margin-bottom: 0;
}

.wizard-welcome-copy[hidden] {
    display: none !important;
}

/* Part title: above question counter (same place on start and throughout) */
.wizard-part-heading {
    margin: 4px 0 12px;
    text-align: center;
}

.wizard-part-heading[hidden] {
    display: none !important;
}

.wizard-current-part {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--teal-deep);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wizard-current-section {
    margin: 4px 0 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wizard-current-section[hidden] {
    display: none !important;
}

.wizard-part-scale-legend {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--ink-soft);
    background: var(--orange-tint);
    border: 1px solid #F3DFB8;
    border-left: 3px solid var(--orange);
    border-radius: 4px;
    padding: 8px 11px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wizard-part-scale-legend[hidden] {
    display: none !important;
}

.wizard-progress {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
}

.wizard-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 16px;
    flex-wrap: wrap;
    margin: 0 0 8px;
}

.wizard-progress-part,
.wizard-progress-overall {
    margin: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    line-height: 1.35;
}

.wizard-progress-part[hidden] {
    display: none;
}

.wizard-progress-overall {
    margin-left: auto;
    text-align: right;
}

.wizard-progress-bar {
    height: 9px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.wizard-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--teal);
    border-radius: 2px;
    transition: width 0.35s ease;
}

.wizard-part-stages {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.wizard-part-stage {
    position: relative;
    overflow: hidden;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
}

.wizard-part-stage-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--part-progress, 0%);
    background: transparent;
    pointer-events: none;
    transition: width 0.35s ease;
    z-index: 0;
}

.wizard-part-stage-label {
    position: relative;
    z-index: 1;
}

.wizard-part-stage.is-current {
    color: var(--orange-deep);
    border-color: var(--orange);
    background: var(--orange-tint);
    font-weight: 700;
}

.wizard-part-stage.is-current .wizard-part-stage-fill {
    background: rgba(245, 166, 35, 0.35);
}

.wizard-part-stage.is-completed {
    color: var(--teal-deep);
    background: var(--teal-tint);
    border-color: var(--teal);
}

.wizard-part-stage.is-completed .wizard-part-stage-fill {
    background: rgba(61, 122, 133, 0.28);
}

.wizard-step {
    min-height: 160px;
    margin-bottom: 16px;
}

.wizard-loading {
    color: var(--ink-soft);
}

.wizard-step-error {
    margin: 0 0 10px;
    color: #9C2C1F;
    font-size: 13px;
    font-weight: 600;
    background: #FBEAE8;
    border: 1px solid #F0C4BE;
    border-radius: 4px;
    padding: 8px 11px;
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 14px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--line-soft);
}

.wizard-nav .btn:disabled,
#wizard-submit.is-loading {
    opacity: 0.72;
    cursor: wait;
    pointer-events: none;
}

#wizard-submit.is-loading {
    position: relative;
}

.wizard-nav #wizard-next,
.wizard-nav #wizard-submit {
    margin-left: auto;
}

@media (max-width: 600px) {
    .wizard {
        padding: 14px 14px 16px;
    }

    .wizard-nav {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .wizard-nav #wizard-next,
    .wizard-nav #wizard-submit,
    .wizard-nav #wizard-back {
        margin-left: 0;
        width: 100%;
    }

    .wizard-current-part {
        font-size: 15px;
    }
}

/* Hidden submit form – answers synced by JS */
.wizard-form[hidden] {
    display: none !important;
}

/* --- Question inputs --- */
.wizard-question-text {
    font-size: 14.5px;
    font-weight: 600;
    margin: 0 0 12px;
    line-height: 1.4;
    color: var(--ink);
}

.wizard-step-title {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-size: 18px;
    font-weight: 700;
    color: var(--teal-deep);
}

.wizard-step-subtitle,
.wizard-step-intro {
    color: var(--ink-soft);
    margin: 0.4em 0;
    font-size: 14px;
}

.wizard-part-intro,
.wizard-section-intro {
    padding: 4px 0 8px;
}

.wizard-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wizard-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    background: var(--paper);
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.wizard-option:hover {
    border-color: var(--teal);
}

.wizard-option.selected,
.wizard-option:has(input:checked) {
    border-color: var(--teal-deep);
    background: var(--teal);
    color: #fff;
}

.wizard-option input {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--teal);
}

.wizard-option.selected input,
.wizard-option:has(input:checked) input {
    accent-color: #fff;
}

.wizard-likert {
    flex-direction: row;
    flex-wrap: wrap;
}

.wizard-likert .wizard-option {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
    flex: 1 1 auto;
    padding: 8px 11px;
}

.wizard-likert .option-dk {
    flex: 1 1 100%;
}

.wizard-likert .option-dk.selected,
.wizard-likert .option-dk:has(input:checked) {
    background: var(--ink-soft);
    border-color: var(--ink-soft);
    color: #fff;
}

/* ≥16px on real form controls — must beat .field input/select from style.css */
.field.wizard-question .wizard-select,
.field.wizard-question .wizard-number,
.field.wizard-question .wizard-other input[type="text"],
.wizard-select,
.wizard-number,
.wizard-other input[type="text"] {
    font-size: 16px;
}

.wizard-select,
.wizard-number {
    width: 100%;
    max-width: 320px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
}

.wizard-select:focus,
.wizard-number:focus,
.wizard-other input[type="text"]:focus {
    outline: none;
    border-color: var(--teal);
}

.wizard-select:focus-visible,
.wizard-number:focus-visible,
.wizard-other input[type="text"]:focus-visible,
.wizard-nav .btn:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(61, 122, 133, 0.2);
}

.wizard-option:focus-within {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}

.wizard-question-text:focus,
.wizard-question-text:focus-visible,
.wizard-step-title:focus,
.wizard-step-title:focus-visible {
    outline: none;
    box-shadow: none;
}

.wizard-other {
    margin-top: 12px;
}

.wizard-other input[type="text"] {
    width: 100%;
    max-width: 400px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
}

@media (max-width: 600px) {
    .wizard-options {
        gap: 6px;
    }

    .wizard-likert .wizard-option {
        flex: 1 1 calc(33.33% - 6px);
    }
}

.wizard-question-legend {
    margin: 0 0 14px;
    padding: 8px 11px;
    border-left-width: 3px;
}

.wizard-question-legend .part-explanation {
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--ink-soft);
    font-weight: 400;
}
