/* ═══════════════════════════════════════════════
   AVANCCE — setores.css
   Seção "Setores que atendemos": abas + painel
   Abas e glider: setores.js | Entrada: animations.js | Malha: script.js
   ═══════════════════════════════════════════════ */

.setores {
  position: relative;
  z-index: 2;
  overflow: hidden;
  isolation: isolate;
}

/* Malha de pontos (assinatura da marca) no canto do cabeçalho, discreta */
.setores__malha {
  position: absolute;
  top: 28px;
  right: -48px;
  width: min(580px, 62vw);
  aspect-ratio: 2 / 1;
  background: center / 100% 100% no-repeat;
  opacity: 0.32;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 38%);
          mask-image: linear-gradient(90deg, transparent 0%, #000 38%);
  pointer-events: none;
  z-index: 0;
}
/* .setores-anim só existe quando o animations.js assume a seção */
.setores.setores-anim .setores__malha {
  clip-path: inset(0 0 0 100%);
  transition: clip-path 1.2s var(--ease-out) 0.1s;
}
.setores.setores-anim.is-in .setores__malha {
  clip-path: inset(0 0 0 0);
}

.setores .container {
  position: relative;
  z-index: 1;
}

/* ── Cabeçalho ───────────────────────────────── */
.setores__head {
  max-width: 720px;
  margin-bottom: clamp(40px, 5vw, 56px);
}
.setores__head .section-title {
  margin-bottom: 18px;
  text-wrap: balance;
}
.setores__lead {
  max-width: 62ch;
  font-size: var(--fs-lead);
  line-height: var(--lh-lead);
  color: var(--text-muted);
  text-wrap: pretty;
}

/* ── Corpo: abas | painel ────────────────────── */
.setores__body {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: clamp(18px, 2vw, 24px);
  align-items: stretch;
}

/* ── Abas ────────────────────────────────────── */
.setores-tabs {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.setores-tab {
  position: relative;
  z-index: 1;
  /* Divide a altura do painel: a coluna termina alinhada com o card */
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--surface-card);
  color: var(--text-secondary);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-fast) var(--ease-ui), border-color var(--dur-fast) var(--ease-ui), background-color var(--dur-fast) var(--ease-ui);
}
.setores-tab:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 3px;
}
.setores-tab__num {
  flex: 0 0 auto;
  min-width: 2ch;
  /* Numeração da marca: Google Sans Code 700 */
  font-family: var(--font-support);
  font-size: var(--fs-note);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--text-subtle);
  transition: color var(--dur-fast) var(--ease-ui);
}
.setores-tab__icon {
  display: inline-flex;
  flex: 0 0 auto;
}
.setores-tab__icon svg {
  width: 20px;
  height: 20px;
  color: rgba(172, 150, 255, 0.62);
  transition: color var(--dur-fast) var(--ease-ui);
}
.setores-tab__nome {
  flex: 1 1 auto;
  min-width: 0;
}
.setores-tab__seta {
  display: inline-flex;
  flex: 0 0 auto;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--dur-fast) var(--ease-ui), transform var(--dur-base) var(--ease-ui);
}
.setores-tab__seta svg {
  width: 16px;
  height: 16px;
  color: var(--accent-hot);
}
@media (hover: hover) {
  .setores-tab:hover {
    color: #fff;
    border-color: var(--line-strong);
    background-color: var(--surface-card-hover);
  }
  .setores-tab:hover .setores-tab__icon svg {
    color: var(--accent-hot);
  }
}

/* Selecionada. Sem JS o próprio botão leva o destaque; com o glider ativo
   (has-glider) quem desenha o destaque é ele, deslizando entre as abas. */
.setores-tab[aria-selected="true"] {
  color: #fff;
  border-color: rgba(172, 150, 255, 0.5);
  background-color: rgba(118, 56, 234, 0.16);
}
.setores-tab[aria-selected="true"] .setores-tab__num {
  color: var(--brand-burnt-orange);
}
.setores-tab[aria-selected="true"] .setores-tab__icon svg {
  color: var(--accent-hot);
}
.setores-tab[aria-selected="true"] .setores-tab__seta {
  opacity: 1;
  transform: none;
}
.setores-tabs.has-glider .setores-tab[aria-selected="true"] {
  background-color: transparent;
  border-color: transparent;
}

