/**
 * MOBILE-ENHANCED.CSS
 * Optimisations avancées pour expérience mobile
 * Quantum Quiz - PHY321
 */

/* ============================================================================
   VARIABLES POUR MOBILE
   ============================================================================ */

:root {
    --touch-target-min: 44px; /* Taille minimum recommandée Apple/Google */
    --mobile-spacing: 1rem;
    --mobile-font-base: 16px; /* Évite le zoom automatique sur iOS */
}

/* ============================================================================
   OPTIMISATIONS TACTILES GLOBALES
   ============================================================================ */

/* Désactiver le highlight au touch sur iOS */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Améliorer le scrolling sur mobile */
body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none; /* Empêche le bounce sur iOS */
}

/* Optimiser les zones cliquables */
button,
a,
input[type="radio"],
input[type="checkbox"],
.clickable {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================================================
   TOUCH TARGETS - TAILLE MINIMUM 44×44px
   ============================================================================ */

@media (max-width: 768px) {
    /* Boutons principaux */
    .btn,
    button {
        min-height: var(--touch-target-min);
        min-width: 120px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem; /* Évite zoom iOS */
        touch-action: manipulation; /* Désactive double-tap zoom */
    }

    /* Boutons de navigation */
    .nav-buttons button,
    .quiz-nav button {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
        padding: 1rem;
    }

    /* Options de QCM */
    .option-item {
        min-height: var(--touch-target-min);
        margin-bottom: 0.75rem;
        padding: 0.5rem;
    }

    .option-item input[type="radio"] {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        /* Zone de clic étendue */
        margin: 0 0.5rem;
    }

    .option-item label {
        display: flex;
        align-items: center;
        min-height: var(--touch-target-min);
        padding: 0.5rem;
        cursor: pointer;
        /* Agrandir la zone cliquable */
        width: 100%;
    }

    /* Checkboxes et radio buttons */
    input[type="radio"],
    input[type="checkbox"] {
        transform: scale(1.5); /* Agrandir pour faciliter le touch */
        margin-right: 1rem;
    }

    /* Inputs texte */
    input[type="text"],
    input[type="number"],
    textarea {
        min-height: var(--touch-target-min);
        font-size: 16px; /* Évite zoom automatique iOS */
        padding: 0.75rem;
    }

    /* Selects */
    select {
        min-height: var(--touch-target-min);
        font-size: 16px;
        padding: 0.75rem;
    }
}

/* ============================================================================
   NAVIGATION MOBILE SIMPLIFIÉE
   ============================================================================ */

@media (max-width: 768px) {
    /* En-tête compact */
    header {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    /* Navigation sticky en bas sur mobile */
    .nav-buttons {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
        z-index: 100;
        display: flex;
        gap: 0.5rem;
        justify-content: space-between;
    }

    .nav-buttons button {
        flex: 1;
        max-width: 48%;
    }

    /* Progress bar plus visible */
    .progress-bar {
        height: 6px; /* Plus épais sur mobile */
    }

    /* Quiz info compact */
    .quiz-info {
        flex-direction: column;
        gap: 0.5rem;
        font-size: 0.875rem;
    }
}

/* ============================================================================
   QUESTIONS - OPTIMISATIONS MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .question-card {
        padding: 1rem;
        margin: 0.5rem;
    }

    .question-header {
        margin-bottom: 1rem;
    }

    .question-text {
        font-size: 1.125rem; /* Légèrement plus grand pour lisibilité */
        line-height: 1.6;
        margin-bottom: 1rem;
    }

    /* Images */
    .question-image {
        max-width: 100%;
        height: auto;
        margin: 1rem 0;
        border-radius: 8px;
    }

    /* Formules */
    .formula {
        font-size: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================================
   HOTSPOT - OPTIMISÉ POUR TACTILE
   ============================================================================ */

@media (max-width: 768px) {
    .hotspot-container {
        position: relative;
        touch-action: none; /* Désactive gestes navigateur */
        user-select: none;
    }

    .hotspot-canvas {
        cursor: crosshair;
        touch-action: none;
    }

    /* Zones hotspot plus grandes sur mobile */
    .hotspot-zone {
        min-width: 60px; /* Au lieu de 40px */
        min-height: 60px;
    }

    /* Feedback visuel amélioré */
    .hotspot-canvas:active {
        opacity: 0.9;
    }

    /* Instruction plus visible */
    .hotspot-instruction {
        font-size: 1rem;
        padding: 0.75rem;
        background: var(--accent-cyan);
        color: var(--text-primary);
        border-radius: 8px;
        margin-bottom: 1rem;
        text-align: center;
    }
}

/* ============================================================================
   DRAG & DROP - OPTIMISÉ POUR TACTILE
   ============================================================================ */

@media (max-width: 768px) {
    .drag-drop-container {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    /* Items draggables */
    .draggable-item {
        min-height: var(--touch-target-min);
        padding: 1rem;
        margin: 0.5rem 0;
        font-size: 1rem;
        border: 2px solid var(--accent-cyan);
        border-radius: 8px;
        background: var(--bg-secondary);
        cursor: grab;
        touch-action: none;
        user-select: none;
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .draggable-item:active {
        cursor: grabbing;
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 1000;
    }

    /* Drop zones */
    .drop-zone {
        min-height: calc(var(--touch-target-min) + 1rem);
        padding: 1rem;
        border: 2px dashed var(--accent-purple);
        border-radius: 8px;
        background: var(--bg-primary);
        margin: 0.5rem 0;
    }

    .drop-zone.drag-over {
        background: rgba(157, 78, 221, 0.2);
        border-color: var(--accent-pink);
        transform: scale(1.02);
    }

    .drop-zone.filled {
        background: rgba(45, 212, 191, 0.1);
        border-style: solid;
        border-color: var(--accent-cyan);
    }

    /* Layout vertical sur mobile */
    .drag-drop-sources,
    .drag-drop-targets {
        width: 100%;
    }

    .drag-drop-instruction {
        font-size: 1rem;
        padding: 0.75rem;
        background: var(--accent-purple);
        color: white;
        border-radius: 8px;
        margin-bottom: 1rem;
        text-align: center;
    }
}

/* ============================================================================
   MATCHING QUESTIONS - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .matching-container {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .matching-item {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem;
        background: var(--bg-secondary);
        border-radius: 8px;
        margin-bottom: 0.75rem;
    }

    .matching-left {
        font-weight: 600;
        margin-bottom: 0.5rem;
    }

    .matching-right select {
        width: 100%;
        min-height: var(--touch-target-min);
        font-size: 16px;
    }
}

/* ============================================================================
   RÉSULTATS - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .results-card {
        padding: 1rem;
        margin: 0.5rem;
    }

    .score-circle {
        width: 120px;
        height: 120px;
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    /* Review questions */
    .review-question {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .review-question summary {
        min-height: var(--touch-target-min);
        padding: 0.75rem;
        font-size: 1rem;
        cursor: pointer;
    }
}

/* ============================================================================
   MODALES - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .modal {
        padding: 0.5rem;
    }

    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        margin: 1rem auto;
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        font-size: 1rem;
    }

    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer button {
        width: 100%;
    }

    /* Close button plus grand */
    .modal-close {
        font-size: 2rem;
        width: var(--touch-target-min);
        height: var(--touch-target-min);
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================================================
   CONFIGURATION PAGE - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .config-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .config-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .checkbox-group {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .checkbox-label {
        display: flex;
        align-items: center;
        min-height: var(--touch-target-min);
        padding: 0.5rem;
    }

    .checkbox-label input[type="checkbox"] {
        margin-right: 0.75rem;
        transform: scale(1.5);
    }
}

/* ============================================================================
   ANIMATIONS OPTIMISÉES MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    /* Réduire les animations sur mobile pour performances */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Désactiver animations complexes sur mobile bas de gamme */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation: none !important;
            transition: none !important;
        }
    }
}

/* ============================================================================
   ORIENTATION LANDSCAPE - SMARTPHONES
   ============================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
    /* Optimiser pour mode paysage */
    .question-card {
        padding: 0.75rem;
    }

    .nav-buttons {
        padding: 0.5rem;
    }

    /* Réduire header en landscape */
    header {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    /* Images plus petites en landscape */
    .question-image {
        max-height: 40vh;
        object-fit: contain;
    }
}

/* ============================================================================
   TABLETTES
   ============================================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablettes : mix entre mobile et desktop */
    .touch-target {
        min-width: 44px;
        min-height: 44px;
    }

    .nav-buttons {
        padding: 1rem;
    }

    .question-card {
        padding: 2rem;
        max-width: 800px;
        margin: 1rem auto;
    }
}

/* ============================================================================
   SAFE AREAS (iPhone X+, notch)
   ============================================================================ */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .nav-buttons {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
}

/* ============================================================================
   PRINT (pour exporter sur mobile)
   ============================================================================ */

@media print {
    .nav-buttons,
    .modal,
    .particles-canvas,
    button {
        display: none !important;
    }
}
