/* ==========================================================================
   STORIES LAYER SYSTEM — THEMENU BY LF1 
   ========================================================================== */

/* BLOCCO RIGIDO ANTI-RIMBALZO VERTICALE PER HTML E BODY */
html.no-scroll-stories, 
body.no-scroll-stories {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    overscroll-behavior-y: none !important; /* Blocca l'effetto trascinamento elastico nei browser */
    overscroll-behavior: none !important;
}

/* 1. CONTAINER STRUTTURALE (A TUTTO SCHERMO OPACIZZATO) */
.swiper-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    background-color: #000000 !important;
    background: #000000 !important;
    z-index: 9999999 !important; /* In cima all'universo visivo della pagina */
    margin: 0 !important;
    padding: 0 !important;
    display: none;
    overflow: hidden !important;
    touch-action: pan-x !important; /* Dice al browser di accettare tocchi SOLO in orizzontale */
}

.swiper-wrapper {
    display: flex !important;
    flex-direction: row !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}

.swiper-slide {
    position: relative !important;
    width: 100vw !important;
    height: 100vh !important;
    flex-shrink: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background: #000000 !important;
    overflow: hidden !important;
    margin: 0 !important;
}

/* 2. MEDIA ADATTIVI (9:16 RITAGLIO INSTAGRAM STYLE) */
.story-media {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
}

.story-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(to bottom, 
                rgba(0,0,0,0.6) 0%, 
                rgba(0,0,0,0) 15%, 
                rgba(0,0,0,0) 75%, 
                rgba(0,0,0,0.8) 100%) !important;
    z-index: 50 !important;
    pointer-events: none !important;
}

/* 3. TIMELINE DI AVANZAMENTO IN ALTO */
.story-progress-bar {
    position: absolute !important;
    top: 15px !important;
    left: 15px !important;
    right: 15px !important;
    height: 3px !important;
    background: rgba(255, 255, 255, 0.3) !important;
    border-radius: 2px !important;
    z-index: 100 !important;
    overflow: hidden !important;
}

.story-progress-fill {
    height: 100% !important;
    background: #ffffff !important;
    width: 0%;
}

/* CONTATORE NUMERICO "STORIA X DI Y" */
.story-counter {
    position: absolute !important;
    top: 28px !important; 
    left: 18px !important;
    color: rgba(255, 255, 255, 0.8) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    z-index: 100 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
    pointer-events: none !important;
}

/* 4. BLOCCO DEI TESTI ED ETICHETTE IN BASSO (CON MARGINI PROTETTI) */
.story-content, 
.story-content * {
    color: #ffffff !important;
    text-align: left !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.story-content {
    position: absolute !important;
    bottom: 95px !important; 
    left: 25px !important;   
    right: 25px !important;  
    width: calc(100% - 50px) !important;
    z-index: 150 !important; 
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.story-badge-new {
    display: inline-block !important;
    background-color: #ff3b30 !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    padding: 3px 10px !important;
    border-radius: 4px !important;
    margin-bottom: 10px !important;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4) !important;
    animation: pulseBadge 2s infinite alternate;
}

@keyframes pulseBadge {
    0% { transform: scale(1); box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4); }
    100% { transform: scale(1.05); box-shadow: 0 2px 12px rgba(255, 59, 48, 0.7); }
}

.story-author {
    font-weight: 700 !important;
    font-size: 20px !important;
    line-height: 24px !important;
    margin-bottom: 8px !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
}

.story-description {
    font-weight: 400 !important;
    font-size: 15px !important;
    line-height: 21px !important;
    margin-bottom: 20px !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8) !important;
    word-wrap: break-word !important;
    max-height: 100px;
    overflow-y: auto;
}

/* 5. BOTTONE INTERATTIVO "TORNA AL MENÙ" */
.story-action-btn {
    position: relative !important;
    z-index: 160 !important; 
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100% !important;
    padding: 12px 24px !important;
    background: rgba(255, 255, 255, 0.25) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 25px !important;
    color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    transition: background 0.2s ease, transform 0.1s ease;
}

.story-action-btn:active {
    background: rgba(255, 255, 255, 0.4) !important;
    transform: scale(0.98);
}

/* 6. PULSANTI E ZONE DI INTERAZIONE GLOBALI (TAP E CHIUDI) */
.story-close-btn {
    position: absolute !important;
    top: 25px !important;
    right: 20px !important;
    background: none !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 35px !important;
    line-height: 35px !important;
    cursor: pointer !important;
    z-index: 200 !important; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.5) !important;
    opacity: 0.8;
}

.story-tap-zone {
    position: absolute !important;
    top: 0 !important;
    width: 30% !important; 
    height: 100% !important;
    z-index: 80 !important;  
    pointer-events: auto !important;
}

.story-tap-zone.left { left: 0 !important; }
.story-tap-zone.right { right: 0 !important; }

/* 7. UTILITY DI COPERTURA E TRIGGER DEL LAUNCHER DEL MENÙ SOTTOSTANTE */
.hide-only-menu {
    display: none !important;
}

.menu-stories-trigger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #ffffff !important;
    color: #333333 !important;
    border: none !important;
    padding: 10px 22px !important;
    border-radius: 30px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.menu-stories-trigger::before {
    content: '';
    position: absolute;
    top: -3px; left: -3px; right: -3px; bottom: -3px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    border-radius: 34px;
    z-index: -1;
}

.menu-stories-trigger:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(220, 39, 67, 0.25) !important;
}

.menu-stories-trigger:active {
    transform: scale(0.98);
}
/* Quando il content diventa visibile, il loader deve sparire tassativamente */
#content[style*="display: block"] ~ .loader,
#content:not([style*="display: none"]) ~ .loader {
  display: none !important;
}