/* ==========================================================================
   Prática interativa — Formação de CIPA (componente isolado da landing page).
   Só CSS + JS vanilla. Uma feature section escura: cabeçalho, seletor de
   atividades (tabs) e UM painel que troca de conteúdo via JavaScript.
   Personalização pela LP: sobrescreva as variáveis --pi-* em .pi.
   Estados da microanimação: [data-phase] no painel (0 a 4).
   ========================================================================== */

.pi {
  --pi-bg: #0d0b19;
  --pi-purple: #7559ff;
  --pi-purple-deep: #5d18ea;
  --pi-purple-light: #a864f2;
  --pi-green: #3ddc97;
  --pi-green-deep: #0fbd72;
  --pi-text: #f4f2ff;
  --pi-muted: rgba(244, 242, 255, 0.66);
  --pi-faint: rgba(244, 242, 255, 0.42);
  --pi-line: rgba(255, 255, 255, 0.08);
  --pi-container: 1160px;
  --pi-gutter: 20px;
  --pi-pad: clamp(24px, 4.4vw, 56px);
  --pi-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pi-font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --pi-font-body: "Inter", "Segoe UI", system-ui, sans-serif;

  position: relative;
  padding: clamp(72px, 10vw, 128px) 0 clamp(64px, 8vw, 104px);
  overflow: hidden;
  color: var(--pi-text);
  background: var(--pi-bg);
  font-family: var(--pi-font-body);
}

.pi *,
.pi *::before,
.pi *::after {
  box-sizing: border-box;
}

.pi__inner {
  width: min(100% - 2 * var(--pi-gutter), var(--pi-container));
  margin: 0 auto;
}

/* ---------- entrada (só quando o JS está ativo) ---------- */

.pi.is-enhanced [data-pi-enter] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--pi-ease), transform 0.7s var(--pi-ease);
  transition-delay: calc(var(--d, 0) * 1ms);
}

.pi.is-enhanced.is-revealed [data-pi-enter] {
  opacity: 1;
  transform: none;
}

/* ---------- cabeçalho ---------- */

.pi__header {
  max-width: 1040px;
  margin: 0 auto;
  text-align: center;
}

.pi__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--pi-purple-light);
}

.pi__eyebrow i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pi-purple);
  box-shadow: 0 0 0 4px rgba(117, 89, 255, 0.22);
}

.pi__title {
  margin: 0;
  font-family: var(--pi-font-display);
  font-size: clamp(30px, 4.6vw, 54px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.pi__title-line {
  display: block;
}

.pi__title-line--accent {
  width: fit-content;
  margin: 0 auto;
  color: transparent;
  background: linear-gradient(92deg, var(--pi-green) 0%, #8e78ff 78%);
  -webkit-background-clip: text;
  background-clip: text;
}

.pi__lead {
  max-width: 620px;
  margin: 22px auto 0;
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.65;
  color: var(--pi-muted);
}

/* ---------- seletor (tabs) ---------- */

.pi__tabs {
  position: relative;
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: clamp(40px, 5vw, 56px) auto 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-bottom: 1px solid var(--pi-line);
  -webkit-overflow-scrolling: touch;
}

.pi__tabs::-webkit-scrollbar {
  display: none;
}

.pi__tab {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px clamp(16px, 2vw, 26px);
  border: 0;
  border-radius: 14px 14px 0 0;
  background: transparent;
  color: var(--pi-faint);
  font: 600 15px/1 var(--pi-font-body);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.35s var(--pi-ease), background-color 0.35s var(--pi-ease);
  -webkit-tap-highlight-color: transparent;
}

.pi__tab:hover {
  color: var(--pi-muted);
}

.pi__tab[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(180deg, rgba(117, 89, 255, 0) 0%, rgba(117, 89, 255, 0.16) 100%);
}

.pi__tab:focus-visible {
  outline: 2px solid var(--pi-purple-light);
  outline-offset: -2px;
}

.pi__tab-n {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: inherit;
  opacity: 0.7;
  transition: color 0.35s var(--pi-ease);
}

.pi__tab[aria-selected="true"] .pi__tab-n {
  color: var(--pi-purple-light);
  opacity: 1;
}

.pi__tab-ind {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: var(--w, 100px);
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--pi-purple-deep), var(--pi-purple), var(--pi-purple-light));
  box-shadow: 0 0 14px 1px rgba(117, 89, 255, 0.7);
  transform: translateX(var(--x, 0px));
  transition: transform 0.5s var(--pi-ease), width 0.5s var(--pi-ease);
  pointer-events: none;
}

/* ---------- painel principal ---------- */

.pi__panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
  margin-top: 28px;
  min-height: 580px;
  overflow: hidden;
  border: 1px solid var(--pi-line);
  border-radius: 28px;
  background:
    radial-gradient(56% 80% at 82% 30%, rgba(117, 89, 255, 0.2) 0%, rgba(117, 89, 255, 0) 70%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 60%);
}

