/* Globimat — version smartphone (écrans < 1024px) */

/* Barre de navigation : reste en haut de l'écran sur tous les écrans
   (l'emporte sur "body > *:not(.logo-watermark) { position: relative }" des pages) */
body > nav.fixed {
    position: fixed;
    z-index: 50;
}

/* Les liens vers une section (#presentation…) ne la cachent pas sous la barre */
html {
    scroll-padding-top: 80px;
}

@media (max-width: 1023px) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        overflow-x: hidden;
    }

    nav.fixed {
        padding-top: env(safe-area-inset-top, 0);
    }

    nav.fixed > div:not(.mobile-nav-panel) {
        height: 64px;
        padding-left: max(1rem, env(safe-area-inset-left, 0));
        padding-right: max(1rem, env(safe-area-inset-right, 0));
    }

    nav.fixed .logo-nav {
        height: 2.5rem;
        width: 2.5rem;
    }

    nav.fixed .font-semibold.text-xl {
        font-size: 1.125rem;
    }

    nav.fixed .flex.items-center.gap-3 {
        gap: 0.5rem;
    }

    /* Bouton contact compact */
    nav.fixed a[href="contact.html"]:not(.mobile-nav-cta) {
        padding: 0.55rem 0.85rem;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    /* Filigrane logo */
    .logo-watermark img {
        width: min(72vw, 300px);
        opacity: 0.07;
    }

    /* Décalage contenu sous la barre */
    .pt-\[72px\] {
        padding-top: 64px !important;
    }

    .section {
        scroll-margin-top: 72px;
    }

    /* Sections : espacement réduit */
    .py-20 {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }

    .py-16 {
        padding-top: 2.5rem;
        padding-bottom: 2.5rem;
    }

    .py-14 {
        padding-top: 2.25rem;
        padding-bottom: 2.25rem;
    }

    .py-10 {
        padding-top: 1.75rem;
        padding-bottom: 1.75rem;
    }

    /* Hero */
    header .text-4xl,
    header h1.text-3xl {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }

    header .text-lg {
        font-size: 1rem;
    }

    header .flex.flex-wrap.gap-4 {
        flex-direction: column;
    }

    header .flex.flex-wrap.gap-4 a {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* Badges flottants sur images */
    .absolute.-bottom-4.-left-4,
    .absolute.-bottom-4 {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        margin-top: 1rem;
        max-width: 100% !important;
    }

    /* Cartes et grilles */
    .card-lift:hover {
        transform: none;
    }

    /* Tableau comparatif : défilement horizontal */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .compare-table th,
    .compare-table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.8125rem;
    }

    .compare-table .col-feature {
        min-width: 11rem;
    }

    .compare-table .col-plan {
        min-width: 6.5rem;
    }

    /* Logos formules */
    .formula-logo-lg {
        width: 10rem;
        height: 10rem;
    }

    .formula-logo-lg.formula-logo-express {
        width: 11rem;
        height: 11rem;
    }

    /* Pages import : hero image */
    .relative.h-64.sm\:h-80.lg\:h-96 {
        height: 14rem;
    }

    .relative.h-64.sm\:h-80.lg\:h-96 h1 {
        font-size: 1.5rem !important;
    }

    /* Footer */
    footer .flex-col.sm\:flex-row {
        text-align: center;
    }

    /* Bouton hamburger */
    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
        border: 1px solid #e2e8f0;
        border-radius: 0.65rem;
        background: #fff;
        color: var(--navy, #1e3a5f);
        cursor: pointer;
        flex-shrink: 0;
        transition: border-color 0.2s, background 0.2s;
    }

    .mobile-nav-toggle:hover,
    .mobile-nav-toggle[aria-expanded="true"] {
        border-color: var(--green, #166534);
        background: #ecfdf5;
    }

    .mobile-nav-toggle-icon {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 18px;
        height: 14px;
    }

    .mobile-nav-toggle-icon span {
        display: block;
        height: 2px;
        width: 100%;
        background: currentColor;
        border-radius: 1px;
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    .mobile-nav-toggle[aria-expanded="true"] .mobile-nav-toggle-icon span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .mobile-nav-toggle[aria-expanded="true"] .mobile-nav-toggle-icon span:nth-child(2) {
        opacity: 0;
    }

    .mobile-nav-toggle[aria-expanded="true"] .mobile-nav-toggle-icon span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Nav en colonne : barre + panneau menu intégré */
    nav.fixed.has-mobile-nav {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    /* Fond assombri derrière le menu */
    body > div.mobile-nav-overlay {
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(15, 23, 42, 0.35);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .mobile-nav-overlay.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Panneau menu : déroulement fluide sous la barre */
    .mobile-nav-panel {
        display: block;
        width: 100%;
        max-height: 0;
        background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
        border-top: 1px solid transparent;
        box-shadow: none;
        transition: max-height 0.32s ease, border-color 0.2s ease, box-shadow 0.32s ease;
        overflow: hidden;
    }

    .mobile-nav-panel.is-open {
        max-height: calc(100vh - 64px);
        max-height: calc(100dvh - 64px);
        border-top-color: #e2e8f0;
        box-shadow: 0 14px 28px rgba(30, 58, 95, 0.1);
    }

    .mobile-nav-menu {
        box-sizing: border-box;
        width: 100%;
        max-height: calc(100vh - 64px);
        max-height: calc(100dvh - 64px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 0.35rem max(1rem, env(safe-area-inset-left, 0)) max(1rem, env(safe-area-inset-bottom, 0)) max(1rem, env(safe-area-inset-right, 0));
        max-width: 72rem;
        margin: 0 auto;
    }

    .mobile-nav-list {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
    }

    .mobile-nav-link {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        padding: 0.9rem 1rem;
        min-height: 3rem;
        border-radius: 0.85rem;
        color: #334155;
        text-decoration: none;
        font-weight: 500;
        font-size: 0.9375rem;
        transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-link:active {
        transform: scale(0.98);
    }

    .mobile-nav-link-icon {
        width: 1.15rem;
        text-align: center;
        color: var(--navy, #1e3a5f);
        opacity: 0.7;
        flex-shrink: 0;
        font-size: 0.9rem;
    }

    .mobile-nav-link.is-active {
        background: #ecfdf5;
        color: var(--green, #166534);
        font-weight: 600;
        box-shadow: inset 3px 0 0 var(--green, #166534);
    }

    .mobile-nav-link.is-active .mobile-nav-link-icon {
        color: var(--green, #166534);
        opacity: 1;
    }

    html[dir="rtl"] .mobile-nav-link.is-active {
        box-shadow: inset -3px 0 0 var(--green, #166534);
    }

    .mobile-nav-group {
        border-radius: 0.85rem;
        overflow: hidden;
    }

    .mobile-nav-accordion {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        width: 100%;
        padding: 0.9rem 1rem;
        min-height: 3rem;
        border: none;
        border-radius: 0.85rem;
        background: none;
        font: inherit;
        font-weight: 500;
        font-size: 0.9375rem;
        color: #334155;
        cursor: pointer;
        text-align: start;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-accordion.is-open {
        background: #f1f5f9;
        color: var(--navy, #1e3a5f);
        font-weight: 600;
    }

    .mobile-nav-chevron {
        margin-left: auto;
        font-size: 0.625rem;
        opacity: 0.55;
        transition: transform 0.22s ease;
        flex-shrink: 0;
    }

    html[dir="rtl"] .mobile-nav-chevron {
        margin-left: 0;
        margin-right: auto;
    }

    .mobile-nav-accordion.is-open .mobile-nav-chevron {
        transform: rotate(180deg);
    }

    .mobile-nav-submenu {
        display: grid;
        grid-template-rows: 0fr;
        transition: grid-template-rows 0.25s ease;
        visibility: hidden;
        background: #f8fafc;
        border-radius: 0 0 0.85rem 0.85rem;
        margin: 0 0.35rem 0.35rem;
    }

    .mobile-nav-submenu.is-open {
        grid-template-rows: 1fr;
        visibility: visible;
    }

    .mobile-nav-submenu-inner {
        overflow: hidden;
        min-height: 0;
        padding: 0.25rem 0 0.5rem;
    }

    .mobile-nav-submenu .mobile-nav-link--sub {
        padding: 0.75rem 1rem 0.75rem 2.5rem;
        font-size: 0.875rem;
        min-height: 2.75rem;
        border-radius: 0.65rem;
    }

    html[dir="rtl"] .mobile-nav-submenu .mobile-nav-link--sub {
        padding-left: 1rem;
        padding-right: 2.5rem;
    }

    .mobile-nav-footer {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #e2e8f0;
    }

    .mobile-nav-cta {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.6rem;
        width: 100%;
        padding: 0.95rem 1.25rem;
        min-height: 3.1rem;
        border-radius: 0.85rem;
        background: var(--green, #166534);
        color: #fff !important;
        font-weight: 600;
        font-size: 0.9375rem;
        text-decoration: none;
        box-shadow: 0 4px 14px rgba(22, 101, 52, 0.25);
        transition: background 0.15s ease, transform 0.15s ease;
    }

    .mobile-nav-cta:active {
        transform: scale(0.98);
        background: var(--green-dark, #14532d);
    }

    .mobile-nav-cta .mobile-nav-link-icon {
        color: #fff;
        opacity: 1;
    }

    /* Indication défilement tableau comparatif */
    .overflow-x-auto.rounded-2xl {
        position: relative;
    }

    .overflow-x-auto.rounded-2xl::after {
        content: '← glisser →';
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: #94a3b8;
        padding: 0.45rem 0 0.15rem;
        letter-spacing: 0.02em;
    }

    html[lang="en"] .overflow-x-auto.rounded-2xl::after { content: '← swipe →'; }
    html[lang="de"] .overflow-x-auto.rounded-2xl::after { content: '← wischen →'; }
    html[lang="it"] .overflow-x-auto.rounded-2xl::after { content: '← scorri →'; }
    html[lang="ar-MA"] .overflow-x-auto.rounded-2xl::after { content: '← اسحب →'; }

    body.mobile-nav-open {
        overflow: hidden;
    }

    nav.fixed.mobile-nav-open {
        z-index: 50;
    }
}

@media (max-width: 1023px) and (min-width: 641px) {
    .mobile-nav-toggle {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    nav.fixed a[href="contact.html"]:not(.mobile-nav-cta) {
        padding: 0.55rem;
        min-width: 2.5rem;
        text-align: center;
    }

    nav.fixed .font-semibold.text-xl {
        display: none;
    }
}

@media (max-width: 380px) {
    nav.fixed a[href="contact.html"]:not(.mobile-nav-cta) {
        font-size: 0;
        line-height: 0;
    }

    nav.fixed a[href="contact.html"]:not(.mobile-nav-cta)::after {
        content: '\f0e0';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.875rem;
        line-height: 1;
    }
}

/* Desktop : masquer les éléments mobile */
@media (min-width: 1024px) {
    .mobile-nav-toggle,
    .mobile-nav-overlay,
    .mobile-nav-panel {
        display: none !important;
    }

    nav.fixed.has-mobile-nav {
        display: block;
    }
}