.story-wrapper {
    position: relative;
    /* Обертка подстраивается под размер изображения, а не под весь экран */
    display: inline-block;
    width: auto;
    height: 100%;
}
.story-link {
    /* Ссылки внизу полноэкранной истории: делим ширину на 3 равные части */
    position: absolute;
    bottom: 0;
    left: 0;
    height: 10%;
    width: 33.3333%;
    padding: 8px 12px;
    border-radius: 0;
    text-decoration: none;
    font-size: 14px;
    text-align: center;
    display: none;
}

@media (max-width: 650px) {
    .story-wrapper {
        height: auto;
    }
}

/* Левая, центральная и правая части соответственно */
#story-link3 {
    left: 0;
}
#story-link2 {
    left: 33.3333%;
}
#story-link {
    left: 66.6666%;
}

/* Чуть выше и больше на очень низких экранах для удобства нажатия */
@media (max-height: 600px) {
    .story-link {
        height: 14%;
        padding: 6px 8px;
        font-size: 12px;
    }
}

.story-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.story-fullscreen {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#progress-bar-container {
    margin-bottom: 5px;
    display: flex;
    gap: 8px; /* адаптация  */
    height: 6px;
    justify-content: space-between;
}

@media screen and (max-width: 585px) {
    #progress-bar-container {
        width: 100%;
    }
}

.progress-bar {
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    width: 0;
    background-color: white;
    animation: none; /* Анимация заполняется динамически */
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    margin-left: -28px;
    margin-top: -28px;
    border: 4px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner-rotate 0.9s linear infinite;
    z-index: 4;
}

.story-modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000;
    display: none; /* управление через JS */
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.9);
}
.story-fullscreen {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.story-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#story-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: auto;
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

/* Прогресс-бар поверх изображения */
.progress-bar-container {
    position: absolute;
    top: 25px;
    width: 30%;
    max-width: none;
    z-index: 3;
    padding: 0 6px;
    pointer-events: none;
}
.progress-bar {
    flex: 1 1 auto;
    height: 4px;
    background: rgba(255,255,255,0.35);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 4px;
}

@keyframes spinner-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes progress {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

.story-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 30px;
    color: white;
    cursor: pointer;
    z-index: 1001;
}

/* Секция историй */
.stories-container {
    display: flex;
    justify-content: center; /* Центрирование по горизонтали */
    width: 100%;
    overflow:hidden;
}

.stories {
    padding: 10px 0;
    max-width: 1888px;
    width: 100%;
    min-height: 150px;
}

.swiper-container {
    width: 100%;
    height: 100%;
}

.swiper-wrapper {
    margin-left: auto;
    display: flex;
    margin-right: auto;

}

/* Скелетон-плейсхолдеры историй */
.story-skeleton {
    position: relative;
}
.story-skeleton .story-skeleton-box {
    width: 100%;
    height: 150px; /* вернуть прежнюю высоту скелетона */
    border-radius: 12px;
    background: #e0e0e0;
    overflow: hidden;
    position: relative; /* ограничить анимацию внутри бокса */
}
.skeleton-stories .story-skeleton,
.skeleton-stories .story-skeleton * {
    opacity: 1 !important; /* перекрываем глобальное скрытие дочерних элементов в skeleton-контейнере */
}
.skeleton-stories .story-skeleton .story-skeleton-box::after {
    content: "";
    position: absolute;
    left: -150px;
    top: 0;
    height: 100%;
    width: 150px;
    background: linear-gradient(90deg, transparent, #f5f5f5 50%, transparent);
    animation: skeleton-loading 1.2s infinite;
}

/* В лёгком режиме подключаем ту же анимацию для каждого плейсхолдера */
.stories-skeleton-lite .story-skeleton .story-skeleton-box::after {
    content: "";
    position: absolute;
    left: -150px;
    top: 0;
    height: 100%;
    width: 150px;
    background: linear-gradient(90deg, transparent, #f5f5f5 50%, transparent);
    animation: skeleton-loading 1.2s infinite;
}
@keyframes skeleton-loading {
    0% { left: -150px; }
    100% { left: 100%; }
}

/* В режиме скелетона фиксируем высоту карточек историй, чтобы не расползались */
.skeleton-stories .story-card {
    height: 150px;
}

/* Явно отключаем общий оверлей скелетона контейнера историй, когда показываем плейсхолдеры */
.skeleton-stories.has-story-skeleton:after {
    display: none !important;
}

/* Лёгкий режим скелетона для историй: без общего оверлея и без глобального скрытия */
.stories-skeleton-lite {
    position: relative;
}
.stories-skeleton-lite:after {
    display: none !important;
}
.stories-skeleton-lite * {
    opacity: 1 !important;
}

.story-card {
    width: 16%; /* Начальная ширина для больших экранов */
    max-width: 261px; /* Ограничение максимальной ширины */
    height: auto;
}

.story-card img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.story-card:hover {
    transform: translateY(-5px);
}

.story-modal img {
    max-width: 78%;     /* адаптация  */
    max-height: 78%; /* адаптация  */
    margin: auto;
    display: block;
}

/* Стили для изображения в полноэкранном режиме */
.swiper-container-fullscreen {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}


.swiper-container-fullscreen .swiper-slide img {
    width: 1000px;
    max-width: 100%; /* Установите желаемый максимум для ширины */
    max-height: 90%; /* Установите желаемый максимум для высоты */
    object-fit: contain;
    margin: auto;
    display: block;
}

.text-o {
    line-height: 87px;
    font-family: Zen Kurenaido, serif;
    position: absolute;
    width: max-content;
    text-align: end;
    top: 38%;
    left: 56%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 80px;
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    white-space: pre-wrap;
}

@media (max-width: 2560px) and (min-width: 1921px) {
    .stories {
        max-width: 100%;
    }
    .swiper-wrapper {
        justify-content: center;
    }
}

/* Адаптивные стили для уменьшения размеров блока историй и перегородки */
@media (max-width: 1200px) {
    .story-card {
        width: 20%;
    }
}

@media (max-width: 992px) {
    .story-card {
        width: 25%;
    }
}

@media (max-width: 768px) {
    .story-card {
        width: 33.33%;
    }
    .text-o {
        font-size: 69px;
        line-height: 87px;
        top: 43%;
        left: 56%;
    }
}

@media (max-width: 480px) {
    .story-card {
        width: 50%;
    }
    .story-modal img {
        max-width: 100%;
        max-height: 100%;
    }
    #progress-bar-container {
        max-width: 100%;
    }
    .text-o {
        font-size: 57px;
        line-height: 62px;
        top: 43%;
        left: 56%;
    }
}

@media (max-width: 380px) {
    .text-o {
        font-size: 41px;
        line-height: 46px;
        top: 43%;
        left: 56%;
    }
    .story-card {
        width: 100%;
    }
}