/* ==========================================================================
   Como Funciona — fluxo interativo
   ========================================================================== */

.section-how-it-works {
  position: relative;
  background: var(--white);
  overflow: visible;
  padding-top: clamp(1.25rem, 2.5vw, 1.75rem);
  padding-bottom: var(--section-py);
  box-shadow: inset 0 24px 28px -24px rgba(8, 16, 32, 0.12);
}

.section-how-it-works .section-header {
  max-width: none;
  width: 100%;
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}

.hiw-pains-block {
  margin-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
  padding: clamp(1rem, 2vw, 1.25rem);
  background: rgba(180, 83, 9, 0.045);
  border: 1px dashed rgba(180, 83, 9, 0.28);
  border-radius: var(--radius-lg);
}

.hiw-pains-block__header {
  margin-bottom: 0.875rem;
}

.hiw-pains-block__label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9A3412;
  margin-bottom: 0.375rem;
}

.hiw-pains-block__label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #C2410C;
  flex-shrink: 0;
}

.hiw-pains-block__intro {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--gray);
  margin: 0;
  max-width: 42rem;
}

.hiw-pains {
  display: grid;
  gap: 0.625rem;
}

@media (min-width: 640px) {
  .hiw-pains {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .hiw-pains {
    grid-template-columns: repeat(4, 1fr);
  }
}

.hiw-pain {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--white);
  border: 1px solid rgba(180, 83, 9, 0.14);
  border-radius: var(--radius-md);
  border-left: 3px solid #C2410C;
  box-shadow: 0 1px 2px rgba(154, 52, 18, 0.06);
}

.hiw-pain__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(194, 65, 12, 0.1);
  color: #C2410C;
}

.hiw-pain__icon svg {
  width: 1rem;
  height: 1rem;
}

.hiw-pain__body h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.2rem;
}

.hiw-pain__body p {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--gray);
  margin: 0;
}

.hiw-bridge {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--navy);
  text-align: center;
  margin-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.hiw-bridge__solution {
  display: inline-block;
  color: var(--teal);
  margin-right: 0.25rem;
}

.hiw-flow {
  max-width: 72rem;
  margin-inline: auto;
  display: grid;
  gap: 1.75rem;
  align-items: center;
}

@media (min-width: 1024px) {
  .hiw-flow {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 1rem 0.75rem;
  }
}

.hiw-step-label {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 0.875rem;
  opacity: 0.85;
}

.hiw-card {
  background: var(--white);
  border: 1px solid rgba(15, 30, 61, 0.08);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.hiw-card:hover {
  border-color: rgba(46, 139, 122, 0.22);
  box-shadow: var(--shadow-md);
}

/* Insumos */
.hiw-input-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hiw-input-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--navy);
  transition: background 0.2s ease;
}

.hiw-input-item:hover {
  background: rgba(240, 240, 241, 0.9);
}

.hiw-input-item svg {
  width: 18px;
  height: 18px;
  color: var(--teal);
  flex-shrink: 0;
}

/* Conectores */
.hiw-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(46, 139, 122, 0.55);
}

.hiw-connector--h { display: none; }
.hiw-connector--v { display: flex; }

@media (min-width: 1024px) {
  .hiw-connector--h { display: flex; }
  .hiw-connector--v { display: none; }
}

.hiw-connector svg {
  overflow: visible;
}

.hiw-connector-line {
  stroke: currentColor;
  stroke-width: 2;
  stroke-dasharray: 5 5;
  fill: none;
}

.hiw-flow.is-active .hiw-connector-line {
  animation: hiwDash 1.2s linear infinite;
}

@keyframes hiwDash {
  to { stroke-dashoffset: -20; }
}

.hiw-connector-arrow {
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hiw-connector-icon {
  width: 2rem;
  height: 2rem;
  color: var(--teal);
  opacity: 0.75;
}

/* Hub IA */
.hiw-step--ai {
  display: flex;
  justify-content: center;
}

.hiw-ai-hub {
  position: relative;
  width: 11rem;
  height: 11rem;
}

@media (min-width: 1024px) {
  .hiw-ai-hub {
    width: 13rem;
    height: 13rem;
  }
}

.hiw-ai-glow {
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 139, 122, 0.22) 0%, rgba(31, 75, 143, 0.08) 55%, transparent 72%);
  filter: blur(14px);
  animation: hiwGlow 3.5s ease-in-out infinite;
}

@keyframes hiwGlow {
  0%, 100% { transform: scale(0.96); opacity: 0.75; }
  50% { transform: scale(1.04); opacity: 1; }
}

.hiw-ai-ring {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  background:
    linear-gradient(var(--white), var(--white)) padding-box,
    linear-gradient(135deg, var(--teal), var(--blue)) border-box;
  border: 2px solid transparent;
  box-shadow: var(--shadow-md);
}

.hiw-ai-ring svg {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--teal);
  margin-bottom: 0.375rem;
}

.hiw-ai-ring p {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.25;
  color: var(--navy);
}

/* Laudo mockup */
.hiw-doc {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hiw-doc-lines {
  display: flex;
  flex-direction: column;
  gap: 0.4375rem;
}

.hiw-doc-line {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(15, 30, 61, 0.08);
  transform-origin: left center;
  transform: scaleX(0);
}

.hiw-doc-line--75 { width: 75%; }
.hiw-doc-line--100 { width: 100%; }
.hiw-doc-line--85 { width: 85%; }
.hiw-doc-line--65 { width: 65%; }
.hiw-doc-line--50 { width: 50%; }

.hiw-doc-block {
  height: 4rem;
  border-radius: var(--radius-sm);
  background: rgba(240, 240, 241, 0.85);
  border: 1px solid rgba(15, 30, 61, 0.06);
  opacity: 0;
  transform: translateY(6px);
}

.hiw-doc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.375rem;
  opacity: 0;
}

