/* ============================================================
   ANIM.CSS – Système d'animation "Construction & Blueprint"
   Atlas Working · palette Végétale & Zeste
   - Fond global mesh fin + splines
   - Fond hero mesh + courbes splines + ligne de scan
   - Préloader assemblage (AW en construction)
   - Révélations au scroll type construction ([data-build])
   - Barre de progression de lecture
   - Micro-interactions (sheen boutons, souligné nav, tabs)
   ============================================================ */

:root {
    --aw-zeste: #99CC33;
    --aw-zeste-strong: #aedb52;
    --aw-zeste-soft: rgba(153, 204, 51, 0.55);
    --aw-forest: #2F4F4F;
    --aw-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================
   FOND GLOBAL MESH (fixé sur toute la page, derrière le contenu)
   ============================================================ */
.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(47, 79, 79, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(47, 79, 79, 0.05) 1px, transparent 1px);
    background-size: 42px 42px;
    overflow: hidden;
}

/* Contenu au-dessus de la couche de fond */
main,
.container,
.brand-hero__content,
section > * { position: relative; z-index: 2; }

.bg-mesh svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bg-mesh .gdrift {
    animation: drone-drift 46s ease-in-out infinite alternate;
}

.bg-spline {
    fill: none;
    stroke: #2F4F4F;
    stroke-width: 1;
    opacity: 0.16;
    stroke-linecap: round;
    stroke-dasharray: 1400;
    stroke-dashoffset: 1400;
    animation: draw-spline 2.2s var(--aw-ease) forwards;
}

.bg-spline-2 { animation-delay: 0.5s; opacity: 0.1; }

.bg-node {
    fill: #99CC33;
    opacity: 0.3;
    transform-box: fill-box;
    transform-origin: center;
    animation: node-pop 0.8s var(--aw-ease) 2s backwards;
}

/* Bâtiments mesh génératifs éparpillés dans le fond
   Les lignes se tracent lentement, puis restent immobiles. */
.bg-mesh .bg-units { transform: none; }

.bg-mesh .mv-lines {
    fill: none;
    stroke: #2F4F4F;
    stroke-width: 1;
    opacity: 0.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 620;
    stroke-dashoffset: 620;
    animation: mesh-draw var(--md, 7s) var(--aw-ease) var(--del, 0s) forwards;
}

.bg-mesh .mv-soft {
    stroke: #99CC33;
    opacity: 0.35;
    stroke-dasharray: 6 8;
}

/* Nœuds : simples points statiques (aucune animation) */
.bg-mesh .mv-node {
    fill: #99CC33;
    opacity: 0.55;
}

@keyframes drone-drift {
    from { transform: translate(0, 0); }
    to   { transform: translate(-52px, 34px); }
}

/* ============================================================
   FOND HERO (mesh + splines + scanline), injecté par anim.js
   ============================================================ */
.home .home__container,
.home__scroll,
.brand-hero__content { position: relative; z-index: 2; }

.hero-build {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.hero-build svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hero-build .hero-grid line {
    stroke: rgba(153, 204, 51, 0.10);
    stroke-width: 1;
}

.hero-build .spline {
    fill: none;
    stroke: rgba(153, 204, 51, 0.5);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    animation: draw-spline 1.3s var(--aw-ease) forwards;
}

.hero-build .spline-2 { animation-delay: 0.2s; }
.hero-build .spline-3 { animation-delay: 0.4s;  }
.hero-build .spline-4 { animation-delay: 0.6s; }

/* Ligne de lumière : trait continu lumineux qui se trace proprement */
.hero-build .dash {
    fill: none;
    stroke: #aedb52;
    stroke-width: 1.8;
    stroke-linecap: round;
    opacity: 0.95;
    filter: drop-shadow(0 0 7px rgba(153, 204, 51, 0.85));
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    animation: draw-spline 1.4s var(--aw-ease) 0.5s forwards;
}

.hero-build .hero-circle {
    fill: none;
    stroke: rgba(153, 204, 51, 0.3);
    stroke-width: 1;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: draw-spline 1.2s var(--aw-ease) 0.35s forwards;
}

.hero-build .node {
    fill: #99CC33;
    transform-box: fill-box;
    transform-origin: center;
    animation: node-pop 0.5s var(--aw-ease) backwards;
}
.hero-build .node-1 { animation-delay: 0.9s; }
.hero-build .node-2 { animation-delay: 1.1s; }
.hero-build .node-3 { animation-delay: 1.3s; }

/* Ligne de scan qui balaye le hero */
.hero-build::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(153, 204, 51, 0.5), transparent);
    box-shadow: 0 0 18px 2px rgba(153, 204, 51, 0.25);
    opacity: 0;
    animation: scan-line 5s ease-in-out 1.2s infinite;
    z-index: 1;
}

