/* ============================================================
   Истории (сторис) на главной: лента кружков + полноэкранный плеер.
   Подключается только на главной при наличии историй (templates/home.php).
   ============================================================ */

/* --- Лента кружков --- */
.stories-strip {
    margin: 26px 0 26px;
}

/* Без баннеров сверху — лента ближе к шапке и к новостям */
.stories-strip.stories-strip-tight {
    margin: 12px 0 12px;
}

.stories-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 2px 10px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

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

.story-ring {
    flex: 0 0 auto;
    width: calc(var(--story-size, 76px) + 14px);
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    font-family: inherit;
}

.story-ring-media {
    width: var(--story-size, 76px);
    height: var(--story-h, var(--story-size, 76px));
    border-radius: var(--story-radius, 50%);
    padding: 3px;
    /* обводка: свой цвет из настройки или градиент по умолчанию */
    background: var(--story-ring-bg, linear-gradient(135deg, #f59e0b, #ec4899 45%, #8b5cf6));
    transition: transform .2s ease;
}

.story-ring:hover .story-ring-media {
    transform: scale(1.06);
}

.story-ring-media img,
.story-ring-media video {
    width: 100%;
    height: 100%;
    border-radius: var(--story-radius, 50%);
    object-fit: cover;
    border: 3px solid #fff;
    background: #0c4a6e;
    display: block;
}

.story-ring-placeholder {
    width: 100%;
    height: 100%;
    border-radius: var(--story-radius, 50%);
    border: 3px solid #fff;
    background: linear-gradient(135deg, #0c4a6e, #0284c7);
    color: rgba(255, 255, 255, .85);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Просмотренная история — серая обводка */
.story-ring.viewed .story-ring-media {
    background: #cbd5e1;
}

.story-ring-label {
    font-size: 12px;
    line-height: 1.25;
    color: #475569;
    text-align: center;
    max-width: calc(var(--story-size, 76px) + 14px);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Полноэкранный плеер --- */
.stories-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(2, 6, 23, .92);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.stories-modal[hidden] {
    display: none;
}

.stories-player {
    position: relative;
    width: min(var(--player-w, 420px), 100%);
    max-height: calc(100vh - 32px);
    aspect-ratio: 9 / 16;
    border-radius: 18px;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
    user-select: none;
    -webkit-user-select: none;
}

.stories-slides {
    position: absolute;
    inset: 0;
}

.stories-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.stories-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.stories-slide img,
.stories-slide video {
    width: 100%;
    height: 100%;
    /* contain: весь кадр целиком (как в YouTube-просмотре). cover
       масштабировал горизонтальные фото «в покрытие» — картинка
       оказывалась больше экрана и обрезалась по бокам. */
    object-fit: contain;
    display: block;
}

.stories-slide-fallback {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #0c4a6e, #0284c7 55%, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .7);
}

.stories-shade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 70px 18px 22px;
    background: linear-gradient(to top, rgba(2, 6, 23, .88), rgba(2, 6, 23, .5) 55%, transparent);
    color: #fff;
}

.stories-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px;
    line-height: 1.3;
}

.stories-text {
    font-size: 14.5px;
    line-height: 1.55;
    margin: 0 0 12px;
    color: rgba(255, 255, 255, .88);
}

.stories-btn {
    position: relative;
    z-index: 5; /* выше тап-зон (z-index: 2) — иначе клик перехватывает тап-зона */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0ea5e9;
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 999px;
    text-decoration: none;
    transition: background .2s ease;
}

.stories-btn:hover {
    background: #0284c7;
}

.stories-bars {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 52px;
    display: flex;
    gap: 5px;
    z-index: 3;
}

.stories-bar {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .3);
    overflow: hidden;
}

/* Группа баров одной истории: равная ширина у каждой истории,
   внутренние бары делят её между слайдами */
.stories-bar-group {
    flex: 1;
    display: flex;
    gap: 4px;
}

.stories-bar-fill {
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 2px;
}

.stories-close {
    position: absolute;
    top: 18px;
    right: 10px;
    z-index: 4;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(2, 6, 23, .5);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease;
}

.stories-close:hover {
    background: rgba(2, 6, 23, .75);
}

.stories-tap {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    border: 0;
    background: none;
    cursor: pointer;
    z-index: 2;
}

.stories-tap--prev {
    left: 0;
}

.stories-tap--next {
    right: 0;
}

@media (max-width: 520px) {
    .stories-modal {
        padding: 0;
    }

    .stories-player {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* --- Карусель ленты (включается JS'ом при переполнении кружков,
       как в секции «Наша команда»: стрелки по бокам + точки) --- */
.stories-strip.stories-carousel {
    position: relative;
}

.stories-carousel .stories-track {
    overflow: hidden;
    padding: 9px 2px 15px;
    margin: -5px 0;
    transition: transform .5s cubic-bezier(.25, .46, .45, .94);
    will-change: transform;
}

.stories-strip.stories-carousel .carousel-btn {
    position: absolute;
    top: calc(var(--story-h, var(--story-size, 76px)) / 2 + 3px);
    transform: translateY(-50%);
    z-index: 6;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, .55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-color: rgba(255, 255, 255, .65);
    color: rgba(71, 85, 105, .65);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.stories-strip.stories-carousel .carousel-btn:hover {
    background: rgba(14, 165, 233, .85);
    border-color: rgba(14, 165, 233, .85);
    color: #fff;
}

.stories-strip.stories-carousel .carousel-btn-prev {
    left: -6px;
}

.stories-strip.stories-carousel .carousel-btn-next {
    right: -6px;
}

.stories-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.stories-dots .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #cbd5e1;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all .3s ease;
}

.stories-dots .dot.active {
    background: #0ea5e9;
    width: 28px;
    border-radius: 5px;
}

@media (max-width: 560px) {
    .stories-strip.stories-carousel .carousel-btn {
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, .65);
    }

    .stories-strip.stories-carousel .carousel-btn-prev {
        left: -4px;
    }

    .stories-strip.stories-carousel .carousel-btn-next {
        right: -4px;
    }
}