.pi.is-enhanced [data-pi-panel] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.8s var(--pi-ease), transform 0.8s var(--pi-ease);
}

.pi.is-enhanced [data-pi-panel].is-revealed {
  opacity: 1;
  transform: none;
}

/* lado esquerdo: conteúdo e fluxo */

.pi__left,
.pi__right {
  min-width: 0;
}

.pi__left {
  align-self: center;
  padding: var(--pi-pad);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pi__left.is-swapping,
.pi__card.is-swapping {
  opacity: 0;
  transform: translateY(8px);
}

.pi__act-eyebrow {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--pi-purple-light);
}

.pi__act-title {
  margin: 0;
  font-family: var(--pi-font-display);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.pi__act-desc {
  max-width: 470px;
  min-height: 5.2em;
  margin: 16px 0 0;
  font-size: 16px;
  line-height: 1.65;
  color: var(--pi-muted);
}

/* fluxo vertical com linha animada */

.pi__steps {
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.pi__step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 22px;
  opacity: 0.38;
  transition: opacity 0.5s var(--pi-ease);
}

.pi__step:last-child {
  padding-bottom: 0;
}

.pi__step.is-on {
  opacity: 1;
}

.pi__node {
  position: relative;
  z-index: 1;
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: var(--pi-bg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--pi-muted);
  transition: background-color 0.5s var(--pi-ease), border-color 0.5s var(--pi-ease), color 0.5s var(--pi-ease), box-shadow 0.5s var(--pi-ease);
}

.pi__node > * {
  grid-area: 1 / 1;
  transition: opacity 0.35s ease, transform 0.5s var(--pi-ease);
}

.pi__node-ok {
  width: 18px;
  height: 18px;
  opacity: 0;
  transform: scale(0.4);
}

.pi__step.is-active .pi__node {
  border-color: var(--pi-purple);
  color: #fff;
  background: rgba(117, 89, 255, 0.28);
  box-shadow: 0 0 0 5px rgba(117, 89, 255, 0.16);
}

.pi__step.is-done .pi__node {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--pi-purple-deep), var(--pi-purple));
}

.pi__step.is-done .pi__node-n {
  opacity: 0;
  transform: scale(0.4);
}

.pi__step.is-done .pi__node-ok {
  opacity: 1;
  transform: none;
}

.pi__step--final.is-done .pi__node {
  background: linear-gradient(135deg, var(--pi-green-deep), var(--pi-green));
  box-shadow: 0 0 0 5px rgba(61, 220, 151, 0.14);
}

.pi__step-txt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--pi-muted);
}

.pi__step-txt b {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pi-text);
}

.pi__step--final.is-done .pi__step-txt b {
  color: var(--pi-green);
}

/* trecho da linha que liga um passo ao próximo */
.pi__seg {
  position: absolute;
  left: 19.5px;
  top: 42px;
  bottom: 2px;
  width: 1px;
  background: rgba(255, 255, 255, 0.14);
}

