/* =============================================
   Hydrafizz Quiz — Frontend (scoped, no globals)
   ============================================= */

.hfq-quiz-wrap,
.hfq-result-wrap {
    font-family: var(--hfq-font, 'Indivisible', inherit, sans-serif);
    font-size: var(--hfq-size, 18px);
    color: var(--hfq-color, #272B5B);
    font-weight: 500;
    box-sizing: border-box;
    max-width: 100%;
}

/* The quiz is at most 1140px wide on desktop and centered; on smaller
   screens it simply fills the available width. */
.hfq-quiz-wrap {
    width: 100%;
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
}

.hfq-quiz-wrap *,
.hfq-result-wrap * {
    box-sizing: border-box;
}

/* Top bar: centered stepper (dots + connector lines) with the visible
   "Question X sur Y" counter on the right, all on one row. */
.hfq-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.hfq-stepper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    gap: 0;
}

.hfq-progress-text {
    flex: 0 0 auto;
    margin: 0;
    font-size: 0.78em;
    font-weight: 700;
    color: var(--hfq-color, #272B5B);
    white-space: nowrap;
}

.hfq-step {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(39, 43, 91, 0.2);
    background: #fff;
    color: var(--hfq-color, #272B5B);
    opacity: 0.6;
    font-size: 0.72em;
    font-weight: 600;
    line-height: 1;
    transition: background 0.25s, color 0.25s, border-color 0.25s, opacity 0.25s;
}

/* Connector line between consecutive dots */
.hfq-step-line {
    flex: 1 1 12px;
    max-width: 46px;
    height: 2px;
    background: rgba(39, 43, 91, 0.15);
    transition: background 0.25s;
}

.hfq-step-line-done {
    background: var(--hfq-btn-bg, #272B5B);
}

.hfq-step-active {
    background: var(--hfq-btn-bg, #272B5B);
    border-color: var(--hfq-btn-bg, #272B5B);
    color: #fff;
    opacity: 1;
}

/* Completed step: filled dot with a check mark instead of the number */
.hfq-step-done {
    background: var(--hfq-btn-bg, #272B5B);
    border-color: var(--hfq-btn-bg, #272B5B);
    color: #fff;
    opacity: 0.9;
    font-size: 0;
}

.hfq-step-done::after {
    content: '\2713';
    font-size: 13px;
    line-height: 1;
}

/* Screen-reader-only progress text ("Vraag X van Y") */
.hfq-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* White card holding the question area + prev/next navigation. Takes ~75%
   of the viewport height so the layout never jumps between questions. */
.hfq-card {
    display: flex;
    flex-direction: column;
    min-height: 75vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 6px 28px rgba(39, 43, 91, 0.08);
    padding: 24px;
}

/* Question area */
.hfq-question-wrap {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.hfq-question {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* Image column: ALWAYS the same fixed size so nothing shifts between
   questions. The photo FILLS the frame completely (object-fit: cover), so
   there are never empty bands around it; the soft backdrop only shows
   while the photo is still loading. */
.hfq-question-image-wrap {
    margin-bottom: 20px;
    height: 240px;
    border-radius: 12px;
    overflow: hidden;
    flex: 0 0 auto;
    background: rgba(39, 43, 91, 0.05);
}

/* The responsive <picture> wrapper must be a transparent, frame-filling
   box so the img inside can size itself against the wrap. */
.hfq-question-image-wrap picture {
    display: block;
    width: 100%;
    height: 100%;
}

/* Two-column layout: image left, question + answers right (desktop only) */
@media (min-width: 768px) {
    .hfq-question.hfq-has-image {
        display: grid;
        grid-template-columns: minmax(0, 11fr) minmax(0, 9fr);
        gap: 40px;
        /* Vertically CENTER both columns on the row's midline. The photo
           frame has a FIXED size (aspect-ratio below) and never stretches;
           the text column grows symmetrically up AND down around the same
           midline, so the optical weight stays stable between questions. */
        align-items: center;
        flex: 1 1 auto;
    }
    .hfq-question.hfq-has-image .hfq-question-image-wrap {
        margin-bottom: 0;
        /* FIXED frame: always the exact same 1200:1300 shape, regardless of
           the uploaded photo's dimensions or the amount of content beside
           it. Width comes from the grid column, height follows the ratio. */
        height: auto;
        aspect-ratio: 1200 / 1300;
    }
    /* Fallback for old browsers without aspect-ratio support: the classic
       padding-top trick keeps the exact same fixed 1200:1300 frame. */
    @supports not (aspect-ratio: 1 / 1) {
        .hfq-question.hfq-has-image .hfq-question-image-wrap {
            height: 0;
            padding-top: calc(1300 / 1200 * 100%);
            position: relative;
        }
        .hfq-question.hfq-has-image .hfq-question-image-wrap picture {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
    }
    /* Questions without an image keep the exact same content geometry: an
       invisible placeholder with the exact 1200:1300 frame shape reserves
       the image column, so the text sits at the same horizontal position
       AND is centered on the same vertical midline as questions WITH a
       photo — nothing jumps between question types. */
    .hfq-question:not(.hfq-has-image) {
        display: grid;
        grid-template-columns: minmax(0, 11fr) minmax(0, 9fr);
        gap: 40px;
        align-items: center;
        flex: 1 1 auto;
    }
    .hfq-question:not(.hfq-has-image)::before {
        content: '';
        grid-column: 1;
        grid-row: 1;
        height: auto;
        aspect-ratio: 1200 / 1300;
    }
    .hfq-question:not(.hfq-has-image) .hfq-question-content {
        grid-column: 2;
        grid-row: 1;
    }
    /* Same placeholder shape for old browsers without aspect-ratio. */
    @supports not (aspect-ratio: 1 / 1) {
        .hfq-question:not(.hfq-has-image)::before {
            height: 0;
            padding-top: calc(1300 / 1200 * 100%);
        }
    }
}

.hfq-question-image-wrap img,
.hfq-question-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    /* The photo always FILLS its frame; edges are cropped when the aspect
       ratio differs (admins upload separate desktop/mobile photos, so the
       crop stays minimal). */
    object-fit: cover;
    /* Default: keep the center of the photo in view when cropping. */
    object-position: center center;
    border-radius: 12px;
    display: block;
    margin: 0;
}

/* Per-question crop focus, chosen in the admin ("Foto-uitlijning"):
   which side of the photo stays visible when cover-cropping. */
.hfq-question-image-wrap img.hfq-img-pos-left {
    object-position: left center;
}

.hfq-question-image-wrap img.hfq-img-pos-right {
    object-position: right center;
}

.hfq-question-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.hfq-question-title {
    font-size: 1.3em;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--hfq-color, #272B5B);
    line-height: 1.3;
}

.hfq-question-text {
    margin: 0 0 24px;
    line-height: 1.55;
    opacity: 0.8;
}

/* Answers */
.hfq-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hfq-answer-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 20px;
    background: #fff;
    border: 2px solid rgba(39, 43, 91, 0.18);
    border-radius: var(--hfq-btn-radius, 8px);
    box-shadow: 0 2px 8px rgba(39, 43, 91, 0.06);
    color: var(--hfq-color, #272B5B);
    font-family: var(--hfq-font, 'Indivisible', inherit, sans-serif);
    font-size: var(--hfq-size, 18px);
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.1s;
    line-height: 1.3;
    /* Defensive: themes/Elementor often set white-space:nowrap on buttons,
       which clips long answers on mobile. Force wrapping and auto height. */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    height: auto;
    min-height: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* All button states set background, color AND border explicitly, with
   !important, so global theme/Elementor hover colors (e.g. red) can never
   bleed through. Colors always follow the "Buttonkleur" setting.
   Rest: filled in the configured button color with white text. */
.hfq-quiz-wrap .hfq-answer-btn {
    background: var(--hfq-btn-bg, #272B5B) !important;
    color: #fff !important;
    border-color: var(--hfq-btn-bg, #272B5B) !important;
}

/* Hover/focus: transparent with only the blue border + blue text */
.hfq-quiz-wrap .hfq-answer-btn:hover,
.hfq-quiz-wrap .hfq-answer-btn:focus,
.hfq-quiz-wrap .hfq-answer-btn:focus-visible,
.hfq-quiz-wrap .hfq-answer-btn:active {
    background: transparent !important;
    color: var(--hfq-btn-bg, #272B5B) !important;
    border-color: var(--hfq-btn-bg, #272B5B) !important;
    box-shadow: 0 4px 14px rgba(39, 43, 91, 0.12);
    outline: none;
}

.hfq-answer-btn:active {
    transform: scale(0.98);
}

/* Chosen answer: keeps the "hover" look permanently — transparent with the
   blue border and blue bold text — so it clearly stands out from the filled
   rest state, also while hovered. */
.hfq-quiz-wrap .hfq-answer-btn.hfq-selected,
.hfq-quiz-wrap .hfq-answer-btn.hfq-selected:hover,
.hfq-quiz-wrap .hfq-answer-btn.hfq-selected:focus,
.hfq-quiz-wrap .hfq-answer-btn.hfq-selected:focus-visible,
.hfq-quiz-wrap .hfq-answer-btn.hfq-selected:active {
    background: transparent !important;
    border-color: var(--hfq-btn-bg, #272B5B) !important;
    color: var(--hfq-btn-bg, #272B5B) !important;
    font-weight: 700;
}

/* Optional per-answer SVG icon */
.hfq-answer-icon {
    display: inline-flex;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
}

.hfq-answer-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Default icon handling (no custom icon colors configured): on the filled
   blue rest state the icon is inverted to white for contrast; on the
   transparent hover/selected states the SVG keeps its own colors. */
.hfq-answer-btn .hfq-answer-icon svg {
    filter: brightness(0) invert(1);
}

.hfq-answer-btn:hover .hfq-answer-icon svg,
.hfq-answer-btn:focus .hfq-answer-icon svg,
.hfq-answer-btn:focus-visible .hfq-answer-icon svg,
.hfq-answer-btn:active .hfq-answer-icon svg,
.hfq-answer-btn.hfq-selected .hfq-answer-icon svg {
    filter: none;
}

.hfq-answer-label {
    flex: 1 1 auto;
    min-width: 0;
}

/* Loading */
.hfq-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 0;
    color: var(--hfq-color, #272B5B);
    opacity: 0.75;
}

.hfq-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(39, 43, 91, 0.2);
    border-top-color: var(--hfq-btn-bg, #272B5B);
    border-radius: 50%;
    animation: hfq-spin 0.7s linear infinite;
}

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

/* Error */
.hfq-error-msg,
.hfq-error {
    color: #c0392b;
    margin: 12px 0;
    padding: 12px 16px;
    border: 1px solid #e74c3c;
    border-radius: 6px;
    background: #fdf2f2;
    font-size: 0.9em;
}

/* Inline validation error (required question not answered) */
.hfq-inline-error {
    color: #c0392b;
    font-size: 0.82em;
    margin: 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hfq-inline-error::before {
    content: '⚠';
    flex-shrink: 0;
}

/* Prev/Next navigation: pill buttons pinned to the bottom of the card */
.hfq-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    flex: 0 0 auto;
}

.hfq-prev-btn,
.hfq-next-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 26px;
    border-radius: 999px;
    font-family: var(--hfq-font, 'Indivisible', inherit, sans-serif);
    font-size: 0.9em;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, opacity 0.18s;
}

.hfq-quiz-wrap .hfq-prev-btn {
    background: #fff !important;
    border: 1px solid rgba(39, 43, 91, 0.25) !important;
    color: var(--hfq-color, #272B5B) !important;
    box-shadow: 0 2px 8px rgba(39, 43, 91, 0.06);
}

.hfq-quiz-wrap .hfq-prev-btn:hover,
.hfq-quiz-wrap .hfq-prev-btn:focus,
.hfq-quiz-wrap .hfq-prev-btn:focus-visible,
.hfq-quiz-wrap .hfq-prev-btn:active {
    background: transparent !important;
    border-color: var(--hfq-btn-bg, #272B5B) !important;
    color: var(--hfq-btn-bg, #272B5B) !important;
    outline: none;
}

/* Next: filled blue by default… */
.hfq-quiz-wrap .hfq-next-btn {
    background: var(--hfq-btn-bg, #272B5B) !important;
    border: 1px solid var(--hfq-btn-bg, #272B5B) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(39, 43, 91, 0.18);
}

/* …and transparent with only the blue border + blue text on hover */
.hfq-quiz-wrap .hfq-next-btn:hover,
.hfq-quiz-wrap .hfq-next-btn:focus,
.hfq-quiz-wrap .hfq-next-btn:focus-visible,
.hfq-quiz-wrap .hfq-next-btn:active {
    background: transparent !important;
    border-color: var(--hfq-btn-bg, #272B5B) !important;
    color: var(--hfq-btn-bg, #272B5B) !important;
    outline: none;
}

/* Stop message: replaces the whole quiz when a stop-flagged answer is chosen */
.hfq-stop-message {
    padding: 24px 28px;
    border: 2px solid var(--hfq-btn-bg, #272B5B);
    border-radius: var(--hfq-btn-radius, 8px);
    background: rgba(39, 43, 91, 0.06);
    color: var(--hfq-color, #272B5B);
    font-weight: 500;
    line-height: 1.55;
}

.hfq-stop-message p {
    margin: 0;
}

/* Deliberate restart button under the stop message. All states are pinned
   with !important so theme button styles (red hover/focus) cannot bleed in —
   same approach as the prev/next buttons. */
.hfq-quiz-wrap .hfq-restart-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--hfq-btn-bg, #272B5B) !important;
    border: 1px solid var(--hfq-btn-bg, #272B5B) !important;
    border-radius: var(--hfq-btn-radius, 8px);
    color: #fff !important;
    font-family: var(--hfq-font, 'Indivisible', inherit, sans-serif);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
}

/* Transparent with only the blue border + blue text on hover/focus/active */
.hfq-quiz-wrap .hfq-restart-btn:hover,
.hfq-quiz-wrap .hfq-restart-btn:focus,
.hfq-quiz-wrap .hfq-restart-btn:focus-visible,
.hfq-quiz-wrap .hfq-restart-btn:active {
    background: transparent !important;
    border-color: var(--hfq-btn-bg, #272B5B) !important;
    color: var(--hfq-btn-bg, #272B5B) !important;
    outline: none;
}

/* Fallback */
.hfq-fallback {
    color: var(--hfq-color, #272B5B);
    opacity: 0.65;
    padding: 16px 0;
}

/* Result */
.hfq-result-score {
    font-weight: 700;
    color: var(--hfq-color, #272B5B);
}

.hfq-product-block {
    width: 100%;
}

/* Question transition: a quick fade out → fade in (~0.5s total) for a
   premium feel without making the user wait. Pure opacity, no slide. */
.hfq-question--entering {
    animation: hfq-fade-in 0.28s ease forwards;
}

.hfq-question--leaving {
    animation: hfq-fade-out 0.22s ease forwards;
}

/* Loading state fades in with the same gentle timing as a question. */
.hfq-loading--entering {
    animation: hfq-fade-in 0.25s ease forwards;
}

@keyframes hfq-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes hfq-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* Respect users who prefer reduced motion: swap instantly, no fade. */
@media (prefers-reduced-motion: reduce) {
    .hfq-question--entering,
    .hfq-question--leaving,
    .hfq-loading--entering {
        animation: none;
    }
}

/* Responsive */
@media (max-width: 599px) {
    .hfq-question-title {
        font-size: 1.1em;
    }
    .hfq-card {
        padding: 16px;
        min-height: 0;
    }
    .hfq-topbar {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    .hfq-progress-text {
        text-align: center;
    }
}

/* ------------------------------------------------------------------ *
 * Admin-only score-debug panel
 * Deliberately styled distinct from the quiz (dark "developer" look)
 * so it never reads as part of the visitor-facing experience.
 * ------------------------------------------------------------------ */
.hfq-debug {
    margin-top: 18px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.hfq-debug-toggle {
    display: inline-block;
    background: #1f2430;
    color: #e6e6e6;
    border: 1px solid #3a4150;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.2;
}
.hfq-debug-toggle:hover {
    background: #2a3140;
}
.hfq-debug-body {
    margin-top: 10px;
    background: #11151c;
    color: #e6e6e6;
    border: 1px solid #2c333f;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
}
.hfq-debug-head {
    font-weight: 700;
    color: #9ad0ff;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.hfq-debug-empty,
.hfq-debug-loading {
    color: #9aa3b2;
    font-style: italic;
}
.hfq-debug-err {
    color: #ff9a9a;
}
.hfq-debug-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}
.hfq-debug-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px solid #1c222c;
}
.hfq-debug-row:last-child {
    border-bottom: none;
}
.hfq-debug-q {
    color: #cdd5e1;
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}
.hfq-debug-calc {
    color: #7fd1a0;
    white-space: nowrap;
    text-align: right;
}
.hfq-debug-calc strong {
    color: #fff;
}
.hfq-debug-totals {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #2c333f;
}
.hfq-debug-totals > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.hfq-debug-totals span {
    color: #9aa3b2;
}
.hfq-debug-totals strong {
    color: #ffd479;
}
