/* =====================================================================
   Siratullah Lifestyle — mobile UX layer (loads after every other sheet)
   Phone-first refinements: compact header, calmer hero, collapsible home
   filters, bottom tab bar, checkout stepper + sticky total, tap targets,
   iOS-safe inputs, focus states. Desktop is untouched unless noted.
   ===================================================================== */

:root {
    --mx-nav-h: 60px;                 /* bottom tab bar height */
    --mx-safe: env(safe-area-inset-bottom, 0px);
}

/* ---------- 0. Global Viewport & Anti-Wobble Shield ---------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.page-wrapper {
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

img, video, iframe, svg {
    max-width: 100%;
}

/* ---------- Accessibility: visible keyboard focus everywhere ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[role="button"]:focus-visible, label.ms-lst-filter-btn:focus-visible {
    outline: 2px solid var(--ms-ink, #123a5a);
    outline-offset: 2px;
    border-radius: .25rem;
}

/* ---------- Header: compact on phones, shadow once scrolled ---------- */
.ms-header { transition: box-shadow 200ms ease; }
.ms-header.is-scrolled { box-shadow: 0 6px 20px rgba(18, 58, 90, .10); }

@media (max-width: 767.98px) {
    .ms-header-inner { height: 60px; gap: .5rem; }
    .ms-header-actions { gap: .35rem; }
    .ms-header-actions .ms-icon-btn,
    .ms-header-actions .ms-bag-btn { width: 42px; height: 42px; min-width: 42px; }
    .ms-ticker { font-size: .68rem; }
}

/* ---------- Hero slider: touch swipe + visible side navigation arrows ---------- */
.ms-hero-slider .splide__arrows {
    display: block !important;
}

.ms-hero-slider .splide__arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 25 !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(18, 58, 90, 0.16) !important;
    color: var(--ms-ink, #123a5a) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    opacity: 0.95 !important;
    visibility: visible !important;
    box-shadow: 0 4px 18px rgba(18, 58, 90, 0.22) !important;
    transition: all 0.22s ease !important;
    padding: 0 !important;
}

