/* ============================================================
   iSFP-Selbsttest (Präfix: isfp-quiz-)
   Gehört zu:  content/isfp-test.html  +  scripts/isfp-test.js
   Eingebunden in: isfp.php, Sektion #isfp-test

   Bewusst ohne CSS-Variablen der Seite, damit die Datei
   unabhängig von der Ladereihenfolge des Fragments funktioniert.
   Farben identisch zum Energieausweis-Test.
   ============================================================ */

.isfp-quiz {
    width: 100%;
    scroll-margin-top: calc(var(--global-header-height, 100px) + 76px);
}

.isfp-quiz [hidden] {
    display: none !important;
}

/* Platzhalter reserviert die Höhe, solange das Fragment lädt.
   Verhindert Layoutsprünge (CLS) beim Nachladen. */
#isfp-test-placeholder:empty {
    min-height: 480px;
}

/* Ohne JavaScript gibt es nichts nachzuladen, dann entfällt die Reserve */
.isfp-test-noscript {
    max-width: 720px;
    margin: 0 auto;
    padding: 22px 26px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 8px;
    color: #5c6353;
    font-size: 0.95rem;
    line-height: 1.65;
    text-align: center;
}

.isfp-test-noscript a {
    color: #55701c;
    font-weight: 600;
}

/* ---------- Horizontaler Phasen-Stepper ---------- */

.isfp-quiz-phases {
    display: flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: 100%;
    margin: 0 auto 40px;
    padding: 12px 28px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 999px;
    list-style: none;
}

.isfp-quiz-phase {
    display: flex;
    align-items: center;
}

.isfp-quiz-phase:not(:last-child)::after {
    content: "";
    width: 44px;
    height: 1px;
    margin: 0 14px;
    background: #d0cdbd;
}

.isfp-quiz-phase-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px;
    background: transparent;
    border: 0;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
}

.isfp-quiz-phase-btn:disabled {
    cursor: default;
}

.isfp-quiz-phase-btn:focus-visible {
    outline: 2px solid #698b22;
    outline-offset: 3px;
    border-radius: 6px;
}

.isfp-quiz-phase-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    background: #ffffff;
    border: 1px solid #b7b4a4;
    border-radius: 50%;
    color: #77806d;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.isfp-quiz-phase-marker svg {
    display: none;
    width: 14px;
    height: 14px;
}

.isfp-quiz-phase-label {
    color: #6f7566;
    font-size: 0.88rem;
    font-weight: 650;
    white-space: nowrap;
    transition: color 0.18s ease;
}

.isfp-quiz-phase[data-state="active"] .isfp-quiz-phase-marker {
    background: #698b22;
    border-color: #698b22;
    color: #ffffff;
}

.isfp-quiz-phase[data-state="active"] .isfp-quiz-phase-label {
    color: #20251b;
}

.isfp-quiz-phase[data-state="done"] .isfp-quiz-phase-marker {
    border-color: #698b22;
    color: #55701c;
}

.isfp-quiz-phase[data-state="done"] .isfp-quiz-phase-marker b {
    display: none;
}

.isfp-quiz-phase[data-state="done"] .isfp-quiz-phase-marker svg {
    display: block;
}

.isfp-quiz-phase[data-state="done"] .isfp-quiz-phase-label {
    color: #20251b;
}

.isfp-quiz-phase[data-state="done"] .isfp-quiz-phase-btn:not(:disabled):hover .isfp-quiz-phase-marker {
    background: #e9ecdd;
}

.isfp-quiz-phase[data-state="skipped"] .isfp-quiz-phase-btn {
    opacity: 0.45;
}

.isfp-quiz-phase[data-state="skipped"] .isfp-quiz-phase-label {
    text-decoration: line-through;
}

/* ---------- Fragenbereich ----------
   Der Rahmen setzt erst hier an, damit der Stepper frei darüber steht. */

.isfp-quiz-main {
    display: flex;
    flex-direction: column;
    min-height: 460px;
    padding: 52px 56px;
    border: 1px solid #dcd9c9;
    border-radius: 10px;
}

/* Inhalt bleibt in lesbarer Breite mittig, der Rahmen darf voll ausladen */
.isfp-quiz-main form,
.isfp-quiz-loading,
.isfp-quiz-result,
.isfp-quiz-note {
    width: 100%;
    max-width: 1040px;
    margin-left: auto;
    margin-right: auto;
}

