/**
 * Quiz Page Styles
 *
 * @package Inspire_Resources
 */

/* ==========================================================================
   Quiz Page
   ========================================================================== */

.quiz-page .resource-hero {
    background-position: right top;
    background-size: cover;
}

.quiz-page .resource-hero__title {
    font-family: var(--font-primary);
    font-size: 45px;
    letter-spacing: 1px;
    max-width: 70%;
    margin: 0 auto;
}

.quiz-page .resource-hero__description {
    font-family: var(--font-primary);
    font-size: 18px;
    color: #fff;
    line-height: 1.7;
    max-width: 70%;
    margin: 20px auto 0;
    text-align: center;
}

.quiz-page .resource-hero__description p {
    margin: 0;
}

.quiz-form-section {
    padding: 80px 0 0;
    background-color: #fff;
    background-image: url('/wp-content/uploads/2025/12/form-background-overlay.png');
    background-size: 80% auto;
    background-position: center bottom 0px;
    background-repeat: no-repeat;
}

.quiz-form-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

/* Gravity Forms Styling Override */
.quiz-page .gform_wrapper {
    position: relative;
    z-index: 30;
}

/* Progress bar wrapper - positioned via JS */
.quiz-page .gform_wrapper .gf_progressbar_wrapper {
    margin-top: 30px !important;
    margin-bottom: 15px !important;
}

/* Form heading styles */
.quiz-page .form-heading {
    color: #57499e;
    font-size: 27px;
    margin: 0;
    font-family: var(--font-primary);
}

.quiz-page .form-subheading {
    color: #57499e;
    font-size: 18px;
    margin: 0;
    font-family: var(--font-primary);
}

.quiz-page .form-heading-underline {
    width: 45%;
    height: 2px;
    background: #57499e;
    margin-bottom: 40px;
}

/* Form headings */
.quiz-page .gform_wrapper.gravity-theme h3 {
    color: #57499e !important;
    font-size: var(--step-1);
    margin: 0px !important;
    font-weight: 700;
}

.quiz-page .gform_wrapper.gravity-theme h3 + hr,
.quiz-page .gform_wrapper .form-heading-underline {
    display: block;
    width: 400px;
    max-width: 100%;
    height: 2px;
    background-color: #57499e;
    border: none;
    margin: 15px 0 30px 0;
}

/* Radio field styling - target the fieldset container */
.quiz-page .gform_wrapper fieldset.gfield.gfield--type-radio {
    background-color: #f5fcfb !important;
    box-shadow: 0px 4px 25px 0px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    margin: 20px 0 !important;
    position: relative !important;
    padding: 30px 40px !important;
    padding-top: 30px !important;
    border-radius: 4px !important;
    overflow: visible;
}

/* E background only on first question */
.quiz-page .gform_wrapper fieldset.gfield.gfield--type-radio:first-of-type {
    background-image: url('/wp-content/uploads/2025/12/form-first-question-background.png') !important;
    background-position: left bottom !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
}

/* Legend (label) inside fieldset - needs special handling */
.quiz-page .gform_wrapper fieldset.gfield.gfield--type-radio legend.gfield_label,
.quiz-page .gform_wrapper fieldset.gfield--type-radio > legend {
    display: block !important;
    position: relative !important;
    float: left !important;
    width: 100% !important;
    font-size: 16px !important;
    font-family: 'Area Normal', sans-serif !important;
    font-weight: 400 !important;
    color: #333 !important;
    line-height: 1.6 !important;
    margin: 0 0 20px 0 !important;
    padding: 0 !important;
    background: transparent !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
}

.quiz-page .gform_wrapper fieldset.gfield--type-radio .ginput_container_radio {
    margin-top: 0;
    clear: both;
}

.quiz-page .gform_wrapper fieldset.gfield--type-radio .ginput_container_radio .gchoice {
    padding: 8px 0;
    display: flex;
    align-items: center;
}

.quiz-page .gform_wrapper fieldset.gfield--type-radio .ginput_container_radio .gfield-choice-input {
    width: 18px;
    height: 18px;
    border: 1px solid #ccc !important;
    border-radius: 3px !important;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    flex-shrink: 0;
}

