/* ══════════════════════════════════════════════
   CHANNELS.CSS — Compra Turbo
   Seção "Canais Constellation"
   Hub central + 7 cards satelites + linhas conectoras
   Dependencias: tokens.css, components.css
   ══════════════════════════════════════════════ */

/* ── SECAO CONTAINER ────────────────────────── */

.channels {
  position: relative;
  overflow: hidden;
  padding: var(--section-padding) 0;
}

.channels__header {
  max-width: 720px;
  margin: 0 auto var(--space-4xl);
  text-align: center;
}

.channels__header h2 {
  font-family: var(--ff-heading);
  font-weight: 900;
  font-size: var(--fs-h2);
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-white);
  margin-bottom: var(--space-md);
}

.channels__intro {
  font-size: var(--fs-body);
  color: var(--text-muted-2);
  line-height: 1.7;
}

/* ── STAGE (palco dos cards + hub + linhas) ─── */

.channels__stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, minmax(180px, auto));
  gap: var(--space-xl);
  max-width: 1100px;
  margin: 0 auto;
}

/* Track eh transparente no desktop (cards viram filhos diretos do grid) */
.channels__track {
  display: contents;
}

/* SVG das linhas conectoras (absoluto, cobre todo o stage) */
.channels__lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.channels__line {
  fill: none;
  stroke: var(--brand-orange);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
}

.channels__lines--visible .channels__line {
  opacity: 0.22;
  /* Draw + pulse sutil pos-draw: a linha "acende" brevemente
     com drop-shadow laranja e assenta no estado final.
     Extende o ciclo de vida da animacao, dando sensacao
     de "fluxo" em vez de corte seco. */
  animation:
    channelLineDraw 1.4s var(--ease-out) forwards,
    channelLinePulse 0.9s var(--ease-out) 1.4s forwards;
}

@keyframes channelLinePulse {
  0% {
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    filter: drop-shadow(0 0 8px rgba(212, 80, 10, 0.55));
  }
  100% {
    filter: drop-shadow(0 0 2px rgba(212, 80, 10, 0.18));
  }
}

/* Stagger dos desenhos das linhas */
.channels__lines--visible .channels__line:nth-child(1) { animation-delay: 0.3s; }
.channels__lines--visible .channels__line:nth-child(2) { animation-delay: 0.45s; }
.channels__lines--visible .channels__line:nth-child(3) { animation-delay: 0.6s; }
.channels__lines--visible .channels__line:nth-child(4) { animation-delay: 0.75s; }
.channels__lines--visible .channels__line:nth-child(5) { animation-delay: 0.9s; }
.channels__lines--visible .channels__line:nth-child(6) { animation-delay: 1.05s; }
.channels__lines--visible .channels__line:nth-child(7) { animation-delay: 1.2s; }

@keyframes channelLineDraw {
  to { stroke-dashoffset: 0; }
}

/* Linha destacada (quando card em hover) */
.channels__line--active {
  opacity: 0.9 !important;
  stroke-width: 2;
  filter: drop-shadow(0 0 8px var(--brand-orange));
}

/* PARTICULAS fluindo nas linhas (fluxo de dados do hub ao card) */
.channels__particle {
  fill: var(--brand-orange);
  filter: drop-shadow(0 0 4px rgba(212, 80, 10, 0.8));
  opacity: 0;
  transition: opacity 0.8s var(--ease-out);
}

.channels__lines--visible .channels__particle {
  opacity: 1;
  transition-delay: 1.4s;
}

/* Particula acelera e brilha quando card em hover */
.channels__particle--active {
  fill: var(--color-particle-yellow);
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.9));
}

/* ── HUB CENTRAL ────────────────────────────── */

.channel-hub {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.channel-hub__logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  z-index: 3;
  filter: drop-shadow(0 0 32px rgba(212, 80, 10, 0.55));
}

/* Anel rotacionando ao redor do hub */
.channel-hub__ring {
  position: absolute;
  inset: -28px;
  border-radius: 50%;
  border: 1.5px solid var(--brand-orange);
  border-top-color: transparent;
  border-right-color: var(--brand-orange-20);
  animation: channelHubSpin 12s linear infinite;
  opacity: 0.6;
  z-index: 2;
}

/* Glow radial pulsante */
.channel-hub__glow {
  position: absolute;
  inset: -100px;
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    rgba(212, 80, 10, 0.28) 0%,
    rgba(212, 80, 10, 0.1) 40%,
    transparent 70%
  );
  animation: channelHubPulse 4s var(--ease-in-out) infinite;
  z-index: 1;
  pointer-events: none;
}

@keyframes channelHubSpin {
  to { transform: rotate(360deg); }
}

@keyframes channelHubPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* ── CARDS SATELITES ────────────────────────── */

