/* --- Concept 3: Stories/App-Like Category Overlay --- */
.story-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0a0a0a 100%);
    z-index: 99999;
    /* Higher than everything */
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: scale(1.1);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    overflow: hidden;
    will-change: opacity, transform;
}

@media (max-width: 768px) {
    .story-overlay {
        backdrop-filter: blur(5px);
        /* Much lower for performance */
        -webkit-backdrop-filter: blur(5px);
        background: rgba(10, 10, 10, 0.95);
        /* Solid background to compensate for less blur */
    }
}

.story-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

/* Enhanced Background Effects - Golden particles */
.story-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 80%, rgba(197, 160, 89, 0.15) 0%, transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(197, 160, 89, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 50% 50%, rgba(197, 160, 89, 0.05) 0%, transparent 50%);
    animation: pulseGold 4s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

/* Second layer - Rotating shimmer */
.story-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(197, 160, 89, 0.08),
            transparent);
    animation: shimmerSlide 4s ease-in-out infinite;
    /* Slower animation for performance */
    pointer-events: none;
    z-index: 0;
}

@media (max-width: 768px) {

    .story-overlay::before,
    .story-overlay::after {
        animation: none !important;
        /* Disable heavy animations on mobile */
        display: none;
        /* Hide background particle effects on mobile to save GPU */
    }
}

@keyframes pulseGold {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1.1);
    }
}

@keyframes shimmerSlide {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

/* Header */
.story-header {
    position: relative;
    z-index: 2;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.6);
}

.story-header h2 {
    color: #c5a059;
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    margin: 0;
    text-shadow: 0 2px 10px rgba(197, 160, 89, 0.3);
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.story-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.story-close-btn:hover {
    background: #c5a059;
    transform: rotate(90deg);
}

/* Main Scrollable Content */
.story-content-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
    z-index: 1;
    display: block;
    /* Hide scrollbar for Chrome, Safari and Opera */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.story-content-container::-webkit-scrollbar {
    display: none;
}

/* The Grid inside the overlay - 2 per row on mobile */
.story-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 15px;
    padding-bottom: 80px;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

/* Desktop - Even larger cards */
@media (min-width: 768px) {
    .story-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 35px;
        padding: 40px;
    }

    .story-header {
        padding: 25px 40px;
    }
}

/* Card overrides inside Story Mode to make them pop */
.story-overlay .product-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(197, 160, 89, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: cardSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(40px) scale(0.9);
    transition: transform 0.4s ease, box-shadow 0.4s ease, border-color 0.3s ease;
}

/* Enhanced hover effect */
.story-overlay .product-card:hover {
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: 0 20px 50px rgba(197, 160, 89, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
    border-color: rgba(197, 160, 89, 0.5);
}

/* Stagger animation for items - Extended for 12 items */
.story-overlay .product-card:nth-child(1) {
    animation-delay: 0.05s;
}

.story-overlay .product-card:nth-child(2) {
    animation-delay: 0.1s;
}

.story-overlay .product-card:nth-child(3) {
    animation-delay: 0.15s;
}

.story-overlay .product-card:nth-child(4) {
    animation-delay: 0.2s;
}

.story-overlay .product-card:nth-child(5) {
    animation-delay: 0.25s;
}

.story-overlay .product-card:nth-child(6) {
    animation-delay: 0.3s;
}

.story-overlay .product-card:nth-child(7) {
    animation-delay: 0.35s;
}

.story-overlay .product-card:nth-child(8) {
    animation-delay: 0.4s;
}

.story-overlay .product-card:nth-child(9) {
    animation-delay: 0.45s;
}

.story-overlay .product-card:nth-child(10) {
    animation-delay: 0.5s;
}

.story-overlay .product-card:nth-child(11) {
    animation-delay: 0.55s;
}

.story-overlay .product-card:nth-child(12) {
    animation-delay: 0.6s;
}

.story-overlay .product-card:nth-child(n+13) {
    animation-delay: 0.65s;
}

/* Enhanced card entrance animation */
@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.9);
    }

    60% {
        opacity: 1;
        transform: translateY(-5px) scale(1.01);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Text Color Overrides - Black text on product cards */
.story-overlay .product-card h3,
.story-overlay .product-card .price {
    color: #000 !important;
    text-shadow: none;
}

.story-overlay .product-card {
    color: #111 !important;
    background: rgba(255, 255, 255, 0.95) !important;
}

.story-overlay .product-card .btn-add-cart {
    background: #c5a059;
    color: #000;
}

/* Highlight effect when product is found */
@keyframes highlightPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(197, 160, 89, 0);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(197, 160, 89, 0.4);
    }
}

