/* /include_areas/stories/stories.css */
/* Instagram Stories — с кнопками навигации */

.stories-wrapper {
    max-width: 100%;
    margin: 0 auto;
    padding: 16px 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.stories-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 4px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.stories-scroll::-webkit-scrollbar { display: none; }

/* Карточка */
.story-card {
    width: 160px;
    min-width: 160px;
    height: 240px;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    background: #1a1a1a;
    -webkit-tap-highlight-color: transparent;
}
.story-card:active { transform: scale(0.96); }
.story-card-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.3s ease;
}
.story-card:hover .story-card-bg { transform: scale(1.03); }
.story-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.7) 100%);
}
.story-card-label {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    z-index: 2;
}
.story-card-title {
    position: absolute;
    bottom: 16px;
    left: 12px;
    right: 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========== VIEWER ========== */
.stories-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
}
.stories-overlay.active { display: block; }

.stories-viewer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #000;
    touch-action: pan-y;
}
.stories-viewer.active { display: flex; }
.stories-viewer-inner {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    overflow: hidden;
}
@media (min-width: 769px) {
    .stories-viewer {
        align-items: center;
        justify-content: center;
    }
    .stories-viewer-inner {
        height: auto;
        max-height: 90vh;
        aspect-ratio: 9/16;
        border-radius: 20px;
    }
}

.stories-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stories-content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.stories-content video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.stories-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Прогресс-бары */
.stories-progress {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    gap: 3px;
    z-index: 20;
}
.stories-progress-item {
    flex: 1;
    height: 2px;
    background: rgba(255,255,255,0.3);
    border-radius: 1px;
    overflow: hidden;
}
.stories-progress-bar {
    height: 100%;
    background: #fff;
    border-radius: 1px;
    width: 0;
}
.stories-progress-bar.active {
    animation: storiesProgress var(--dur, 60s) linear forwards;
}
.stories-progress-bar.done { width: 100%; }

@keyframes storiesProgress {
    to { width: 100%; }
}

/* Хедер */
.stories-header {
    position: absolute;
    top: 20px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 20;
}
.stories-header-name {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stories-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 21;
}
.stories-close:hover { background: rgba(255,255,255,0.3); }

/* Кнопка звука */
.stories-sound {
    position: absolute;
    bottom: 32px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.stories-sound.visible {
    opacity: 1;
    pointer-events: auto;
}
.stories-sound.muted .sound-on { display: none; }
.stories-sound:not(.muted) .sound-off { display: none; }

/* Кнопка действия */
.stories-action {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    white-space: nowrap;
}
.stories-action a {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transition: transform 0.15s;
}
.stories-action a:active { transform: scale(0.96); }

/* Зоны тача */
.stories-touch {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    z-index: 5;
    -webkit-tap-highlight-color: transparent;
}
.stories-touch-prev { left: 0; }
.stories-touch-next { right: 0; }

/* ========== КНОПКИ НАВИГАЦИИ (ДЕСКТОП) ========== */
.stories-nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
}
.stories-nav-btn.visible {
    opacity: 1;
    pointer-events: auto;
}
.stories-nav-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-50%) scale(1.05);
}
.stories-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}
.stories-nav-btn svg {
    width: 24px;
    height: 24px;
}
.stories-nav-prev-btn {
    left: calc(50% - 280px);
}
.stories-nav-next-btn {
    right: calc(50% - 280px);
}
@media (max-width: 768px) {
    .stories-nav-btn { display: none; }
}

/* Скрываем меню */
html.stories-modal-open .mobile_panel {
    display: none !important;
}

/* Адаптив */
@media (max-width: 480px) {
    .stories-wrapper { padding: 12px 4px; }
    .stories-scroll { gap: 10px; }
    .story-card { width: 140px; min-width: 140px; height: 210px; border-radius: 14px; }
    .story-card-title { font-size: 11px; bottom: 12px; left: 10px; right: 10px; }
    .stories-progress { top: 6px; left: 6px; right: 6px; gap: 2px; }
    .stories-header { top: 16px; left: 12px; right: 12px; }
    .stories-header-name { font-size: 14px; }
    .stories-sound { bottom: 24px; right: 12px; }
    .stories-action { bottom: 24px; }
    .stories-action a { padding: 8px 16px; font-size: 12px; }
}