/* =============================================================
   UP2TECH — Hero « Cartes qui gravitent »
   - Grosses cartes qui TOMBENT vers le bas au scroll
   - Rotation douce sur l'AXE VERTICAL (droite ↔ gauche), effet
     « carte Pokémon holo » : la brillance balaie la carte en
     synchro avec l'inclinaison 3D
   - Flottement doux + parallaxe à la souris
   Visuels fournis plus tard : <img class="up2-card__img"> dans
   .up2-card__inner (le placeholder disparaît alors tout seul).
   Chargé APRÈS styles.css.
   Keyframes préfixés « up2Card* » pour NE PAS écraser ceux du
   template (ex. up2Shine du titre .up2-slogan).
   ============================================================= */

/* Le contenu du hero passe au-dessus des cartes */
.section-hero .container { position: relative; z-index: 5; }

/* Couche des cartes */
.up2-cards {
    position: absolute;
    inset: 16px 16px 0 16px;
    border-radius: 40px;
    overflow: hidden;      /* AU REPOS : cartes croppées par le cadre arrondi */
    pointer-events: none;
    z-index: 2;
}

/* AU SCROLL : on lève le clip -> les cartes sortent du cadre du hero */
.up2-cards.is-exiting { overflow: visible; }
/* Pendant la sortie, les cartes ne captent plus le survol / les clics */
.up2-cards.is-exiting .up2-card { pointer-events: none; }

/* Le hero passe AU-DESSUS des sections suivantes le temps que les cartes
   glissent dehors et se dissolvent (z-index > sections suivantes).
   PAS d'overflow:clip ici -> les cartes doivent pouvoir déborder sur la
   section suivante. Le scroll infini est évité en bornant la chute en JS
   (applyScroll : translateY plafonné à ~1 écran). */
.section-hero { position: relative; z-index: 2; }

/* Wrapper positionné + parallaxe souris (--px/--py) + fondu d'entrée */
.up2-card {
    position: absolute;
    left: var(--x);
    top: var(--y);
    /* Taille = base (pilotée par le responsive) × échelle propre à la carte */
    --base-w: 242px;
    --base-h: 336px;
    --w: calc(var(--base-w) * var(--scale, 1));
    --h: calc(var(--base-h) * var(--scale, 1));
    width: var(--w);
    height: var(--h);
    margin-left: calc(var(--w) / -2);
    margin-top: calc(var(--h) / -2);
    transform: translate3d(var(--px, 0px), var(--py, 0px), 0);
    transition: transform .6s cubic-bezier(.2, .8, .2, 1);
    pointer-events: auto;
    z-index: 3;
    opacity: 0;
    animation: up2CardIn .9s ease var(--in, .1s) forwards;
}

/* Couche « chute au scroll » (JS pilote translateY, vers le bas) */
.up2-card__drop {
    width: 100%;
    height: 100%;
    will-change: transform;
}

/* Couche « flottement » continu */
.up2-card__float {
    width: 100%;
    height: 100%;
    animation: up2CardFloat var(--floatDur, 7s) ease-in-out var(--floatDelay, 0s) infinite;
}

/* Couche « tilt 3D » : légère rotation sur l'axe vertical (droite ↔ gauche) */
.up2-card__tilt {
    width: 100%;
    height: 100%;
    animation: up2CardTilt var(--tiltDur, 6s) ease-in-out var(--tiltDelay, 0s) infinite;
    transform-origin: 50% 50%;
}

/* La carte visible */
.up2-card__inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow:
        0 40px 80px rgba(0, 0, 0, 0.55),
        0 8px 26px rgba(224, 30, 104, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    background:
        radial-gradient(120% 80% at 20% 8%, rgba(255, 77, 145, 0.38) 0%, rgba(255, 77, 145, 0) 55%),
        linear-gradient(155deg, #201a2b 0%, #171420 45%, #2a1330 100%);
    transition: box-shadow .35s ease, transform .35s ease;
}

/* Image de la carte (si fournie) */
.up2-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Placeholder (masqué dès qu'une image est présente) */
.up2-card__img ~ .up2-card__ph { display: none; }
.up2-card__ph {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
    padding: 16px;
}
.up2-card__ph .ic {
    font-size: 38px;
    color: #ff4d91;
    filter: drop-shadow(0 4px 16px rgba(255, 77, 145, 0.6));
}
.up2-card__ph .lb {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    opacity: .8;
}

/* Brillance holographique : glare qui balaie en SYNCHRO avec le tilt */
.up2-card__inner::after {
    content: "";
    position: absolute;
    inset: -25%;
    background: linear-gradient(
        108deg,
        transparent 26%,
        rgba(255, 255, 255, 0.12) 40%,
        rgba(255, 255, 255, 0.75) 50%,
        rgba(255, 77, 145, 0.35) 56%,
        rgba(255, 255, 255, 0.12) 64%,
        transparent 76%
    );
    transform: translateX(0);
    animation: up2CardHolo var(--tiltDur, 6s) ease-in-out var(--tiltDelay, 0s) infinite;
    pointer-events: none;
}

/* Liseré brillant sur le bord */
.up2-card__inner::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 40%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: .6;
    z-index: 1;
}

/* Survol : la carte se redresse et brille plus fort */
.up2-card:hover { z-index: 9; }
.up2-card:hover .up2-card__inner {
    transform: translateY(-6px) scale(1.04);
    box-shadow:
        0 50px 100px rgba(0, 0, 0, 0.6),
        0 12px 38px rgba(224, 30, 104, 0.45);
}

/* ---- Keyframes (préfixés up2Card*) ---- */
@keyframes up2CardIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes up2CardFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}
/* Tilt 3D droite ↔ gauche autour de l'axe vertical (perspective incluse).
   rotate(--rot) conserve l'inclinaison « éparpillée » de repos de chaque carte.
   --tiltAmp = amplitude du pivot (plus grand = effet plus prononcé). */
@keyframes up2CardTilt {
    0%, 100% { transform: rotate(var(--rot, 0deg)) perspective(800px) rotateY(var(--tiltAmp, 30deg)); }
    50%      { transform: rotate(var(--rot, 0deg)) perspective(800px) rotateY(calc(var(--tiltAmp, 30deg) * -1)); }
}
/* La brillance suit l'inclinaison (balaie de gauche à droite en synchro) */
@keyframes up2CardHolo {
    0%, 100% { transform: translateX(58%);  opacity: .5; }
    50%      { transform: translateX(-58%); opacity: 1; }
}

/* Responsive : on ajuste la taille de BASE (le facteur --scale de chaque carte reste appliqué) */
@media (max-width: 1400px) { .up2-card { --base-w: 216px; --base-h: 301px; } }
@media (max-width: 1200px) { .up2-card { --base-w: 186px; --base-h: 260px; } }
@media (max-width: 991px) {
    .up2-card { --base-w: 147px; --base-h: 207px; }
    .up2-card[data-sm-hide] { display: none; }
}
@media (max-width: 575px) { .up2-cards { display: none; } }

/* Mouvement réduit : pas de tilt/flottement/brillance/parallaxe */
@media (prefers-reduced-motion: reduce) {
    .up2-card__float,
    .up2-card__tilt { animation: none; }
    .up2-card__inner::after { animation: none; opacity: 0; }
    .up2-card { transition: none; }
}
