/* ================================
   FICHE D'AGENCE EN PANNEAU GLISSANT (mobile)
   ================================
   Chargé après responsive.css. Sur grand écran, la fiche reste sous la carte
   et la poignée est masquée. Sur petit écran (BOTTOM_SHEET_QUERY, BottomSheet.js),
   la fiche glisse depuis le bas par-dessus la page : la carte reste visible
   au-dessus, sans défilement. Seul le contenu de la fiche défile.
   États : .is-collapsed (seul l'en-tête dépasse), .is-dragging (suit le doigt,
   décalage dans --sheet-drag). */

.sheet-handle {
    display: none;
}

@media (max-width: 768px) {
    .agency-panel {
        --sheet-peek: 7.5rem;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        display: flex;
        flex-direction: column;
        max-height: 60vh;
        max-height: 60dvh;
        padding: 0;
        border-width: 2px 0 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
        overflow: hidden;
        animation: sheetUp 0.3s ease;
        transform: translateY(var(--sheet-drag, 0px));
        transition: transform var(--transition-normal);
    }

    .agency-panel.is-collapsed {
        transform: translateY(calc(100% - var(--sheet-peek) + var(--sheet-drag, 0px)));
    }

    .agency-panel.is-dragging {
        transition: none;
    }

    /* Seul le contenu défile ; la poignée et le bouton × restent en place */
    .agency-panel #agency-content {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0 var(--spacing-md) calc(var(--spacing-md) + env(safe-area-inset-bottom, 0px));
    }

    /* Poignée : zone tactile large, barre visible au centre */
    .sheet-handle {
        display: block;
        flex-shrink: 0;
        width: 100%;
        height: 44px; /* cible tactile */
        border: none;
        background: transparent;
        cursor: grab;
        touch-action: none;
        position: relative;
    }

    .sheet-handle::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 3rem;
        height: 5px;
        border-radius: 999px;
        background: var(--text-secondary);
        transform: translate(-50%, -50%);
    }

    .is-dragging .sheet-handle {
        cursor: grabbing;
    }

    .agency-panel .close-btn {
        top: 0.25rem;
        right: 0.5rem;
        z-index: 1;
        width: 44px;
        height: 44px;
        line-height: 1;
    }

    /* En-tête compact : il sert d'aperçu quand le panneau est réduit */
    .agency-panel .agency-header {
        padding-right: 2.5rem;
        margin-bottom: var(--spacing-sm);
    }

    .agency-panel .agency-title {
        font-size: 1.5rem;
    }

    .agency-panel .agency-rocket {
        font-size: 1rem;
    }

    /* Un ancêtre transformé (animation fadeIn de .view) servirait de repère à
       position: fixed : le panneau serait placé dans la vue et non dans l'écran */
    #map-view {
        animation-name: viewFade;
    }
}

@keyframes viewFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes sheetUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .agency-panel {
        animation: none;
        transition: none;
    }
}