.setores-tabs__glider {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: rgba(118, 56, 234, 0.14);
  box-shadow: var(--inset-top);
  opacity: 0;
  pointer-events: none;
  will-change: transform;
  transition:
    transform 400ms var(--ease-out),
    width 400ms var(--ease-out),
    height 400ms var(--ease-out),
    opacity var(--dur-base) var(--ease-ui);
}
/* Fio laranja na borda esquerda (eco do fio lilás do FAQ) */
.setores-tabs__glider::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 24%;
  bottom: 24%;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, var(--brand-burnt-orange), transparent);
}
.setores-tabs.has-glider .setores-tabs__glider {
  opacity: 1;
}
/* Na entrada animada o destaque espera as abas chegarem (is-pousado) */
.setores.setores-anim:not(.is-pousado) .setores-tabs__glider {
  opacity: 0;
}

/* ── Painel ──────────────────────────────────── */
/* O card é o palco; os painéis são camadas empilhadas na mesma célula do grid.
   Assim o card fica com a altura do maior painel e não pula ao trocar. */
.setores-stage {
  --stage-pad: clamp(22px, 2.4vw, 32px);
  position: relative;
  display: grid;
  min-width: 0;
  padding: var(--stage-pad);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card), var(--inset-top);
  overflow: hidden;
  isolation: isolate;
}
/* Luz de canto bem baixa, a mesma do painel do Diagnóstico */
.setores-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
    560px circle at 0% 0%,
    rgba(172, 150, 255, 0.07),
    transparent 60%
  );
  pointer-events: none;
}

.setores-panel {
  grid-area: 1 / 1;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  /* Entrada: espera a saída do painel anterior começar */
  transition:
    opacity 400ms var(--ease-out) 80ms,
    transform 400ms var(--ease-out) 80ms,
    visibility 0s linear 0s;
}
.setores-panel:not(.is-active) {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity var(--dur-fast) var(--ease-ui),
    transform var(--dur-fast) var(--ease-ui),
    visibility 0s linear var(--dur-fast);
}
.setores-panel:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 10px;
  border-radius: 10px;
}

/* Número gigante vazado no canto: eco dos números das etapas em Automação */
.setores-panel__marca {
  position: absolute;
  top: calc(var(--stage-pad) * -1 + 14px);
  right: calc(var(--stage-pad) * -1 + clamp(18px, 2.2vw, 30px));
  z-index: -1;
  font-family: var(--font-display);
  font-size: clamp(76px, 8vw, 118px);
  font-size-adjust: none;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1.25px rgba(225, 217, 255, 0.42);
  background: linear-gradient(180deg, rgba(172, 150, 255, 0.3) 0%, rgba(118, 56, 234, 0.1) 78%);
  -webkit-background-clip: text;
          background-clip: text;
  filter: drop-shadow(0 0 16px rgba(118, 56, 234, 0.18));
  pointer-events: none;
  user-select: none;
}

.setores-panel__head {
  display: flex;
  align-items: center;
  gap: 16px;
  /* Espaço para o número do canto não encostar no título */
  padding-right: clamp(72px, 9vw, 128px);
}
/* Mesmo ícone dos cards de Soluções, em tamanho de cabeçalho */
.setores-panel__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: rgba(172, 150, 255, 0.08);
}
.setores-panel__icon svg {
  width: 24px;
  height: 24px;
  color: var(--accent-hot);
}
.setores-panel__label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-support);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--ls-label);
  color: var(--text-muted);
}
/* "O que costumamos automatizar ———" : o fio substitui um divisor separado */
.setores-panel__label--rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 -6px;
}
.setores-panel__label--rule::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, rgba(172, 150, 255, 0.3), rgba(172, 150, 255, 0));
}
.setores-panel__title {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: var(--lh-h3);
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.setores-panel__resumo {
  max-width: 62ch;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-secondary);
  text-wrap: pretty;
}

