/*
 * Custom Stories Implementation for Gigi Pizza
 * Includes styles for main page cards and story viewer modal
 */

/* === MAIN PAGE STORIES SECTION === */

.stories-wrapper {
    position: relative;
    max-width: 100%;
}

/* Stories container - horizontal scroll */
.zuck-container {
    display: flex !important;
    gap: 16px;
    overflow-x: auto;
    overflow-y: visible; /* allow shadows to be visible */
    scroll-behavior: smooth;
    padding: 12px 0px; /* space for shadows left/right */
    -ms-overflow-style: none;
    scrollbar-width: none;
    overflow: visible; 
}

.zuck-container::-webkit-scrollbar {
    display: none;
}

/* Individual story card */
.story {
    flex-shrink: 0;
    width: 180px !important;
    height: 240px !important;
    border-radius: 20px;
    overflow: visible; /* allow shadows */
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 0px 12px rgba(0, 0, 0, 0.1);
    position: relative;
}

.stories-container {
    padding: 0px !important;
}

.story:hover {
    transform: translateY(-4px);
    box-shadow: 8px 0px 20px rgba(0, 0, 0, 0.10)
}

/* Story preview container */
.item-preview {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 20px;
}

.item-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Title overlay on cards - HIDDEN */
.story-title-overlay {
    display: none;
}

/* Navigation arrow for main page scroll */
.stories-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.stories-arrow:hover {
    transform: translateY(-50%) scale(1.05);
    background: #fff;
}

.stories-arrow.next {
    right: -16px;
}

.stories-arrow.next::after {
    content: '›';
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-left: 2px;
}

.stories-arrow.hidden {
    opacity: 0;
    pointer-events: none;
}

/* === STORY VIEWER MODAL === */

.story-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(25px);
}

.story-viewer-container {
    position: relative;
    width: 450px;
    height: 867px;
    max-width: 90vw;
    max-height: 90vh;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Story viewer header */
.story-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 20px 20px 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), transparent);
}

.story-progress-bars {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

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

.story-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}

.story-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.story-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.story-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.story-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Story content area */
.story-content {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.story-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    height: 100%;
    width: auto;
}

/* Text overlay on story content */
.story-text-overlay {
    position: absolute;
    bottom: 120px;
    left: 20px;
    right: 20px;
    z-index: 5;
}

.story-text-content {
    color: #fff;
    text-align: center;
    font-size: 18px;
    line-height: 1.4;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
    font-weight: 500;
}

/* Navigation buttons in viewer */
.story-navigation {
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 6;
}

.story-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}

.story-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.story-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Action button */
.story-action-button {
    position: absolute;
    bottom: 30px;
    left: 20px;
    right: 20px;
    z-index: 7;
}

.story-action-btn {
    width: 100%;
    padding: 16px 24px;
    background: #ff6b35; /* Default color, will be overridden by JS */
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.story-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    filter: brightness(0.9);
}

/* Tap areas for navigation */
.story-tap-areas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    z-index: 4;
}

.story-tap-left,
.story-tap-right {
    flex: 1;
    cursor: pointer;
}

/* === Page transition animation === */
@keyframes storyFade {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.story-fade {
    animation: storyFade 0.35s ease forwards;
}

/* Slide between stories */
@keyframes storySlideLeft {
    from { transform: translateX(100%); opacity:0; }
    to   { transform: translateX(0);   opacity:1; }
}
@keyframes storySlideRight {
    from { transform: translateX(-100%); opacity:0; }
    to   { transform: translateX(0);    opacity:1; }
}
.story-slide-left {
    animation: storySlideLeft 0.4s ease forwards;
}
.story-slide-right {
    animation: storySlideRight 0.4s ease forwards;
}

.story-preview {
    /* z-index set dynamically via JS */
}

@media (max-width: 1367px) {
    .zuck-container {
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    .story{
        width: 100px !important;
        height: 140px !important;
    }
}

@media (max-width: 480px) {
    .zuck-container {
        padding: 12px 0px; /* убираем боковые отступы */
        gap: 10px;
        overflow-x: auto;   /* горизонтальная прокрутка */
        overflow-y: visible; /* показываем тень карточек вертикально */
        -webkit-overflow-scrolling: touch; /* плавный скролл на iOS */
    }

    .story {
        width: 100px !important;
        height: 140px !important;
        flex: 0 0 auto; /* запрещаем сжатие и позволяем прокрутку */
        scroll-snap-align: start; /* опционально – прилипаем к началу */
    }

    .stories-arrow { /* скрываем навигационные стрелки */
        display: none !important;
    }

    .story-viewer-overlay {
        background: rgb(0 0 0 / 75%);
    }

    .story-viewer-container {
       width: 100% !important;
       height: 100% !important;
       border-radius: 8px !important;
       max-width: 100% !important;
       max-height: 100% !important;
    }

    .stories-container {
        margin-top: 0px;
        margin-bottom: 16px;
    }
    
    .stories-section {
        margin-top: 10px;
    }
    
    .story-navigation { display:none !important; }
}

/* Отключаем синий tap-highlight на мобильных */
.story-tap-left,
.story-tap-right,
.story-viewer-container,
.story-close-btn {
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    outline: none;
}