/* Universal Responsive Typography & Layout for Personality Tests
   Ensures consistent mobile/desktop experience across all template versions */

/* -----------------------------------
   1. CSS Custom Properties for Consistency
----------------------------------- */

:root {
    /* Base font sizes for progressive scaling */
    --font-size-xs: 0.875rem;   /* 14px */
    --font-size-sm: 1rem;       /* 16px */
    --font-size-base: 1.125rem; /* 18px */
    --font-size-lg: 1.25rem;    /* 20px */
    --font-size-xl: 1.5rem;     /* 24px */
    --font-size-2xl: 2rem;      /* 32px */
    --font-size-3xl: 2.5rem;    /* 40px */
    
    /* Touch target sizes */
    --touch-target-min: 48px;   /* Minimum accessible touch target */
    --touch-target-comfort: 60px; /* Comfortable touch target */
    
    /* Spacing scale */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-base: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border radius scale */
    --border-radius-sm: 0.375rem;
    --border-radius-base: 0.5rem;
    --border-radius-lg: 0.75rem;
    --border-radius-xl: 1rem;
}

/* -----------------------------------
   2. Universal Responsive Typography
----------------------------------- */

/* Progressive font scaling for all personality test headings */
.personality-test-heading,
.test-header h1,
.game-wrapper h1 {
    font-size: var(--font-size-3xl);
    line-height: 1.2;
    font-weight: 700;
}

.personality-test-subheading,
.test-header .lead,
.game-wrapper .subheading {
    font-size: var(--font-size-lg);
    line-height: 1.4;
    font-weight: 500;
}

.personality-test-question,
#question,
.question-text {
    font-size: var(--font-size-xl);
    line-height: 1.4;
    font-weight: 600;
}

.personality-test-choice,
.choice-text {
    font-size: var(--font-size-base);
    line-height: 1.4;
    font-weight: 400;
}

/* -----------------------------------
   3. Universal Touch Targets
----------------------------------- */

