/**
 * The Sensory Coach Quiz Complete Styles - Fixed Version
 * Modern, responsive styling for the sensory types quiz with proper question hiding
 * 
 * @version 1.2.0
 * @author The Sensory Coach
 */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Quiz Container */
#sensory-quiz-container {
    max-width: 800px;
    margin: 20px auto;
    padding: 30px;
    background: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    font-family: Georgia, serif;
    position: relative;
}

/* Quiz Sections - Proper section hiding */
.quiz-section {
    display: none !important;
    animation: fadeIn 0.4s ease-out;
}

.quiz-section.active {
    display: block !important;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Introduction Section */
#quiz-intro {
    text-align: center;
}

.intro-content h2 {
    color: #8868e0;
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
}

.intro-text {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: #555;
    line-height: 1.8;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.intro-text strong {
    color: #8868e0;
    font-weight: 600;
}

/* User Info Form */
.user-info-form {
    max-width: 400px;
    margin: 2rem auto;
    text-align: left;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: Georgia, serif;
    background: #fff;
}

.form-group input:focus {
    outline: none;
    border-color: #8868e0;
    box-shadow: 0 0 0 3px rgba(136, 104, 224, 0.1);
    transform: translateY(-1px);
}

.form-group input:invalid {
    border-color: #ff6b6b;
}

/* Progress Section */
#quiz-progress {
    margin-bottom: 2rem;
    text-align: center;
}

#progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
    position: relative;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8868e0, #cfc2f2);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
    position: relative;
}

#progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-20px); }
    100% { transform: translateX(20px); }
}

#question-counter {
    font-size: 1rem;
    color: #362761;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Question Styles - CRITICAL: Proper question hiding */
.question-container {
    display: none !important;
    padding: 1rem 0;
    min-height: auto;
    max-height: 70vh;
    overflow-y: auto;
}

.question-container.active {
    display: block !important;
}

.question-container h3 {
    color: #8868e0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.question-text {
    font-size: 1.15rem;
    color: #333;
    margin-bottom: 1rem;
    line-height: 1.4;
    font-weight: 500;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

/* Compact option labels to fit everything on screen */
.option-label {
    display: flex;
    align-items: flex-start;
    padding: 0.8rem 1rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    font-size: 0.9rem;
    line-height: 1.3;
}

/* Simplified hover effects - no transforms that could interfere with form state */
.option-label:hover {
    background: #e8f0fe;
    border-color: #8868e0;
    box-shadow: 0 2px 8px rgba(136, 104, 224, 0.15);
}

.option-label.selected {
    background: #e8f0fe;
    border-color: #8868e0;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(136, 104, 224, 0.2);
}

/* Fixed radio button styles to prevent state loss */
.option-label input[type="radio"] {
    margin-right: 1rem;
    margin-top: 0.2rem;
    width: 18px;
    height: 18px;
    accent-color: #8868e0;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.option-text {
    flex: 1;
    pointer-events: none;
}

/* Button Styles */
.quiz-btn {
    background: #8868e0;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    margin: 0 5px;
    font-family: Georgia, serif;
}

.quiz-btn:hover {
    background: #7154d6;
    box-shadow: 0 4px 12px rgba(136, 104, 224, 0.3);
}

.quiz-btn:active {
    background: #5d47c7;
}

.quiz-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

.quiz-btn.primary {
    background: #8868e0;
    font-size: 1.1rem;
    padding: 15px 30px;
    border-radius: 50px;
}

.quiz-btn.primary:hover {
    background: #7154d6;
    box-shadow: 0 6px 20px rgba(136, 104, 224, 0.4);
}

/* Navigation - More compact */
#quiz-navigation {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Results Preview Section */
#quiz-results-preview {
    text-align: center;
    padding: 2rem;
}

#preview-content {
    max-width: 600px;
    margin: 0 auto;
}

.results-teaser {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    border: 2px solid #8868e0;
}

.results-teaser h3 {
    color: #8868e0;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    font-weight: 600;
}

.type-badge {
    background: #8868e0;
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    display: inline-block;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.teaser-text {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: #555;
    line-height: 1.6;
}

.score-preview {
    margin-top: 1.5rem;
}

.score-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.95rem;
}

