/* ===== STORIES BAR ===== */
#storiesContainer {
    display: none;
    padding: 15px 0 15px 0;
    margin-top: 10px;
    margin-bottom: 5px;
}

/* Desktop: more spacing for stories */
@media (min-width: 768px) {
    #storiesContainer {
        margin-top: 20px;
        margin-bottom: 25px;
        padding: 20px 0;
    }
}

.stories-bar {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 5px 15px 10px 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.story-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.story-circle:hover {
    transform: scale(1.05);
}

.story-circle:active {
    transform: scale(0.95);
}

.story-circle-border {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.story-circle.viewed .story-circle-border {
    background: linear-gradient(45deg, #666, #888);
    opacity: 0.6;
}

.story-circle-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--color-dark, #1a1a1a);
    background: var(--color-dark, #1a1a1a);
    pointer-events: none;
}

.story-circle-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
    user-drag: none;
}

.story-title {
    font-size: 11px;
    color: var(--color-text, #fff);
    text-align: center;
    max-width: 80px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* ===== STORY VIEWER ===== */
.story-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.story-viewer.active {
    opacity: 1;
    visibility: visible;
}

.story-viewer-content {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 100vh;
    background: #000;
    display: flex;
    flex-direction: column;
    -webkit-user-select: none;
    user-select: none;
}

@media (min-width: 768px) {
    .story-viewer-content {
        max-height: 90vh;
        border-radius: 12px;
        overflow: hidden;
    }
}

/* Progress bar */
.story-progress-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

.story-progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    border-radius: 2px;
    will-change: width;
}

/* Close button */
.story-close {
    position: absolute;
    top: 25px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.story-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Story media container */
.story-media-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0; /* Important for flex child to shrink properly */
}

.story-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.story-image,
.story-video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
}

.story-video {
    pointer-events: auto;
}

/* Overlay info */
.story-overlay-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 60px 20px 30px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: none;
}

.story-overlay-info > * {
    pointer-events: auto;
}

.story-info-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin: 0;
}

.story-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 30px;
    background: #fff;
    color: #000;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    transition: transform 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.story-link-btn:hover {
    transform: scale(1.05);
    background: #f0f0f0;
}

.story-link-btn i {
    font-size: 12px;
}

/* Navigation areas */
.story-nav {
    position: absolute;
    top: 50px;
    bottom: 80px;
    width: 35%;
    z-index: 5;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.story-nav-prev {
    left: 0;
}

.story-nav-next {
    right: 0;
}

/* Slide indicators */
.story-slide-indicators {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 15;
}

.story-slide-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: background 0.2s ease, transform 0.2s ease;
}

.story-slide-dot.active {
    background: #fff;
    transform: scale(1.2);
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 480px) {
    #storiesContainer {
        padding: 20px 0 10px 0;
    }

    .story-circle-border {
        width: 64px;
        height: 64px;
    }

    .story-title {
        font-size: 10px;
        max-width: 70px;
    }

    .stories-bar {
        gap: 12px;
        padding: 5px 12px 8px 12px;
    }

    .story-viewer-content {
        max-width: 100%;
        border-radius: 0;
    }

    .story-close {
        top: 15px;
        right: 10px;
        width: 36px;
        height: 36px;
    }

    .story-overlay-info {
        padding: 40px 15px 25px;
    }

    .story-info-title {
        font-size: 16px;
    }

    .story-link-btn {
        padding: 10px 25px;
        font-size: 13px;
    }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .story-progress-bar {
        top: calc(10px + env(safe-area-inset-top));
    }

    .story-close {
        top: calc(25px + env(safe-area-inset-top));
    }

    .story-overlay-info {
        padding-bottom: calc(30px + env(safe-area-inset-bottom));
    }
}

/* ===== ANIMATIONS ===== */
@keyframes storyPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(240, 148, 51, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(240, 148, 51, 0);
    }
}

.story-circle:not(.viewed) .story-circle-border {
    animation: storyPulse 2s infinite;
}

/* Loading state */
.story-image[src=""],
.story-video[src=""] {
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Prevent text selection on long press */
.story-viewer * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Highlight effect for scrolled-to menu items */
.highlight-item {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(212, 165, 116, 0.7);
        transform: scale(1);
    }
    20% {
        box-shadow: 0 0 0 15px rgba(212, 165, 116, 0);
        transform: scale(1.02);
    }
    40% {
        transform: scale(1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(212, 165, 116, 0);
    }
}

/* ===== STORY LOADING INDICATOR ===== */
.story-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.story-loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinLoader 0.8s linear infinite;
}

@keyframes spinLoader {
    to {
        transform: rotate(360deg);
    }
}

/* ===== STORY TRANSITION ANIMATIONS ===== */
/* Animations are handled via JavaScript inline styles on .story-media-container */
