/* Lionshop PWA — app-shell styles. Loaded only when the plugin is enabled.
   Faz 1: safe-area + "new version" bar.  Faz 2: bottom tab bar, touch polish, page transitions,
   skeleton shimmer, "add to home screen" prompt.
   Everything that changes the look is scoped to standalone mode (html.pwa-standalone is set by pwa.js,
   display-mode media query for the transition rules) unless the admin chose "every mobile visit". */

:root {
    --pwa-tabbar-h: 56px;
    --pwa-safe-b: env(safe-area-inset-bottom, 0px);
}

/* ==========================================================================
   1. Standalone safe-area (Faz 1)
   ========================================================================== */
html.pwa-standalone body {
    padding-bottom: var(--pwa-safe-b);
}

html.pwa-standalone .sticky-add-to-bag {
    padding-bottom: calc(12px + var(--pwa-safe-b));
}

html.pwa-standalone body.has-sticky-bag {
    padding-bottom: calc(76px + var(--pwa-safe-b));
}

html.pwa-standalone .html-category-page .plp-filters__foot {
    padding-bottom: calc(14px + var(--pwa-safe-b));
}

/* ==========================================================================
   2. "A new version is ready" bar (Faz 1)
   ========================================================================== */
.pwa-update-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--pwa-safe-b));
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #141414;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    font-size: 14px;
    line-height: 1.3;
    font-weight: 600;
}

.pwa-update-bar button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 14px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    color: #141414;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.pwa-update-bar button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ==========================================================================
   3. Bottom tab bar (Faz 2) — markup is always rendered when the mode is not Off;
      CSS decides visibility so the browser view stays untouched in "standalone" mode.
   ========================================================================== */
.pwa-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 990; /* below the theme's off-canvas panels (1050+) and the PLP drawer (1001+) */
    display: none;
    box-sizing: border-box;
    height: calc(var(--pwa-tabbar-h) + var(--pwa-safe-b));
    padding: 0 0 var(--pwa-safe-b);
    background: #fff;
    border-top: 1px solid #e5e5e5;
    -webkit-user-select: none;
    user-select: none;
    transform: translateY(0);
    transition: transform .22s ease;
    view-transition-name: pwa-tabbar;
    border-radius: 0 !important; /* the theme reset rounds every element (10px !important); a tab bar must be edge-to-edge */
}

.pwa-tabbar__list,
.pwa-tabbar__list li,
.pwa-tabbar__item {
    border-radius: 0 !important;
}

.pwa-tabbar--hidden {
    transform: translateY(100%);
}

.pwa-tabbar__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--pwa-tabbar-h);
}

.pwa-tabbar__list li {
    margin: 0;
    padding: 0;
    min-width: 0;
}

.pwa-tabbar__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: #757575;
    text-decoration: none;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .04em;
    text-transform: uppercase;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pwa-tabbar__item:hover,
.pwa-tabbar__item:visited {
    color: #757575;
    text-decoration: none;
}

.pwa-tabbar__item[aria-current="page"],
.pwa-tabbar__item[aria-current="page"]:hover {
    color: #141414;
}

.pwa-tabbar__item:active {
    opacity: .6;
}

.pwa-tabbar__item:focus-visible {
    outline: 2px solid #141414;
    outline-offset: -2px;
}

.pwa-tabbar__icon {
    position: relative;
    display: inline-flex;
}

.pwa-tabbar__icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.pwa-tabbar__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pwa-tabbar__badge {
    position: absolute;
    top: -6px;
    right: -10px;
    box-sizing: border-box;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #141414;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    letter-spacing: 0;
}

.pwa-tabbar__badge[hidden] {
    display: none;
}

/* visibility by mode */
html.pwa-standalone .pwa-tabbar[data-mode="standalone"] {
    display: block;
}

@media (max-width: 959px) {
    .pwa-tabbar[data-mode="all"] {
        display: block;
    }
}

/* room for the bar — html.pwa-has-tabbar is set by pwa.js when the bar is actually displayed */
html.pwa-has-tabbar body {
    padding-bottom: calc(var(--pwa-tabbar-h) + var(--pwa-safe-b));
}

html.pwa-has-tabbar .sticky-add-to-bag {
    bottom: calc(var(--pwa-tabbar-h) + var(--pwa-safe-b));
    padding-bottom: 12px;
    box-shadow: none;
    border-top: 1px solid #eee;
}

html.pwa-has-tabbar body.has-sticky-bag {
    padding-bottom: calc(76px + var(--pwa-tabbar-h) + var(--pwa-safe-b));
}

html.pwa-has-tabbar .eu-cookie-bar-notification {
    bottom: calc(var(--pwa-tabbar-h) + var(--pwa-safe-b));
}