.hiw-doc-checks {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.hiw-doc-check {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.hiw-doc-check svg {
  width: 14px;
  height: 14px;
  color: var(--teal);
  flex-shrink: 0;
}

.hiw-doc-check span {
  display: block;
  height: 0.375rem;
  border-radius: 999px;
  background: rgba(15, 30, 61, 0.08);
}

.hiw-doc-check span:first-of-type { width: 4rem; }
.hiw-doc-check:last-child span { width: 3rem; }

.hiw-doc-badge {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--teal);
}

/* Perito */
.hiw-expert-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hiw-expert-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: rgba(46, 139, 122, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hiw-expert-avatar svg {
  width: 1.375rem;
  height: 1.375rem;
  color: var(--teal);
}

.hiw-expert-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.hiw-expert-meta span {
  display: block;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(15, 30, 61, 0.08);
}

.hiw-expert-meta span:first-child { width: 75%; }
.hiw-expert-meta span:last-child { width: 50%; height: 0.375rem; opacity: 0.7; }

.hiw-expert-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(15, 30, 61, 0.06);
  margin-top: 0.25rem;
}

.hiw-expert-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--gray);
}

.hiw-expert-action svg {
  width: 14px;
  height: 14px;
  color: var(--teal);
  flex-shrink: 0;
}

/* Animações de entrada */
.hiw-step,
.hiw-connector {
  opacity: 0;
  transform: translateY(16px);
}

.hiw-flow.is-active .hiw-step,
.hiw-flow.is-active .hiw-connector {
  animation: hiwStepIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hiw-flow.is-active .hiw-step--inputs { animation-delay: 0.05s; }
.hiw-flow.is-active .hiw-connector--a { animation-delay: 0.15s; }
.hiw-flow.is-active .hiw-step--ai { animation-delay: 0.22s; }
.hiw-flow.is-active .hiw-connector--b { animation-delay: 0.32s; }
.hiw-flow.is-active .hiw-step--doc { animation-delay: 0.38s; }
.hiw-flow.is-active .hiw-connector--c { animation-delay: 0.48s; }
.hiw-flow.is-active .hiw-step--expert { animation-delay: 0.54s; }

@keyframes hiwStepIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hiw-input-item {
  opacity: 0;
  transform: translateX(-8px);
}

.hiw-flow.is-active .hiw-input-item {
  animation: hiwItemIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hiw-flow.is-active .hiw-input-item:nth-child(1) { animation-delay: 0.2s; }
.hiw-flow.is-active .hiw-input-item:nth-child(2) { animation-delay: 0.26s; }
.hiw-flow.is-active .hiw-input-item:nth-child(3) { animation-delay: 0.32s; }
.hiw-flow.is-active .hiw-input-item:nth-child(4) { animation-delay: 0.38s; }
.hiw-flow.is-active .hiw-input-item:nth-child(5) { animation-delay: 0.44s; }

@keyframes hiwItemIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.hiw-flow.is-active .hiw-doc-line {
  animation: hiwLineGrow 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hiw-flow.is-active .hiw-doc-line:nth-child(1) { animation-delay: 0.52s; }
.hiw-flow.is-active .hiw-doc-line:nth-child(2) { animation-delay: 0.58s; }
.hiw-flow.is-active .hiw-doc-line:nth-child(3) { animation-delay: 0.64s; }

.hiw-flow.is-active .hiw-doc-lines--2 .hiw-doc-line:nth-child(1) { animation-delay: 0.78s; }
.hiw-flow.is-active .hiw-doc-lines--2 .hiw-doc-line:nth-child(2) { animation-delay: 0.84s; }

@keyframes hiwLineGrow {
  to { transform: scaleX(1); }
}

.hiw-flow.is-active .hiw-doc-block {
  animation: hiwStepIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.7s forwards;
}

.hiw-flow.is-active .hiw-doc-footer {
  animation: hiwStepIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.88s forwards;
}

.hiw-expert-head,
.hiw-expert-action {
  opacity: 0;
  transform: translateY(8px);
}

.hiw-flow.is-active .hiw-expert-head {
  animation: hiwStepIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.62s forwards;
}

.hiw-flow.is-active .hiw-expert-action {
  animation: hiwStepIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hiw-flow.is-active .hiw-expert-action:nth-child(1) { animation-delay: 0.72s; }
.hiw-flow.is-active .hiw-expert-action:nth-child(2) { animation-delay: 0.78s; }
.hiw-flow.is-active .hiw-expert-action:nth-child(3) { animation-delay: 0.84s; }

.hiw-ai-ring {
  opacity: 0;
  transform: scale(0.92);
}

.hiw-flow.is-active .hiw-ai-ring {
  animation: hiwRingIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.28s forwards;
}

@keyframes hiwRingIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hiw-flow.is-active .hiw-step,
  .hiw-flow.is-active .hiw-connector,
  .hiw-flow.is-active .hiw-input-item,
  .hiw-flow.is-active .hiw-doc-line,
  .hiw-flow.is-active .hiw-doc-block,
  .hiw-flow.is-active .hiw-doc-footer,
  .hiw-flow.is-active .hiw-expert-head,
  .hiw-flow.is-active .hiw-expert-action,
  .hiw-flow.is-active .hiw-ai-ring {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .hiw-doc-line { transform: scaleX(1); }
  .hiw-ai-glow { animation: none; }
  .hiw-flow.is-active .hiw-connector-line { animation: none; }
}
