/* --- Контейнер и Скролл --- */
.wp-stories-container-wrapper {
    position: relative;
    max-width: 100%;
    overflow: hidden;
    padding: 15px 0;
    /* Защита от глобальных стилей темы */
    box-sizing: border-box; 
}

.wp-stories-list {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 5px 15px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    user-select: none;
    align-items: flex-start; /* Чтобы элементы не растягивались по высоте */
}
.wp-stories-list.active-drag {
    cursor: grabbing;
    scroll-behavior: auto;
}
.wp-stories-list::-webkit-scrollbar {
    display: none;
}

.wp-stories-fade-left,
.wp-stories-fade-right {
    position: absolute;
    top: 0; bottom: 0;
    width: 60px;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.wp-stories-fade-left { left: 0; background: linear-gradient(to right, #fff, transparent); }
.wp-stories-fade-right { right: 0; background: linear-gradient(to left, #fff, transparent); }
.wp-stories-container-wrapper.can-scroll-left .wp-stories-fade-left { opacity: 1; }
.wp-stories-container-wrapper.can-scroll-right .wp-stories-fade-right { opacity: 1; }

/* --- Стрелки ленты --- */
.wp-list-nav {
    position: absolute;
    top: 40%;
    transform: translateY(-50%);
    width: 40px; min-width: 40px; 
    height: 40px; min-height: 40px;
    border-radius: 50%;
    padding: 0;
    background: var(--ws-arrow-bg);
    color: var(--ws-arrow-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: none;
    z-index: 20; 
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.2s;
}
.wp-list-nav:hover { transform: translateY(-50%) scale(1.1); }
.wp-list-prev { left: 10px; }
.wp-list-next { right: 10px; }
.wp-stories-container-wrapper.can-scroll-left .wp-list-prev { opacity: 1; visibility: visible; }
.wp-stories-container-wrapper.can-scroll-right .wp-list-next { opacity: 1; visibility: visible; }

/* --- Кружочек (Item) --- */
.wp-story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    width: var(--ws-size);
    /* Запрещаем сжатие */
    flex-shrink: 0; 
    flex-grow: 0;
    user-select: none;
    -webkit-user-drag: none; 
    margin: 0; 
    padding: 0;
}
.wp-story-item img { -webkit-user-drag: none; }

.story-circle {
    width: var(--ws-size) !important;
    height: var(--ws-size) !important;
    border-radius: 50% !important;
    padding: 3px; 
    position: relative;
    background: #fff;
    /* Исправление для Elementor, который может менять box-sizing */
    box-sizing: border-box !important;
    display: block;
}

.story-ring {
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 50% !important;
    background: var(--ws-ring-color);
    z-index: 0;
    box-sizing: border-box !important;
}
.wp-story-item.seen .story-ring { background: var(--ws-ring-seen); }

.story-circle img {
    /* !important нужен, чтобы перебить стили Elementor */
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    position: relative;
    z-index: 1;
    border: 2px solid #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    max-width: none !important;
    min-height: 0 !important;
    background: #fff; /* Чтобы не просвечивало */
}

.story-title {
    margin-top: 8px;
    text-align: center;
    font-size: var(--ws-font-size);
    color: var(--ws-text-color);
    font-family: var(--ws-font-family);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    width: 100%;
}

/* --- POPUP --- */
.wp-story-popup {
    display: none; position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 9999999;
}
.wp-story-popup.active { display: flex; justify-content: center; align-items: center; }
.wp-story-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
}
.wp-story-content-wrapper {
    position: relative; width: 100%; max-width: 450px;
    height: 95vh; max-height: 900px;
    background: var(--ws-popup-bg); border-radius: 12px;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 5px 30px rgba(0,0,0,0.8);
}
.wp-story-header {
    position: absolute; top: 15px; left: 0; width: 100%;
    z-index: 10; padding: 0 10px; box-sizing: border-box; background: transparent;
}
.wp-story-progress-container { display: flex; gap: 4px; margin-bottom: 12px; }
.progress-bar-item {
    flex: 1; height: 3px; background: rgba(255,255,255,0.3);
    border-radius: 2px; overflow: hidden;
}
.progress-bar-fill { height: 100%; background: #fff; width: 0; }
.wp-story-meta { display: flex; align-items: center; gap: 10px; padding-left: 5px; }
.meta-avatar {
    width: 36px !important; height: 36px !important; border-radius: 50% !important;
    border: 1px solid rgba(255,255,255,0.5); object-fit: cover !important;
}

/* --- ЗАГОЛОВОК ГРУППЫ В ПЛЕЕРЕ --- */
.meta-title {
    display: none; 
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    font-family: sans-serif;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.wp-story-popup.has-title .meta-title { display: block; }

.wp-story-close {
    position: absolute; top: 35px; right: 15px; z-index: 25;
    background: none; border: none; color: #fff;
    font-size: 36px; cursor: pointer; line-height: 1; padding: 0;
    text-shadow: 0 0 5px rgba(0,0,0,0.5); opacity: 0.8;
}
.wp-story-close:hover { opacity: 1; }

.wp-story-viewer {
    width: 100%; height: 100%;
    background: var(--ws-popup-bg);
    display: flex; align-items: center; justify-content: center;
    position: relative; 
}
.wp-story-media-container {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.wp-story-media-container img,
.wp-story-media-container video {
    width: 100% !important; height: 100% !important; object-fit: contain !important; 
    border-radius: 0 !important; border: none !important;
}

/* --- КНОПКА СТОРИС --- */
.wp-story-button-container {
    position: absolute; bottom: 30px; left: 0; width: 100%;
    display: flex; justify-content: center; z-index: 40;
    padding: 0 20px; box-sizing: border-box; pointer-events: none;
}
.wp-story-btn {
    pointer-events: auto; display: inline-block;
    padding: 12px 25px; font-size: 16px; font-weight: 600;
    text-align: center; text-decoration: none; border: none; cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); transition: transform 0.2s, opacity 0.2s;
    color: var(--ws-btn-text); background: var(--ws-btn-bg);
    border-radius: var(--ws-btn-radius); font-family: var(--ws-font-family);
}
.wp-story-btn:hover { transform: scale(1.05); opacity: 0.95; }
.wp-story-btn:active { transform: scale(0.98); }

/* Стрелки ВНУТРИ попапа */
.wp-story-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 30; transition: transform 0.2s;
    background: var(--ws-arrow-bg); color: var(--ws-arrow-color); opacity: 0.7;
}
.wp-story-arrow:hover { opacity: 1; transform: translateY(-50%) scale(1.1); }
.wp-arrow-left { left: 15px; }
.wp-arrow-right { right: 15px; }

@media (max-width: 600px) {
    .wp-story-arrow, .wp-list-nav { display: none !important; }
    .wp-story-content-wrapper { width: 100%; height: 100%; border-radius: 0; }
}