.pi__seg > span {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--pi-purple-light), var(--pi-purple));
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.75s var(--pi-ease);
}

.pi__step.is-done .pi__seg > span {
  transform: scaleY(1);
}

/* lado direito: demonstração visual */

.pi__right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--pi-pad) var(--pi-pad) var(--pi-pad) 0;
}

.pi__card {
  position: relative;
  z-index: 2;
  width: min(100%, 392px);
  padding: 22px 22px 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 25, 62, 0.94), rgba(21, 17, 44, 0.96));
  box-shadow: 0 36px 70px -20px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(117, 89, 255, 0.06);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pi__card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pi__logo {
  flex: none;
  width: 34px;
  height: auto;
}

.pi__card-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}

.pi__card-id small {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pi-faint);
}

.pi__card-id b {
  font-family: var(--pi-font-display);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 0 14px;
}

.pi__pill {
  flex: none;
  display: inline-grid;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  color: #c9bfff;
  background: rgba(117, 89, 255, 0.2);
  transition: color 0.4s ease, background-color 0.4s ease;
}

.pi__pill > span {
  grid-area: 1 / 1;
  transition: opacity 0.4s ease;
}

.pi__pill-b,
.pi__panel[data-phase="4"] .pi__pill-a {
  opacity: 0;
}

.pi__panel[data-phase="4"] .pi__pill-b {
  opacity: 1;
}

.pi__panel[data-phase="4"] .pi__pill {
  color: #06180f;
  background: var(--pi-green);
}

.pi__done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--pi-green);
  transition: opacity 0.5s var(--pi-ease), transform 0.5s var(--pi-ease);
}

.pi__done svg {
  width: 17px;
  height: 17px;
}

.pi__panel[data-phase="0"] .pi__done {
  opacity: 0;
  transform: translateY(6px);
}

.pi__files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pi__file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.pi.is-enhanced .pi__file {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s var(--pi-ease), transform 0.5s var(--pi-ease);
}

.pi.is-enhanced .pi__file.is-in {
  opacity: 1;
  transform: none;
}

.pi__file-ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #b9adff;
  background: rgba(117, 89, 255, 0.18);
}

.pi__file-ico svg {
  width: 20px;
  height: 20px;
}

.pi__file-ico--photo {
  color: #fff;
  background: linear-gradient(135deg, rgba(93, 24, 234, 0.75), rgba(168, 100, 242, 0.7));
}

.pi__file-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.pi__file-txt b {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pi__file-txt small {
  font-size: 11.5px;
  color: var(--pi-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pi__file-ok {
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: auto;
  color: var(--pi-green);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.4s ease, transform 0.5s var(--pi-ease);
  transition-delay: calc(var(--k, 0) * 110ms);
}

.pi__panel[data-phase="4"] .pi__file-ok {
  opacity: 1;
  transform: none;
}

/* envio: barra -> confirmação (mesma altura, sem "pulo" de layout) */

.pi__upload {
  position: relative;
  height: 46px;
  margin-top: 16px;
}

.pi__sending,
.pi__saved {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: opacity 0.45s var(--pi-ease), transform 0.45s var(--pi-ease);
}

.pi__sending {
  gap: 9px;
  opacity: 0;
  transform: translateY(6px);
}

.pi__panel[data-phase="3"] .pi__sending {
  opacity: 1;
  transform: none;
}

.pi__sending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--pi-muted);
}

.pi__sending-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pi__sending-row svg {
  width: 15px;
  height: 15px;
  color: var(--pi-purple-light);
}

.pi__sending-row b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.pi__bar {
  height: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
}

.pi__bar > span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--pi-purple-deep), var(--pi-purple), var(--pi-purple-light));
  transform: scaleX(calc(var(--p, 0) / 100));
  transform-origin: left;
  transition: transform 0.7s var(--pi-ease);
}

