/* ============================================
   AI QUIZ MODAL — SCOPED STYLES
   Uses existing CSS custom properties from base.css
   ============================================ */

/* Prevent body scroll when modal is open */
body.ai-quiz-open {
    overflow: hidden;
}

/* Overlay */
.ai-quiz-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(10, 10, 10, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-quiz-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal shell */
.ai-quiz-modal {
    position: relative;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 124, 135, 0.08);
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 124, 135, 0.04);
    padding: 2.5rem;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-quiz-overlay.active .ai-quiz-modal {
    transform: translateY(0) scale(1);
}

/* Close button */
.ai-quiz-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    color: var(--color-text-muted);
    z-index: 2;
}

.ai-quiz-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.ai-quiz-close svg {
    width: 20px;
    height: 20px;
}

/* ---- Progress bar ---- */
.ai-quiz-progress {
    margin-bottom: 1.75rem;
}

.ai-quiz-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.ai-quiz-progress-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}

.ai-quiz-progress-track {
    width: 100%;
    height: 4px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.ai-quiz-progress-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    width: 0%;
}

/* ---- Intro screen ---- */
.ai-quiz-intro {
    text-align: center;
}

.ai-quiz-intro-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.25rem;
    background: rgba(0, 124, 135, 0.08);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
}

.ai-quiz-intro-icon svg {
    width: 28px;
    height: 28px;
}

.ai-quiz-intro h2 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.15;
    margin-bottom: 0.75rem;
}

.ai-quiz-intro p {
    font-size: 1.0625rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: 1.75rem;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

.ai-quiz-intro-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.ai-quiz-intro-meta span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* ---- Question screen ---- */
.ai-quiz-question h3 {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.25;
    margin-bottom: 1.5rem;
    padding-right: 2rem;
}

.ai-quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1.5rem;
}

.ai-quiz-answer {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    text-align: left;
    line-height: 1.45;
    transition: all 0.2s ease;
}

.ai-quiz-answer:hover,
.ai-quiz-answer:focus-visible {
    border-color: var(--color-accent);
    background: rgba(0, 124, 135, 0.04);
    box-shadow: 0 0 0 3px rgba(0, 124, 135, 0.08);
}

.ai-quiz-answer:active {
    transform: scale(0.985);
}

.ai-quiz-answer-letter {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(0, 124, 135, 0.08);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-accent);
    transition: all 0.2s ease;
}

.ai-quiz-answer:hover .ai-quiz-answer-letter,
.ai-quiz-answer:focus-visible .ai-quiz-answer-letter {
    background: var(--color-accent);
    color: #fff;
}

.ai-quiz-back {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 0.25rem 0;
    transition: color 0.2s;
}

.ai-quiz-back:hover {
    color: var(--color-text);
}

.ai-quiz-back svg {
    width: 16px;
    height: 16px;
}

/* ---- Email gate ---- */
.ai-quiz-gate h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 0.5rem;
    text-align: center;
}

.ai-quiz-gate > p {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.ai-quiz-gate-form {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.ai-quiz-gate-form label:not(.ai-quiz-checkbox) {
    display: block;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
}

.ai-quiz-gate-form label .required {
    color: var(--color-accent);
}

.ai-quiz-gate-form input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
}

.ai-quiz-gate-form input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.ai-quiz-gate-form input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 124, 135, 0.1);
}

.ai-quiz-gate-form textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
    resize: vertical;
    min-height: 80px;
}

.ai-quiz-gate-form textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.ai-quiz-gate-form textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 124, 135, 0.1);
}

.ai-quiz-gate-form input.error,
.ai-quiz-gate-form textarea.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.ai-quiz-gate-error {
    font-size: 0.8125rem;
    color: #dc3545;
    margin-top: -0.25rem;
    display: none;
}

.ai-quiz-gate-error.visible {
    display: block;
}

/* ---- Consent checkboxes (eval form) ---- */
.ai-quiz-consent {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.ai-quiz-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--color-text-muted);
}

.ai-quiz-checkbox input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--color-accent);
    cursor: pointer;
}

/* ---- Primary button (shared by intro, gate, results) ---- */
.ai-quiz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 2rem;
    background: var(--color-accent);
    color: #fff;
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 16px rgba(0, 124, 135, 0.2);
    margin-top: 0.25rem;
}

.ai-quiz-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 124, 135, 0.35);
    background: var(--color-accent-dark);
}

.ai-quiz-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 16px rgba(0, 124, 135, 0.2);
}

.ai-quiz-btn.secondary {
    background: transparent;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
    box-shadow: none;
    margin-top: 0.5rem;
}

.ai-quiz-btn.secondary:hover {
    background: rgba(0, 124, 135, 0.05);
    box-shadow: none;
}

/* ---- Results screen ---- */
.ai-quiz-results {
    text-align: center;
}

.ai-quiz-results-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.ai-quiz-results-badge svg {
    width: 32px;
    height: 32px;
}

.ai-quiz-results-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent);
    margin-bottom: 0.375rem;
}

.ai-quiz-results h3 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.15;
    margin-bottom: 0.25rem;
}

.ai-quiz-results-score {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.ai-quiz-results-desc {
    font-size: 1rem;
    color: var(--color-text-muted);
    line-height: 1.65;
    margin-bottom: 1.75rem;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.ai-quiz-results-ctas {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ---- Screen transitions ---- */
.ai-quiz-screen {
    animation: aiqFadeIn 0.3s ease both;
}

@keyframes aiqFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Loading spinner for submit ---- */
.ai-quiz-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aiqSpin 0.6s linear infinite;
}

@keyframes aiqSpin {
    to { transform: rotate(360deg); }
}

/* ---- Floating bubble trigger (bottom-left) ---- */
.ai-quiz-bubble {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem 0.75rem 1rem;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 20px rgba(0, 124, 135, 0.35), 0 0 0 0 rgba(0, 124, 135, 0);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, background 0.3s ease;
}

.ai-quiz-bubble.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ai-quiz-bubble:hover {
    background: var(--color-accent-dark);
    box-shadow: 0 8px 32px rgba(0, 124, 135, 0.45), 0 0 0 4px rgba(0, 124, 135, 0.1);
    transform: translateY(-2px);
}

.ai-quiz-bubble:active {
    transform: translateY(0) scale(0.97);
}

.ai-quiz-bubble svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.ai-quiz-bubble-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: #ff6b35;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: aiqPulse 2s ease-in-out infinite;
}

@keyframes aiqPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: 0.7; }
}

/* Hide bubble when modal is open */
body.ai-quiz-open .ai-quiz-bubble {
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .ai-quiz-modal {
        padding: 1.75rem 1.25rem;
        border-radius: 12px;
        max-height: 95vh;
    }

    .ai-quiz-intro h2 {
        font-size: 1.5rem;
    }

    .ai-quiz-question h3 {
        font-size: 1.1875rem;
    }

    .ai-quiz-answer {
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
    }

    .ai-quiz-answer-letter {
        width: 24px;
        height: 24px;
        font-size: 0.6875rem;
    }

    .ai-quiz-intro-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .ai-quiz-results h3 {
        font-size: 1.5rem;
    }

    .ai-quiz-bubble {
        bottom: 1rem;
        left: 1rem;
        padding: 0.625rem 1rem 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }

    .ai-quiz-bubble svg {
        width: 16px;
        height: 16px;
    }
}
