/* ============================================================
   STORY MODAL — Samokat-style story viewer
   ============================================================ */

/* Overlay */
.story-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.65);
    animation: storyFadeIn 0.2s ease;
}
.story-modal-overlay[hidden] { display: none !important; }

@keyframes storyFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Modal container */
.story-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: storySlideUp 0.25s ease;
}
.story-modal[hidden] { display: none !important; }

@keyframes storySlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Dialog */
.story-modal-dialog {
    display: flex;
    background: #fff;
    border-radius: 24px;
    width: 100%;
    max-width: 900px;
    height: 80vh;
    max-height: 700px;
    overflow: hidden;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.25);
    position: relative;
}

/* ===== LEFT: Slide viewer ===== */
.story-modal-slides {
    width: 380px;
    flex-shrink: 0;
    background: #1a1a1a;
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 24px 0 0 24px;
    overflow: hidden;
}

/* Progress bars */
.story-progress-bar {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

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

.story-progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 0;
    transition: width 0.3s ease;
}

.story-progress-segment.active .story-progress-fill,
.story-progress-segment.done .story-progress-fill {
    width: 100%;
}

/* Slide content */
.story-slide-content {
    position: relative;
    flex: 1;
    min-height: 0;
}

.story-slide-item {
    position: absolute;
    inset: 0;
    display: none;
}

.story-slide-item.active {
    display: block;
}

.story-slide-item img,
.story-slide-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Text overlay on slide */
.story-slide-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 32px 24px 80px;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.6) 100%);
    color: #fff;
    z-index: 5;
}

.story-slide-label {
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.story-slide-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 8px;
}

.story-slide-desc {
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
}

/* Navigation arrows */
.story-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.story-nav-arrow:hover {
    background: rgba(255, 255, 255, 0.3);
}

.story-nav-arrow--prev { left: 12px; }
.story-nav-arrow--next { right: 12px; }

.story-nav-arrow svg {
    width: 16px;
    height: 16px;
}

/* Sound volume control toggle button */
.story-sound-toggle {
    position: absolute;
    top: 24px;
    right: 16px;
    z-index: 15;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

.story-sound-toggle:hover {
    background: rgba(0, 0, 0, 0.6);
}

.story-sound-toggle:active {
    transform: scale(0.95);
}

.story-sound-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
}

.story-sound-toggle[hidden] {
    display: none !important;
}

/* CTA button at bottom of slides */
.story-slide-cta {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 15;
    display: block;
    text-align: center;
    padding: 14px 20px;
    background: #fff;
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 600;
    border-radius: 14px;
    text-decoration: none;
    transition: background 0.15s;
}

.story-slide-cta:hover {
    background: #f0f0f0;
}

/* ===== RIGHT: Content panel ===== */
.story-modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

/* Close button */
.story-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: background 0.15s;
}

.story-modal-close:hover {
    background: #e5e5e5;
}

.story-modal-close svg {
    width: 14px;
    height: 14px;
}

/* Content header */
.story-modal-header {
    padding: 24px 24px 0;
    padding-right: 60px;
    flex-shrink: 0;
}

.story-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.25;
    margin: 0 0 12px;
}

.story-modal-desc {
    font-size: 14px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 16px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
    transition: max-height 0.2s ease;
}

.story-no-products .story-modal-desc {
    max-height: 480px;
}

.story-modal-desc::-webkit-scrollbar {
    width: 4px;
}

.story-modal-desc::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

.story-modal-desc p {
    margin-bottom: 8px;
}

/* Category chips */
.story-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 16px;
    flex-shrink: 0;
}

.story-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1.5px solid #e0e0e0;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.story-chip:hover {
    border-color: #ccc;
    background: #f9f9f9;
}

.story-chip.active {
    border-color: #1a1a1a;
    background: #1a1a1a;
    color: #fff;
}

/* Products scrollable area */
.story-products-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

.story-products-scroll::-webkit-scrollbar { width: 4px; }
.story-products-scroll::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* Products grid */
.story-products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* Product card inside story */
.story-product-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
    overflow: hidden;
    transition: box-shadow 0.15s;
    cursor: pointer;
}

.story-product-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.story-product-img {
    width: 100%;
    aspect-ratio: 1;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    position: relative;
}

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

.story-product-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.story-product-info {
    padding: 8px 10px 10px;
}

.story-product-name {
    font-size: 12px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 2px;
}

.story-product-weight {
    font-size: 11px;
    color: #999;
    margin-bottom: 6px;
}

.story-product-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.story-product-price-old {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
}

.story-product-price {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
}

.story-product-add {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #1F9356;
    border: none;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
    line-height: 1;
}

.story-product-add:hover {
    background: #1a8049;
}

/* Loading state */
.story-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 48px;
}

.story-modal-loading[hidden] {
    display: none !important;
}

.story-modal-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e5e5;
    border-top-color: #1F9356;
    border-radius: 50%;
    animation: storySpinnerSpin 0.7s linear infinite;
}

@keyframes storySpinnerSpin {
    to { transform: rotate(360deg); }
}

/* ===== MOBILE: Full-screen mode ===== */
@media (max-width: 768px) {
    .story-modal {
        padding: 0;
        align-items: stretch;
    }

    .story-modal-dialog {
        flex-direction: column;
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .story-modal-slides {
        width: 100%;
        height: 50vh;
        flex-shrink: 0;
        border-radius: 0;
    }

    .story-modal-content {
        flex: 1;
        border-radius: 24px 24px 0 0;
        margin-top: -16px;
        z-index: 5;
        background: #fff;
    }

    .story-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .story-modal-close {
        top: 12px;
        right: 12px;
    }

    .story-modal-desc {
        max-height: 120px;
    }

    .story-no-products .story-modal-desc {
        max-height: 350px;
    }

    .story-sound-toggle {
        top: 20px;
        right: 12px;
    }
}

@media (max-width: 480px) {
    .story-modal-title {
        font-size: 18px;
    }

    .story-modal-desc {
        font-size: 13px;
    }

    .story-slide-title {
        font-size: 18px;
    }

    .story-chip {
        padding: 6px 12px;
        font-size: 13px;
    }
}