@keyframes draw-spline { to { stroke-dashoffset: 0; } }

@keyframes node-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

@keyframes scan-line {
    0%   { top: -3%;  opacity: 0; }
    6%   { opacity: 0.6; }
    45%  { opacity: 0.25; }
    92%  { opacity: 0.6; }
    100% { top: 103%; opacity: 0; }
}

@keyframes fade-in { to { opacity: 1; } }

/* ============================================================
   PRELOADER – assemblage du logo "AW"
   ============================================================ */
.preloader {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: radial-gradient(circle at 50% 30%, #24403f 0%, #152728 70%);
    animation: preloader-auto 0s 3s forwards;
}
.preloader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.7s ease, visibility 0.7s ease;
}

.preloader::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(153, 204, 51, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(153, 204, 51, 0.06) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0;
    animation: grid-in 0.8s ease 0.1s forwards, grid-drift 6s linear 1s infinite;
}

.preloader__logo {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.preloader__logo span {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 800;
    font-size: 4.4rem;
    line-height: 1;
    color: #99CC33;
    text-shadow: 0 0 38px rgba(153, 204, 51, 0.4);
    transform-origin: bottom center;
    opacity: 0;
    animation: build-letter 0.8s var(--aw-ease) backwards;
}
.preloader__logo span:nth-child(2) { animation-delay: 0.2s; }

.preloader__title {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
    letter-spacing: 5px;
    text-transform: uppercase;
    opacity: 0;
    animation: fade-in 0.6s ease 0.55s forwards;
}

.preloader__bar {
    width: 220px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    position: relative;
}
.preloader__bar i {
    position: absolute;
    inset: 0;
    transform-origin: left;
    background: linear-gradient(90deg, #99CC33, #aedb52);
    box-shadow: 0 0 14px rgba(153, 204, 51, 0.55);
    animation: grow-bar 1.6s var(--aw-ease) forwards;
}

.preloader__status {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: status-blink 1.2s ease alternate infinite;
}

@keyframes preloader-auto { to { visibility: hidden; opacity: 0; } }
@keyframes build-letter { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }
@keyframes grow-bar    { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grid-in     { from { opacity: 0; } to { opacity: 1; } }
@keyframes grid-drift  { from { background-position: 0 0; } to { background-position: 40px 40px; } }
@keyframes status-blink{ to { opacity: 0.35; } }

/* ============================================================
   BARRE DE PROGRESSION DE LECTURE
   ============================================================ */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 2001;
    background: linear-gradient(90deg, #99CC33, #aedb52);
    box-shadow: 0 0 12px rgba(153, 204, 51, 0.6);
    transition: width 0.08s linear;
}

/* ============================================================
   RÉVÉLATIONS AU SCROLL – construction
   ============================================================ */
[data-build] {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.75s var(--aw-ease), transform 0.75s var(--aw-ease);
    transition-delay: var(--bd, 0ms);
    will-change: opacity, transform;
}
[data-build="left"]  { transform: translateX(-46px); }
[data-build="right"] { transform: translateX(46px); }
[data-build="zoom"]  { transform: scale(0.9); }
[data-build="mesh"]  { transform: scale(0.97); }

[data-build].is-built {
    opacity: 1;
    transform: none;
}

/* Coins de "selection CAD" pour les blocs construits type mesh */
[data-build="mesh"] { position: relative; }
[data-build="mesh"]::before,
[data-build="mesh"]::after {
    content: '';
    position: absolute;
    z-index: 3;
    width: 18px;
    height: 18px;
    opacity: 0;
    pointer-events: none;
}
[data-build="mesh"]::before {
    top: 8px; left: 8px;
    border-top: 2px solid #99CC33;
    border-left: 2px solid #99CC33;
}
[data-build="mesh"]::after {
    bottom: 8px; right: 8px;
    border-bottom: 2px solid #99CC33;
    border-right: 2px solid #99CC33;
}
[data-build="mesh"].is-built::before,
[data-build="mesh"].is-built::after {
    animation: mesh-in 0.5s var(--aw-ease) 0.12s forwards, mesh-out 0.6s ease 1.5s forwards;
}

@keyframes mesh-in  { from { opacity: 0; transform: scale(0.3); } to { opacity: 0.85; transform: scale(1); } }
@keyframes mesh-out { to { opacity: 0; } }

/* ============================================================
   HERO – entrée en cascade au chargement
   ============================================================ */
.header,
.brand-header {
    animation: header-in 0.8s var(--aw-ease) both;
}

.home__subtitle,
.home__title,
.home__description,
.home__buttons,
.home__stats > *,
.brand-hero__tag,
.brand-hero__title,
.brand-hero__desc,
.brand-hero__cta > * {
    opacity: 0;
    animation: build-up 0.9s var(--aw-ease) forwards;
}

.home__subtitle       { animation-delay: 0.08s; }
.home__title          { animation-delay: 0.2s; }
.home__description    { animation-delay: 0.34s; }
.home__buttons        { animation-delay: 0.5s; }
.home__stats > *:nth-child(1) { animation-delay: 0.62s; }
.home__stats > *:nth-child(2) { animation-delay: 0.74s; }
.home__stats > *:nth-child(3) { animation-delay: 0.86s; }

.brand-hero__tag     { animation-delay: 0.1s; }
.brand-hero__title   { animation-delay: 0.26s; }
.brand-hero__desc    { animation-delay: 0.4s; }
.brand-hero__cta > *:nth-child(1) { animation-delay: 0.55s; }
.brand-hero__cta > *:nth-child(2) { animation-delay: 0.68s; }

@keyframes build-up {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: none; }
}
@keyframes header-in {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: none; }
}

/* ============================================================
   MICRO-INTERACTIONS
   ============================================================ */

/* Sheen "scintillement" sur les boutons primaires */
.btn--primary,
.btn-brand--primary,
.brand-nav__btn,
.filter-btn.active {
    position: relative;
    overflow: hidden;
}
.btn--primary::after,
.btn-brand--primary::after,
.brand-nav__btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -160%;
    width: 55%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.38), transparent);
    transform: skewX(-18deg);
    transition: left 0.55s ease;
}
.btn--primary:hover::after,
.btn-brand--primary:hover::after,
.brand-nav__btn:hover::after {
    left: 160%;
}

