/* ===================================
   MODERN MOBILE OPTIMIZATION (PRIORITÉ 1)
   Améliorations basées sur audit professionnel
   =================================== */

/* 1. Global Breathability & Stacking */
@media (max-width: 768px) {

    /* Force Grid Stacking (1 colonne) */
    .grid-2,
    .grid-3,
    .grid-2-flux,
    .cards-grid,
    .blockchain-features,
    .tokenization-grid,
    .stats-grid,
    .mechanisms-grid,
    .objectives-grid,
    .analysis-grid,
    .forecast-grid,
    .definitions-grid,
    .universe-grid {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
    }

    /* Section Padding - Plus aéré verticalement, safe horizontalement */
    section {
        padding: 50px 20px !important;
    }

    .content-block {
        width: 100% !important;
        padding: 0 15px !important;
        max-width: 100% !important;
    }

    /* Typography Responsive - Tailles augmentées pour lisibilité */
    body {
        font-size: 16px !important;
        line-height: 1.7 !important;
    }

    h1 {
        font-size: 28px !important;
        line-height: 1.2 !important;
        margin-bottom: 20px !important;
    }

    h2 {
        font-size: 24px !important;
        line-height: 1.3 !important;
        margin-bottom: 16px !important;
    }

    h3 {
        font-size: 20px !important;
        line-height: 1.4 !important;
        margin-bottom: 12px !important;
    }

    p,
    li {
        font-size: 16px !important;
        line-height: 1.7 !important;
        margin-bottom: 16px !important;
    }

    /* Hero Adjustments */
    .hero {
        padding: 100px 20px 60px !important;
        text-align: center !important;
    }

    .hero h1 {
        font-size: 32px !important;
    }

    .hero-subtitle {
        font-size: 16px !important;
        margin-bottom: 20px !important;
    }

    .hero-description {
        font-size: 15px !important;
    }

    /* Buttons - Touch-friendly (min 44px) */
    .cta-button,
    .mode-switch,
    button {
        min-height: 48px !important;
        padding: 14px 28px !important;
        font-size: 16px !important;
    }

    /* Cards - Espacement optimisé */
    .card,
    .risk-card,
    .interactive-card {
        padding: 24px !important;
        margin-bottom: 20px !important;
    }

    /* Flux Comparison Tabs Stacking */
    .tabs {
        flex-direction: column;
        border-bottom: none !important;
        gap: 12px;
    }

    .tab-btn {
        width: 100%;
        border: 1px solid #334155 !important;
        border-radius: 8px;
        padding: 16px !important;
        background: rgba(15, 23, 42, 0.5) !important;
        min-height: 48px;
    }

    .tab-btn.active {
        background: #3b82f6 !important;
        color: white !important;
        border-color: #3b82f6 !important;
    }

    /* Flux Comparison Responsive */
    .comp-wrapper {
        flex-direction: column !important;
        gap: 40px !important;
        perspective: none !important;
    }

    .comp-card {
        width: 100% !important;
        max-width: 340px !important;
        height: auto !important;
        min-height: 380px !important;
        transform: none !important;
    }

    .comp-icon,
    .comp-name,
    .comp-desc {
        transform: none !important;
    }

    .vs-badge {
        margin: 20px 0;
        transform: rotate(90deg);
        /* Rotate VS for vertical stack */
    }

    /* Section Title - Centré et lisible */
    .section-title {
        text-align: center;
        padding: 0 20px;
    }

    .section-number {
        font-size: 14px !important;
    }
}

/* 2. Tables Responsive - Scroll horizontal fluide */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 24px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Indicateur de scroll */
.table-responsive-wrapper::after {
    content: '← Scroll →';
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    pointer-events: none;
    opacity: 0.8;
}

@media (min-width: 769px) {
    .table-responsive-wrapper::after {
        display: none;
    }
}

table {
    min-width: 600px;
}

/* 3. Menu Hamburger Amélioré */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: block !important;
        font-size: 1.8rem !important;
        padding: 12px !important;
        min-width: 48px;
        min-height: 48px;
        background: rgba(59, 130, 246, 0.1);
        border-radius: 8px;
        transition: all 0.3s;
    }

    .mobile-menu-toggle:hover {
        background: rgba(59, 130, 246, 0.2);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }
}

/* 4. Utility Classes */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* Espacement réduit pour mobile */
    .mt-80 {
        margin-top: 40px !important;
    }

    .mb-80 {
        margin-bottom: 40px !important;
    }

    .py-80 {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

/* 5. Images & Media Responsive */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }

    iframe,
    video {
        max-width: 100%;
    }

    /* Footer Optimization */
    .super-footer {
        padding: 40px 0 30px !important;
    }
}

/* 6. Animations - Réduites sur mobile pour performance */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
    .stagger-animation>* {
        animation-duration: 0.4s !important;
    }

    .interactive-card {
        transition-duration: 0.2s !important;
    }
}

/* 7. Touch-friendly spacing */
@media (max-width: 768px) {

    /* Minimum touch target 44x44px */
    a,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Espacement entre éléments cliquables */
    nav a+a,
    button+button {
        margin-left: 12px;
    }
}

/* ===================================
   SCROLL TO TOP (SHARED)
   =================================== */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #3b82f6;
    /* Accent Blue */
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: #2563eb;
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.6);
}

@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        /* Minimum touch target */
    }

    /* 8. Terminal Panel Mobile Optimization */
    .terminal-panel {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        right: -100% !important;
        border-radius: 0 !important;
        z-index: 2000 !important;
    }

    .terminal-panel.open {
        right: 0 !important;
    }

    .panel-header {
        padding: 20px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .panel-close {
        width: 48px !important;
        height: 48px !important;
        font-size: 32px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .panel-scroll-area {
        padding: 20px !important;
    }

    .panel-title {
        font-size: 20px !important;
    }

    .panel-subtitle {
        font-size: 15px !important;
    }

    .panel-stats-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-box {
        padding: 15px !important;
    }

    .table-row {
        font-size: 14px !important;
        padding: 12px 0 !important;
    }

    .panel-btn-primary,
    .panel-btn-secondary,
    .panel-btn-ghost {
        width: 100% !important;
        justify-content: center !important;
        min-height: 48px !important;
        font-size: 16px !important;
    }

    .panel-soft-capture {
        padding: 15px !important;
        margin-top: 30px !important;
    }

    .panel-soft-capture div {
        flex-direction: column !important;
    }

    .panel-soft-capture button {
        width: 100% !important;
    }
}