/**
 * 🌌 THÈME STAR WARS - UNIVERS SPATIAL
 * Effet spatial avec vaisseaux, lasers et texte qui défile
 */

:root {
    --sw-primary: #00bfff;
    --sw-secondary: #ff4500;
    --sw-accent: #32cd32;
    --sw-text: #ffff00;
    --sw-white: #ffffff;
    
    /* VITESSE DE DÉFILEMENT : ajustez cette valeur pour accélérer/ralentir
       Valeurs recommandées : 
       - 60s = très rapide
       - 120s = rapide
       - 180s = normal (film Star Wars)
       - 240s = lent
       - 300s+ = très lent pour textes très longs */
    --crawl-speed: 60s;
}

/* =================================================================
   CONTENEUR STAR WARS PRINCIPAL
   ================================================================= */

.starwars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #1b2735 0%, #090a0f 100%);
    overflow: hidden;
    z-index: 999;
    /* Perspective très courte pour un effet dramatique "cinéma" */
    perspective: 3000px;
    /* Le point de fuite est en haut au centre */
    perspective-origin: 50% 0%;
    
    /* MASQUE DE FONDU : disparition progressive dans les 30% supérieurs */
    -webkit-mask-image: linear-gradient(to bottom, 
        transparent 0%,        /* Invisible tout en haut */
        rgba(0,0,0,0.3) 15%,   /* Commence à apparaître */
        black 30%,             /* Complètement visible à 30% */
        black 100%             /* Reste visible jusqu'en bas */
    );
    mask-image: linear-gradient(to bottom, 
        transparent 0%, 
        rgba(0,0,0,0.3) 15%, 
        black 30%, 
        black 100%
    );
}

/* Effet Nébuleuse en arrière-plan */
.nebula-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(76, 29, 149, 0.15), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 69, 0, 0.1), transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(0, 191, 255, 0.05), transparent 60%);
    animation: nebulaPulse 15s ease-in-out infinite alternate;
    z-index: 0;
}

@keyframes nebulaPulse {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 0.8; transform: scale(1.1); }
}

/* =================================================================
   ÉTOILES EN ARRIÈRE-PLAN - ESPACE PROFOND
   ================================================================= */

.starwars-star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: starTwinkle linear infinite;
    z-index: 1;
}

@keyframes starTwinkle {
    0% { opacity: 0.2; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); box-shadow: 0 0 4px white; }
    100% { opacity: 0.2; transform: scale(0.8); }
}

/* =================================================================
   VAISSEAUX SPATIAUX
   ================================================================= */

.starwars-spaceship {
    position: absolute;
    width: 40px;
    height: 20px;
    background: linear-gradient(45deg, var(--sw-primary) 0%, var(--sw-secondary) 100%);
    border-radius: 50% 10px 50% 10px;
    animation: spaceshipFly linear infinite;
    filter: drop-shadow(0 0 10px var(--sw-primary));
    z-index: 5;
}

@keyframes spaceshipFly {
    0% { left: -10%; transform: rotate(5deg); }
    100% { left: 110%; transform: rotate(-5deg); }
}

.starwars-tie {
    background: linear-gradient(45deg, #333 0%, #666 100%);
    border: 2px solid var(--sw-secondary);
    box-shadow: 0 0 10px var(--sw-secondary);
}

/* =================================================================
   TEXTE QUI DÉFILE - CRAWL (STYLE STAR WARS ORIGINAL)
   ================================================================= */

.starwars-text {
    position: absolute;
    /* Commence en bas de l'écran */
    top: 100%;
    left: 50%;
    /* Largeur très confortable */
    width: 90%;
    max-width: 1400px;
    
    /* Transformation simple : centré et incliné */
    transform: translateX(-50%) rotateX(25deg);
    transform-origin: 50% 100%;
    
    font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
    font-weight: bold;
    color: var(--sw-text);
    text-align: justify;
    letter-spacing: 2px;
    line-height: 1.5;
    
    /* Animation : utilise la variable de vitesse définie dans :root */
    animation: starwarsOpeningCrawl var(--crawl-speed) linear forwards;
    z-index: 10;
}

.opening-crawl {
    text-align: center;
    width: 100%;
}

.opening-title {
    /* Titre GÉANT */
    font-size: 6rem; /* Taille de base */
    font-size: clamp(4rem, 15vw, 15rem); /* Responsive */
    text-transform: uppercase;
    margin-bottom: 1rem;
    color: var(--sw-text);
    text-shadow: 0 0 20px var(--sw-text);
    line-height: 1;
    font-weight: 900;
}

.opening-subtitle {
    font-size: 4rem;
    font-size: clamp(3rem, 10vw, 10rem);
    text-transform: uppercase;
    margin-top: 0;
    margin-bottom: 5rem;
    letter-spacing: 0.2em;
    font-weight: 900;
}

.opening-crawl p {
    /* Texte TRÈS grand et lisible */
    font-size: 3rem;
    font-size: clamp(2rem, 6vw, 6rem);
    margin-bottom: 4rem;
    text-align: justify;
    text-align-last: center;
    line-height: 1.4;
    font-weight: bold;
}

.celebration-text {
    color: var(--sw-primary);
    font-size: 5rem !important;
    font-size: clamp(4rem, 12vw, 12rem) !important;
    text-shadow: 0 0 40px var(--sw-primary);
    margin: 8rem 0 !important;
    font-weight: 900;
    letter-spacing: 0.1em;
}

/* Image de fin */
.final-image-container {
    margin-top: 10rem;
    margin-bottom: 20rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.crawl-image {
    width: 80%;
    height: auto;
    border: 10px solid var(--sw-text);
    border-radius: 20px;
    box-shadow: 0 0 60px var(--sw-text);
    opacity: 1;
}

/* Animation Star Wars SIMPLIFIÉE et CORRIGÉE */
/* Défilement du BAS (100%) vers le HAUT (-X%) */
/* Distance fixe TRÈS grande pour supporter n'importe quelle longueur de texte */
@keyframes starwarsOpeningCrawl {
    0% {
        top: 100%; /* Tout en bas */
        opacity: 1;
        transform: translateX(-50%) rotateX(25deg); 
    }
    100% {
        /* Distance en pixels absolus : assez grande pour un texte même très long
           Si votre texte est VRAIMENT gigantesque (comme un livre entier),
           augmentez cette valeur (ex: -30000px, -50000px, etc.) */
        top: -20000px;
        opacity: 1; /* Le masque s'occupe de la disparition */
        transform: translateX(-50%) rotateX(25deg) translateZ(-2500px); 
    }
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 768px) {
    .starwars-text {
        width: 95%;
        /* Sur mobile, même vitesse (ou ajustez si besoin) */
        animation-duration: var(--crawl-speed);
    }
    
    .opening-title {
        font-size: 15vw;
    }
    
    .opening-subtitle {
        font-size: 10vw;
        margin-bottom: 3rem;
    }
    
    .opening-crawl p {
        font-size: 6vw;
        margin-bottom: 2rem;
    }
    
    .crawl-image {
        width: 95%;
        border-width: 5px;
    }
}