/* Soulignement animé nav marques */
.brand-nav a:not(.brand-nav__btn) {
    position: relative;
    padding-bottom: 3px;
}
.brand-nav a:not(.brand-nav__btn)::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: #99CC33;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s var(--aw-ease);
}
.brand-nav a:not(.brand-nav__btn):hover::after {
    transform: scaleX(1);
}

/* Onglets 360° : petit "pop" à l'activation */
.pano-tab { position: relative; overflow: hidden; }
.pano-tab.active { animation: tab-pop 0.32s var(--aw-ease); }
@keyframes tab-pop {
    0%   { transform: scale(0.93); }
    100% { transform: scale(1); }
}

/* Icônes des cards : très léger souffle au survol */
.service-card__icon,
.cabine-card__badge { transition: transform 0.4s var(--aw-ease); }
.service-card:hover .service-card__icon { transform: scale(1.06) rotate(-3deg); }

/* ============================================================
   MESH CARDS – wireframe de cabine/bâtiment en construction
   Chaque carte reçoit un "mesh" isométrique dont les lignes se
   tracent + une animation ambiante choisie aléatoirement.
   ============================================================ */
.mesh-card {
    position: relative;
    overflow: hidden;
}

.mesh-card > *:not(.mesh-veil) {
    position: relative;
    z-index: 1;
}

.mesh-veil {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.mesh-veil svg {
    position: absolute;
    right: 3%;
    bottom: 0;
    width: 60%;
    height: 82%;
    opacity: 0.5;
    transition: opacity 0.4s ease;
}

.mesh-card:hover .mesh-veil svg { opacity: 1; }

/* Sur les images des projets : mesh au-dessus du fond gradient
   (transparent, n'empêche pas la lecture), texte/détails toujours au-dessus */
.project-card__image .mesh-veil { z-index: 2; }
.project-card__image .mesh-veil svg { width: 46%; height: 70%; right: 4%; bottom: 4%; opacity: 0.7; }

.mesh-veil .mv-lines {
    fill: none;
    stroke: #99CC33;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 480;
    stroke-dashoffset: 480;
    animation: mesh-draw var(--md, 5s) var(--aw-ease) var(--del, 0s) forwards;
}

.mesh-veil .mv-lines--soft {
    stroke: rgba(47, 79, 79, 0.5);
    stroke-width: 1;
    stroke-dasharray: 6 7;
    opacity: 0.55;
}

.mesh-veil .mv-node {
    fill: #99CC33;
    transform-box: fill-box;
    transform-origin: center;
    animation: node-pop 0.5s var(--aw-ease) var(--del, 0s) backwards;
}

@keyframes mesh-draw { to { stroke-dashoffset: 0; } }

@media (max-width: 640px) {
    .mesh-veil svg { width: 74%; height: 78%; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .preloader { display: none !important; }
    .hero-build { display: none; }
    .bg-mesh { display: none; }
    [data-build],
    .fade-in { opacity: 1 !important; transform: none !important; }
    *,
    *::before,
    *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
    }
}