/* ==========================================================================
   marlin-hero-background · marlin-hero-bg.css
   Background completo do Hero Banner Marlin V3 (fundo, peixe, fundo tecnológico,
   halo, chips interativos, água e acabamento inferior) como módulo independente.

   - Tudo fica sob a classe .mhb (adicionada pelo JS ao container
     [data-marlin-hero-bg]); nada aqui altera estilos globais da página.
   - Nomes com prefixo mhb- para não colidir com o CSS do site de destino
     (o site original usa .hero, .fish-stage, .network-nodes…).
   - Valores visuais copiados da V3 aprovada (styles.css, hero-network.css,
     hero-chip-nodes.css, hero-reveal.css, hero-fish-halo.css, hero-join.css,
     hero-mobile-fish.css, marlin-fish.css). Origem indicada em cada bloco.

   PONTOS DE QUEBRA (os mesmos da V3, mas medidos na largura do CONTAINER via
   container queries, para o módulo se adaptar ao espaço que receber):
     > 1240   desktop                       (margem 78 px, coluna do texto 500 px)
     ≤ 1240   desktop estreito / notebook   (margem 48 px, coluna do texto 460 px)
     961–1199 tablet deitado (iPad mini 1024/1133): palco = 100% da coluna
     ≤ 960    tablet em pé (iPad mini 744/768, iPad Air 820): palco centralizado no peixe, K = 1
     ≤ 600    celular (320–430): palco centralizado no peixe, K = 1,111
   Altura da janela (só desktop, como na V3): ≤ 820 e ≤ 680 px mudam a altura do peixe.

   VARIÁVEIS QUE PODEM SER AJUSTADAS NO PROJETO DE DESTINO (ver README, seção 7):
     --mhb-container    largura máxima da área de conteúdo (V3: 1284px)
     --mhb-gutter       margem lateral (V3: 78 / 48 / 40 / 20 px)
     --mhb-col          largura da coluna do texto no desktop (V3: 500 / 460 px)
     --mhb-gap          espaço entre texto e peixe no desktop (V3: 40px)
     --mhb-stage-cy     desktop: centro vertical do peixe, medido do topo do container
                        (V3: 334.5px; 271px com janela ≤ 820 px de altura; 262.5px ≤ 680)
     --mhb-stage-bottom tablet/celular: distância do peixe até a base (V3: 72px / 88px)
     --mhb-join         altura da onda inferior (V3: clamp(44px, 6vw, 88px))
     --mhb-next-bg      cor da seção seguinte, abaixo da onda (V3/M.IA: #f4f9fb)
     --mhb-bg-color     cor de base sob a imagem (V3: #073440)
     --mhb-label-font   fonte do nome das categorias (V3: Manrope 600)
   ========================================================================== */

/* ---------- Container ---------- */

/* Os valores da V3 ficam em variáveis internas (--_…). As variáveis públicas (--mhb-…)
   não são definidas aqui: quando o projeto define uma delas (no .mhb ou em qualquer
   elemento acima dele), ela vale em todos os pontos de quebra. */