.isfp-quiz-main form {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.isfp-quiz-question {
    margin: 0;
    padding: 0;
    border: 0;
    animation: isfp-quiz-in 0.26s ease;
}

@keyframes isfp-quiz-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.isfp-quiz-question-title {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    padding: 0;
    color: #20251b;
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.3;
    text-align: center;
    outline: none;
}

.isfp-quiz-question-hint {
    max-width: 560px;
    margin: 0 auto;
    color: #5c6353;
    font-size: 0.92rem;
    line-height: 1.6;
    text-align: center;
}

.isfp-quiz-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 30px;
}

/* Dreispaltig, wenn die Frage drei gleichwertige Optionen hat */
.isfp-quiz-options--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Mehrfachauswahl: eckiger Marker statt Kreis, damit der Unterschied
   zur Einfachauswahl auf den ersten Blick erkennbar ist */
.isfp-quiz-options--multi .isfp-quiz-option-check {
    border-radius: 6px;
}

/* Zwischenüberschrift im Optionsraster, läuft über die volle Breite */
.isfp-quiz-optgroup {
    grid-column: 1 / -1;
    margin: 10px 0 0;
    color: #77806d;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.isfp-quiz-optgroup:first-child {
    margin-top: 0;
}

.isfp-quiz-options > input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.isfp-quiz-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 19px 20px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 7px;
    cursor: pointer;
    transition: border-color 0.16s ease;
}

.isfp-quiz-option:hover {
    border-color: #9fa993;
}

.isfp-quiz-option-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: #eef3e0;
    border-radius: 9px;
    color: #55701c;
}

.isfp-quiz-option-icon svg {
    width: 27px;
    height: 27px;
}

.isfp-quiz-option-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding-right: 34px;
}

.isfp-quiz-option-copy strong {
    color: #20251b;
    font-size: 0.99rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.isfp-quiz-option-copy small {
    color: #687064;
    font-size: 0.8rem;
    line-height: 1.45;
}

.isfp-quiz-option-check {
    position: absolute;
    top: 50%;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    background: #ffffff;
    border: 1px solid #ccd2bd;
    border-radius: 50%;
    color: #ffffff;
    transform: translateY(-50%);
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.isfp-quiz-option-check svg {
    width: 13px;
    height: 13px;
    opacity: 0;
    transition: opacity 0.16s ease;
}

.isfp-quiz-options > input:checked + .isfp-quiz-option {
    border-color: #55701c;
    box-shadow: inset 0 0 0 1px #55701c;
}

.isfp-quiz-options > input:checked + .isfp-quiz-option .isfp-quiz-option-check {
    background: #55701c;
    border-color: #55701c;
}

.isfp-quiz-options > input:checked + .isfp-quiz-option .isfp-quiz-option-check svg {
    opacity: 1;
}

.isfp-quiz-options > input:focus-visible + .isfp-quiz-option {
    outline: 2px solid #698b22;
    outline-offset: 3px;
}

/* ---------- Freie Eingabe (Baujahr) ---------- */

.isfp-quiz-field {
    width: 100%;
    max-width: 300px;
    margin: 30px auto 0;
}

.isfp-quiz-field-label {
    display: block;
    margin-bottom: 8px;
    color: #77806d;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    text-align: center;
}

.isfp-quiz-field input {
    width: 100%;
    padding: 15px 18px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 7px;
    color: #20251b;
    font-family: inherit;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-align: center;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.isfp-quiz-field input::placeholder {
    color: #a8ad9f;
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: 0;
}

.isfp-quiz-field input:focus {
    border-color: #55701c;
    box-shadow: 0 0 0 3px rgba(105, 139, 34, 0.14);
}

.isfp-quiz-field input.is-invalid {
    border-color: #c8452f;
}

.isfp-quiz-field input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(200, 69, 47, 0.14);
}

.isfp-quiz-field-error {
    margin: 10px 0 0;
    color: #c8452f;
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: center;
}

.isfp-quiz-field-error[hidden] {
    display: none;
}

/* ---------- Fußzeile der Frageansicht ---------- */

.isfp-quiz-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: auto;
    padding-top: 26px;
}

.isfp-quiz-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid #bcb9a9;
    border-radius: 5px;
    color: #20251b;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
    transition: border-color 0.16s ease, color 0.16s ease;
}

