/* =========================================================================
   GIGA — MOTION LAYER
   Camada cinematográfica de movimento (GSAP + ScrollTrigger + Lenis).
   Só entra em ação quando <html> recebe a classe .gsap-motion.
   Sem a classe (reduced-motion, mobile leve, falha de CDN), o site
   permanece 100% funcional com o visual original.
   ========================================================================= */

/* -------------------------------------------------------------------------
   0. Base / Lenis
   ------------------------------------------------------------------------- */
html.gsap-motion { scroll-behavior: auto; }

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-scrolling iframe { pointer-events: none; }

/* -------------------------------------------------------------------------
   1. Handoff: o GSAP assume o controle de reveal/transform
      (transition: none evita "smearing" enquanto o GSAP escreve por frame)
   ------------------------------------------------------------------------- */
html.gsap-motion .reveal {
    opacity: 0;
    transform: none;
    transition: none !important;
}

/* Cards controlados por GSAP: mantém só a sombra suave no hover */
html.gsap-motion .service-card,
html.gsap-motion .news-card {
    transition: box-shadow .45s ease !important;
}
html.gsap-motion .news-image img,
html.gsap-motion .service-card .icon-service,
html.gsap-motion .icon-service-wrap {
    transition: none !important;
}

/* Botões magnéticos: preserva cor/sombra, remove transição de transform */
html.gsap-motion .magnet {
    transition: color .4s ease, background-color .4s ease,
                box-shadow .4s ease, border-color .4s ease !important;
}

/* -------------------------------------------------------------------------
   2. Preloader cinematográfico (auto-destrutivo via CSS, à prova de falha)
   ------------------------------------------------------------------------- */
