/**
 * MOBILE MAP OVERRIDES — INTRO_1 + ANUNAKI
 * Google Maps-style bottom sheet pattern
 *
 * Ladowany WYLACZNIE na stronie demo (page-parcelselector-demo.php).
 * Pliki intro-popup.css i anunaki-popup.css pozostaja nienaruszone.
 *
 * Urzadzenia: smartfony i tablety (max-width: 768px)
 * Orientacja: portrait + landscape (osobne reguly)
 *
 * UX flow na mobile:
 *   1. Mapa wypelnia caly ekran (fullscreen)
 *   2. Header: minimalny pasek (flagi + X) — logo ukryte
 *   3. Sidebar: bottom sheet — wysuwa sie od dolu nad mapa
 *      - Drag handle (szary paski) sugeruje mozliwosc przesuwania
 *      - Wyszukiwarka zawsze widoczna u gory sheeta
 *      - Wyniki pojawiaja sie ponizej pola wyszukiwania (max 50% ekranu)
 *   4. Klikniecie markera: detail panel wysuwa sie od dolu (80vh max)
 *   5. Landscape: header jeszcze mniejszy, sidebar max 35%
 */

/* ============================================================
   INTRO_1 — Portrait mobile (<=768px)
   ============================================================ */
@media (max-width: 768px) {

    /* OVERLAY: bez blur — oszczednosc GPU na slabszych urzadzeniach */
    .inpost-popup-overlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    /* CONTAINER: scisly pelny ekran
       100dvh = dynamic viewport height — uwzglednia toolbar Chrome/Safari/Firefox
       Fallback 100vh dla starszych przegladarek */
    .inpost-popup-container {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        max-width: none;
        border-radius: 0;
        margin: 0;
        animation: none;
    }

    /* HEADER: minimalny pasek ~52px */
    .inpost-popup-header {
        flex-shrink: 0;
    }

    .inpost-popup-header-top {
        padding: 6px 10px;
        gap: 6px;
        min-height: 52px;
    }

    /* Logo: ukryte — miejsce dla flag i przycisku X
       Przycisk zamknij (.inpost-popup-close) pozostaje widoczny */
    .inpost-popup-logo-left {
        display: none;
    }
    .inpost-popup-logo-right .inpost-logo-img,
    .inpost-popup-logo-right .shop-logo-img {
        display: none;
    }
    .inpost-popup-logo-right {
        min-width: 44px;
        justify-content: flex-end;
    }

    /* Flagi: pelna szerokosc, horizontal scroll, bez widocznego scrollbara */
    .inpost-popup-flags {
        flex: 1;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        gap: 4px;
        padding: 4px 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .inpost-popup-flags::-webkit-scrollbar { display: none; }

    .inpost-flag-btn {
        width: 30px;
        height: 30px;
        font-size: 17px;
        flex-shrink: 0;
        border-width: 2px;
    }
    .inpost-flag-btn.active::after {
        width: 14px;
        height: 14px;
        font-size: 9px;
        bottom: -3px;
        right: -3px;
    }

    /* Instrukcje (dolny wiersz headera): ukryte — zbedne na mobile */
    .inpost-popup-header-bottom {
        display: none;
    }

    /* BODY: kontener wzgledny — mapa i sidebar pozycjonowane absolutnie */
    .inpost-popup-body {
        flex: 1;
        flex-direction: column;
        position: relative;
        min-height: 0;
        overflow: hidden;
    }

    /* MAPA: absolute fill — wypelnia caly obszar body */
    .inpost-popup-map-container {
        position: absolute;
        inset: 0;
        flex: none;
        width: 100%;
        height: 100%;
    }

    /* SIDEBAR: bottom sheet nakladajacy sie na mape
       touch-action: pan-y — przewijanie listy nie porusza mapa */
    .inpost-popup-sidebar {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50%;
        z-index: 500;
        background: #fff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
        border-right: none;
        display: flex;
        flex-direction: column;
        touch-action: pan-y;
    }

    /* Drag handle — wizualny hint sugerujacy mozliwosc przesuwania */
    .inpost-popup-sidebar::before {
        content: '';
        display: block;
        flex-shrink: 0;
        width: 36px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        margin: 8px auto 0;
    }

    /* Lista punktow: przewijalna wewnatrz sheeta
       overscroll-behavior: contain — nie propaguje scrollu na mape */
    .inpost-points-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Footer statystyki: ukryty — zbedny na mobile */
    .inpost-popup-footer {
        display: none;
    }

    /* SELECTION MODE override: sidebar zostaje widoczny po wyborze paczkomatu
       (na desktopie chowa sie — tu nie chcemy tego zachowania) */
    .ps-selection-mode .inpost-popup-sidebar {
        transform: none !important;
        margin-left: 0 !important;
        opacity: 1 !important;
    }

    /* DETAIL MODAL: wysuwa sie od dolu jak bottom sheet */
    .inpost-detail-modal {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 80vh;
        max-height: 80dvh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
    }

    .detail-modal-header h3 {
        font-size: 18px;
        padding-right: 55px;
    }

    .detail-modal-close {
        width: 48px;
        height: 48px;
        font-size: 26px;
    }

    .detail-modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    .detail-modal-footer .inpost-btn {
        width: 100%;
    }
}

/* iPhone SE i bardzo male ekrany: scisly pelny ekran bez marginesow */
@media (max-width: 480px) {
    .inpost-popup-container {
        width: 100% !important;
        margin: 0 !important;
        inset: 0 !important;
    }
}

/* ============================================================
   INTRO_1 — Landscape mobile (krotki ekran, np. iPhone poziomo)
   max-height: 500px wyklucza tablety w landscape
   ============================================================ */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {

    .inpost-popup-container {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        margin: 0;
        animation: none;
    }

    /* Header jeszcze bardziej kompaktowy — liczy sie kazdy piksel */
    .inpost-popup-header-top {
        padding: 4px 10px;
        min-height: 40px;
    }
    .inpost-popup-header-bottom { display: none; }
    .inpost-popup-logo-left { display: none; }
    .inpost-popup-logo-right .inpost-logo-img,
    .inpost-popup-logo-right .shop-logo-img { display: none; }
    .inpost-popup-logo-right { min-width: 40px; }

    .inpost-flag-btn {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }

    .inpost-popup-body {
        flex: 1;
        position: relative;
        min-height: 0;
        overflow: hidden;
    }

    .inpost-popup-map-container {
        position: absolute;
        inset: 0;
        flex: none;
        width: 100%;
        height: 100%;
    }

    /* Sidebar: max 35% — landscape jest krotki, mapa musi oddychac */
    .inpost-popup-sidebar {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 35%;
        z-index: 500;
        background: #fff;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -3px 16px rgba(0, 0, 0, 0.18);
        border-right: none;
        display: flex;
        flex-direction: column;
        touch-action: pan-y;
    }

    .inpost-popup-sidebar::before {
        content: '';
        display: block;
        flex-shrink: 0;
        width: 30px;
        height: 3px;
        background: #ddd;
        border-radius: 2px;
        margin: 6px auto 0;
    }

    .inpost-popup-footer { display: none; }

    .ps-selection-mode .inpost-popup-sidebar {
        transform: none !important;
        margin-left: 0 !important;
        opacity: 1 !important;
    }
}

/* ============================================================
   ANUNAKI — Mobile fixes (<=768px)
   ============================================================ */
@media (max-width: 768px) {

    /* Overlay: bez blur na mobile */
    .ank-overlay {
        padding: 0;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    /* Container: scisly pelny ekran */
    .ank-container {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        max-width: none;
        border-radius: 0;
        animation: none;
    }

    .ank-header-top { padding: 8px 12px; gap: 8px; }
    .ank-flags { padding: 0 12px 8px; }

    /* Detail panel: od dolu, bez marginesow */
    .ank-detail-panel {
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 16px 16px 0 0;
    }
}

/* ANUNAKI landscape */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .ank-container {
        position: fixed;
        inset: 0;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        animation: none;
    }
    .ank-header-top { padding: 4px 12px; min-height: 40px; }
}
