/* =========================================
   PREMIUM STORIES & VIEWER UI
   ========================================= */

/* --- 1. STORIES LIST (Circles on Homepage) --- */
#stories-section {
    padding: 60px 0;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    overflow: hidden;
}

.stories-header { text-align: center; margin-bottom: 40px; }
.stories-title { font-family: 'Playfair Display', serif; font-size: 2rem; color: var(--accent-dark); margin-bottom: 10px; }
.separator-gold { width: 60px; height: 3px; background: var(--primary-gold); margin: 0 auto; }

/* Scroll Container */
.stories-scroll-container {
    width: 100%; overflow-x: auto; padding-bottom: 20px;
    scrollbar-width: none; display: flex; justify-content: center;
}
.stories-scroll-container::-webkit-scrollbar { display: none; }

.stories-wrapper { display: flex; gap: 30px; padding: 0 20px; padding-top: 20px;}

/* Story Item */
.story-item { display: flex; flex-direction: column; align-items: center; cursor: pointer; width: 100px; flex-shrink: 0; }

.story-ring-wrapper {
    position: relative; width: 90px; height: 90px;
    display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.story-item:hover .story-ring-wrapper { transform: scale(1.1); }

/* Animated Gold Ring */
.story-gradient-ring {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 50%;
    background: conic-gradient(from 0deg, #B37839, #FFE5B4, #EA964C, #B37839);
    animation: spinRing 4s linear infinite;
    box-shadow: 0 4px 15px rgba(179, 120, 57, 0.25);
}

.story-img-box {
    position: absolute; top: 3px; left: 3px; right: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; padding: 3px; overflow: hidden; z-index: 2;
}
.story-img-box img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.story-name { font-family: 'Lato', sans-serif; font-size: 0.85rem; font-weight: 600; color: var(--accent-dark); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }

@keyframes spinRing { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


/* --- 2. VIEWER MODAL (The Fix) --- */
.story-modal {
    display: none; /* CRITICAL: Hidden by default */
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #1a1a1a; z-index: 99999; /* Highest Z-Index */
    justify-content: center; align-items: center;
}

.story-modal.active { display: flex; }

.story-content-wrapper {
    width: 100%; max-width: 450px; height: 100%; position: relative;
    background: #000; overflow: hidden;
    /* On desktop, make it look like a phone */
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
@media(min-width: 768px) { .story-content-wrapper { height: 90vh; border-radius: 12px; } }

/* Media Layer */
.story-media-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #000; }
.media-cover { width: 100%; height: 100%; object-fit: cover; }
.media-contain { width: 100%; height: 100%; object-fit: contain; }
#story-video { display: none; }

/* Header Info */
.story-header-info {
    position: absolute; top: 20px; left: 15px; right: 60px; /* Space for close btn */
    display: flex; align-items: center; gap: 10px; z-index: 20;
    color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
#viewer-profile-img { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.5); }
#viewer-username { font-weight: 700; font-size: 0.95rem; font-family: 'Lato', sans-serif; }

/* Progress Bars */
.story-progress-container { position: absolute; top: 8px; left: 5px; right: 5px; display: flex; gap: 4px; z-index: 30; }
.progress-bar-bg { height: 2px; background: rgba(255,255,255,0.3); flex: 1; border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #fff; width: 0%; }

/* --- 3. PREMIUM ACTION BUTTONS (Right Side) --- */
.story-actions-right {
    position: absolute;
    bottom: 120px; /* Position above text area */
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 50;
    /* Ensure they are hidden if modal is closed */
}

.action-icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 48px; height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    backdrop-filter: blur(8px); /* Premium Glass Effect */
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.action-icon-btn:hover {
    background: #fff; color: #000; transform: scale(1.1);
}

/* --- 4. TEXT OVERLAY --- */
.story-text-overlay {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    padding: 20px 20px 40px;
    z-index: 40;
    text-align: left;
    display: flex; flex-direction: column; align-items: flex-start;
}

#story-heading { font-size: 1.4rem; font-family: 'Playfair Display'; margin-bottom: 5px; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
#story-desc { font-size: 0.9rem; color: rgba(255,255,255,0.9); margin-bottom: 15px; max-width: 85%; line-height: 1.5; }

.story-link-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(255,255,255,0.2); color: #fff; border: 1px solid rgba(255,255,255,0.4);
    padding: 8px 20px; border-radius: 30px; font-weight: 600; font-size: 0.8rem;
    backdrop-filter: blur(5px); text-decoration: none; transition: 0.3s;
}
.story-link-btn:hover { background: #fff; color: #000; }

/* Taps & Close */
.close-story { position: absolute; top: 20px; right: 20px; color: #fff; font-size: 2rem; cursor: pointer; z-index: 60; opacity: 0.8; transition:0.3s;}
.close-story:hover { opacity: 1; transform: rotate(90deg); }
.tap-area { position: absolute; top: 0; bottom: 0; width: 35%; z-index: 15; }
.tap-area.left { left: 0; }
.tap-area.right { right: 0; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .story-content-wrapper { height: 100%; max-width: 100%; border-radius: 0; }
    .stories-scroll-container { justify-content: flex-start; } /* Allow scrolling left */
}