/* ═══════════════════════════════════════════════════════════════════════════
   Compact top area on phones (<= 767px). Loaded only when the switch is on
   (StorefrontHeaderSetting.compact_phone_header, App\Support\CompactPhoneHeader),
   and every rule is scoped to body.pk-compact-top, so without it nothing here applies.

   Before: app banner ~89px + promo strip 38px + header ~200px (logo row, a full
   search box) = the first content at ~330px on a 390px phone.
   Now: banner 52px + strip 28px + one 56px header row; the search is an icon that
   opens the same search field as an overlay row.

   Logical properties throughout (RTL). Taps are 44px.
═══════════════════════════════════════════════════════════════════════════ */

.pk-header-search-toggle,
.pk-search-close { display: none; }

@media (max-width: 767.98px) {

    /* ── 1. App banner: one row ────────────────────────────────────────── */
    body.pk-compact-top.smart-banner-visible { padding-top: 52px; }
    body.pk-compact-top .smart-banner {
        box-sizing: border-box;
        height: 52px;
        padding: 0 4px 0 8px;
        padding-inline: 4px 8px;
        gap: 8px;
    }
    body.pk-compact-top .smart-banner__close { width: 44px; height: 44px; font-size: 24px; }
    body.pk-compact-top .smart-banner__icon { width: 36px; height: 36px; border-radius: 9px; }
    body.pk-compact-top .smart-banner__title { font-size: 14px; line-height: 1.2; }
    body.pk-compact-top .smart-banner__subtitle { font-size: 11.5px; line-height: 1.2; }
    body.pk-compact-top .smart-banner__stars,
    body.pk-compact-top .smart-banner__store { display: none; }
    body.pk-compact-top .smart-banner__btn {
        display: inline-flex; align-items: center; justify-content: center;
        min-height: 44px; padding: 0 16px; font-size: 13px;
    }
    body.pk-compact-top .smart-banner__close:focus-visible,
    body.pk-compact-top .smart-banner__btn:focus-visible { outline: 2px solid #5C18E4; outline-offset: 1px; }

    /* ── 2. Promo strip: one slim line ─────────────────────────────────── */
    body.pk-compact-top .pf-strip { height: 28px; font-size: 12px; }
    body.pk-compact-top .pf-strip__item { padding: 0 24px; gap: 5px; }
    body.pk-compact-top .pf-strip__code { position: relative; padding: 3px 8px; border-radius: 5px; }
    /* A taller hit area than the 28px strip can show. */
    body.pk-compact-top .pf-strip__code::before { content: ''; position: absolute; inset: -10px -6px; }

    /* ── 3. Header: menu, logo, search icon, basket on one row ─────────── */
    body.pk-compact-top > header {
        max-width: none;
        margin: 0 !important; /* global.css pins header margins with !important */
        padding: 0 4px;
        gap: 0;
    }
    body.pk-compact-top > header .page-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 0 !important;
        min-height: 56px;
    }
    body.pk-compact-top > header .menu__btn {
        position: static; order: 1; flex: none;
        box-sizing: border-box; width: 44px; height: 44px; padding: 10px;
        align-items: center; justify-content: center;
    }
    body.pk-compact-top > header .menu__btn:focus-visible,
    body.pk-compact-top > header .pk-header-search-toggle:focus-visible,
    body.pk-compact-top > header .pk-search-close:focus-visible,
    body.pk-compact-top > header .bascket__btn:focus-visible { outline: 2px solid #5C18E4; outline-offset: -2px; border-radius: 10px; }
    body.pk-compact-top > header .web__logo {
        order: 2; flex: none;
        width: 96px !important; height: 32px !important;
        margin-inline: 4px auto;
    }
    body.pk-compact-top > header .pk-header-search-toggle {
        display: flex; order: 3; flex: none; align-items: center; justify-content: center;
        box-sizing: border-box; width: 44px; height: 44px; padding: 0;
        border: 0; background: none; cursor: pointer;
    }
    body.pk-compact-top > header .pk-header-search-toggle img { width: 24px; height: 24px; }
    body.pk-compact-top > header .bascket__btn {
        position: relative !important; inset: auto !important; order: 4; flex: none;
        box-sizing: border-box; width: 44px !important; height: 44px !important;
        align-items: center; justify-content: center;
    }
    body.pk-compact-top > header .bascket__btn img { width: 24px; height: 24px; }
    /* The count's inline style pins it with physical top/right: move it with logical ones. */
    body.pk-compact-top > header .bascket__btn .basket-count {
        top: 2px !important; right: auto !important; inset-inline-end: 0 !important;
    }
    /* "Delivering to" (signed in, home page): its own row under the icons, as before. */
    body.pk-compact-top > header .page-header .delivery-area {
        order: 9; flex: 1 0 calc(100% - 20px); width: auto; margin: 0 10px 10px;
    }

    /* ── The search: an overlay row under the header row ───────────────── */
    body.pk-compact-top > header .web__search { display: none !important; }
    body.pk-compact-top > header.is-search-open .web__search {
        display: flex !important;
        position: absolute; top: 100%; inset-inline: 0; z-index: 9000;
        box-sizing: border-box; width: auto; margin: 0;
        align-items: center; gap: 8px;
        padding: 8px 4px 8px 16px !important;
        padding-inline: 16px 4px !important;
        background: #fff; border-radius: 0 !important;
        border-bottom: 1px solid #eceef3; box-shadow: 0 8px 16px rgba(16, 22, 40, .08);
    }
    body.pk-compact-top > header.is-search-open .web__search input {
        flex: 1; min-width: 0; height: 40px; padding: 0 12px;
        border-radius: 10px; background: #f4f5f9; font-size: 16px;
    }
    body.pk-compact-top > header.is-search-open .web__search input:focus-visible { outline: 2px solid #5C18E4; outline-offset: 0; }
    body.pk-compact-top > header.is-search-open .pk-search-close {
        display: flex; flex: none; align-items: center; justify-content: center;
        box-sizing: border-box; width: 44px; height: 44px; padding: 0;
        border: 0; background: none; cursor: pointer;
    }
    body.pk-compact-top > header.is-search-open .pk-search-close img { width: 20px; height: 20px; }
    /* The suggestions open under the row, full width. */
    body.pk-compact-top > header.is-search-open .web__search .search-autocomplete { inset-inline: 8px; width: auto; min-width: 0; }

    /* The funnel pages (basket, checkout) have no header search at all. */
    body.pk-compact-top:has(.bassket__section) > header .pk-header-search-toggle { display: none !important; }
}