.mhb {
  --_cy: 334.5px;                                   /* centro vertical do peixe no desktop */
  --_join: var(--mhb-join, clamp(44px, 6vw, 88px)); /* altura da onda inferior */
  --_font: var(--mhb-label-font, "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif);
  --mhb-glow: 0, 188, 212;          /* --glow da V3 */
  --mhb-cyan-200: #8eeaf2;          /* --color-cyan-200 da V3 */
  --mhb-accent: #00bcd4;            /* --accent da V3 (foco por teclado) */

  position: absolute;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  background: var(--mhb-bg-color, #073440);
  container: mhb / inline-size;
  pointer-events: none;             /* só o palco do peixe e os chips recebem o mouse */
  line-height: normal;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.mhb, .mhb *, .mhb *::before, .mhb *::after { box-sizing: border-box; }
.mhb img, .mhb svg, .mhb canvas { display: block; max-width: none; margin: 0; padding: 0; border: 0; outline: 0; box-shadow: none; }

/* Imagem de fundo (ondas luminosas e malha de partículas fazem parte da arte).
   Fica por baixo da água em WebGL (engine/water.js), que a refrata; sem WebGL, ela
   continua sozinha. V3: .hero::before + hero-join.css (enquadramento acima da onda). */
.mhb-bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url("assets/background/hero-underwater-background.webp") center center / cover no-repeat;
  pointer-events: none;
}
.mhb--wave .mhb-bg { background-position: 50% calc(50% - var(--_join) / 2); }

/* água (V3: hero-reveal.css .hero-water) */
.mhb-water {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Geometria do palco (V3: styles.css .hero-inner / .hero-visual / .fish-stage) ---------- */

/* área de conteúdo: mesma largura do .container da V3 */
.mhb-frame {
  --_gutter: 78px;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(var(--mhb-container, 1284px), 100% - 2 * var(--mhb-gutter, var(--_gutter)));
  transform: translateX(-50%);
  pointer-events: none;
}

/* coluna do peixe (à direita da coluna do texto), com o peixe centrado em --mhb-stage-cy */
.mhb-visual {
  --_col: 500px;
  --_bottom: 72px;
  position: absolute;
  left: calc(var(--mhb-col, var(--_col)) + var(--mhb-gap, 40px));
  right: 0;
  top: var(--mhb-stage-cy, var(--_cy));
  transform: translateY(-50%);
  pointer-events: none;
}

/* Palco: proporção 2:1 = espaço 1000 × 500 compartilhado pelo peixe, fundo tecnológico,
   halo, linhas e chips. Desktop: 110% da coluna, 2% para a esquerda (V3). */
.mhb-stage {
  position: relative;
  isolation: isolate;
  width: 110%;
  margin-left: -2%;
  aspect-ratio: 1088 / 544;
  pointer-events: auto;             /* hover do peixe e do fundo tecnológico */
}

@container mhb (max-width: 1240px) {
  .mhb-frame { --_gutter: 48px; }
  .mhb-visual { --_col: 460px; }
}

/* tablet deitado e 961–1199 px (V3: hero-mobile-fish.css): o palco não passa da coluna */
@container mhb (min-width: 961px) and (max-width: 1199px) {
  .mhb-stage { width: 100%; margin-left: 0; }
}

/* desktop em janelas baixas (V3: styles.css, max-height 820 / 680) */
@media (min-width: 961px) and (max-height: 820px) { .mhb { --_cy: 271px; } }
@media (min-width: 961px) and (max-height: 680px) { .mhb { --_cy: 262.5px; } }

/* Tablet em pé e celular (V3: styles.css ≤ 960 + hero-mobile-fish.css):
   o texto fica em cima e o peixe embaixo, ancorado à base. O palco é dimensionado e
   deslocado por proporção da largura, sem valor fixo de aparelho:
     largura = K × largura do container;  o ponto x = 601 do palco (centro do peixe
     ao longo do nado, x ≈ 240…962) cai no centro do container.
   K = 1 no tablet (peixe ≈ 72% da largura), K = 1,111 no celular (≈ 80%, ~10% de margem). */
@container mhb (max-width: 960px) {
  .mhb-frame { left: 0; width: 100%; transform: none; }
  .mhb-visual { left: 0; right: 0; top: auto; bottom: var(--mhb-stage-bottom, var(--_bottom)); transform: none; }
  /* com a onda inferior, a distância é medida acima dela (na V3 a onda ficava abaixo do Hero) */
  .mhb--wave .mhb-visual { bottom: calc(var(--mhb-stage-bottom, var(--_bottom)) + var(--_join)); }
  .mhb-stage {
    --mhb-k: 1;
    --mhb-cx: .601;
    width: calc(var(--mhb-k) * 100%);
    margin-left: calc((.5 - var(--mhb-cx) * var(--mhb-k)) * 100%);
  }
}
@container mhb (max-width: 600px) {
  .mhb-visual { --_bottom: 88px; }
  .mhb-stage { --mhb-k: 1.111; }
}

/* ---------- Atmosfera ciano atrás do peixe (V3: styles.css .fish-stage::before) ---------- */

.mhb-stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -16% -14%;
  pointer-events: none;
  background: url("assets/background/cyan-atmosphere-v2.webp") 58% 50% / 84% auto no-repeat;
  filter: blur(14px);
  mix-blend-mode: screen;
  opacity: .5;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: 58% 50%;
  will-change: opacity, transform;
  animation: mhb-atmosphere 9s ease-in-out infinite alternate;
}
@keyframes mhb-atmosphere {
  0%   { opacity: .46; transform: translate3d(-.35%, .2%, 0) scale(1); }
  55%  { opacity: .54; transform: translate3d(.25%, -.15%, 0) scale(1.012); }
  100% { opacity: .49; transform: translate3d(.1%, .25%, 0) scale(1.006); }
}

/* ---------- Fundo tecnológico (engine/marlin-tech-hero.js; V3: index.html <style>) ---------- */

/* as camadas estáticas já trazem o esmaecimento gravado; a máscara fica só na animada.
   Esmaece do lado do texto (o canvas vai de -26% a 126% do palco). */
.mhb .marlin-tech-fx {
  -webkit-mask-image: linear-gradient(to right, transparent 8%, #000 26%);
          mask-image: linear-gradient(to right, transparent 8%, #000 26%);
}
/* entra em etapas desde o início (não espera o peixe): véu + chips → trilhas → luzes e pulsos */
.mhb .marlin-tech { opacity: 0; transition: opacity .5s ease-out; }
.mhb .marlin-tech-far { transition-duration: .35s; }
.mhb .marlin-tech-fx { transition-duration: .6s; }
.mhb .marlin-tech.is-on { opacity: 1; }

/* ---------- Halo do peixe (V3: hero-fish-halo.css v4, aprovado) ----------
   Massa de luz difusa (gradientes) + 3 arcos abertos e 2 feixes (SVG estático, sem desfoque).
   Só aparece quando o peixe animado fica pronto (não atrasa o primeiro quadro). */
.mhb-halo { position: absolute; inset: 0; pointer-events: none; display: none; }
.mhb-stage:has(> .mhb-fish.is-ready) .mhb-halo { display: block; animation: mhb-halo-in .9s ease-out both; }
@keyframes mhb-halo-in { from { opacity: 0; } to { opacity: 1; } }
@supports not selector(:has(*)) { .mhb-halo { display: block; } }
.mhb-halo-glow {
  position: absolute;
  left: 17%; width: 88%;
  top: -3%; height: 108%;
  border-radius: 50%;
  background:
    radial-gradient(32% 19% at 52% 52%, rgba(175, 247, 255, .5), rgba(80, 222, 255, .18) 55%, transparent),
    radial-gradient(closest-side, rgba(140, 238, 255, .5), rgba(50, 212, 250, .27) 30%, rgba(30, 190, 235, .08) 58%, transparent 72%),
    radial-gradient(closest-side, rgba(25, 205, 225, .4), rgba(20, 165, 230, .22) 42%, rgba(24, 115, 215, .09) 70%, rgba(24, 100, 210, .03) 86%, transparent);
  transform: rotate(-18deg);
}
.mhb-halo-arcs { position: absolute; left: 12%; width: 98%; top: -8%; height: 116%; overflow: visible; }

/* ---------- Peixe (engine/marlin-swim.js; V3: marlin-fish.css + styles.css + hero-network.css) ---------- */

.mhb-fish {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: filter 1.4s ease;
}
.mhb-fish.is-ready { animation: mhb-fish-in .9s ease-out forwards; }
@keyframes mhb-fish-in { to { opacity: 1; } }

/* imagem estática do 1º quadro até o peixe animado ficar pronto (fusão de 0,9 s) */
.mhb-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: opacity .9s ease-out;
}
.mhb-fish.is-ready ~ .mhb-poster { opacity: 0; }

/* o peixe responde quando um sinal da rede chega perto dele (intensidade em --fish-sig) */
.mhb-stage.is-signal .mhb-fish {
  filter:
    brightness(calc(1 + .14 * var(--fish-sig, 1)))
    drop-shadow(0 0 calc(16px * var(--fish-sig, 1)) rgba(var(--mhb-glow), .5));
  transition-duration: .55s;
}

/* ---------- Linhas da rede (interactions/network.js; V3: styles.css + hero-network.css + hero-chip-nodes.css) ---------- */

.mhb-net-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.mhb-net-lines line {
  stroke: rgba(var(--mhb-glow), .22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: stroke .25s ease, stroke-width .25s ease;
}
/* linhas ligadas ao ponto ativo: acesas em azul/ciano */
.mhb-net-lines line.is-active {
  stroke: rgba(170, 244, 255, .95);
  stroke-width: 1.7;
  filter: drop-shadow(0 0 3px rgba(60, 214, 255, 1)) drop-shadow(0 0 9px rgba(46, 132, 255, .65));
}
.mhb-net-lines circle {
  fill: rgba(var(--mhb-glow), .55);
  transition: fill .25s ease;
  transform-box: fill-box;
  transform-origin: center;
}
.mhb-net-lines circle.is-active { fill: color-mix(in srgb, var(--mhb-cyan-200) 95%, transparent); }

/* sinal que percorre as linhas (criado e removido a cada propagação) */
.mhb-net-lines .mhb-spark {
  fill: none;
  stroke: rgba(186, 248, 255, .95);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: .16 1.2;
  stroke-dashoffset: .16;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  filter: drop-shadow(0 0 4px rgba(var(--mhb-glow), .95));
  pointer-events: none;
  transition: none;
}

/* ---------- Os cinco pontos = chips (interactions/chip-nodes.js; V3: hero-chip-nodes.css) ----------
   Normal: chip aceso em azul/ciano, linhas discretas, sem nome.
   Hover / foco / toque (li.is-active): chip mais brilhante, linhas ligadas acesas e o nome. */

.mhb-net-nodes {
  --chip: 32px;                     /* ajustado pelo JS: 40 unidades do palco (mínimo 30 px) */
  --chip-cyan: 60, 214, 255;
  --chip-elec: 46, 132, 255;
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.mhb-net-nodes li { position: absolute; width: 0; height: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.mhb-net-nodes li::before, .mhb-net-nodes li::marker { content: none; }

/* o botão tem o tamanho do chip: a área de clique/hover é o chip inteiro.
   Reset completo para não herdar estilos de botão do site de destino. */
.mhb-node {
  all: unset;
  position: absolute;
  left: calc(var(--chip) / -2);
  top: calc(var(--chip) / -2);
  display: block;
  width: var(--chip);
  height: var(--chip);
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
  box-sizing: border-box;
  /* resiste a estilos globais de botão com !important no site de destino */
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
}
.mhb-node:focus-visible { outline: 2px solid var(--mhb-accent); outline-offset: 3px; }

.mhb-chip-glow {
  position: absolute;
  left: 50%; top: 50%;
  width: calc(var(--chip) * 2.2); height: calc(var(--chip) * 2.2);
  margin: calc(var(--chip) * -1.1) 0 0 calc(var(--chip) * -1.1);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--chip-cyan), .42) 0%, rgba(var(--chip-elec), .22) 34%, rgba(var(--chip-elec), 0) 68%);
  opacity: .75;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
  animation: mhb-chip-breath 3.6s ease-in-out infinite;
}
@keyframes mhb-chip-breath { 50% { opacity: .5; } }

.mhb-chip {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: #aef2ff;
  filter: drop-shadow(0 0 2px rgba(var(--chip-cyan), .9)) drop-shadow(0 0 7px rgba(var(--chip-elec), .55));
  transition: filter .35s ease, transform .35s ease, color .35s ease;
}
.mhb-chip-pins { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; opacity: .9; }
.mhb-chip-body { fill: #082a44; stroke: currentColor; stroke-width: 1.3; transition: fill .35s ease; }
.mhb-chip-die { fill: rgba(var(--chip-elec), .32); stroke: rgba(var(--chip-cyan), .95); stroke-width: 1; transition: fill .35s ease; }
.mhb-chip-cells rect { fill: rgba(var(--chip-cyan), var(--c, .4)); transition: fill .35s ease; }
.mhb-chip-pin1 { fill: #e8fdff; }

.mhb-net-nodes li.is-active { z-index: 5; }
.mhb-net-nodes li.is-active .mhb-chip-glow { opacity: 1; transform: scale(1.12); animation: none; }
.mhb-net-nodes li.is-active .mhb-chip {
  color: #f0feff;
  transform: scale(1.1);
  filter: drop-shadow(0 0 2px rgba(var(--chip-cyan), 1)) drop-shadow(0 0 8px rgba(var(--chip-cyan), .95)) drop-shadow(0 0 18px rgba(var(--chip-elec), .85));
}
.mhb-net-nodes li.is-active .mhb-chip-body { fill: #0c4370; }
.mhb-net-nodes li.is-active .mhb-chip-die { fill: rgba(var(--chip-elec), .6); }
.mhb-net-nodes li.is-active .mhb-chip-cells rect { fill: rgba(200, 248, 255, calc(var(--c, .4) + .35)); }

/* sinais da rede viva (interactions/network-signal.js) passam pelo chip */
.mhb-net-nodes li.is-signal .mhb-chip,
.mhb-net-nodes li.is-signal-strong .mhb-chip { animation: mhb-chip-signal 1.2s cubic-bezier(.2, .7, .3, 1); }
@keyframes mhb-chip-signal { 28% { filter: drop-shadow(0 0 3px rgba(var(--chip-cyan), 1)) drop-shadow(0 0 calc(10px + 6px * var(--sig, 1)) rgba(var(--chip-elec), .85)); } }

/* nome da categoria: texto claro em caixa alta, sem fundo, borda ou cápsula */
.mhb-chip-label {
  position: absolute;
  left: 0; top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--_font);
  font-size: 12.5px;
  font-style: normal;
  font-weight: 600;
  line-height: normal;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(232, 252, 255, .97);
  text-shadow: 0 0 12px rgba(var(--mhb-glow), .6), 0 0 2px rgba(0, 20, 30, .9), 0 1px 2px rgba(0, 20, 30, .7);
  pointer-events: none;             /* o nome nunca tira o cursor do chip */
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, transform .5s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .35s;
}
/* fio curto de luz ligando o nome ao chip */
.mhb-chip-label::before {
  content: "";
  width: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--mhb-cyan-200) 90%, transparent));
}
.mhb-chip-label--above { top: calc(var(--chip) / -2 - 22px); transform: translate(-50%, 6px); }
.mhb-chip-label--below { top: calc(var(--chip) / 2 + 8px);   transform: translate(-50%, 6px); }

.mhb-net-nodes li.is-active .mhb-chip-label {
  opacity: 1;
  visibility: visible;
  transition: opacity .35s ease .05s, transform .5s cubic-bezier(.2, .7, .2, 1);
}
.mhb-net-nodes li.is-active .mhb-chip-label--above,
.mhb-net-nodes li.is-active .mhb-chip-label--below { transform: translate(-50%, 0); }

@container mhb (max-width: 600px) {
  .mhb-chip-label { font-size: 11px; letter-spacing: .13em; gap: 8px; }
  .mhb-chip-label::before { width: 16px; }
}

/* sobre a ilustração revelada na água: o clique leva à categoria (interactions/reveal.js) */
.mhb-pointer { cursor: pointer; }

/* ---------- Acabamento inferior (V3: hero-join.css + .mia-wave) ----------
   A curva da junção Hero → seção seguinte, com borda luminosa. A área abaixo da curva
   recebe a cor da seção seguinte (--mhb-next-bg). data-wave="off" remove. */
.mhb-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--_join);
  pointer-events: none;
}
.mhb-wave-fill {
  position: absolute;
  inset: 0;
  background: var(--mhb-next-bg, #f4f9fb);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 90' preserveAspectRatio='none'%3E%3Cpath d='M0 50C300 76 520 57 760 34C1050 6 1250 70 1440 30V90H0Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 90' preserveAspectRatio='none'%3E%3Cpath d='M0 50C300 76 520 57 760 34C1050 6 1250 70 1440 30V90H0Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.mhb-wave-edge {
  position: absolute;
  left: 0;
  top: -2px;
  width: 100%;
  height: calc(100% + 2px);
  overflow: visible;
}

/* ---------- Pausa (MarlinHeroBg.pause()) e movimento reduzido ---------- */

.mhb-paused .mhb-stage::before,
.mhb-paused .mhb-chip-glow { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .mhb-stage::before { animation: none; }
  .mhb-net-lines line { transition: none; }
  :root:not([data-marlin-motion="full"]) .mhb-fish { transition: none; }
  .mhb-stage:has(> .mhb-fish.is-ready) .mhb-halo { animation: none; }
  .mhb-chip-glow { animation: none; }
  .mhb-chip, .mhb-chip-glow { transition: none; }
  .mhb-net-nodes li.is-signal .mhb-chip, .mhb-net-nodes li.is-signal-strong .mhb-chip { animation: none; }
  .mhb-chip-label { transition: opacity .3s ease, visibility 0s linear .3s; }
}