.channel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-decoration: none;
  color: inherit;
  z-index: 2;
  overflow: hidden;
  /* Parallax: translate aplicado via JS sem transition (movimento direto) */
  /* Hover: scale animado separadamente nao colide com transform */
  transition:
    border-color 0.3s var(--ease-out),
    background 0.3s var(--ease-out),
    scale 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out);
  cursor: pointer;
}

.channel-card:hover {
  border-color: var(--brand-orange-25);
  background: rgba(212, 80, 10, 0.04);
  scale: 1.04;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.20),
    0 20px 56px rgba(0, 0, 0, 0.28),
    0 0 48px rgba(212, 80, 10, 0.18);
}

/* SPOTLIGHT — glow radial que segue o mouse dentro do card */
.channel-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 260px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(212, 80, 10, 0.28),
    transparent 55%
  );
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  pointer-events: none;
  border-radius: inherit;
  z-index: 0;
}

.channel-card:hover::after {
  opacity: 1;
}

/* Garantir que o conteudo fica acima do spotlight */
.channel-card > * {
  position: relative;
  z-index: 2;
}

/* Dim dos cards nao-ativos quando um esta em hover */
.channels__stage--hovering .channel-card:not(:hover) {
  opacity: 0.45;
}

/* Ícone do canal (SVG monocromatico quadrado).
   Os SVGs usam stroke="currentColor", mas como sao carregados
   via <img>, o currentColor nao herda do CSS do documento. Por
   isso aplicamos filter para forcar branco — mesmo tratamento
   dos logos de marca, so que sem a conversao de cor (brightness 0
   nao e necessario porque o SVG ja e de contorno sem fill). */
.channel-card__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

/* Forca branco apenas nos icones SVG (nao-brand).
   Usa :not() para nao afetar os logos de marca, que tem
   regras proprias de monocromatizacao e excecao do hero. */
.channel-card__icon:not(.channel-card__icon--brand) {
  filter: brightness(0) invert(1);
  opacity: 0.88;
  transition: opacity 0.3s var(--ease-out);
}

.channel-card:hover .channel-card__icon:not(.channel-card__icon--brand) {
  opacity: 1;
}

/* Logo de marca (PNG horizontal) — usado em Shopee, Amazon, Mercado Livre.
   Altura fixa com largura auto preserva proporção original da marca.
   Filter monocromatiza (texto preto -> branco) para legibilidade no fundo
   dark + consistencia visual com os outros 5 icones SVG dos canais. */
.channel-card__icon--brand {
  width: auto;
  height: 22px;
  max-width: 140px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 0.88;
  transition: opacity 0.3s var(--ease-out);
}

.channel-card:hover .channel-card__icon--brand {
  opacity: 1;
}

/* Excecao: Mercado Livre (card hero) mantem cores originais.
   Razao: logo ML tem fundo amarelo preenchido + mao azul negativa.
   Aplicar brightness(0) invert(1) colapsa o handshake num circulo
   branco solido. Como o ML ja e o card hero da constelacao (gradient
   orange background + badge Mercado Lider), manter o logo colorido
   reforca a hierarquia visual em vez de destoar. */
.channel-card--hero .channel-card__icon--brand {
  filter: none;
  opacity: 1;
}

.channel-card__title {
  font-family: var(--ff-heading);
  font-weight: 800;
  font-size: var(--fs-card-title);
  color: var(--text-white);
  letter-spacing: -0.02em;
  margin: 0;
}

.channel-card__desc {
  font-size: var(--fs-small);
  color: var(--text-muted-2);
  line-height: 1.6;
  margin: 0;
  flex-grow: 1;
}

/* Badge de status */
.channel-card__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 10px;
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.3);
  color: #2ECC71;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: var(--radius-full);
}

.channel-card__status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2ECC71;
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
}

/* Badge "Em breve" */
.channel-card--coming .channel-card__status {
  background: transparent;
  border: 1px dashed var(--brand-orange-40);
  color: var(--brand-orange);
}

.channel-card--coming .channel-card__status::before {
  background: var(--brand-orange);
  box-shadow: 0 0 8px rgba(212, 80, 10, 0.6);
  animation: channelPulseOrange 2s var(--ease-in-out) infinite;
}

@keyframes channelPulseOrange {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Card HERO (Mercado Livre) - destaque */
.channel-card--hero {
  background: linear-gradient(
    135deg,
    rgba(212, 80, 10, 0.08) 0%,
    rgba(255, 255, 255, 0.03) 100%
  );
  border-color: var(--brand-orange-25);
}

.channel-card--hero::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    135deg,
    var(--brand-orange) 0%,
    transparent 50%,
    var(--brand-orange-25) 100%
  );
  opacity: 0.3;
  z-index: -1;
  animation: channelHeroGlow 4s var(--ease-in-out) infinite;
}

@keyframes channelHeroGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.55; }
}