.isfp-quiz-back::before {
    content: "←";
}

.isfp-quiz-back:hover {
    border-color: #55701c;
    color: #55701c;
}

.isfp-quiz-footer-hint {
    margin-left: auto;
    color: #68705f;
    font-size: 0.78rem;
    text-align: right;
}

.isfp-quiz-next {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    margin-left: auto;
    padding: 10px 18px;
    background: #55701c;
    border: 1px solid #55701c;
    border-radius: 5px;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.isfp-quiz-next::after {
    content: "→";
}

.isfp-quiz-next:hover {
    background: #465d17;
    border-color: #465d17;
}

/* ---------- Ladeansicht ---------- */

.isfp-quiz-loading {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 320px;
    text-align: center;
}

.isfp-quiz-loading p {
    margin: 0;
    color: #5c6353;
    font-size: 0.95rem;
}

.isfp-quiz-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid #ddd9c9;
    border-top-color: #698b22;
    border-radius: 50%;
    animation: isfp-quiz-spin 0.85s linear infinite;
}

@keyframes isfp-quiz-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Ergebnisansicht ---------- */

.isfp-quiz-result {
    animation: isfp-quiz-in 0.26s ease;
}

.isfp-quiz-result-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px 28px;
    padding: 26px 30px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 8px;
}

.isfp-quiz-result-intro {
    min-width: 0;
    max-width: 560px;
}

