/*
   Transitions entre les pages et animation d'ouverture
*/

html.transition-entree::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 39;
    background: var(--accent);
    animation: transition-masquer 0.01s 4.5s forwards;
}

html.transition-entree.transition-typeB::after {
    content: "";
    position: fixed;
    z-index: 39;
    left: 50%;
    top: 50%;
    width: var(--taille-etoile, 300px);
    height: var(--taille-etoile, 300px);
    transform: translate(-50%, -50%) rotate(90deg);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='%23fff' d='M50 0Q58 42 100 50Q58 58 50 100Q42 58 0 50Q42 42 50 0Z'/%3E%3C/svg%3E")
        center/contain no-repeat;
    animation: transition-masquer 0.01s 4.5s forwards;
}

html.transition-entree.transition-typeC::before {
    inset: auto;
    left: -30vw;
    top: -25vh;
    width: 160vw;
    height: 150vh;
    transform: rotate(-6deg);
    background: linear-gradient(
        #0c0d12 0 14.28%,
        var(--accent) 0 28.56%,
        #0c0d12 0 42.84%,
        var(--accent) 0 57.12%,
        #0c0d12 0 71.4%,
        var(--accent) 0 85.68%,
        #0c0d12 0
    );
}

html.transition-demarrage
    body
    > *:not(#transition-canvas):not(#transition-etoiles):not(#transition-bandes) {
    visibility: hidden;
    animation: transition-afficher 0.01s 3.5s forwards;
}

@keyframes transition-afficher {
    to {
        visibility: visible;
    }
}

html.transition-accueil::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: var(--papier);
    animation: transition-masquer 0.01s 6s forwards;
}

@keyframes transition-masquer {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

html.transition-en-cours {
    pointer-events: none;
}

#transition-canvas {
    position: fixed;
    inset: 0;
    z-index: 39;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#transition-etoiles {
    position: fixed;
    inset: 0;
    z-index: 39;
    pointer-events: none;
    display: grid;
    place-items: center;
    overflow: hidden;
}

#transition-etoiles svg {
    position: absolute;
    width: 100px;
    height: 100px;
    overflow: visible;
    transform: scale(0);
}

#transition-bandes {
    position: fixed;
    z-index: 39;
    pointer-events: none;
    left: -30vw;
    top: -25vh;
    width: 160vw;
    height: 150vh;
    transform: rotate(-6deg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#transition-bandes i {
    flex: 1;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    font-style: normal;
    color: #fff;
    font-family: "Arial Black", Impact, sans-serif;
    font-weight: 900;
    font-size: clamp(28px, 5vw, 56px);
    letter-spacing: -0.03em;
    text-transform: uppercase;
}

#transition-bandes i.bande-noire {
    background: #0c0d12;
}

#transition-bandes i.bande-bleue {
    background: var(--accent);
}

#transition-bandes u {
    text-decoration: none;
    color: var(--accent);
    margin: 0 0.5em;
}

#transition-bandes i.bande-bleue u {
    color: #fff;
}

html.transition-bleue .entete,
html.transition-entree.transition-typeA .entete {
    background: var(--accent) !important;
    border-color: #fff !important;
}

html.transition-bleue .entete a:not(.logo),
html.transition-bleue .entete button,
html.transition-bleue .entete .langue-code,
html.transition-entree.transition-typeA .entete a:not(.logo),
html.transition-entree.transition-typeA .entete button,
html.transition-entree.transition-typeA .entete .langue-code {
    color: #fff !important;
}

@keyframes entree-montante {
    from {
        opacity: 0;
        translate: 0 38px;
    }
}

@keyframes entree-descendante {
    from {
        opacity: 0;
        translate: 0 -30px;
    }
}

@keyframes entree-visuel {
    from {
        translate: 0 38px;
    }
}

@keyframes entree-fondu {
    from {
        opacity: 0;
    }
}

@keyframes entree-portrait {
    from {
        clip-path: inset(100% -30px -60px -30px);
    }
    to {
        clip-path: inset(-30px -30px -60px -30px);
    }
}

html.animation-entree .entete {
    animation: entree-descendante 0.8s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

html.animation-entree .hero .etiquette {
    animation: entree-montante 0.7s 0.15s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

html.animation-entree .hero .intro-texte {
    animation: entree-montante 0.7s 0.6s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

html.animation-entree .hero .boutons {
    animation: entree-montante 0.7s 0.75s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

/* Le visuel (étoile + portrait) monte de derrière le ruban noir. Le portrait se dévoile par le bas
   au lieu de se fondre : un fondu laissait voir le texte des rubans à travers sa chemise. */
html.animation-entree .hero .hero-visuel {
    animation: entree-visuel 1.3s 0.45s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

html.animation-entree .hero .etoile {
    animation: entree-fondu 0.6s 0.45s ease-out both;
}

html.animation-entree .hero .portrait {
    animation: entree-portrait 1s 0.5s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

html.animation-entree .hero .autocollant {
    animation:
        flottement 3.2s ease-in-out infinite,
        entree-fondu 0.6s 0.9s ease-out both;
}

html.animation-entree main > :not(.hero):nth-child(-n + 4) {
    animation: entree-montante 0.7s 0.3s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

html.animation-entree main > :not(.hero):nth-child(2) {
    animation-delay: 0.45s;
}

html.animation-entree main > :not(.hero):nth-child(3) {
    animation-delay: 0.6s;
}

html.animation-entree main > :not(.hero):nth-child(4) {
    animation-delay: 0.75s;
}

/* Les rubans ne s'animent pas eux-mêmes : une animation en faisait un bloc à part qui passait
   SOUS la photo pendant l'ouverture (la photo coupée net se voyait par-dessus le ruban noir,
   puis le ruban repassait devant d'un coup). Sans animation, la photo monte de derrière le ruban. */
html.animation-entree main > .rubans:nth-child(n) {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    html.transition-entree::before,
    html.transition-entree::after,
    html.transition-accueil::before {
        display: none;
    }

    html.transition-demarrage body > * {
        visibility: visible !important;
    }

    html.animation-entree * {
        animation: none !important;
    }
}