.channel-card--hero .channel-card__badge-leader {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  padding: 3px 9px;
  background: linear-gradient(135deg, var(--color-particle-yellow) 0%, #C49900 100%);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(255, 215, 0, 0.3);
}

/* ── POSICIONAMENTO NO GRID (desktop) ──────── */
/* Layout 3x3 completo (8 cards + hub central):
   [Shopee     ] [Amazon   ] [M.Livre ★ ]
   [Televendas ] [  HUB    ] [V.Técnica ]
   [Venda B2B  ] [Embaixad.] [E-commerce]
*/

.channel-card--pos-1 { grid-column: 1; grid-row: 1; } /* Shopee */
.channel-card--pos-2 { grid-column: 2; grid-row: 1; } /* Amazon */
.channel-card--pos-3 { grid-column: 3; grid-row: 1; } /* Mercado Livre (hero) */
.channel-card--pos-4 { grid-column: 1; grid-row: 2; } /* Televendas */
.channel-card--pos-5 { grid-column: 3; grid-row: 2; } /* Vendas Técnicas */
.channel-card--pos-6 { grid-column: 1; grid-row: 3; } /* Venda B2B */
.channel-card--pos-7 { grid-column: 2; grid-row: 3; } /* Embaixadores */
.channel-card--pos-8 { grid-column: 3; grid-row: 3; } /* E-commerce (em breve) */

/* ── TABLET (2 colunas) ─────────────────────── */

@media (max-width: 1024px) {
  .channels__stage {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    max-width: 720px;
    gap: var(--space-lg);
  }

  /* Hub vai para o topo (span 2 colunas) */
  .channel-hub {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: var(--space-xl) 0;
  }

  .channel-hub__ring {
    inset: -16px;
  }

  /* Reorganizar cards em 2 colunas (ordem visual por importancia) */
  .channel-card--pos-1 { grid-column: auto; grid-row: auto; order: 3; } /* Shopee */
  .channel-card--pos-2 { grid-column: auto; grid-row: auto; order: 2; } /* Amazon */
  .channel-card--pos-3 { grid-column: auto; grid-row: auto; order: 1; } /* ML hero */
  .channel-card--pos-4 { grid-column: auto; grid-row: auto; order: 4; } /* Televendas */
  .channel-card--pos-5 { grid-column: auto; grid-row: auto; order: 5; } /* V.Tecnica */
  .channel-card--pos-6 { grid-column: auto; grid-row: auto; order: 6; } /* Venda B2B */
  .channel-card--pos-7 { grid-column: auto; grid-row: auto; order: 7; } /* Embaixadores */
  .channel-card--pos-8 { grid-column: auto; grid-row: auto; order: 8; } /* E-commerce */

  /* Linhas escondidas no tablet (nao conectariam bem) */
  .channels__lines {
    display: none;
  }
}

/* ── MOBILE (scroll horizontal) ─────────────── */

@media (max-width: 768px) {
  .channels__stage {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
  }

  /* Hub fica fixo no topo como apresentacao */
  .channel-hub {
    margin: 0 auto var(--space-xl);
    padding: var(--space-lg) 0;
  }

  /* Cards em scroll horizontal */
  .channels__track {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: var(--gutter);
    padding: var(--space-sm) var(--gutter) var(--space-lg);
    margin: 0 calc(var(--gutter) * -1);
    -webkit-overflow-scrolling: touch;
  }

  .channels__track::-webkit-scrollbar { display: none; }
  .channels__track { scrollbar-width: none; }

  .channel-card {
    flex: 0 0 78%;
    max-width: 320px;
    scroll-snap-align: center;
  }

  /* Reset de grid-column/row em todos os cards no mobile */
  .channel-card[class*="--pos-"] {
    grid-column: auto;
    grid-row: auto;
    order: 0;
  }

  /* Dim hover não aplica em mobile */
  .channels__stage--hovering .channel-card:not(:hover) {
    opacity: 1;
  }
}

/* ── ACESSIBILIDADE ─────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .channels__lines--visible .channels__line {
    animation: none;
    stroke-dashoffset: 0;
    opacity: 0.22;
  }
  .channel-hub__ring,
  .channel-hub__glow,
  .channel-card--hero::before,
  .channel-card--coming .channel-card__status::before {
    animation: none;
  }
}

/* Focus visible nos cards */
.channel-card:focus-visible {
  outline: 2px solid var(--brand-orange);
  outline-offset: 4px;
}

/* ── STAGGER CURTO (scoped) ──────────────────
   Override dos .stagger-* globais (0.2s -> 1.2s) especificamente
   para .channel-card: em scroll rapido, delays grandes faziam
   os ultimos cards "piscarem tardiamente". Aqui maximo 0.20s. */
.channel-card.stagger-1 { transition-delay: 0.04s; }
.channel-card.stagger-2 { transition-delay: 0.08s; }
.channel-card.stagger-3 { transition-delay: 0.12s; }
.channel-card.stagger-4 { transition-delay: 0.16s; }
.channel-card.stagger-5 { transition-delay: 0.20s; }