.isfp-quiz-result-kicker {
    display: block;
    margin-bottom: 7px;
    color: #55701c;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Gedämpfte Variante, wenn der Bonus nicht greift */
.isfp-quiz-result[data-tone="neutral"] .isfp-quiz-result-kicker {
    color: #77806d;
}

.isfp-quiz-result-title {
    margin: 0 0 10px;
    color: #20251b;
    font-size: clamp(1.6rem, 2.5vw, 2.15rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
}

.isfp-quiz-result-note {
    margin: 0;
    color: #5c6353;
    font-size: 0.93rem;
    line-height: 1.65;
}

.isfp-quiz-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.isfp-quiz-request {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 22px;
    background: #191b1a;
    border: 1px solid #191b1a;
    border-radius: 5px;
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.isfp-quiz-request:hover {
    background: #2b2e2c;
    border-color: #2b2e2c;
}

/* Sekundärer Weg, z. B. Verweis auf die Heizungsförderung */
.isfp-quiz-request-alt {
    background: transparent;
    border-color: #191b1a;
    color: #191b1a;
}

.isfp-quiz-request-alt:hover {
    background: #191b1a;
    border-color: #191b1a;
    color: #ffffff;
}

.isfp-quiz-request-alt[hidden] {
    display: none;
}

.isfp-quiz-restart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 18px;
    background: transparent;
    border: 1px solid #bcb9a9;
    border-radius: 5px;
    color: #20251b;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 650;
    cursor: pointer;
    transition: border-color 0.16s ease, color 0.16s ease;
}

.isfp-quiz-restart:hover {
    border-color: #55701c;
    color: #55701c;
}

/* Kennzahl zur Kostenstaffel, je nach Anzahl der Wohneinheiten */
.isfp-quiz-figure {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin-top: 18px;
    padding: 18px 22px;
    background: #eef3e0;
    border: 1px solid #dde5c8;
    border-radius: 8px;
}

.isfp-quiz-figure-value {
    color: #55701c;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.isfp-quiz-figure-label {
    color: #4b5244;
    font-size: 0.88rem;
    line-height: 1.5;
}

.isfp-quiz-detail {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 34px;
}

/* Ergänzender Hinweis innerhalb eines Detailblocks */
.isfp-quiz-inline-note {
    margin: 0;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-left: 3px solid #698b22;
    border-radius: 6px;
    color: #5c6353;
    font-size: 0.9rem;
    line-height: 1.6;
}

.isfp-quiz-inline-note strong {
    color: #20251b;
}

.isfp-quiz-inline-note[hidden] {
    display: none;
}

.isfp-quiz-detail-block h5 {
    margin: 0 0 14px;
    color: #55701c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.isfp-quiz-check-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.isfp-quiz-check-list li {
    position: relative;
    padding-left: 26px;
    color: #4b5244;
    font-size: 0.92rem;
    line-height: 1.6;
}

.isfp-quiz-check-list li::before {
    content: "✓";
    position: absolute;
    top: 0;
    left: 0;
    color: #698b22;
    font-weight: 700;
}

/* Ausschluss-Liste, gleiche Form aber neutrales Zeichen */
.isfp-quiz-check-list--plain li::before {
    content: "→";
    color: #77806d;
}

.isfp-quiz-doc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.isfp-quiz-doc {
    padding: 18px 20px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 7px;
    transition: border-color 0.18s ease;
}

.isfp-quiz-doc:hover {
    border-color: #b9c19f;
}

.isfp-quiz-doc span {
    display: block;
    color: #698b22;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.isfp-quiz-doc strong {
    display: block;
    margin: 7px 0 4px;
    color: #20251b;
    font-size: 0.95rem;
    font-weight: 700;
}

.isfp-quiz-doc p {
    margin: 0;
    color: #5c6353;
    font-size: 0.85rem;
    line-height: 1.55;
}

.isfp-quiz-answers-block {
    margin-top: 30px;
    padding-top: 26px;
    border-top: 1px solid #d8d5c5;
}

.isfp-quiz-answers-label {
    display: block;
    margin-bottom: 12px;
    color: #77806d;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.isfp-quiz-answers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.isfp-quiz-answer-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    background: #ffffff;
    border: 1px solid #dcd9c9;
    border-radius: 999px;
    color: #20251b;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.16s ease;
}

.isfp-quiz-answer-chip span {
    color: #77806d;
}

.isfp-quiz-answer-chip strong {
    font-weight: 650;
}

.isfp-quiz-answer-chip svg {
    width: 12px;
    height: 12px;
    color: #698b22;
}

.isfp-quiz-answer-chip:hover {
    border-color: #9fa993;
}

.isfp-quiz-note {
    margin: 30px auto 0;
    padding-top: 20px;
    border-top: 1px solid #d8d5c5;
    color: #68705f;
    font-size: 0.78rem;
    text-align: center;
}

/* ---------- Responsive ---------- */

@media (prefers-reduced-motion: reduce) {
    .isfp-quiz-question,
    .isfp-quiz-result {
        animation: none;
    }
}

@media (max-width: 960px) {
    .isfp-quiz-main {
        padding: 36px 32px;
    }

    .isfp-quiz-options--three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .isfp-quiz-main {
        padding: 26px 20px;
        border-radius: 8px;
        min-height: 0;
    }

    .isfp-quiz-phases {
        margin-bottom: 30px;
        padding: 9px 16px;
    }

    .isfp-quiz-phase:not(:last-child)::after {
        width: 18px;
        margin: 0 8px;
    }

    .isfp-quiz-phase-btn {
        gap: 7px;
    }

    .isfp-quiz-phase-marker {
        width: 29px;
        height: 29px;
    }

    .isfp-quiz-phase-label {
        font-size: 0.76rem;
    }

    .isfp-quiz-question-title,
    .isfp-quiz-question-hint {
        text-align: left;
    }

    .isfp-quiz-options,
    .isfp-quiz-options--three {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 22px;
    }

    .isfp-quiz-option {
        padding: 16px;
    }

    .isfp-quiz-option-icon {
        width: 48px;
        height: 48px;
    }

    .isfp-quiz-footer {
        flex-wrap: wrap;
        padding-top: 20px;
    }

    .isfp-quiz-back,
    .isfp-quiz-next {
        flex: 1 1 auto;
        justify-content: center;
    }

    .isfp-quiz-footer-hint {
        flex-basis: 100%;
        order: 3;
        margin: 0;
        text-align: center;
    }

    .isfp-quiz-result-head {
        align-items: stretch;
        flex-direction: column;
        padding: 20px;
    }

    .isfp-quiz-result-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 620px) {
    .isfp-quiz-doc-grid {
        grid-template-columns: 1fr;
    }

    .isfp-quiz-phase-label {
        display: none;
    }

    .isfp-quiz-phase[data-state="active"] .isfp-quiz-phase-label {
        display: block;
    }
}
