/* Namespace: .iv-stories-... */

.iv-stories-wrapper {
    --iv-bubble-size: 80px;
    --iv-gap: 15px;
    margin-bottom: 20px;
}

.iv-stories-list {
    display: flex;
    flex-wrap: nowrap; /* or nowrap with overflow-x: auto for scroll */
    gap: var(--iv-gap);
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: none; /* Firefox */
	justify-content: space-between;
}

.iv-stories-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.iv-story-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    width: var(--iv-bubble-size);
    min-width: var(--iv-bubble-size); /* Prevent shrinking issues */
    flex-shrink: 0;
}

.iv-bubble-ring {
    width: var(--iv-bubble-size);
    height: var(--iv-bubble-size);
    border-radius: 50%;
    padding: 2px; /* Gap between image and ring */
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    position: relative;
    transition: transform 0.2s;
}

/* Seen state */
.iv-story-bubble.seen .iv-bubble-ring {
    background: #ccc;
}

.iv-story-bubble:hover .iv-bubble-ring {
    transform: scale(1.05);
}

.iv-bubble-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #fff; /* White gap */
    background: #fff;
    /* Prevent image jump by enforcing Aspect Ratio if supported, or strict sizing */
    position: relative;
}

.iv-bubble-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.iv-story-title {
    margin-top: 5px;
    font-size: 12px;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modal / Overlay */
.iv-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.iv-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.iv-modal-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
   background: rgba(0, 0, 0, 0.8)!important;
}

.iv-story-viewer {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px; /* Mobile style usually */
    /* max-height: 800px;  Optional desktop constraint */
    background: #222;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .iv-story-viewer {
        height: 90vh;
        border-radius: 8px;
    }
}

.iv-story-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.iv-story-content img,
.iv-story-content video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* or contain, depending on preference. Cover is "story" style */
    display: block;
}

/* Header / Progress */
.iv-story-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 10px 30px 10px;
    z-index: 20;
    pointer-events: none; /* Let clicks pass through */
    background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
}

.iv-progress-bar {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}

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

.iv-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    /* Transition handled via JS or CSS animation */
}

.iv-story-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-size: 18px;
    font-weight: 600;
}

.iv-close-btn {
    pointer-events: auto !important;
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 24px !important;
    cursor: pointer !important;
    padding: 5px !important;
    line-height: 1 !important;
    min-width: auto !important;
    min-height: auto !important;
    box-shadow: none !important;
}

/* Controls */
.iv-nav-area {
    position: absolute;
    top: 0;
    height: 100%;
    width: 30%;
    z-index: 10;
    /* transparent */
}
.iv-nav-prev { left: 0; }
.iv-nav-next { right: 0; }

.iv-cta {
    position: absolute;
    bottom: 30px;
    width: 100%;
    text-align: center;
    z-index: 20;
    pointer-events: none;
}
.iv-cta a {
    pointer-events: auto;
    display: inline-block;
    background: rgba(0,0,0,0.5);
    color: #fff;
    padding: 10px 24px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.3);
}

/* Spinner */
.iv-loader {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: iv-spin 1s infinite linear;
    display: none;
}
.iv-loader.active { display: block; }

@keyframes iv-spin {
    to { transform: rotate(360deg); }
}
