/*
 * CafePOS+ rendering / scroll tuning (customer + cashier).
 * Keeps the SaaS look; reduces blur/filters inside scroll-heavy regions,
 * containment for isolation, skeleton media frames shared across apps.
 */

/* ---------------------------------------------------------------------------
   Shared skeleton + deferred image fade (needs data-media-frame + cafepos-async-img)
--------------------------------------------------------------------------- */
.customer-public [data-media-frame],
.cafepos-staff [data-media-frame] {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    overflow-anchor: none;
    background: #dff4e8;
}

.customer-public [data-media-frame]::before,
.cafepos-staff [data-media-frame]::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease, visibility 0.2s step-end;
    background: linear-gradient(
        135deg,
        #dff4e8,
        #edf7f0,
        #eaf3ff
    );
}

.customer-public [data-media-frame]::after,
.cafepos-staff [data-media-frame]::after {
    content: none;
}

.customer-public [data-media-frame].is-media-ready::before,
.cafepos-staff [data-media-frame].is-media-ready::before {
    opacity: 0;
    visibility: hidden;
    animation: none;
}

.customer-public [data-media-frame].is-media-ready::after,
.cafepos-staff [data-media-frame].is-media-ready::after {
    opacity: 0;
    visibility: hidden;
    animation: none;
}

.customer-public [data-media-frame] > img,
.cafepos-staff [data-media-frame] > img {
    position: relative;
    z-index: 1;
    opacity: 0;
    backface-visibility: hidden;
    transform: translateZ(0);
    transition: opacity 0.18s ease;
}

.customer-public [data-media-frame].is-media-ready > img,
.cafepos-staff [data-media-frame].is-media-ready > img {
    opacity: 1;
}

.customer-public .customer-product-media > .customer-product-ribbon {
    z-index: 2;
}

/* =======================================================================
   CUSTOMER (public storefront)
 ======================================================================== */
.customer-public {
    --cafepos-cp-blur-chrome: blur(14px);
    --cafepos-cp-blur-soft: blur(10px);
}

@media (max-width: 991.98px) {
    .customer-public {
        --cafepos-cp-blur-chrome: blur(10px);
        --cafepos-cp-blur-soft: blur(6px);
    }

    .customer-public .customer-topbar,
    .customer-public .customer-category-wrap {
        backdrop-filter: var(--cafepos-cp-blur-soft);
        -webkit-backdrop-filter: var(--cafepos-cp-blur-soft);
    }
}

.customer-public .customer-topbar {
    backdrop-filter: var(--cafepos-cp-blur-chrome);
    -webkit-backdrop-filter: var(--cafepos-cp-blur-chrome);
}

/* Product cards — no backdrop blur (scroll regions); solid surface */
.customer-public .customer-product-card {
    contain: layout;
    overflow-anchor: none;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.94) !important;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.customer-public .customer-product-media,
.customer-public .customer-trending-thumb-frame,
.customer-public .customer-strip-cell {
    contain: layout;
}

.customer-public .customer-main {
    overflow: visible;
}

.customer-public .customer-menu-shell {
    overflow: visible;
}

@supports (overflow: clip) {
    .customer-public,
    .customer-public .customer-main {
        overflow-x: clip;
    }
}

.customer-public .customer-menu-catalog {
    contain: layout;
}

/* Skip rendering far-off menu categories until needed (scroll perf) */
@supports (content-visibility: auto) {
    .customer-public .customer-category-section {
        content-visibility: auto;
        contain-intrinsic-size: 1px 480px;
    }
}

.customer-public .customer-trending-rail {
    contain: layout;
}


.customer-public .customer-category-wrap {
    z-index: 1035;
    transform: none;
    will-change: auto;
    overflow-anchor: none;
}

@media (hover: hover) and (pointer: fine) {
    .customer-public .customer-product-card:hover {
        transform: translateY(-4px);
        border-color: rgba(27, 67, 50, 0.2);
        box-shadow: var(--customer-shadow-strong);
    }
}

