/*
 * QuotInfo — adaptation du site public au téléphone et à la tablette.
 * Chargé APRÈS premium.css. Les vues utilisent beaucoup de styles en ligne
 * (grilles fixes, grandes marges, largeurs en pixels) : ces règles les
 * adaptent sans réécrire chaque page.
 */

/* ---------- Toutes tailles ---------- */
.m-actions { display: none; }

html, body { max-width: 100%; overflow-x: hidden; }
img, video, iframe { max-width: 100%; }

/* Contenu rédigé (articles, offres, éditoriaux) : rien ne sort de la colonne */
.article-body, .article-content { overflow-wrap: anywhere; }
.article-body img, .article-content img,
.article-body video, .article-content video { max-width: 100% !important; height: auto !important; }
.article-body iframe, .article-content iframe { max-width: 100% !important; aspect-ratio: 16 / 9; height: auto; }
.article-body table, .article-content table { display: block; max-width: 100%; overflow-x: auto; }
.article-body pre, .article-content pre { max-width: 100%; overflow-x: auto; }

/* ---------- Tablette et téléphone ---------- */
@media (max-width: 992px) {
    .container { padding-left: 16px !important; padding-right: 16px !important; max-width: 100% !important; }

    /* En-tête compact sur une ligne : logo à gauche, actions à droite */
    nav { padding: 0 !important; position: sticky; top: 0; z-index: 900; }
    nav .nav-content {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0 !important;
        padding: 8px 16px !important;
    }
    nav .logo img { height: 40px !important; max-width: 150px !important; }
    nav .logo span { font-size: 20px !important; }

    .m-actions { display: flex; align-items: center; gap: 8px; }
    .m-btn {
        min-width: 42px; height: 42px; padding: 0 10px;
        display: inline-flex; align-items: center; justify-content: center; gap: 6px;
        border-radius: 10px; border: 1px solid var(--border);
        background: transparent; color: var(--text-main);
        font-size: 17px; font-weight: 800; text-decoration: none; cursor: pointer;
    }
    .m-live { color: #ef4444; font-size: 12px; text-transform: uppercase; border-color: rgba(239, 68, 68, 0.4); }
    .m-live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: blink-dot 1.2s infinite; }

    /* Recherche : repliée, ouverte par le bouton loupe */
    nav .nav-content > form {
        display: none !important;
        order: 10; flex: 1 1 100% !important; max-width: 100% !important;
        margin: 10px 0 4px !important;
    }
    body.m-search-open nav .nav-content > form { display: block !important; }
    nav .nav-content > form input { font-size: 16px !important; }

    /* Liens (compte, magazines, podcasts…) : repliés dans le menu ☰ */
    nav .nav-auth {
        display: none !important;
        order: 11; flex: 1 1 100% !important; width: 100% !important;
        flex-direction: column !important; align-items: stretch !important;
        gap: 0 !important; margin: 8px 0 4px !important;
        border-top: 1px solid var(--border);
    }
    body.m-menu-open nav .nav-auth { display: flex !important; }
    nav .nav-auth > a {
        margin: 0 !important; padding: 14px 4px !important;
        font-size: 16px !important; justify-content: flex-start !important;
        border-bottom: 1px solid var(--border); transform: none !important;
    }
    nav .nav-auth > a.btn-premium {
        margin: 10px 0 0 !important; padding: 13px 16px !important;
        justify-content: center !important; text-align: center; border-bottom: none;
        display: flex !important;
    }
    nav .nav-auth .theme-toggle { margin: 12px 0 4px !important; align-self: flex-start; }

    /* Bandeau d'actualités */
    .news-ticker { height: 34px !important; }
    .ticker-label { font-size: 11px !important; padding: 0 10px !important; }
    .ticker-item { font-size: 13px !important; }

    /* Barre des catégories : défilement horizontal au doigt, sans barre visible */
    .nav-categories {
        gap: 20px !important; padding-top: 2px !important; padding-bottom: 2px !important;
        scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .nav-categories::-webkit-scrollbar { display: none; }
    .nav-categories a { font-size: 14px !important; flex: 0 0 auto; }

    /* Grilles en ligne : 2 colonnes sur tablette */
    main [style*="grid-template-columns"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 16px !important; }
    main .article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 16px !important; }

    /* Grandes marges des pages */
    main [style*="padding-top: 40px"] { padding-top: 20px !important; }
    main [style*="padding-top: 60px"], main [style*="padding: 60px"] { padding-top: 24px !important; }
    main [style*="padding-bottom: 60px"] { padding-bottom: 30px !important; }
    main [style*="margin-bottom: 60px"], main [style*="margin-bottom: 50px"] { margin-bottom: 28px !important; }
    main [style*="padding: 40px"], main [style*="padding: 50px"] { padding: 18px !important; }
    main [style*="padding: 30px"] { padding: 16px !important; }

    /* Blocs à largeur fixe */
    main [style*="max-width: 800px"], main [style*="max-width: 900px"],
    main [style*="max-width: 1000px"], main [style*="max-width: 1200px"] { max-width: 100% !important; }
    main [style*="min-width: 300px"], main [style*="min-width: 350px"], main [style*="min-width: 400px"] { min-width: 0 !important; }

    /* Lignes flexibles : passage à la ligne au lieu de déborder */
    main [style*="display: flex"] { flex-wrap: wrap; }

    /* Titres */
    main h1 { font-size: 26px !important; line-height: 1.25 !important; }
    main h2 { font-size: 20px !important; line-height: 1.3 !important; }

    /* Bouton cloche : plus petit, ne masque pas le contenu */
    #notificationBell { width: 46px !important; height: 46px !important; left: 14px !important; bottom: 14px !important; }
    #notificationBell i { font-size: 18px !important; }

    /* Fenêtre « Ne manquez rien » */
    #autoPopup > div { width: calc(100% - 32px) !important; max-width: 420px !important; padding: 24px 18px !important; max-height: 90vh; overflow-y: auto; }

    #autoPopup form { flex-wrap: wrap !important; gap: 8px !important; }
    #autoPopup form input { flex: 1 1 160px !important; min-width: 0 !important; width: auto !important; font-size: 16px !important; }
    #autoPopup form button { flex: 1 1 auto !important; }

    /* Carrousel : le titre ne passe plus sous les points de navigation */
    .hero-overlay { padding-bottom: 34px !important; }

    footer { padding-top: 30px !important; }
}