.motion-loader {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 45%, #0A1D37 0%, #05101c 70%);
    animation: loaderOut .9s cubic-bezier(0.16, 1, 0.3, 1) 1.15s forwards;
}
.motion-loader__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.motion-loader__logo {
    width: clamp(150px, 26vw, 240px);
    height: auto;
    filter: drop-shadow(0 0 34px rgba(222, 185, 146, 0.35));
    animation: loaderLogo 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.motion-loader__bar {
    width: 168px;
    height: 2px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
    border-radius: 2px;
}
.motion-loader__bar i {
    display: block;
    height: 100%;
    width: 42%;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
    animation: loaderBar 1.05s ease-in-out infinite;
}
@keyframes loaderLogo {
    0%   { opacity: 0; transform: translateY(14px) scale(0.94); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes loaderBar {
    0%   { transform: translateX(-130%); }
    100% { transform: translateX(340%); }
}
@keyframes loaderOut {
    0%   { opacity: 1; visibility: visible; }
    100% { opacity: 0; visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .motion-loader { display: none; }
}

/* -------------------------------------------------------------------------
   3. Cursor customizado (somente desktop com pointer fino)
   ------------------------------------------------------------------------- */
.motion-cursor,
.motion-cursor__dot {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
}
.motion-cursor {
    width: 34px;
    height: 34px;
    border: 1.5px solid rgba(222, 185, 146, 0.85);
    border-radius: 50%;
    transition: opacity .35s ease, width .35s cubic-bezier(0.16, 1, 0.3, 1),
                height .35s cubic-bezier(0.16, 1, 0.3, 1),
                background-color .35s ease, border-color .35s ease;
    will-change: transform;
}
.motion-cursor__dot {
    width: 6px;
    height: 6px;
    background: var(--accent-gold);
    border-radius: 50%;
    z-index: 10000;
    transition: opacity .35s ease;
    will-change: transform;
}
html.has-cursor .motion-cursor.is-ready,
html.has-cursor .motion-cursor__dot.is-ready { opacity: 1; }
html.has-cursor .motion-cursor.is-hover {
    width: 76px;
    height: 76px;
    background: rgba(222, 185, 146, 0.12);
    border-color: rgba(222, 185, 146, 0.55);
}
html.has-cursor .motion-cursor.is-down { width: 24px; height: 24px; }
html.has-cursor,
html.has-cursor a,
html.has-cursor button,
html.has-cursor .btn { cursor: none; }

/* -------------------------------------------------------------------------
   4. Grão de filme / ruído (textura surreal, estática)
   ------------------------------------------------------------------------- */
.motion-grain {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.55'/></svg>");
}

/* -------------------------------------------------------------------------
   5. Faixas MARQUEE (movimento contínuo)
   ------------------------------------------------------------------------- */
.marquee-band {
    position: relative;
    overflow: hidden;
    padding: 26px 0;
    background: linear-gradient(90deg, #0A1D37 0%, #0B2447 50%, #0A1D37 100%);
    border-top: 1px solid rgba(222, 185, 146, 0.16);
    border-bottom: 1px solid rgba(222, 185, 146, 0.16);
}
.marquee-band--ghost {
    background: transparent;
    border: 0;
    padding: 56px 0;
}
.marquee-track {
    display: flex;
    align-items: center;
    gap: 44px;
    width: max-content;
    white-space: nowrap;
    will-change: transform;
}
.marquee-item {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: clamp(1.15rem, 3.1vw, 2.4rem);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.92);
}
.marquee-sep {
    color: var(--accent-gold);
    font-size: clamp(0.7rem, 1.4vw, 1.1rem);
    opacity: 0.9;
}
.marquee-band--ghost .marquee-item {
    color: transparent;
    -webkit-text-stroke: 1px rgba(222, 185, 146, 0.55);
    font-size: clamp(2rem, 8vw, 6rem);
}
.marquee-band--ghost .marquee-sep {
    font-size: clamp(1rem, 2.4vw, 2rem);
}

/* -------------------------------------------------------------------------
   7. Títulos com máscara (reveal palavra por palavra)
   ------------------------------------------------------------------------- */
.m-word {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    padding-bottom: 0.14em;
    margin-bottom: -0.14em;
}
.m-inner {
    display: inline-block;
    will-change: transform;
}

/* -------------------------------------------------------------------------
   8. Serviços — trilho horizontal "pinado" (desktop)
   ------------------------------------------------------------------------- */
@media (min-width: 1024px) {
    html.gsap-motion .services-pin {
        position: relative;
        overflow: hidden;
    }
    html.gsap-motion .services-pin .services-grid.grid-4-cards {
        display: flex;
        flex-wrap: nowrap;
        grid-template-columns: none;
        gap: 30px;
        width: max-content;
        margin-top: 70px;
        padding-bottom: 6px;
    }
    html.gsap-motion .services-pin .service-card {
        flex: 0 0 auto;
        width: 400px;
        max-width: 74vw;
    }
}
/* Barra de progresso do trilho horizontal */
.services-track-progress {
    display: none;
    width: min(520px, 70vw);
    height: 2px;
    margin: 34px auto 0;
    background: rgba(11, 36, 71, 0.12);
    border-radius: 2px;
    overflow: hidden;
}
@media (min-width: 1024px) {
    html.gsap-motion .services-track-progress { display: block; }
}
.services-track-progress i {
    display: block;
    height: 100%;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, var(--logo-blue), var(--secondary-blue), var(--accent-gold));
}

/* -------------------------------------------------------------------------
   9. Divisores animados
   ------------------------------------------------------------------------- */
html.gsap-motion .section-divider .divider-line {
    transform-origin: center;
}

/* -------------------------------------------------------------------------
   10. Acessibilidade — respeita "reduzir movimento"
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .motion-grain,
    .motion-cursor,
    .motion-cursor__dot { display: none !important; }
}

/* =========================================================================
   CAMADA ESPAÇO / CIRCUITOS  ("insanidade tech")
   Campo de estrelas, scanlines e trilhas de conexão.
   ========================================================================= */

/* -------------------------------------------------------------------------
   E1. Campo de estrelas (deriva via CSS)
   ------------------------------------------------------------------------- */
.hero-stars {
    position: absolute;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    overflow: hidden;
    will-change: transform;
}
.hero-stars span {
    position: absolute;
    inset: -25%;
    background-repeat: repeat;
}
.hero-stars .st1 {
    background-image:
        radial-gradient(1px 1px at 20px 30px, rgba(255, 255, 255, 0.9), transparent 62%),
        radial-gradient(1px 1px at 130px 90px, rgba(255, 255, 255, 0.7), transparent 62%),
        radial-gradient(1px 1px at 70px 170px, rgba(222, 185, 146, 0.9), transparent 62%),
        radial-gradient(1px 1px at 180px 40px, rgba(160, 220, 255, 0.8), transparent 62%);
    background-size: 210px 210px;
    animation: starDrift 150s linear infinite;
    opacity: 0.8;
}
.hero-stars .st2 {
    background-image:
        radial-gradient(1.4px 1.4px at 90px 70px, rgba(255, 255, 255, 0.95), transparent 60%),
        radial-gradient(1.4px 1.4px at 260px 210px, rgba(130, 215, 255, 0.8), transparent 60%),
        radial-gradient(1.4px 1.4px at 30px 250px, rgba(222, 185, 146, 0.7), transparent 60%);
    background-size: 360px 360px;
    animation: starDrift 105s linear infinite reverse;
    opacity: 0.7;
}
.hero-stars .st3 {
    background-image:
        radial-gradient(2px 2px at 60px 150px, rgba(255, 255, 255, 1), transparent 58%),
        radial-gradient(1.8px 1.8px at 400px 90px, rgba(190, 235, 255, 0.85), transparent 58%);
    background-size: 540px 540px;
    animation: starDrift 70s linear infinite;
    opacity: 0.65;
}
.hero-stars .st4 {
    background-image:
        radial-gradient(1px 1px at 12% 20%, rgba(255, 255, 255, 0.9), transparent 60%),
        radial-gradient(1px 1px at 68% 42%, rgba(255, 255, 255, 0.8), transparent 60%),
        radial-gradient(1px 1px at 34% 78%, rgba(127, 227, 255, 0.9), transparent 60%),
        radial-gradient(1px 1px at 84% 66%, rgba(255, 255, 255, 0.85), transparent 60%);
    background-size: 100% 100%;
    animation: starTwinkle 4.5s ease-in-out infinite;
}
@keyframes starDrift {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-160px, -110px, 0); }
}
@keyframes starTwinkle {
    0%, 100% { opacity: 0.25; }
    50%      { opacity: 0.85; }
}

/* -------------------------------------------------------------------------
   E2. Keyframes das trilhas de energia
   ------------------------------------------------------------------------- */
@keyframes traceFlow { to { stroke-dashoffset: -260; } }
@keyframes nodePulse {
    0%, 100% { opacity: 0.3; transform: scale(0.7); }
    50%      { opacity: 1;   transform: scale(1.3); }
}

/* -------------------------------------------------------------------------
   E3. Scanlines
   ------------------------------------------------------------------------- */
.hero-scanlines {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.14;
    mix-blend-mode: overlay;
    background: repeating-linear-gradient(180deg,
        rgba(255, 255, 255, 0.10) 0 1px,
        transparent 1px 4px);
    animation: scanShift 14s linear infinite;
}
@keyframes scanShift { to { background-position: 0 8px; } }

/* -------------------------------------------------------------------------
   E5. Padrão de placa de circuito no fundo dos serviços (desktop)
   ------------------------------------------------------------------------- */
html.gsap-motion .services .section-bg-tech::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(11, 36, 71, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(11, 36, 71, 0.055) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 38%, #000 0%, transparent 72%);
    mask-image: radial-gradient(ellipse at 50% 38%, #000 0%, transparent 72%);
    animation: pcbPan 22s linear infinite;
}
@keyframes pcbPan {
    to { background-position: 46px 46px, 46px 46px; }
}

/* -------------------------------------------------------------------------
   E6. Seção de contato: trilhas de conexão
   ------------------------------------------------------------------------- */
.contact { position: relative; overflow: hidden; }

.contact-space {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.contact-traces {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.75;
}
.ctrace {
    fill: none;
    stroke: url(#traceGrad);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: url(#nodeGlow);
    stroke-dasharray: 18 260;
    animation: traceFlow 4.2s linear infinite;
}
.ctrace.c2 { animation-duration: 3.1s; }
.ctrace.c3 { animation-duration: 5.6s; }
.cnode {
    fill: #fff6dc;
    filter: url(#nodeGlow);
    transform-box: fill-box;
    transform-origin: center;
    animation: nodePulse 3s ease-in-out infinite;
}
.cnode.n2 { animation-delay: 0.9s; }
.cnode.n3 { animation-delay: 1.7s; }

html.gsap-motion .contact .container { position: relative; z-index: 2; }

/* -------------------------------------------------------------------------
   E7. Acessibilidade
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .hero-stars,
    .hero-scanlines,
    .ctrace,
    .cnode { animation: none !important; }
    .hero-scanlines { display: none; }
}

