/* ============================================
 * BlueGym Mobile CSS — Phase 0 Foundation
 * Shared mobile-responsive utilities for all
 * customer-facing pages.
 * ============================================ */

/* ============================================
 * 1. CSS Custom Properties — Safe Areas
 * ============================================ */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================
 * 2. Touch-Friendly Resets (≤768px)
 * ============================================ */
@media (max-width: 768px) {
    button,
    a,
    input,
    select,
    textarea,
    [role="button"] {
        min-height: 44px;
    }

    input,
    select,
    textarea {
        font-size: max(1rem, 16px);
    }

    button,
    a,
    input,
    select,
    textarea,
    [role="button"] {
        touch-action: manipulation;
    }
}

/* ============================================
 * 3. Scroll Container Utilities
 * ============================================ */
.scroll-x {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar {
    display: none;
}
.scroll-x > * {
    scroll-snap-align: start;
}

/* ============================================
 * 4. Scroll Fade Indicator
 * ============================================ */
.mobile-carousel-wrapper {
    position: relative;
}
.mobile-carousel-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, rgba(8, 8, 15, 0.85));
    pointer-events: none;
    z-index: 2;
    border-radius: 0 var(--r, 14px) var(--r, 14px) 0;
}

/* ============================================
 * 5. Scroll Dots Component
 * ============================================ */
.scroll-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 1rem 0;
}
.scroll-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
    border: none;
    padding: 0;
    cursor: pointer;
}
.scroll-dots .dot.active {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
}

/* ============================================
 * 6. Bottom-Sheet Modal (≤600px)
 * ============================================ */
@media (max-width: 600px) {
    .modal,
    .modal.bottom-sheet-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        margin: 0;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        padding-bottom: calc(1rem + var(--safe-bottom));
        overflow-y: auto;
        z-index: 1010;
    }

    .modal.active,
    .modal.bottom-sheet-mobile.active {
        transform: translateY(0);
    }

    /* Drag handle */
    .modal::before,
    .modal.bottom-sheet-mobile::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
        margin: 12px auto 8px;
        flex-shrink: 0;
    }

    /* Overlay */
    .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1005;
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.3s, visibility 0.3s;
    }
    .modal-overlay.active {
        visibility: visible;
        opacity: 1;
    }
}

/* ============================================
 * 7. Notification Repositioning (≤600px)
 * ============================================ */
@media (max-width: 600px) {
    .notification,
    .toast,
    #notification,
    .bluegym-notification {
        top: auto !important;
        bottom: calc(1rem + var(--safe-bottom));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: calc(100vw - 2rem);
    }
}

/* ============================================
 * 8. Active State Feedback (Touch Devices)
 * ============================================ */
@media (pointer: coarse) {
    .card:active,
    .btn:active,
    [role="button"]:active {
        transform: scale(0.97);
        transition: transform 0.1s;
    }
}

/* ============================================
 * 9. Mobile Carousel Component
 * ============================================ */
.mobile-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 1rem;
    padding: 0 1rem;
}
.mobile-carousel::-webkit-scrollbar {
    display: none;
}
.mobile-carousel > * {
    flex: 0 0 85vw;
    scroll-snap-align: start;
}

/* ============================================
 * 10. Shared Footer — Mobile Tap Targets (≤768px)
 * ============================================ */
@media (max-width: 768px) {
    footer a,
    footer button,
    .footer a,
    .footer button,
    .site-footer a,
    .site-footer button {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        font-size: max(0.8rem, 13px);
    }

    .footer-social a,
    .social-icons a,
    footer .social a {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================
 * 11. Sticky CTA Utility
 * ============================================ */
.sticky-cta-mobile {
    position: sticky;
    bottom: 0;
    z-index: 50;
    padding: 1rem;
    padding-bottom: calc(1rem + var(--safe-bottom));
    background: linear-gradient(to top, rgba(10, 10, 15, 1) 60%, transparent);
}

/* ============================================
 * Body scroll lock — used by mobile menu
 * ============================================ */
body.mobile-menu-open {
    overflow: hidden;
}