.product-card.highlight-pulse {
    animation: highlightPulse 0.6s ease-in-out 3;
    border-color: #c5a059 !important;
}

/* ===== Story Product Detail Panel ===== */
.story-product-detail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    will-change: transform;
}

.story-product-detail.active {
    transform: translateX(0);
}

/* Header with Back Button */
.spd-header {
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.spd-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: #c5a059;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.spd-back-btn:hover {
    background: rgba(197, 160, 89, 0.1);
}

/* Content Area */
.spd-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 768px) {
    .spd-content {
        flex-direction: row;
        padding: 40px;
        gap: 40px;
    }
}

/* Images Section */
.spd-images {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.spd-images img#spd-main-img {
    width: 100%;
    max-height: 350px;
    object-fit: contain;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .spd-images img#spd-main-img {
        max-height: 450px;
    }
}

.spd-thumbs {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.spd-thumbs img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.spd-thumbs img:hover,
.spd-thumbs img.active {
    border-color: #c5a059;
    transform: scale(1.05);
}

/* Info Section */
.spd-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.spd-info h2#spd-name {
    font-size: 1.6rem;
    color: #1a1a1a;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.spd-price {
    display: flex;
    align-items: center;
    gap: 15px;
}

.spd-price .current-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: #c5a059;
}

.spd-price .original-price {
    font-size: 1.2rem;
    color: #999;
    text-decoration: line-through;
}

.spd-info p#spd-description {
    color: #555;
    font-size: 1rem;
    line-height: 1.7;
    margin: 0;
}

.spd-specs {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spd-specs li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #444;
    font-size: 0.95rem;
}

.spd-specs li::before {
    content: '✓';
    color: #c5a059;
    font-weight: bold;
}

/* Add to Cart Button */
.spd-add-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #c5a059 0%, #d4b36a 100%);
    color: #000;
    border: none;
    padding: 16px 30px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: auto;
    box-shadow: 0 5px 20px rgba(197, 160, 89, 0.3);
}

.spd-add-cart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(197, 160, 89, 0.4);
}

.spd-add-cart-btn:active {
    transform: translateY(0);
}

/* Category Swipe Indicator Pop-up */
#story-swipe-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #c5a059;
    padding: 20px 40px;
    border-radius: 50px;
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-ar);
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(197, 160, 89, 0.3);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(197, 160, 89, 0.2);
    text-align: center;
    white-space: nowrap;
}

#story-swipe-indicator.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Swipe Hint Hint Overlay */
.story-swipe-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
}

.story-swipe-hint.active {
    opacity: 1;
    visibility: visible;
}

.swipe-arrows-hint {
    display: flex;
    gap: 40px;
    margin-bottom: 15px;
    direction: ltr !important;
    /* Force arrows to stay in logical order */
}

.swipe-arrow-gold {
    color: #c5a059;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(197, 160, 89, 0.6);
}

.swipe-arrow-gold.left {
    animation: arrowSlideLeft 1.5s ease-in-out infinite;
}

.swipe-arrow-gold.right {
    animation: arrowSlideRight 1.5s ease-in-out infinite;
}

@keyframes arrowSlideLeft {

    0%,
    100% {
        transform: translateX(0);
        opacity: 0.5;
    }

    50% {
        transform: translateX(-20px);
        opacity: 1;
    }
}

@keyframes arrowSlideRight {

    0%,
    100% {
        transform: translateX(0);
        opacity: 0.5;
    }

    50% {
        transform: translateX(20px);
        opacity: 1;
    }
}

.swipe-text {
    color: #c5a059;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.85);
    padding: 10px 25px;
    border-radius: 30px;
    border: 1px solid rgba(197, 160, 89, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    white-space: nowrap;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
}

@media (min-width: 1025px) {
    .story-swipe-hint {
        display: none !important;
    }
}
/* Ensure modals are always above the story overlay */
.modal { z-index: 100002 !important; }