html.pwa-has-tabbar .pwa-update-bar,
html.pwa-has-tabbar .pwa-install {
    bottom: calc(var(--pwa-tabbar-h) + var(--pwa-safe-b) + 12px);
}

/* ==========================================================================
   4. Touch polish — standalone only
   ========================================================================== */
html.pwa-standalone {
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none; /* no browser pull-to-refresh inside the app */
}

html.pwa-standalone a,
html.pwa-standalone button,
html.pwa-standalone [role="button"],
html.pwa-standalone input[type="submit"],
html.pwa-standalone input[type="button"] {
    touch-action: manipulation; /* no 300 ms double-tap delay, pinch still allowed */
}

html.pwa-standalone .responsive-nav-wrapper {
    -webkit-user-select: none;
    user-select: none;
}

@media (hover: none) {
    html.pwa-standalone .item-box:active {
        transform: scale(.985);
        transition: transform .12s ease;
    }
}

/* ==========================================================================
   5. Page transitions — cross-document View Transitions, standalone only.
      Browsers without support ignore the whole block; reduced motion turns it off.
   ========================================================================== */
@media (display-mode: standalone) {
    @view-transition {
        navigation: auto;
    }

    ::view-transition-old(root) {
        animation: pwa-vt-out 110ms ease-in both;
    }

    ::view-transition-new(root) {
        animation: pwa-vt-in 180ms ease-out both;
    }

    /* the tab bar stays put while the page crossfades */
    ::view-transition-group(pwa-tabbar),
    ::view-transition-old(pwa-tabbar),
    ::view-transition-new(pwa-tabbar) {
        animation: none;
    }

    @media (prefers-reduced-motion: reduce) {
        @view-transition {
            navigation: none;
        }
    }
}

@keyframes pwa-vt-out {
    to { opacity: 0; }
}

@keyframes pwa-vt-in {
    from { opacity: 0; transform: translateY(8px); }
}

/* ==========================================================================
   6. Skeleton shimmer on AJAX reloads — standalone only
   ========================================================================== */
html.pwa-standalone .tabbed-carousel__panel.is-loading,
html.pwa-standalone .products-wrapper.is-loading {
    position: relative;
    overflow: hidden;
}

html.pwa-standalone .tabbed-carousel__panel.is-loading::after,
html.pwa-standalone .products-wrapper.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .75) 50%, rgba(255, 255, 255, 0) 100%);
    background-size: 200% 100%;
    animation: pwa-shimmer 1.1s linear infinite;
}

@keyframes pwa-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ==========================================================================
   7. "Add to home screen" prompt — browser mode only (pwa.js never shows it in standalone)
   ========================================================================== */
.pwa-install {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--pwa-safe-b));
    z-index: 1045; /* under the theme header/panels, over content */
    display: grid;
    grid-template-columns: 48px 1fr 32px;
    gap: 10px 12px;
    align-items: start;
    box-sizing: border-box;
    padding: 14px 12px 12px 14px;
    background: #fff;
    color: #141414;
    border: 1px solid #e5e5e5;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
    font-size: 14px;
    line-height: 1.35;
}

.pwa-install[hidden] {
    display: none;
}

.pwa-install__icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid #eee;
    background: #fff;
}

.pwa-install__title {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
}

.pwa-install__text {
    margin: 0;
    color: #4a4741;
}

.pwa-install__text[hidden] {
    display: none;
}

.pwa-install__text svg {
    width: 16px;
    height: 16px;
    vertical-align: -3px;
    fill: currentColor;
}

.pwa-install__close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #757575;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.pwa-install__actions {
    grid-column: 2 / -1;
    display: flex;
    gap: 8px;
}

.pwa-install__actions[hidden] {
    display: none;
}

.pwa-install__btn {
    min-height: 40px;
    padding: 8px 16px;
    border: 0;
    border-radius: 10px;
    background: #141414;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.pwa-install__btn--ghost {
    background: transparent;
    color: #141414;
}

.pwa-install__btn:focus-visible,
.pwa-install__close:focus-visible {
    outline: 2px solid #141414;
    outline-offset: 2px;
}

/* ==========================================================================
   Wide screens: bars hug the right edge instead of stretching
   ========================================================================== */
@media (min-width: 600px) {
    .pwa-update-bar,
    .pwa-install {
        left: auto;
        right: 24px;
        max-width: 420px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-tabbar {
        transition: none;
    }

    html.pwa-standalone .tabbed-carousel__panel.is-loading::after,
    html.pwa-standalone .products-wrapper.is-loading::after {
        animation: none;
    }

    html.pwa-standalone .item-box:active {
        transform: none;
    }
}