.ms-hero-slider .splide__arrow:hover {
    background: #ffffff !important;
    color: var(--ms-marigold, #d4a252) !important;
    box-shadow: 0 6px 22px rgba(18, 58, 90, 0.32) !important;
    transform: translateY(-50%) scale(1.08) !important;
    opacity: 1 !important;
}

.ms-hero-slider .splide__arrow:active {
    transform: translateY(-50%) scale(0.95) !important;
}

.ms-hero-slider .splide__arrow--prev {
    left: 1.5rem !important;
}

.ms-hero-slider .splide__arrow--next {
    right: 1.5rem !important;
}

.ms-hero-slider .splide__arrow i {
    font-size: 1.6rem !important;
    line-height: 1 !important;
    color: inherit !important;
    display: inline-block !important;
}

.ms-hero-slider .splide__arrow svg {
    display: block !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    fill: currentColor !important;
}

@media (max-width: 767.98px) {
    .ms-hero-slider .splide { height: clamp(440px, 72vh, 620px); }
    .ms-hero-slider .splide__arrow {
        display: flex !important;
        width: 38px !important;
        height: 38px !important;
        background: rgba(255, 255, 255, 0.9) !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
        z-index: 25 !important;
        opacity: 0.95 !important;
        visibility: visible !important;
    }
    .ms-hero-slider .splide__arrow--prev { left: 0.6rem !important; }
    .ms-hero-slider .splide__arrow--next { right: 0.6rem !important; }
    .ms-hero-slider .splide__arrow i { font-size: 1.25rem !important; }
    .ms-hero-slider .splide__arrow svg { width: 1rem !important; height: 1rem !important; }
    .ms-hero-slide-caption {
        padding: 4.5rem 1.1rem 3.25rem;
        background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(8, 24, 38, .45) 45%, rgba(8, 24, 38, .78) 100%);
    }
    .ms-hero-slide-caption .ms-eyebrow { font-size: .66rem; letter-spacing: .14em; }
    .ms-hero-slide-title { font-size: clamp(1.7rem, 8.2vw, 2.4rem); line-height: 1.12; }
    .ms-hero-slide-caption .ms-btn-primary { margin-top: .9rem; min-height: 2.9rem; }
    .ms-hero-slider .splide__pagination { bottom: .7rem; }
    .ms-hero-slider .splide__pagination__page { width: 8px; height: 8px; margin: 0 4px; background: rgba(255, 255, 255, .55); opacity: 1; }
    .ms-hero-slider .splide__pagination__page.is-active { background: #fff; transform: scale(1.3); }
}

/* ---------- Typography rhythm on phones ---------- */
@media (max-width: 767.98px) {
    .ms-section { padding-top: 3rem; padding-bottom: 3rem; }
    .ms-section-head { flex-direction: column; align-items: flex-start; gap: .9rem; }
    .ms-section-title { font-size: clamp(1.65rem, 7.2vw, 2.3rem); line-height: 1.12; }
    .ms-lede, .ms-support-lede, .ms-craft-lede { font-size: 1rem; line-height: 1.6; }
    .ms-eyebrow, .ms-kicker, .ms-filter-label, .ms-footer-label { font-size: .72rem; }
    .ms-card-sku, .ms-pdp-sku, .ms-pdp-related-sku { font-size: .7rem; }
    .ms-card-name { font-size: .95rem; line-height: 1.3; }
    .ms-card-spec { font-size: .78rem; }
}

/* ---------- Home catalogue: scrollable chips, collapsible filters ---------- */
@media (max-width: 991.98px) {
    .ms-chip-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: .25rem .25rem .6rem;
        margin: 1.1rem -1rem 0;
        padding-left: 1rem;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .ms-chip-row::-webkit-scrollbar { display: none; }
    .ms-chip-row .ms-filter-chip { flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap; }

    .ms-filter-panel { padding: .25rem .9rem; }
    .ms-filter-toggle {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        min-height: 3rem;
        padding: .6rem 0;
        border: 0;
        background: transparent;
        color: var(--ms-ink, #123a5a);
        font: inherit;
        font-size: .82rem;
        font-weight: 800;
        letter-spacing: .12em;
        text-transform: uppercase;
        cursor: pointer;
    }
    .ms-filter-toggle i { transition: transform 200ms ease; }
    .ms-filter-panel.is-open .ms-filter-toggle i { transform: rotate(180deg); }
    .ms-filter-panel .ms-filter-grid { display: none; padding-bottom: .9rem; }
    .ms-filter-panel.is-open .ms-filter-grid { display: grid; }
    .ms-filter-panel .ms-filter-count { padding-bottom: .6rem; }
}
@media (min-width: 992px) {
    .ms-filter-toggle { display: none; }
}

/* ---------- Product cards: generous tap zones ---------- */
@media (max-width: 767.98px) {
    .ms-card-quickadd { min-height: 2.75rem; font-size: .72rem; }
    .ms-save-btn { width: 2.5rem; height: 2.5rem; }
    .ms-card-sizes { gap: .4rem; }
    .ms-pagination .page-link { min-width: 2.6rem; min-height: 2.6rem; display: inline-flex; align-items: center; justify-content: center; }
}

/* ---------- PDP: keep content clear of the sticky WhatsApp bar ---------- */
@media (max-width: 767.98px) {
    .ms-pdp { padding-bottom: calc(5.75rem + var(--mx-safe)); }
    .ms-pdp-thumbs { scroll-snap-type: x mandatory; }
    .ms-pdp-thumb { scroll-snap-align: start; }
    .ms-pdp-actions { position: relative; }
    .ms-pdp-btn { min-height: 3.1rem; }
}

/* ---------- Forms: 16px inputs stop iOS auto-zoom; roomy controls ---------- */
@media (max-width: 767.98px) {
    .ms-form-input, .ms-filter-select, .ms-pdp-field, .ms-lst-sort select, .ms-lst-perpage select,
    .ms-lst-price input, #coupon_input, .ms-search-field input, .form-control, input, select, textarea {
        font-size: 16px !important;
    }
    .ms-form-input, .form-control {
        min-height: 2.85rem;
    }
    .ms-checkout-delivery-option { min-height: 3.25rem; }
    .ms-checkout-item img { width: 56px; height: 72px; object-fit: cover; border-radius: .4rem; }

    /* Modal responsiveness on mobile screens */
    .modal-dialog {
        margin: 0.5rem auto !important;
        max-width: calc(100vw - 1rem) !important;
    }
    .modal-content {
        border-radius: 1rem !important;
        overflow: hidden;
    }
    .modal-body {
        padding: 1rem !important;
        max-height: calc(85vh - 65px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---------- Checkout stepper ---------- */
.ms-steps {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1.4rem;
    padding: 0;
    list-style: none;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #6b7c88;
}
.ms-steps li { display: flex; align-items: center; gap: .45rem; white-space: nowrap; }
.ms-steps li + li::before { content: ""; width: 1.6rem; height: 1px; background: rgba(18, 58, 90, .25); margin-right: .25rem; }
.ms-steps .ms-step-num {
    display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
    border: 1.5px solid rgba(18, 58, 90, .3); font-size: .7rem; color: inherit;
}
.ms-steps li.is-done .ms-step-num { background: var(--ms-ink, #123a5a); border-color: var(--ms-ink, #123a5a); color: #fff; }
.ms-steps li.is-current { color: var(--ms-ink, #123a5a); }
.ms-steps li.is-current .ms-step-num { border-color: var(--ms-ink, #123a5a); border-width: 2px; }
@media (max-width: 420px) {
    .ms-steps { font-size: .66rem; gap: .35rem; }
    .ms-steps li + li::before { width: .9rem; }
}

/* ---------- Checkout: sticky total + confirm on phones ---------- */
.ms-checkout-sticky { display: none; }
@media (max-width: 991.98px) {
    .ms-checkout-sticky {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        padding: .6rem 1rem calc(.6rem + var(--mx-safe));
        background: rgba(255, 255, 255, .98);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
        border-top: 1px solid rgba(212, 162, 82, .35);
        box-shadow: 0 -8px 24px rgba(18, 58, 90, .14);
    }
    .ms-checkout-sticky-total { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1 1 auto; }
    .ms-checkout-sticky-total small { font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #6b7c88; white-space: nowrap; }
    .ms-checkout-sticky-total strong { font-size: 1.15rem; color: var(--ms-ink, #123a5a); }
    .ms-checkout-sticky .ms-pdp-btn { flex: 0 0 auto; min-height: 2.9rem; padding-inline: 1.4rem; }
    .ms-checkout { padding-bottom: calc(5.5rem + var(--mx-safe)); }
    .ms-checkout-summary { order: -1; }           /* items first, then the form, on phones */
}

/* ---------- Bottom tab bar (phones & small tablets) ---------- */
.ms-bottom-nav { display: none; }
@media (max-width: 991.98px) {
    .ms-bottom-nav {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 990;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        height: calc(var(--mx-nav-h) + var(--mx-safe));
        padding-bottom: var(--mx-safe);
        background: rgba(251, 248, 242, .97);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
        border-top: 1px solid rgba(18, 58, 90, .12);
        box-shadow: 0 -6px 18px rgba(18, 58, 90, .08);
    }
    .ms-bottom-nav a, .ms-bottom-nav button {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
        border: 0; background: transparent; padding: .35rem 0;
        color: #4f6475; text-decoration: none; font: inherit;
        font-size: .62rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    }
    .ms-bottom-nav i { font-size: 1.15rem; line-height: 1; }
    .ms-bottom-nav .is-active { color: var(--ms-ink, #123a5a); }
    .ms-bottom-nav .ms-bn-badge {
        position: absolute; top: .2rem; right: calc(50% - 1.3rem);
        min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem; border-radius: 999px;
        background: var(--ms-marigold, #d4a252); color: #fff; font-size: .6rem; line-height: 1.1rem; text-align: center;
    }
    .ms-bottom-nav a { position: relative; }

    /* make room for the bar; pages that own a sticky bar hide it instead */
    body.ms-has-bottom-nav { padding-bottom: calc(var(--mx-nav-h) + var(--mx-safe)); }
    body.ms-no-bottom-nav .ms-bottom-nav { display: none; }
    body.ms-no-bottom-nav { padding-bottom: 0; }

    /* toasts above the bar */
    #toast-container.toast-bottom-right { right: .75rem; bottom: calc(var(--mx-nav-h) + var(--mx-safe) + .75rem); }
    #toast-container > div { width: min(92vw, 22rem); }
    .ms-drawer-panel { padding-bottom: calc(var(--mx-nav-h) + var(--mx-safe) + 1rem); }

    /* Floating WhatsApp button hierarchy on mobile devices */
    body.ms-has-bottom-nav .side-whatsapp-buttons {
        bottom: calc(var(--mx-nav-h) + var(--mx-safe) + 12px) !important;
        right: 14px !important;
        z-index: 985 !important;
    }
    body.ms-no-bottom-nav .side-whatsapp-buttons,
    .ms-pdp .side-whatsapp-buttons,
    .ms-checkout .side-whatsapp-buttons,
    .ms-checkout-sticky .side-whatsapp-buttons {
        display: none !important;
    }
}

/* ---------- PDP Size Guide Modal & Table polish for narrow phones ---------- */
@media (max-width: 575.98px) {
    .ms-pdp-sheet {
        width: calc(100vw - 1.25rem) !important;
        max-height: 86vh !important;
        padding: 1.2rem 1rem !important;
        border-radius: 1rem !important;
    }
    .ms-pdp-sheet-title {
        font-size: 1.25rem !important;
    }
    .ms-pdp-sheet table {
        margin-bottom: 0.85rem !important;
    }
    .ms-pdp-sheet th,
    .ms-pdp-sheet td {
        padding: .5rem .6rem !important;
        font-size: .8rem !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
    }
    .ms-pdp-sheet th {
        width: 38% !important;
    }
    .ms-pdp-sheet-actions {
        flex-direction: column !important;
        gap: .5rem !important;
    }
    .ms-pdp-sheet-wa-btn, .ms-pdp-sheet-done-btn {
        width: 100% !important;
        min-height: 2.9rem !important;
        text-align: center !important;
        justify-content: center !important;
    }
}

/* ---------- Minimum 44px tap targets on touch devices ---------- */
@media (max-width: 767.98px) {
    .ms-icon-btn, .ms-bag-btn, .ms-pdp-sheet-close, .ms-drawer-head .ms-icon-btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    .ms-bottom-nav a, .ms-bottom-nav button {
        min-height: 48px;
    }
}

/* ---------- Narrow Screens (< 380px / < 400px) Safety ---------- */
@media (max-width: 400px) {
    .ms-brand span {
        font-size: 0.95rem !important;
    }
    .ms-brand img {
        height: 32px !important;
        width: auto !important;
    }
    .ms-header-actions .ms-icon-btn,
    .ms-header-actions .ms-bag-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
    }
}

@media (max-width: 380px) {
    .ms-catalogue-grid, .ms-lst-grid {
        gap: 1.1rem .45rem !important;
    }
    .ms-card .ms-card-quickadd {
        font-size: .55rem !important;
        letter-spacing: .02em !important;
        padding: .5rem .15rem !important;
    }
    .ms-card .ms-card-copy .ms-card-name {
        font-size: .72rem !important;
    }
    .ms-card .ms-size-chip {
        min-height: 1.5rem !important;
        min-width: 1.5rem !important;
        padding: .1rem .25rem !important;
        font-size: .55rem !important;
    }
    .ms-pdp-sticky-bar {
        padding: .5rem .6rem calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
        gap: .45rem !important;
    }
    .ms-pdp-sticky-bar .ms-pdp-sticky-wa-btn {
        font-size: .82rem !important;
        padding: .65rem .45rem !important;
        gap: .35rem !important;
    }
    .ms-pdp-sticky-price strong {
        font-size: 1.05rem !important;
    }
    .ms-checkout-sticky .ms-pdp-btn {
        padding-inline: 0.9rem !important;
        font-size: .84rem !important;
    }
}

/* ---------- Footer polish on phones ---------- */
.ms-footer-brand .ms-brand img { background: #fff; padding: .35rem .6rem; border-radius: .5rem; height: 42px; max-width: 190px; }
@media (max-width: 767.98px) {
    .ms-footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 1.25rem; }
    .ms-footer-link { display: block; padding: .3rem 0; }
    .ms-footer-bottom { flex-direction: column; gap: .6rem; text-align: center; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .ms-header, .ms-filter-toggle i, .ms-card-media img { transition: none !important; }
}