.personality-test-button,
.choice-container,
.btn-personality {
    min-height: var(--touch-target-comfort);
    padding: var(--spacing-base) var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.personality-test-progress {
    min-height: 24px;
    border-radius: var(--border-radius-base);
}

/* -----------------------------------
   4. Progressive Responsive Breakpoints
----------------------------------- */

/* Large tablets and small desktops (769px+) */
@media (min-width: 769px) {
    :root {
        --font-size-3xl: 3rem;    /* 48px */
        --font-size-xl: 1.75rem;  /* 28px */
        --font-size-lg: 1.375rem; /* 22px */
    }
    
    .personality-test-button {
        min-height: 56px;
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

/* Tablets (577px - 768px) */
@media (min-width: 577px) and (max-width: 768px) {
    :root {
        --font-size-3xl: 2.25rem; /* 36px */
        --font-size-xl: 1.375rem; /* 22px */
        --font-size-lg: 1.125rem; /* 18px */
        --font-size-base: 1rem;   /* 16px */
    }
    
    .personality-test-button,
    .choice-container {
        min-height: 56px;
        padding: 0.875rem var(--spacing-lg);
    }
    
    .personality-test-progress {
        min-height: 22px;
    }
}

/* Mobile phones (max-width: 576px) */
@media (max-width: 576px) {
    :root {
        --font-size-3xl: 1.75rem; /* 28px */
        --font-size-xl: 1.25rem;  /* 20px */
        --font-size-lg: 1rem;     /* 16px */
        --font-size-base: 0.95rem; /* 15px */
    }
    
    .personality-test-button,
    .choice-container {
        min-height: var(--touch-target-min);
        padding: 0.75rem var(--spacing-base);
        font-size: var(--font-size-base);
    }
    
    .personality-test-progress {
        min-height: 20px;
    }
    
    /* Stack elements vertically on mobile */
    .personality-test-choices {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
}

/* Extra small phones (max-width: 400px) */
@media (max-width: 400px) {
    :root {
        --font-size-3xl: 1.5rem;  /* 24px */
        --font-size-xl: 1.125rem; /* 18px */
        --spacing-base: 0.75rem;
    }
    
    .personality-test-button,
    .choice-container {
        padding: 0.625rem var(--spacing-sm);
    }
}

/* -----------------------------------
   5. Landscape Orientation Support
----------------------------------- */

@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --font-size-3xl: 1.5rem;
        --font-size-xl: 1.125rem;
        --spacing-xl: 1rem;
        --spacing-lg: 0.75rem;
    }
    
    .personality-test-button,
    .choice-container {
        min-height: 40px;
        padding: 0.5rem var(--spacing-base);
    }
    
    .personality-test-section {
        padding: var(--spacing-base) 0;
    }
}

/* -----------------------------------
   6. Touch Device Optimizations
----------------------------------- */

@media (hover: none) and (pointer: coarse) {
    .personality-test-button:hover,
    .choice-container:hover {
        transform: none;
    }
    
    .personality-test-button:active,
    .choice-container:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Prevent zoom on double tap */
    .personality-test-button,
    .choice-container {
        touch-action: manipulation;
    }
}

/* -----------------------------------
   7. Accessibility Enhancements
----------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .personality-test-button,
    .choice-container,
    .personality-test-progress {
        transition: none;
        animation: none;
    }
    
    .personality-test-button:hover,
    .choice-container:hover {
        transform: none;
    }
}

@media (prefers-contrast: high) {
    .personality-test-button,
    .choice-container {
        border-width: 2px;
        border-style: solid;
    }
}

/* -----------------------------------
   8. Print Styles
----------------------------------- */

@media print {
    .personality-test-section {
        background: white !important;
    }
    
    .personality-test-button,
    .choice-container {
        border: 1px solid #000 !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
}

/* -----------------------------------
   9. Dark Mode Support
----------------------------------- */

@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f8f9fa;
        --text-secondary: #dee2e6;
        --bg-primary: #212529;
        --bg-secondary: #343a40;
        --border-color: #495057;
    }
    
    .personality-test-section {
        background: var(--bg-primary);
        color: var(--text-primary);
    }
    
    .personality-test-button,
    .choice-container {
        background: var(--bg-secondary);
        color: var(--text-primary);
        border-color: var(--border-color);
    }
    
    .personality-test-question {
        color: var(--text-primary);
    }
}

/* -----------------------------------
   10. Legacy Compatibility Classes
----------------------------------- */

/* Ensure compatibility with existing class names */
.game-wrapper h1 {
    font-size: var(--font-size-3xl);
}

.game-wrapper .subheading {
    font-size: var(--font-size-lg);
}

#question {
    font-size: var(--font-size-xl);
}

.choice-text {
    font-size: var(--font-size-base);
}

.btn-personality {
    min-height: var(--touch-target-comfort);
    padding: var(--spacing-base) var(--spacing-lg);
}

.app-logo {
    border-radius: var(--border-radius-lg);
    transition: all 0.3s ease;
}

/* Results page compatibility */
.results-header h1,
.type-badge {
    font-size: var(--font-size-3xl);
}

.description-header {
    font-size: var(--font-size-lg);
}

.description-content {
    font-size: var(--font-size-base);
    line-height: 1.6;
}

/* -----------------------------------
   11. High-DPI Display Support
----------------------------------- */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .personality-test-button,
    .choice-container {
        border-width: 0.5px;
    }
}

/* -----------------------------------
   12. Performance Optimizations
----------------------------------- */

/* Use transform3d for hardware acceleration */
.personality-test-button,
.choice-container {
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

/* Optimize repaints for animations */
@media (min-width: 769px) {
    .personality-test-button:hover,
    .choice-container:hover {
        transform: translate3d(0, -2px, 0);
    }
}