.score-grid span {
    padding: 0.5rem;
    background: rgba(136, 104, 224, 0.1);
    border-radius: 5px;
}

.email-capture-section {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
}

.email-capture-section h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
}

.email-capture-section p {
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Results Section */
#quiz-results {
    text-align: center;
    padding: 2rem;
    min-height: 300px;
}

#results-content {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    border: 2px solid #8868e0;
}

#results-content h3 {
    color: #8868e0;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

#results-content p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #8868e0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Homepage Styles */
#sensory-homepage {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.hero-section {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, #8868e0 0%, #cfc2f2 100%);
    color: white;
    border-radius: 20px;
    margin-bottom: 2rem;
}

.hero-section h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.cta-button {
    background: #ff6b6b;
    color: white;
    padding: 18px 40px;
    font-size: 1.2rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    margin: 10px;
    font-weight: bold;
    font-family: Georgia, serif;
}

.cta-button:hover {
    background: #ff5252;
    box-shadow: 0 10px 25px rgba(255, 107, 107, 0.3);
}

/* Focus States for Accessibility */
.quiz-btn:focus,
.form-group input:focus,
.option-label input:focus {
    outline: 2px solid #8868e0;
    outline-offset: 2px;
}

.option-label:focus-within {
    border-color: #8868e0;
    box-shadow: 0 0 0 3px rgba(136, 104, 224, 0.1);
}

/* Error States */
.error {
    color: #ff6b6b;
    border-color: #ff6b6b !important;
}

.error-message {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Success States */
.success {
    color: #28a745;
    border-color: #28a745 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    #sensory-quiz-container {
        margin: 10px;
        padding: 20px;
    }
    
    .intro-content h2 {
        font-size: 2rem;
    }
    
    .question-text {
        font-size: 1.1rem;
    }
    
    .option-label {
        padding: 0.7rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .quiz-btn {
        padding: 10px 20px;
        font-size: 0.95rem;
    }
    
    .quiz-btn.primary {
        padding: 12px 25px;
        font-size: 1rem;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .question-container {
        max-height: 60vh;
    }
    
    .type-badge {
        font-size: 1.2rem;
        padding: 0.8rem 1.5rem;
    }
    
    .results-teaser h3 {
        font-size: 1.5rem;
    }
    
    .teaser-text {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    #sensory-quiz-container {
        margin: 5px;
        padding: 15px;
    }
    
    .intro-content h2 {
        font-size: 1.8rem;
    }
    
    .option-label {
        padding: 0.6rem 0.7rem;
        font-size: 0.8rem;
    }
    
    .quiz-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        margin: 5px 2px;
    }
    
    .quiz-btn.primary {
        padding: 10px 20px;
        font-size: 0.95rem;
    }
    
    #quiz-navigation {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .user-info-form {
        padding: 0 10px;
    }
    
    .question-container {
        max-height: 50vh;
        padding: 0.5rem 0;
    }
    
    .question-text {
        font-size: 1rem;
    }
    
    .type-badge {
        font-size: 1rem;
        padding: 0.6rem 1.2rem;
    }
    
    .results-teaser {
        padding: 1.5rem;
    }
    
    .email-capture-section {
        padding: 1.5rem;
    }
    
    .score-grid {
        grid-template-columns: 1fr;
        gap: 0.3rem;
    }
}

/* Print Styles */
@media print {
    #sensory-quiz-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .quiz-btn {
        display: none;
    }
    
    #quiz-progress {
        display: none;
    }
    
    .question-container {
        display: block !important;
        page-break-inside: avoid;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .option-label {
        border-width: 3px;
    }
    
    .quiz-btn {
        border: 2px solid currentColor;
    }
    
    #progress-fill {
        background: #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .quiz-section {
        animation: none;
    }
    
    #progress-fill::after {
        animation: none;
    }
    
    .loading::after {
        animation: none;
    }
}

/* Additional form state preservation styles */
input[type="radio"]:checked {
    appearance: radio;
    -webkit-appearance: radio;
    -moz-appearance: radio;
}

.option-label input[type="radio"]:before,
.option-label input[type="radio"]:after {
    pointer-events: none;
}

.option-label * {
    will-change: auto;
}