/* ================================== */
/* ЛЕНТА ИСТОРИЙ В ЛЕВОЙ ПАНЕЛИ       */
/* ================================== */

.stories-ribbon {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.stories-ribbon::-webkit-scrollbar {
    display: none;
}

.stories-ribbon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    cursor: pointer;
}

.stories-ribbon-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Кнопка закрытия всей ленты */
.stories-ribbon-close {
    position: absolute;
    right: 12px;
    top: 12px;
    background: var(--stories-ribbon-close-bg, rgba(0, 0, 0, 0.5));
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    z-index: var(--z-base);
    transition: background var(--transition-fast);
}

.stories-ribbon-close:hover {
    background: var(--stories-ribbon-close-hover, rgba(0, 0, 0, 0.7));
}

/* Анимационная обёртка (сворачивание/разворачивание) */
.stories-ribbon-wrapper {
    overflow: hidden;
    transition: max-height var(--transition-slow) ease-out, opacity var(--transition) ease, margin var(--transition) ease;
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.stories-ribbon-wrapper.visible {
    max-height: 200px;
    opacity: 1;
    margin-bottom: 8px;
}

/* ================================== */
/* ТРИ МИНИАТЮРЫ В ПОЛЕ ПОИСКА (ЕДИНЫЙ КОНТУР) */
/* ================================== */
.stories-peek {
    display: flex;
    align-items: center;
    gap: 0;
    filter: drop-shadow(0 0 0 2px var(--primary));
    isolation: isolate;
}

.stories-peek-item {
    cursor: pointer;
    flex-shrink: 0;
    margin-right: -12px;
    position: relative;
    transition: transform var(--transition-fast) ease;
}

.stories-peek-item:hover {
    z-index: var(--z-sticky);
    transform: scale(1.05);
}

.stories-peek:has(.stories-peek-item:hover) {
    filter: none;
}

.stories-peek-item:last-child {
    margin-right: 0;
}

.stories-peek-item > div {
    border: none !important;
    box-shadow: none !important;
    background-clip: padding-box;
}

/* ================================== */
/* АНИМАЦИЯ ДЛЯ КРУЖКОВ ИСТОРИЙ       */
/* ================================== */
.story-circle {
    position: relative;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    transition: transform var(--transition-fast);
}

.story-circle__inner {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--story-circle-text, white);
    text-transform: uppercase;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.story-circle__badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-surface);
    box-sizing: border-box;
}

/* Анимированный кружок (переливающийся градиент) */
.story-circle--animated {
    overflow: hidden;
}

.story-circle--animated::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: conic-gradient(
            from 0deg,
            #ff0066,
            #ffcc00,
            #00ffcc,
            #0066ff,
            #cc00ff,
            #ff0066
    );
    animation: rotate 3s linear infinite;
    opacity: 0.7;
    z-index: 0;
    filter: blur(4px);
}

.story-circle--animated .story-circle__inner {
    position: relative;
    z-index: var(--z-base);
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Альтернативный анимированный слой (если используется) */
.story-circle__animated-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
            from 0deg,
            #ff0066,
            #ffcc00,
            #00ffcc,
            #0066ff,
            #cc00ff,
            #ff0066
    );
    animation: rotate 3s linear infinite;
    opacity: 0.8;
    z-index: 0;
}

/* Маска, которая вырезает только непросмотренные сегменты */
.story-circle__mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    z-index: var(--z-base);
}

/* Слой с аватаром поверх всего */
.story-circle__inner {
    position: relative;
    z-index: 2;
}

/* ================================== */
/* СВЕТЛАЯ ТЕМА ДЛЯ ЛЕНТЫ ИСТОРИЙ     */
/* ================================== */
body.light-theme {
    --stories-ribbon-close-bg: rgba(0, 0, 0, 0.2);
    --stories-ribbon-close-hover: rgba(0, 0, 0, 0.4);
    --story-circle-text: #1e2a3a;
}

body.light-theme .story-circle__badge {
    border-color: #ffffff;
}

body.light-theme .stories-ribbon-close {
    color: #1e2a3a;
}

body.light-theme .stories-ribbon-close:hover {
    background: rgba(0, 0, 0, 0.4);
    color: white;
}

/* ================================== */
/* УВАЖЕНИЕ PREFERS-REDUCED-MOTION    */
/* ================================== */
@media (prefers-reduced-motion: reduce) {
    .stories-ribbon-wrapper,
    .stories-peek-item,
    .story-circle,
    .story-circle--animated::before,
    .story-circle__animated-layer {
        animation: none !important;
        transition: none !important;
    }
    .story-circle--animated::before {
        opacity: 0;
    }
    .stories-peek-item:hover {
        transform: none;
    }
}