/* ─── [16] CSS custom properties ──────────────────────────────────────────── */
:root {
    --vs-accent:      #ffb800;
    --vs-accent-dark: #996e00;
    --vs-viewed:      #9797a0;
    --vs-radius:      20px;
    --vs-slot-h:      40vh;
    --vs-slot-h-active: min(80vh, 1080px);
    --vs-transition:  0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --vs-mobile:      768px;
}

/* ─── Блок историй ─────────────────────────────────────────────────────────── */

.video-stories {
    width: 100%;
    box-sizing: border-box;
    transition: opacity var(--vs-transition), visibility var(--vs-transition),
                height var(--vs-transition), margin var(--vs-transition);
}

.video-stories--hidden {
    opacity: 0;
    visibility: hidden;
    height: 0;
    margin: 0 !important;
    overflow: hidden;
    pointer-events: none;
}

@media only screen and (max-width: 1366px) {
    .video-stories { max-width: 1264px; }
}

@media only screen and (max-width: 1024px) {
    .video-stories { padding: 0; }
}

/* ─── Горизонтальный скролл-контейнер ──────────────────────────────────────── */

.video-stories__container {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    /*border: 1px solid #2f2e3a;*/
}

/*@media only screen and (max-width: 1080px) {*/
/*    .video-stories__container {*/
/*        border-right: none;*/
/*        border-left: none;*/
/*    }*/
/*}*/


.video-stories__container::-webkit-scrollbar {
    display: none;
}

.video-stories__list {
    display: flex;
    align-items: center;
    gap: clamp(23px, 3vw, 48px);
    padding: 14px 44px;
    user-select: none;
}

@media only screen and (max-width: 1366px) {
    .video-stories__list { padding: 12px 18px; }
}

/* ─── Story-item (круглое превью) ───────────────────────────────────────────── */

.story-item {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    background: transparent;
    z-index: 1;
}

/* [18] Keyboard navigation */
.story-item:focus-visible {
    outline: 3px solid var(--vs-accent);
    outline-offset: 4px;
}

/* Thumbnail через CSS custom property --story-bg, которую ставит PHP */
.story-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--story-bg);
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    z-index: 2;
}

/* Градиентное кольцо */
.story-item::after {
    content: '';
    position: absolute;
    inset: -3px;
    background: linear-gradient(135deg, var(--vs-accent), var(--vs-accent-dark));
    border-radius: 50%;
    z-index: 1;
    transition: inset var(--vs-transition);
}

.story-item--viewed::after {
    background: var(--vs-viewed);
}

.story-item:hover::after {
    inset: -5px;
}

/* ─── Модальное окно ─────────────────────────────────────────────────────────── */

.stories-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity var(--vs-transition), visibility var(--vs-transition);
}

.stories-modal--open {
    visibility: visible;
    opacity: 1;
}

.stories-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.stories-modal__content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.stories-modal__close {
    position: absolute;
    top: 50px;
    right: 16px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    pointer-events: auto;
    transition: background var(--vs-transition), transform var(--vs-transition);
}

.stories-modal__close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* [18] */
.stories-modal__close:focus-visible {
    outline: 2px solid var(--vs-accent);
    outline-offset: 3px;
}

/* ─── [15] Nav-кнопки карусели ──────────────────────────────────────────────── */

.stories-modal__nav {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    transition: background var(--vs-transition), transform var(--vs-transition);
    z-index: 10;
}

.stories-modal__nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
}

.stories-modal__nav:disabled {
    opacity: 0.25;
    cursor: default;
}

/* [18] */
.stories-modal__nav:focus-visible {
    outline: 2px solid var(--vs-accent);
    outline-offset: 3px;
}

/* ─── Desktop карусель ──────────────────────────────────────────────────────── */

.stories-modal__desktop {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}

@media (min-width: 769px) {
    .stories-modal__desktop {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0;
    }
}

.stories-modal__track {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ─── Слоты карусели ────────────────────────────────────────────────────────── */

.stories-modal__slot {
    flex: 0 0 auto;
    height: var(--vs-slot-h);
    aspect-ratio: 9 / 16;
    pointer-events: auto;
    /* [17] will-change на анимируемых элементах */
    will-change: transform, opacity, height;
    transition: transform var(--vs-transition), opacity var(--vs-transition),
                height var(--vs-transition), box-shadow var(--vs-transition),
                margin var(--vs-transition);
    border-radius: var(--vs-radius);
    overflow: hidden;
    position: relative;
    background: #111;
    cursor: pointer;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.stories-modal__slot:not(:last-child) {
    margin-right: 40px;
}

.stories-modal__slot--active {
    height: var(--vs-slot-h-active);
    z-index: 30;
    box-shadow: 0 0 0 4px var(--vs-accent), 0 30px 60px rgba(0, 0, 0, 0.8);
    margin-left: 20px;
    margin-right: 60px !important;
    cursor: default;
}

.stories-modal__slot--active + .stories-modal__slot {
    margin-left: 20px;
}

/* Боковые слоты — near (±1) чуть ярче far (±2) */
.stories-modal__slot--side-near {
    opacity: 0.5;
    transform: scale(0.92);
    filter: grayscale(0.6);
}

.stories-modal__slot--side-far {
    opacity: 0.25;
    transform: scale(0.84);
    filter: grayscale(1);
}

.stories-modal__slot--side-near:hover,
.stories-modal__slot--side-far:hover {
    opacity: 0.75;
    filter: grayscale(0.2);
    transform: scale(0.95);
}

.stories-modal__slot--placeholder {
    opacity: 0 !important;
    pointer-events: none;
}

/* [15] Thumbnail и оверлей в боковых слотах */
.stories-modal__slot-thumb {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    border-radius: inherit;
}

.stories-modal__slot-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.5));
    border-radius: inherit;
    pointer-events: none;
}

/* ─── [15] Ошибка плеера ────────────────────────────────────────────────────── */

.stories-modal__error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.875rem;
    text-align: center;
    padding: 16px;
    z-index: 20;
}

.stories-modal__error-icon {
    font-size: 2rem;
    line-height: 1;
}

.stories-modal__error-detail {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    max-width: 200px;
    word-break: break-word;
}

/* ─── Mobile swipe ──────────────────────────────────────────────────────────── */

.stories-modal__mobile {
    display: flex;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

@media (min-width: 769px) {
    .stories-modal__mobile { display: none; }
}

.stories-modal__swipe-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}

.stories-modal__swipe-container::-webkit-scrollbar {
    display: none;
}

.stories-modal__swipe-item {
    scroll-snap-align: start;
    width: 100vw;
    height: 100vh;
    position: relative;
    background-color: #000;
    /* [17] */
    will-change: transform;
}

/* [15] Активный swipe-item — iframe смонтирован здесь */
.stories-modal__swipe-item--active {
    z-index: 1;
}

.stories-modal__swipe-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 60%, rgba(0, 0, 0, 0.4));
    pointer-events: none;
    z-index: 2;
}