/* LoteRifas — Phase 3 Mobile UX polish.
 * All rules are gated to mobile viewports (≤767px) so desktop is unaffected.
 * Loaded globally via WebContent::get_website_header.
 */

:root {
    --pwa-mobile-nav-height: 60px;
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
    --pwa-safe-top: env(safe-area-inset-top, 0px);
}

/* ========== Bottom tab nav (mobile only) ========== */
.pwa-mobile-nav {
    display: none;
}

@media (max-width: 767px) {
    .pwa-mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--pwa-mobile-nav-height) + var(--pwa-safe-bottom));
        padding-bottom: var(--pwa-safe-bottom);
        background: #fff;
        border-top: 1px solid #e5e7eb;
        z-index: 9990;
        justify-content: space-around;
        align-items: stretch;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    }

    .pwa-mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: #6b7280;
        font-size: 10px;
        font-weight: 500;
        min-width: 44px;
        min-height: 44px;
        padding: 6px 4px;
        transition: color 0.15s;
    }
    .pwa-mobile-nav-item.active {
        color: #1e40af;
        font-weight: 700;
    }
    .pwa-mobile-nav-item:hover,
    .pwa-mobile-nav-item:focus,
    .pwa-mobile-nav-item:active {
        color: #1e40af;
        text-decoration: none;
    }
    .pwa-mobile-nav-item .icon {
        font-size: 20px;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 24px;
    }
    .pwa-mobile-nav-item.active .icon {
        background: rgba(30, 64, 175, 0.10);
        border-radius: 8px;
    }

    /* Push the page bottom past the nav bar so content isn't hidden. */
    body {
        padding-bottom: calc(var(--pwa-mobile-nav-height) + var(--pwa-safe-bottom) + 10px);
    }
}

/* ========== Sticky action button (e.g., raffle detail Join CTA) ========== */
.pwa-sticky-cta {
    display: none;
}

@media (max-width: 767px) {
    .pwa-sticky-cta {
        display: block;
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(var(--pwa-mobile-nav-height) + var(--pwa-safe-bottom) + 10px);
        z-index: 9985;
    }
    .pwa-sticky-cta .pwa-sticky-cta-btn {
        display: block;
        width: 100%;
        background: #1e40af;
        color: #fff;
        font-size: 16px;
        font-weight: 700;
        padding: 14px 18px;
        border: 0;
        border-radius: 14px;
        box-shadow: 0 8px 24px rgba(30, 64, 175, 0.35);
        cursor: pointer;
        text-align: center;
    }
    .pwa-sticky-cta .pwa-sticky-cta-btn:active {
        background: #1e3a8a;
    }
    .pwa-sticky-cta .pwa-sticky-cta-btn:focus-visible {
        outline: 2px solid #fff;
        outline-offset: -4px;
    }
}

/* ========== Skeleton loader shimmer ========== */
.pwa-skeleton {
    background: linear-gradient(90deg, #e5e7eb 0%, #f3f4f6 50%, #e5e7eb 100%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: pwa-skel-shimmer 1.5s linear infinite;
}
@keyframes pwa-skel-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}
.pwa-skeleton-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.pwa-skeleton-line { height: 12px; margin-bottom: 8px; }
.pwa-skeleton-line.short { width: 40%; }
.pwa-skeleton-line.med   { width: 60%; }
.pwa-skeleton-line.long  { width: 80%; }
.pwa-skeleton-circle {
    width: 40px; height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ========== Pull-to-refresh indicator ========== */
.pwa-ptr-indicator {
    position: fixed;
    top: calc(var(--pwa-safe-top) + 8px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 9989;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.18s, transform 0.18s;
}
.pwa-ptr-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}
.pwa-ptr-indicator-bubble {
    background: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    font-size: 12px;
    font-weight: 600;
    color: #1e40af;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.pwa-ptr-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #1e40af;
    border-top-color: transparent;
    border-radius: 50%;
    animation: pwa-ptr-spin 0.7s linear infinite;
}
@keyframes pwa-ptr-spin {
    to { transform: rotate(360deg); }
}

/* ========== Touch ergonomics ========== */
@media (max-width: 767px) {
    /* Stop iOS double-tap zoom on interactive elements */
    a, button, .btn, [role="button"], input[type="submit"], input[type="button"] {
        touch-action: manipulation;
    }
    /* Smooth momentum scrolling in scrollable containers */
    .scroll-bar, .activity-log, .feed-body {
        -webkit-overflow-scrolling: touch;
    }
}