/* ---------- Téléphone ---------- */
@media (max-width: 640px) {
    main [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
    main .article-grid { grid-template-columns: minmax(0, 1fr) !important; }

    /* Carrousels de couvertures (magazines, éditoriaux) : 2 par ligne */
    main .mag-grid, main .ed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }

    main h1 { font-size: 22px !important; }

    /* Champs : 16 px minimum (sinon l'iPhone zoome à la saisie) */
    main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    main select, main textarea, footer input { font-size: 16px !important; max-width: 100%; }

    /* Boutons principaux pleine largeur */
    main form button[type="submit"], main .btn-premium { max-width: 100%; }

    /* Article : barre de partage et auteur */
    main [style*="font-size: 48px"], main [style*="font-size: 42px"], main [style*="font-size: 40px"] { font-size: 24px !important; line-height: 1.25 !important; }
    main [style*="font-size: 36px"], main [style*="font-size: 32px"] { font-size: 22px !important; line-height: 1.3 !important; }
    .article-body, .article-content { font-size: 16px !important; }

    /* Kiosque : couverture au-dessus du texte */
    .mag-hero { padding: 24px 0 !important; margin-bottom: 24px !important; }
    .mag-hero-content { grid-template-columns: minmax(0, 1fr) !important; gap: 20px !important; text-align: center; }
    .mag-title { font-size: 28px !important; line-height: 1.15 !important; }
    .mag-summary-box { text-align: left; }
    .mag-archives-header { flex-wrap: wrap; gap: 10px; }
    .mag-cover-main, .mag-cover-main img { max-width: 240px !important; width: 100% !important; margin: 0 auto; }
    .mag-actions { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
    .mag-actions a { text-align: center; justify-content: center; }

    /* Direct : vidéo puis chat, l'un sous l'autre */
    main [style*="height: 600px"], main [style*="height: 550px"], main [style*="height: 500px"] { height: auto !important; min-height: 0 !important; }
    #live-chat-messages { max-height: 300px !important; }
}