.pi__saved {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--pi-green);
  opacity: 0;
  transform: translateY(8px);
}

.pi__saved svg {
  width: 26px;
  height: 26px;
}

.pi__saved svg path {
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
  transition: stroke-dashoffset 0.6s var(--pi-ease) 0.15s;
}

.pi__panel[data-phase="4"] .pi__saved {
  opacity: 1;
  transform: none;
}

.pi__panel[data-phase="4"] .pi__saved svg path {
  stroke-dashoffset: 0;
}

.pi__illus {
  display: block;
  margin-top: 10px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-align: right;
  text-transform: uppercase;
  color: rgba(244, 242, 255, 0.3);
}

/* personagem: sobre a interface, com microanimações */

.pi__char {
  position: absolute;
  left: -34px;
  bottom: -14px;
  z-index: 3;
  width: clamp(230px, 24vw, 292px);
  pointer-events: none;
}

.pi.is-enhanced .pi__char {
  opacity: 0;
  transform: translateY(28px) scale(0.98);
  transition: opacity 0.9s var(--pi-ease) 0.25s, transform 1.1s var(--pi-ease) 0.25s;
}

.pi.is-enhanced [data-pi-panel].is-revealed .pi__char {
  opacity: 1;
  transform: none;
}

.pi__char-par {
  transform: translate3d(calc(var(--px, 0) * 9px), calc(var(--py, 0) * 5px), 0);
  transition: transform 0.7s var(--pi-ease);
  will-change: transform;
}

.pi__char img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.45));
  user-select: none;
}

.pi.is-inview.is-enhanced .pi__char img {
  animation: pi-float 7s ease-in-out infinite;
}

@keyframes pi-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* ---------- nota e acessibilidade ---------- */

.pi__note {
  max-width: 640px;
  margin: 28px auto 0;
  font-size: 13.5px;
  line-height: 1.6;
  text-align: center;
  color: var(--pi-faint);
}

.pi__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- tablet ---------- */

@media (max-width: 1023px) {
  .pi__panel {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .pi__left {
    padding-bottom: 8px;
  }

  .pi__act-desc {
    max-width: 560px;
    min-height: 0;
  }

  .pi__right {
    justify-content: center;
    padding: 24px var(--pi-pad) 132px;
  }

  .pi__card {
    width: min(100%, 440px);
    margin-right: 0;
  }

  .pi__char {
    left: auto;
    right: max(var(--pi-pad), calc(50% - 300px));
    bottom: -12px;
    width: 190px;
  }
}

/* ---------- mobile ---------- */

@media (max-width: 599px) {
  .pi {
    --pi-gutter: 16px;
  }

  .pi__tabs {
    width: 100%;
  }

  .pi__tab {
    padding: 15px 16px;
    font-size: 14px;
  }

  .pi__panel {
    border-radius: 22px;
    background:
      radial-gradient(90% 40% at 50% 78%, rgba(117, 89, 255, 0.2) 0%, rgba(117, 89, 255, 0) 70%),
      linear-gradient(165deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 60%);
  }

  .pi__left {
    padding: 26px 22px 6px;
  }

  .pi__steps {
    margin-top: 26px;
  }

  .pi__right {
    padding: 20px 16px 104px;
  }

  .pi__card {
    padding: 18px 16px 14px;
  }

  .pi__pill {
    padding: 5px 9px;
    font-size: 10.5px;
  }

  .pi__char {
    right: 6px;
    width: 152px;
  }
}

/* ---------- movimento reduzido: tudo estático e completo ---------- */

@media (prefers-reduced-motion: reduce) {
  .pi *,
  .pi *::before,
  .pi *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .pi.is-enhanced [data-pi-enter],
  .pi.is-enhanced [data-pi-panel],
  .pi.is-enhanced .pi__char,
  .pi.is-enhanced .pi__file {
    opacity: 1;
    transform: none;
  }
}
