/*
 * Phone layout. Loaded after the other store styles and only active up to 760px wide,
 * so the desktop layout is untouched.
 */
.m-tabbar, .m-back, .m-order-bar, .m-showroom { display: none; }
dialog.m-sheet { display: none; }
dialog.m-sheet[open] { display: block; }

@media (max-width: 760px) {
    :root { --m-tabbar: calc(3.75rem + env(safe-area-inset-bottom)); }
    body { padding-bottom: var(--m-tabbar); }

    /* ---------- One bottom tab bar with labels ---------- */
    .side-nav, .account-nav { display: none !important; }
    .m-tabbar {
        position: fixed;
        inset: auto 0 0;
        z-index: 35;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        height: var(--m-tabbar);
        padding: .2rem .25rem env(safe-area-inset-bottom);
        background: rgb(255 255 255 / .97);
        border-top: 1px solid #e6e6e6;
        box-shadow: 0 -6px 20px rgb(0 0 0 / .06);
        backdrop-filter: blur(10px);
    }
    .m-tabbar > a, .m-tabbar > button {
        position: relative;
        display: grid;
        justify-items: center;
        align-content: center;
        gap: .18rem;
        min-height: 3.3rem;
        padding: 0;
        border: 0;
        background: none;
        color: #6b6b6b;
        font-size: .68rem;
        font-weight: 600;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .m-tabbar svg { width: 1.45rem; height: 1.45rem; fill: currentColor; }
    .m-tabbar [aria-current="page"], .m-tabbar > :active { color: #141414; }
    .m-tabbar span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .m-tabbar .bag-count {
        position: absolute;
        top: .3rem;
        right: auto;
        left: calc(50% + .35rem);
        min-width: 1.1rem;
        height: 1.1rem;
        padding: 0 .25rem;
        border-radius: 1rem;
        background: #141414;
        color: #fff;
        font-size: .65rem;
        line-height: 1.1rem;
        text-align: center;
    }

    /* ---------- Header ---------- */
    .site-header { padding: .5rem 1rem .6rem; gap: .55rem; }
    .site-header .header-actions [data-dialog="account"] { display: none; }
    .site-header .header-icon { width: 2.75rem; height: 2.75rem; }
    .site-header .search { min-height: 2.9rem; }
    .site-header .search input { font-size: .95rem; text-overflow: ellipsis; }
    /* The virtual showroom is an icon in the header, left of saved products. */
    .showroom-launch { display: none !important; }
    .site-header .m-showroom { position: relative; display: grid; place-items: center; color: inherit; }
    .site-header .m-showroom svg { width: 1.6rem; height: 1.6rem; fill: none; stroke: none; }
    .m-showroom-tag {
        position: absolute;
        right: .1rem;
        bottom: .25rem;
        padding: 0 .2rem;
        border-radius: .3rem;
        background: #141414;
        color: #fff;
        font-size: .55rem;
        font-weight: 800;
        line-height: 1.2;
    }

    /* Even spacing from the header down: search, categories, then the first section. */
    .site-header { padding-bottom: .75rem; }
    .category-menu { margin-top: 0; padding-block: 0 .5rem; }
    main > .store-reviews { margin: 0; width: auto; max-width: none; }
    main > .blog-section { padding-top: 0; }
    main > .trust-strip { padding-block: 0; }

    /* Product, checkout and info pages: one short row — back, logo, saved and bag. */
    body:is(.page-product, .page-checkout, .page-page) .site-header {
        grid-template-columns: auto 1fr auto;
        align-items: center;
        padding-block: .45rem;
        gap: .4rem;
    }
    body:is(.page-product, .page-checkout, .page-page) .m-back {
        display: grid;
        place-items: center;
        width: 2.75rem;
        height: 2.75rem;
        margin-left: -.5rem;
        border-radius: 50%;
        color: inherit;
    }
    .m-back svg { width: 1.4rem; height: 1.4rem; }
    body:is(.page-product, .page-checkout, .page-page) .site-header .logo { grid-column: 2; grid-row: 1; justify-self: center; }
    body:is(.page-product, .page-checkout, .page-page) .site-header .header-actions { grid-column: 3; grid-row: 1; }
    body:is(.page-product, .page-checkout, .page-page) :is(.site-header .search, .showroom-launch, .category-menu) { display: none !important; }
    body:is(.page-product, .page-checkout, .page-page) .site-header .m-showroom { display: none; }
    body.page-checkout .announcement-bar { display: none; }

    /* ---------- Menu and search sheets ---------- */
    dialog.m-sheet {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 22rem);
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0;
        padding: 0;
        border: 0;
        background: #fff;
        overflow-y: auto;
        overscroll-behavior: contain;
        box-shadow: 8px 0 40px rgb(0 0 0 / .2);
    }
    dialog.m-sheet::backdrop { background: rgb(0 0 0 / .45); }
    @media (prefers-reduced-motion: no-preference) {
        dialog.m-menu[open] { animation: m-slide-in .22s ease-out; }
        dialog.m-search[open] { animation: m-drop-in .2s ease-out; }
    }
    .m-sheet-head {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: .9rem 1rem;
        background: #fff;
        border-bottom: 1px solid #eee;
    }
    .m-sheet-head h2 { font-size: 1.2rem; }
    .m-sheet-head form { margin: 0; }
    .m-sheet-close { width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%; background: #f2f2f2; font-size: 1rem; }
    .m-menu-list { display: grid; padding: .35rem 0; }
    .m-menu-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        min-height: 3.25rem;
        padding: .4rem 1rem;
        border-bottom: 1px solid #f0f0f0;
        font-size: 1rem;
        font-weight: 650;
        text-decoration: none;
        list-style: none;
        cursor: pointer;
    }
    .m-menu-row::-webkit-details-marker { display: none; }
    .m-menu-row span { display: flex; align-items: center; gap: .7rem; }
    .m-menu-row img { width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover; background: #eee; }
    .m-menu-row i { font-style: normal; color: #888; font-size: 1.2rem; transition: rotate .2s; }
    .m-menu-group[open] > .m-menu-row i { rotate: 180deg; }
    .m-menu-sale span { color: var(--c, #c0392b); }
    .m-menu-sub { display: grid; padding: .3rem 1rem .8rem 3.7rem; background: #fafafa; border-bottom: 1px solid #f0f0f0; }
    .m-menu-sub a { display: flex; align-items: center; min-height: 2.6rem; color: #333; text-decoration: none; font-size: .95rem; }
    .m-menu-sub .m-menu-all { font-weight: 700; color: #141414; }
    .m-menu-sub .m-menu-head { margin-top: .35rem; font-weight: 700; color: #141414; }
    .m-menu-sub .m-menu-leaf { padding-left: .9rem; min-height: 2.3rem; color: #666; font-size: .9rem; }
    .m-menu-links { display: grid; gap: .1rem; padding: .6rem .5rem calc(1.5rem + env(safe-area-inset-bottom)); }
    .m-menu-links :is(a, button) {
        display: flex;
        align-items: center;
        min-height: 2.9rem;
        padding: 0 .6rem;
        border: 0;
        border-radius: .6rem;
        background: none;
        color: #333;
        font-size: .95rem;
        text-align: left;
        text-decoration: none;
    }
    .m-menu-links :is(a, button):active { background: #f2f2f2; }

    dialog.m-search { inset: 0 0 auto; box-sizing: border-box; width: 100%; height: auto; display: none; padding: .75rem 1rem; box-shadow: 0 8px 30px rgb(0 0 0 / .2); }
    dialog.m-search[open] { display: flex; gap: .5rem; align-items: center; }
    .m-search-form { flex: 1; min-width: 0; display: flex; gap: .4rem; margin: 0; }
    .m-search-form input { flex: 1; min-width: 0; height: 2.9rem; padding: 0 1rem; border: 1px solid #ccc; border-radius: 2rem; font-size: 1rem; }
    .m-search-form button { height: 2.9rem; padding: 0 1rem; border: 0; border-radius: 2rem; background: #141414; color: #fff; font-weight: 700; }
    dialog.m-search > form[method="dialog"] { margin: 0; }

    /* ---------- Floating buttons stay above the tab bar and never cover each other ---------- */
    .chat-widget { right: .75rem; bottom: calc(var(--m-tabbar) + .75rem); }
    .chat-widget .chat-launcher { width: 3.1rem; height: 3.1rem; }
    .sticky-buy { bottom: var(--m-tabbar); padding-bottom: .6rem; z-index: 34; }
    body:has(.sticky-buy:not([hidden])) .chat-widget { translate: 0 0; bottom: calc(var(--m-tabbar) + 5.1rem); }
    /* On a product page the chat button waits until the buy box is scrolled past, so it never covers it. */
    body.page-product .chat-widget:not(.is-open) { display: none; }
    body.page-product:has(.sticky-buy:not([hidden])) .chat-widget { display: block; }
    body:has(.sticky-buy:not([hidden])) { padding-bottom: calc(var(--m-tabbar) + 4.6rem); }
    .store-footer { padding-bottom: 1.25rem; }
    .back-to-top { display: none !important; }

    /* ---------- Checkout: fewer boxes, total and button always in view ---------- */
    .m-hide { display: none !important; }
    body.page-checkout .chat-widget { display: none; }
    body.page-checkout .order-summary .order-submit { display: none; }
    .m-order-bar {
        position: fixed;
        inset: auto 0 var(--m-tabbar);
        z-index: 34;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .6rem 1rem;
        background: #fff;
        border-top: 1px solid #e6e6e6;
        box-shadow: 0 -8px 24px rgb(0 0 0 / .08);
    }
    .m-order-bar span { display: grid; line-height: 1.15; }
    .m-order-bar small { color: #666; font-size: .75rem; }
    .m-order-bar b { font-size: 1.15rem; }
    .m-order-bar button { flex: 0 1 12rem; min-height: 3rem; border: 0; border-radius: 2rem; background: #141414; color: #fff; font-size: 1rem; font-weight: 700; }
    body:has(.m-order-bar) { padding-bottom: calc(var(--m-tabbar) + 4.5rem); }
    .order-checkout input, .order-checkout select, .order-checkout textarea { font-size: 16px; }
    .order-checkout :is(.promo-field, [data-checkout-points] label) > span { display: flex; gap: .5rem; min-width: 0; }
    .order-checkout :is(.promo-field, [data-checkout-points] label) > span input { flex: 1; min-width: 0; width: auto; }
    .order-checkout :is(.promo-field, [data-checkout-points] label) > span button { flex: none; }

    /* ---------- Video gallery: the player keeps its 16:9 shape inside the card ---------- */
    .film-screen { width: 100%; min-height: 0; }
    .film-now { align-items: center; }
    .film-now > div { min-width: 0; }
    .film-now a { flex: none; max-width: none; white-space: nowrap; }

    /* ---------- Footer: "Back to top" stays clear of the chat button ---------- */
    .store-footer-bottom { flex-wrap: wrap; padding-right: 4.25rem; }

    /* ---------- Easier tapping ---------- */
    .category-nav a { min-height: 2.75rem; }
    .discovery-all { display: inline-flex; align-items: center; min-height: 2.75rem; }

    /* Product cards appear quicker while scrolling fast. */
    @media (prefers-reduced-motion: no-preference) {
        .fx-stagger { transform: translateY(.8rem); }
        .fx-stagger.fx-in { transition: opacity .3s ease var(--fx-delay, 0ms), transform .35s ease var(--fx-delay, 0ms); }
    }
}

@keyframes m-slide-in { from { translate: -100% 0; } to { translate: 0 0; } }
@keyframes m-drop-in { from { translate: 0 -100%; } to { translate: 0 0; } }