.quiz-page .gform_wrapper fieldset.gfield--type-radio .ginput_container_radio .gfield-choice-input:checked {
    background-color: #00ac90 !important;
    border-color: #00ac90 !important;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e") !important;
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

.quiz-page .gform_wrapper fieldset.gfield--type-radio .ginput_container_radio .gfield-choice-input + label {
    margin-left: 12px;
    font-family: var(--font-primary);
    font-size: 15px;
    color: #333;
    cursor: pointer;
    width: 100%;
    padding: 0.5em;
}

/* Progress Bar Wrapper */
.quiz-page .gform_wrapper .gf_progressbar_wrapper {
    position: relative !important;
}

/* Progress Bar */
.quiz-page .gform_wrapper .gf_progressbar,
.quiz-page .gform_wrapper.gravity-theme .gf_progressbar {
    border-radius: 50px !important;
    overflow: hidden !important;
    background-color: #00ac90 !important;
    background: #00ac90 !important;
    padding: 6px !important;
    position: relative !important;
    height: 55px !important;
    box-sizing: border-box !important;
    border: none !important;
}

.quiz-page .gform_wrapper .gf_progressbar .gf_progressbar_percentage,
.quiz-page .gform_wrapper.gravity-theme .gf_progressbar .gf_progressbar_percentage {
    background-color: #57499e !important;
    background: #57499e !important;
    border-radius: 40px !important;
    position: absolute !important;
    left: 6px !important;
    top: 6px !important;
    bottom: 6px !important;
    min-width: 50px !important;
    height: auto !important;
}

/* Center the percentage text in the entire bar */
.quiz-page .gform_wrapper .gf_progressbar .gf_progressbar_percentage span,
.quiz-page .gform_wrapper.gravity-theme .gf_progressbar .gf_progressbar_percentage span {
    position: absolute !important;
    top: 50% !important;
    left: 0 !important;
    transform: translateY(-50%) !important;
    width: 900px !important;
    max-width: 90vw !important;
    text-align: center !important;
    font-size: 24px !important;
    font-family: 'Area Normal', sans-serif !important;
    font-weight: 500 !important;
    color: #fff !important;
    z-index: 10 !important;
    pointer-events: none !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
}

.quiz-page .gf_progressbar_title {
    display: none !important;
}

/* Form Buttons */
.quiz-page .gform_wrapper .gform_page_footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quiz-page .gform_wrapper .gform_page_footer button,
.quiz-page .gform_wrapper .gform_page_footer input[type=button],
.quiz-page .gform_wrapper .gform_page_footer input[type=submit],
.quiz-page .gform_wrapper .gform_footer button,
.quiz-page .gform_wrapper .gform_footer input[type=button],
.quiz-page .gform_wrapper .gform_footer input[type=submit] {
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 20px;
    font-family: var(--font-primary);
    background-color: #00ac90;
    padding: 15px 60px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-page .gform_wrapper .gform_page_footer button:hover,
.quiz-page .gform_wrapper .gform_page_footer input[type=button]:hover,
.quiz-page .gform_wrapper .gform_page_footer input[type=submit]:hover,
.quiz-page .gform_wrapper .gform_footer button:hover,
.quiz-page .gform_wrapper .gform_footer input[type=button]:hover,
.quiz-page .gform_wrapper .gform_footer input[type=submit]:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Previous button - purple */
.quiz-page .gform_wrapper .gform_page_footer .gform_previous_button,
.quiz-page .gform_wrapper .gform_page_footer input[type=button].gform_previous_button {
    background-color: #57499e;
    padding: 15px 40px;
}

/* Next button - teal, float right */
.quiz-page .gform_wrapper .gform_page_footer .gform_next_button,
.quiz-page .gform_wrapper .gform_page_footer input[type=button].gform_next_button {
    background-color: #00ac90;
    margin-left: auto;
}

/* Submit button */
.quiz-page .gform_wrapper .gform_page_footer input[type=submit],
.quiz-page .gform_wrapper .gform_footer input[type=submit] {
    background-color: #00ac90;
    padding: 15px 40px;
    min-width: 180px;
    position: relative;
}

/* ==========================================================================
   Form Loading State - Prevents button flicker and layout shift
   ========================================================================== */

/* Hide the default Gravity Forms AJAX spinner completely */
.quiz-page .gform_wrapper .gform_ajax_spinner,
.quiz-page .gform_ajax_spinner,
.quiz-page img.gform_ajax_spinner {
    display: none !important;
}

/* Keep footer layout stable - use justify-content: flex-end for submit-only footer */
.quiz-page .gform_wrapper .gform_page_footer,
.quiz-page .gform_wrapper .gform_footer {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 15px;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative;
    min-height: 60px;
}

/* When only submit button exists (final page), align right */
.quiz-page .gform_wrapper .gform_footer {
    justify-content: flex-end !important;
}

/* Submit button wrapper - create inline-flex container for spinner */
.quiz-page .gform_wrapper .gform_page_footer input[type=submit],
.quiz-page .gform_wrapper .gform_footer input[type=submit] {
    position: relative;
    margin-left: auto !important;
    margin-right: 0 !important;
    flex-shrink: 0;
}

/* Button loading state */
.quiz-page .gform_wrapper input[type=submit].gform-is-submitting,
.quiz-page .gform_wrapper .gform_page_footer input[type=submit][disabled],
.quiz-page .gform_wrapper .gform_footer input[type=submit][disabled] {
    pointer-events: none;
    opacity: 0.85;
    cursor: wait;
}

/* Submit button wrapper */
.quiz-page .quiz-submit-wrap {
    position: relative;
    display: inline-block;
    margin-left: auto !important;
}

/* Loading spinner element (added via JS) */
.quiz-page .quiz-loading-spinner {
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: 3px solid rgba(0, 172, 144, 0.3);
    border-top-color: #00ac90;
    border-radius: 50%;
    animation: quiz-spinner 0.8s linear infinite;
}

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

/* Ensure buttons maintain position and don't shift */
.quiz-page .gform_wrapper .gform_page_footer input[type=submit],
.quiz-page .gform_wrapper .gform_page_footer input[type=button],
.quiz-page .gform_wrapper .gform_page_footer button {
    flex-shrink: 0;
}

/* Previous button stays left */
.quiz-page .gform_wrapper .gform_page_footer .gform_previous_button {
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* Hide form title/description */
.quiz-page .gform_title,
.quiz-page .gform_description {
    display: none;
}

/* HTML field spacing */
.quiz-page .gfield--type-html {
    margin-bottom: 30px;
}

/* Arrow pointing at Next button */
.quiz-arrow {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 20px;
}

.quiz-arrow img {
    max-width: 200px;
    height: auto;
}

/* ==========================================================================
   Quiz Page Responsive
   ========================================================================== */

@media screen and (max-width: 980px) {
    .quiz-page .resource-hero__title {
        font-size: 32px;
        max-width: 90%;
    }

    .quiz-page .gfield--type-radio {
        padding: 25px 30px;
    }

    .quiz-page .gform_wrapper .gform_page_footer button,
    .quiz-page .gform_wrapper .gform_page_footer input[type=button],
    .quiz-page .gform_wrapper .gform_page_footer input[type=submit] {
        padding: 12px 30px;
        font-size: 16px;
    }
}

@media screen and (max-width: 768px) {
    .quiz-page .resource-hero__title {
        font-size: 24px;
        max-width: 100%;
    }

    .quiz-form-section {
        padding: 40px 0 60px;
        background-size: 100% auto;
    }

    .quiz-page .gfield--type-radio {
        padding: 20px;
    }

    .quiz-page .gfield--type-radio .gfield_label {
        font-size: 14px;
    }

    .quiz-page .gfield--type-radio .ginput_container_radio .gfield-choice-input + label {
        font-size: 14px;
    }

    .quiz-page .gform_wrapper .gf_progressbar .gf_progressbar_percentage {
        padding: 15px;
    }

    .quiz-page .gform_wrapper .gf_progressbar .gf_progressbar_percentage span {
        font-size: 18px;
    }

    .quiz-page .gform_wrapper .gform_page_footer {
        flex-direction: column;
        gap: 15px;
    }

    .quiz-page .gform_wrapper .gform_page_footer button,
    .quiz-page .gform_wrapper .gform_page_footer input[type=button],
    .quiz-page .gform_wrapper .gform_page_footer input[type=submit] {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
    }

    .quiz-page .gform_wrapper .gform_page_footer .gform_next_button {
        margin-left: 0;
        order: -1;
    }
}
