/* ==========================================================================
   VETOR SANEAMENTO — fundo visual unificado (Plano A + base do Plano C)
   Camadas fixas, sempre validas mesmo sem WebGL:
     -3 base/aurora A + malha de projeto
     -2 aurora B, aneis de corte de tubo (DN), grao SVG, malha fina, vinheta
     -1 canvas WebGL opcional (#rede-canvas, manejar por rede-visual.css)
   Nada aqui depende de JavaScript. O painel de configuracoes continua
   escrevendo --mesh-alpha / --mesh-duration / --hero-glow / etc.
   ========================================================================== */

body::before {
  content: '';
  position: fixed;
  inset: calc(var(--bg-inset) * -1);
  z-index: -3;
  pointer-events: none;
  background-image:
    radial-gradient(120% 80% at 50% 0%, var(--bg-glow-a), transparent 60%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 100% 100%, var(--bg-grid-size) var(--bg-grid-size), var(--bg-grid-size) var(--bg-grid-size);
  opacity: calc(var(--mesh-alpha) * var(--bg-multiplier));
  will-change: transform;
}
body::after {
  content: '';
  position: fixed;
  inset: calc(var(--bg-inset) * -1);
  z-index: -2;
  pointer-events: none;
  background-image:
    radial-gradient(60% 50% at 30% 30%, var(--bg-glow-b), transparent 60%),
    radial-gradient(50% 45% at 70% 65%, var(--bg-glow-c), transparent 60%),
    repeating-radial-gradient(circle at 84% 26%, var(--bg-pipe-ring) 0 1px, transparent 1px 46px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E"),
    linear-gradient(var(--bg-grid-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid-fine) 1px, transparent 1px),
    radial-gradient(130% 110% at 50% 45%, transparent 45%, var(--bg-vignette) 100%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 160px 160px,
    var(--bg-grid-size-fine) var(--bg-grid-size-fine), var(--bg-grid-size-fine) var(--bg-grid-size-fine), 100% 100%;
  opacity: calc(var(--mesh-alpha) * var(--bg-multiplier) * .55);
  will-change: transform, opacity;
}

@keyframes mesh-drift {
  from { transform: translate3d(0,0,0); }
  to   { transform: translate3d(-100px,-100px,0); }
}
@keyframes mesh-drift-2 {
  from { transform: translate3d(0,0,0); }
  to   { transform: translate3d(100px,-100px,0); }
}
@keyframes mesh-breathe {
  0%, 100% { opacity: calc(var(--mesh-alpha) * var(--bg-multiplier) * .55); }
  50%      { opacity: calc(var(--mesh-alpha) * var(--bg-multiplier) * .82); }
}

/* Movimento so com preferencia explicita. O reduce e definitivo: o toggle
   da cena 3d tambem e desligado no rede-visual.js. */
@media (prefers-reduced-motion: no-preference) {
  body::before { animation: mesh-drift var(--mesh-duration) linear infinite; }
  body::after {
    animation: mesh-drift-2 var(--mesh-duration-2) linear infinite,
      mesh-breathe 11s ease-in-out infinite;
  }
  .top-bar, .topbar { animation: shimmer 3s linear infinite; }
}

/* switch "Fundo animado" do painel: mata as duas camadas e o brilho do hero */
body.mesh-off::before,
body.mesh-off::after,
body.mesh-off .hero-particles { animation: none !important; opacity: 0 !important; }

/* --------------------------------------------------------------------------
   Variantes por pagina. Nao sobrescrevem --mesh-* porque o painel escreve
   essas propriedades em :root e o slider precisa continuar funcionando.
   -------------------------------------------------------------------------- */
body[data-bg="home"] { --bg-multiplier: 1; }

body[data-bg="produto"] {
  --bg-multiplier: .6;
  --bg-pipe-ring: transparent;
}
body[data-bg="produto"] .product-detail-section,
body[data-bg="produto"] .related-products-section,
body[data-bg="produto"] .breadcrumb-section {
  background: rgba(26,26,26,.62);
  border-color: rgba(212,175,55,.16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body[data-bg="marketing"] { --bg-multiplier: .75; }

body[data-bg="documento"] {
  --bg-multiplier: .55;
  --bg-pipe-ring: transparent;
}

/* --------------------------------------------------------------------------
   Home: halo de leitura (traducao do .hero-section::before do Azeph) e foto
   com opacidade reduzida para a cena WebGL aparecer atraves dela.
   -------------------------------------------------------------------------- */
body[data-bg="home"] .hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(620px 620px at 82% 40%, rgba(212,175,55,.14), transparent 62%);
}
body[data-bg="home"] .hero-bg { opacity: .38; }
body[data-bg="home"] .hero-bg img { object-position: center 55%; }
body[data-bg="home"] .hero-overlay {
  background: linear-gradient(135deg, rgba(0,0,0,.86), rgba(0,0,0,.62), rgba(8,19,27,.88));
}
body.home .products-section { background: rgba(17,17,17,.6); }
body.home .footer { background: rgba(26,26,26,.65); }

/* --------------------------------------------------------------------------
   Print global: corrige os tres HTML de marketing (que nao repunham o
   -webkit-text-fill-color) e cria a regra que faltava no site principal.
   -------------------------------------------------------------------------- */
@media print {
  body, body::before, body::after {
    background: #fff !important;
    animation: none !important;
  }
  body::before, body::after { display: none !important; opacity: 0 !important; }
  .section-title, .hero h1, .title, .card h3 {
    -webkit-text-fill-color: #111 !important;
    background: none !important;
  }
  .card, details, .product-detail-section, .related-products-section {
    background: #fff !important;
    border-color: #ccc !important;
    backdrop-filter: none !important;
  }
  .top-bar, .topbar, .navbar, .nav, .wa-float, .whatsapp-float,
  .scroll-top, .settings-button, .no-print, #rede-canvas, [data-rede-toggle] {
    display: none !important;
  }
}