.customer-public .reservation-order-fab {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.customer-public .reservation-order-fab:hover {
    box-shadow: 0 22px 50px rgba(27, 67, 50, 0.3);
}

.customer-public .customer-category-chip {
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.customer-public .customer-category-chip.is-active,
.customer-public .customer-category-chip:hover {
    box-shadow: 0 12px 24px rgba(27, 67, 50, 0.18);
}

.customer-public .customer-category-bar,
body.cafepos-staff .category-chip-bar {
    scroll-snap-type: none;
}

.customer-public .customer-category-chip,
body.cafepos-staff .category-chip {
    scroll-snap-align: none;
}

.customer-public .async-fade {
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.customer-public .async-fade.htmx-swapping,
.customer-public .async-fade.htmx-settling {
    opacity: 1;
    transform: none;
    animation: none;
}

.customer-public .customer-trending-thumb-frame img {
    width: 100%;
    height: 100%;
}

.customer-public .reservation-order-drawer-lines {
    overscroll-behavior: contain;
}

/* =======================================================================
   CASHIER / POS (cafepos-staff)
 ======================================================================== */
.cafepos-staff {
    --cafepos-pos-section-intrinsic: 520px;
}

body.cafepos-staff .sidebar {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.cafepos-staff #pos-menu-grid.async-fade,
body.cafepos-staff .cart-shell.async-fade {
    transition: opacity 0.18s ease, transform 0.18s ease;
}

body.cafepos-staff #pos-menu-grid.async-fade.htmx-swapping,
body.cafepos-staff #pos-menu-grid.async-fade.htmx-settling {
    opacity: 1;
    transform: none;
    animation: none;
}

/* Grid cells isolate layout; avoids full-view repaints cascading */
body.cafepos-staff #pos-workspace .adaptive-menu-grid > .menu-item {
    contain: layout;
    overflow-anchor: none;
}

body.cafepos-staff .pos-product-media-frame,
body.cafepos-staff .addon-thumb-frame {
    contain: layout;
}

/* Stable POS product thumbnail */
body.cafepos-staff .pos-product-media-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: var(--cafepos-radius-lg) var(--cafepos-radius-lg) 0 0;
}

body.cafepos-staff .pos-product-media-frame .pos-product-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100% !important;
    aspect-ratio: unset;
    object-fit: cover;
}

body.cafepos-staff .addon-thumb-frame {
    width: 88px;
    height: 88px;
    flex: 0 0 auto;
    border-radius: 12px;
}

body.cafepos-staff .addon-thumb-frame .addon-thumb {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
}

/* Remove expensive glass/backdrop INSIDE scrolling POS chrome */
body.cafepos-staff .cashier-pos-grid .card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.97) !important;
}

body.cafepos-staff .cashier-pos-grid .interactive-card {
    transition: transform 0.2s ease, border-color 0.2s ease !important;
}

@media (hover: hover) and (pointer: fine) {
    body.cafepos-staff .cashier-pos-grid .interactive-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--cafepos-shadow-md);
    }
}

/* Grayscale unavailable items is repaint-heavy — use lightness only */
body.cafepos-staff .pos-product-card.unavailable,
body.cafepos-staff .addon-card.unavailable {
    filter: none;
    opacity: 0.57;
}

/* Cart panel isolation (HTMX swaps) */
body.cafepos-staff .pos-cart-panel {
    contain: layout;
}

/* Scroll column: tame overscroll chaining */
body.cafepos-staff .cashier-pos-grid > .col-lg-8 {
    overscroll-behavior-y: contain;
}

/* Sidebar: lighter blur on handheld */
@media (max-width: 991.98px) {
    body.cafepos-staff .sidebar {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    body.cafepos-staff .cashier-pos-grid .card {
        box-shadow: 0 8px 20px rgba(27, 67, 50, 0.07) !important;
    }

    body.cafepos-staff .cashier-pos-grid .interactive-card:hover {
        transform: translateY(-1px);
        box-shadow: 0 10px 26px rgba(27, 67, 50, 0.09);
    }

    body.cafepos-staff .cashier-pos-grid .category-chip {
        transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease !important;
    }
}

@media (prefers-reduced-motion: reduce) {

    .customer-public [data-media-frame]::before,
    .cafepos-staff [data-media-frame]::before,
    .customer-public [data-media-frame]::after,
    .cafepos-staff [data-media-frame]::after {
        opacity: 0;
        visibility: hidden;
        transition: none;
        animation: none;
    }

    .customer-public [data-media-frame] > img,
    .cafepos-staff [data-media-frame] > img {
        opacity: 1;
        transition: none;
    }

    .customer-public .customer-product-card,
    .customer-public .interactive-card,
    body.cafepos-staff .cashier-pos-grid .interactive-card {
        transition: none !important;
    }

    body.cafepos-staff .cashier-pos-grid .interactive-card:hover {
        transform: none;
    }
}
