/* ==========================================================================
   Impact Fitness - Instagram Stories Component (Mobile Only)
   Seamless blue honeycomb theme integration, zero black bars, full responsiveness
   ========================================================================== */

/* 1. Mobile Header & Seamless Blue Honeycomb Background */
.mobile-stories-section {
    display: none;
}

.navbar-brand .mobile-logo {
    display: none !important;
}

.navbar-brand .desktop-logo {
    display: block !important;
}

@media (max-width: 767.98px) {
    /* Keep original transparent header over hero background */
    header.main-header {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        background: transparent !important;
        border-bottom: none !important;
        z-index: 50 !important;
        pointer-events: none; /* Prevents empty header background from blocking story taps */
    }

    header.main-header .navbar-brand,
    header.main-header .navbar-toggle,
    header.main-header .slicknav_btn,
    header.main-header .responsive-menu {
        pointer-events: auto; /* Logo and menu button remain 100% interactive */
    }

    header.main-header .header-sticky {
        background: transparent !important;
        pointer-events: none;
    }

    header.main-header .navbar {
        padding-top: max(28px, env(safe-area-inset-top, 28px)) !important;
        padding-bottom: 6px !important;
        pointer-events: none;
    }

    header.main-header .navbar-brand {
        display: inline-flex;
        align-items: center;
        pointer-events: auto;
    }

    header.main-header .navbar-brand .desktop-logo {
        display: none !important;
    }

    header.main-header .navbar-brand .mobile-logo {
        height: 28px !important;
        width: auto !important;
        display: block !important;
    }

    header.main-header .slicknav_btn {
        width: 36px !important;
        height: 36px !important;
    }

    /* Active sticky header when scrolling down past hero */
    header.main-header .header-sticky.active {
        position: fixed !important;
        background: var(--secondary-color, #202737) !important;
        border-bottom: 1px solid var(--divider-color, rgba(255, 255, 255, 0.12)) !important;
        pointer-events: auto;
    }

    header.main-header .header-sticky.active .navbar {
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }

    /* Hero section wraps the stories seamlessly with the original blue honeycomb pattern */
    .hero {
        padding-top: 92px !important;
    }

    .mobile-stories-section {
        display: block;
        position: relative;
        z-index: 60; /* Above header container so story clicks are 100% responsive */
        background: transparent;
        padding: 0;
        margin-bottom: 28px !important;
    }

    /* Reset hero-content margin on mobile so distance to headline is cleanly balanced */
    .hero .hero-content {
        margin-top: 0 !important;
    }
}

/* Stories Tray Container - Compact and Centered on All Mobile Devices */
.stories-tray-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.stories-tray {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 16px;
    padding: 0 8px;
    margin: 0 auto;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.stories-tray::-webkit-scrollbar {
    display: none;
}

/* Story Ring Item */
.story-tray-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
    width: 70px;
    background: transparent;
    border: none;
    padding: 0;
    outline: none;
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.story-tray-item:active {
    transform: scale(0.92);
}

/* Yellow / Gold ring matching Impact Fitness site theme (--accent-color: #ffde59) */
.story-avatar-ring {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff29e 0%, #ffde59 50%, #e6be27 100%);
    padding: 2.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(255, 222, 89, 0.35);
    transition: all 0.3s ease;
}

/* Instagram Close Friends Vibrant Green Ring for 4th Story */
.story-tray-item[data-theme="close-friends"] .story-avatar-ring {
    background: linear-gradient(135deg, #2bf06f 0%, #00ba34 50%, #008726 100%);
    box-shadow: 0 4px 14px rgba(0, 186, 52, 0.45);
}

/* Viewed ring state */
.story-tray-item.viewed .story-avatar-ring {
    background: rgba(255, 255, 255, 0.25) !important;
    box-shadow: none !important;
}

/* Inner gap matching the site's navy blue background */
.story-avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #171e2e;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.story-avatar-inner img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Video Indicator Icon */
.story-mini-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #ffde59;
    color: #171e2e;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #171e2e;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.story-mini-icon svg {
    width: 8px;
    height: 8px;
    fill: currentColor;
    margin-left: 1px;
}

/* Story Label */
.story-title {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    width: 72px;
    min-height: 28px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    word-break: normal;
}

.story-title.emoji-title {
    font-size: 16px;
    line-height: 1;
    align-items: center;
}

/* Extra small devices (iPhone SE / 360px) */
@media (max-width: 375px) {
    .stories-tray {
        gap: 12px;
        padding: 0 4px;
    }
    .story-tray-item {
        width: 66px;
    }
    .story-avatar-ring {
        width: 58px;
        height: 58px;
    }
    .story-title {
        font-size: 10.5px;
        width: 66px;
        min-height: 26px;
    }
    .story-title.emoji-title {
        font-size: 15px;
    }
}


/* ==========================================================================
   2. Full-Screen Instagram Story Viewer (Responsive on any device)
   ========================================================================== */

body.story-viewer-active {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
    touch-action: none !important;
}

.story-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999999;
    /* Deep navy gradient matching the site's brand theme */
    background: radial-gradient(circle at center, #1b2438 0%, #0d121c 100%);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
    transform: scale(0.96);
    user-select: none;
    -webkit-user-select: none;
}

.story-viewer-modal.active {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

/* Dismiss animation on swipe down */
.story-viewer-modal.dismissing {
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
    opacity: 0 !important;
    transform: translateY(100%) !important;
}

/* Container Frame */
.story-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 440px;
    background: #0d121c;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Progress Bars with Notch / Safe Area Support */
.story-progress-bars {
    position: absolute;
    top: max(10px, env(safe-area-inset-top, 10px));
    left: max(12px, env(safe-area-inset-left, 12px));
    right: max(12px, env(safe-area-inset-right, 12px));
    display: flex;
    gap: 4px;
    z-index: 120;
}

.story-progress-bar {
    flex: 1;
    height: 2.5px;
    background: rgba(255, 255, 255, 0.32);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.story-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: #ffffff;
    border-radius: 3px;
    transition: width 0.05s linear;
}

.story-progress-bar.completed .story-progress-fill {
    width: 100% !important;
}

/* Top Header Bar */
.story-viewer-header {
    position: absolute;
    top: calc(max(10px, env(safe-area-inset-top, 10px)) + 12px);
    left: max(14px, env(safe-area-inset-left, 14px));
    right: max(14px, env(safe-area-inset-right, 14px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 120;
    color: #ffffff;
    pointer-events: auto;
}

.story-profile-info {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: #ffffff;
}

.story-profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid #ff2a44;
    object-fit: cover;
    background: #171e2e;
}

.story-profile-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.story-profile-name {
    font-size: 13.5px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 4px;
}

.story-verified-badge {
    width: 13px;
    height: 13px;
    display: inline-flex;
}

.story-time-stamp {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
}

.story-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.story-icon-btn {
    background: rgba(0, 0, 0, 0.35);
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 7px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transition: transform 0.15s ease, background 0.2s ease;
}

.story-icon-btn:active {
    transform: scale(0.88);
    background: rgba(255, 255, 255, 0.25);
}

.story-close-btn {
    font-size: 18px;
    font-weight: 700;
}

/* Horizontal Sliding Track */
.story-carousel-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.story-carousel-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

.story-slide {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0d121c;
}

/* Ambient Background Blur */
.story-ambient-bg {
    position: absolute;
    inset: -30px;
    background-size: cover;
    background-position: center;
    filter: blur(35px) brightness(0.42);
    opacity: 0.9;
    transform: scale(1.15);
    z-index: 1;
}

.story-slide-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 10px 80px;
    box-sizing: border-box;
}

.story-slide-image {
    max-width: 100%;
    max-height: calc(100dvh - 150px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
}

.story-slide-video {
    width: 100%;
    height: 100%;
    max-height: calc(100dvh - 140px);
    object-fit: contain;
    display: block;
    border-radius: 6px;
}

/* Tap Zones */
.story-nav-tap-zones {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 80;
    user-select: none;
    -webkit-user-select: none;
}

.story-tap-left {
    width: 35%;
    height: 100%;
    cursor: pointer;
}

.story-tap-right {
    width: 65%;
    height: 100%;
    cursor: pointer;
}

/* Bottom CTA Pill */
.story-viewer-footer {
    position: absolute;
    bottom: calc(max(16px, env(safe-area-inset-bottom, 16px)) + 8px);
    left: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 120;
    pointer-events: auto;
}

.story-cta-btn {
    background: rgba(255, 255, 255, 0.96);
    color: #111111;
    font-size: 13.5px;
    font-weight: 700;
    padding: 11px 24px;
    border-radius: 28px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(10px);
}

.story-cta-btn:active {
    transform: scale(0.95);
    background: #ffffff;
}

.story-cta-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* Pause Indicator */
.story-pause-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 100;
    backdrop-filter: blur(8px);
}

.story-viewer-modal.is-paused .story-pause-hint {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