.setores-itens {
  display: grid;
  gap: 8px;
}
.setores-itens li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--surface-card);
  border: 1px solid var(--line);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--text-secondary);
}
.setores-itens svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--accent-hot);
}

.setores-canais {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 2px;
}
.setores-canais__label {
  font-family: var(--font-support);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--ls-label);
  color: var(--text-muted);
}
.setores-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.setores-chips li {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 100px;
  font-family: var(--font-support);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--ls-tag);
  color: var(--accent-soft);
  background: rgba(118, 56, 234, 0.1);
  border: 1px solid var(--line);
}

/* Troca de setor: itens e canais entram em cascata. Só depois da primeira
   troca (has-switched) — a entrada inicial é do animations.js. */
@keyframes setorItemIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.setores.has-switched .setores-panel.is-active .setores-itens li,
.setores.has-switched .setores-panel.is-active .setores-canais {
  animation: setorItemIn 400ms var(--ease-out) both;
}
.setores.has-switched .setores-panel.is-active .setores-itens li:nth-child(1) { animation-delay: 0.1s; }
.setores.has-switched .setores-panel.is-active .setores-itens li:nth-child(2) { animation-delay: 0.14s; }
.setores.has-switched .setores-panel.is-active .setores-itens li:nth-child(3) { animation-delay: 0.18s; }
.setores.has-switched .setores-panel.is-active .setores-itens li:nth-child(4) { animation-delay: 0.22s; }
.setores.has-switched .setores-panel.is-active .setores-canais { animation-delay: 0.24s; }

/* ── Responsivo ──────────────────────────────── */
@media (max-width: 1024px) {
  .setores__body {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Abas viram grade acima do painel; o glider anda nos dois eixos */
  .setores-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .setores-tab {
    flex: none;
    min-height: 58px;
    padding: 12px 14px;
    gap: 10px;
  }
  .setores-tab__seta {
    display: none;
  }
  .setores__malha {
    top: 12px;
    right: -64px;
    opacity: 0.26;
  }
}
@media (max-width: 640px) {
  .setores-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  /* O "Setor 0X" do painel já numera; na aba o espaço vai para o nome */
  .setores-tab__num {
    display: none;
  }
  .setores-tab {
    min-height: 54px;
    padding: 12px;
  }
  /* O glider é o primeiro filho; o 5º botão fica ímpar entre as abas */
  .setores-tab:last-of-type:nth-of-type(odd) {
    grid-column: 1 / -1;
  }
  .setores__malha {
    opacity: 0.22;
  }
  .setores-stage {
    --stage-pad: 22px;
  }
  .setores-panel {
    gap: 16px;
  }
  .setores-panel__icon {
    width: 44px;
    height: 44px;
  }
  .setores-panel__icon svg {
    width: 22px;
    height: 22px;
  }
  .setores-itens li {
    padding: 12px 14px;
  }
  /* O número do canto ocupa ~1,26× a fonte de largura (76px → ~96px) e
     passa 4px da margem do painel: o cabeçalho reserva essa medida + 12px,
     senão "Restaurante" e "Outros setores" passam por baixo dele */
  .setores-panel__head {
    padding-right: 104px;
  }
}
/* iPhone 12–16 (390px) e Android (360px): número menor para o título caber */
@media (max-width: 389px) {
  .setores-panel__marca {
    font-size: 60px;
  }
  .setores-panel__head {
    gap: 12px;
    padding-right: 84px;
  }
}
/* Abaixo de 360px não sobra largura para os dois: fica o "Setor 0X" */
@media (max-width: 359px) {
  .setores-panel__marca {
    display: none;
  }
  .setores-panel__head {
    padding-right: 0;
  }
}

/* ── Reduced motion ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .setores-tabs__glider,
  .setores-tab,
  .setores-tab__icon svg,
  .setores-tab__seta,
  .setores-panel,
  .setores-panel:not(.is-active),
  .setores.setores-anim .setores__malha {
    transition: none;
  }
  .setores.has-switched .setores-panel.is-active .setores-itens li,
  .setores.has-switched .setores-panel.is-active .setores-canais {
    animation: none;
  }
}
