.document-flow {
  --flow-ink: #1a1a1a;
  --flow-muted: #666;
  --flow-soft: #f5f5f5;
  --flow-border: #e5e5e5;
  --flow-brand: #f97316;
  --flow-brand-dark: #c2410c;
  --flow-brand-soft: #fff7ed;
  --flow-whatsapp: #25d366;
  --flow-dashboard: #0a0a0a;
  position: relative;
  width: 100%;
  max-width: 42.5rem;
  min-height: 448px;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(180deg, rgb(255 247 237 / 0.5), rgb(250 250 250 / 0.18));
  isolation: isolate;
}

@media (min-width: 768px) {
  .document-flow-hero-grid {
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  }
}

.document-flow::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgb(249 115 22 / 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgb(10 10 10 / 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  opacity: 0.85;
}

.document-flow:focus-visible {
  outline: 2px solid var(--flow-ink);
  outline-offset: 4px;
}

.document-flow__canvas {
  position: relative;
  display: grid;
  min-height: 448px;
  grid-template-columns: 0.72fr 0.48fr 1.9fr;
  align-items: center;
  gap: clamp(0.75rem, 3vw, 1.75rem);
  padding: clamp(1rem, 3vw, 1.5rem);
}

.document-flow__lane {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  z-index: 2;
}

.document-flow__document-stage {
  position: relative;
  display: grid;
  width: min(9rem, 32vw);
  height: 11.25rem;
  place-items: center;
}

.document-flow__doc {
  position: absolute;
  display: grid;
  place-items: center;
  opacity: 0;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  z-index: 3;
}

.document-flow__doc.is-active {
  opacity: 1;
}

.document-flow__doc svg {
  display: block;
  width: min(7.75rem, 26vw);
  max-height: 10.25rem;
  overflow: visible;
}

.document-flow__doc[data-document-type="id-card"] svg {
  width: min(9.75rem, 32vw);
}

.document-flow .doc-body,
.document-flow .doc-checkbox,
.document-flow .doc-stamp {
  fill: #fff;
  stroke: var(--flow-ink);
  stroke-width: 2;
}

.document-flow .doc-header,
.document-flow .doc-line,
.document-flow .doc-total,
.document-flow .doc-chart-bar,
.document-flow .doc-photo-detail {
  fill: var(--flow-ink);
}

.document-flow .doc-muted {
  fill: var(--flow-muted);
}

.document-flow .doc-light {
  fill: #e6e6e6;
  stroke: var(--flow-ink);
  stroke-width: 2;
}

.document-flow .doc-chart {
  fill: #e6e6e6;
  stroke: var(--flow-ink);
  stroke-width: 2;
}

.document-flow .doc-divider,
.document-flow .doc-signature {
  stroke: var(--flow-ink);
  stroke-width: 2;
  stroke-linecap: round;
}

.document-flow .doc-stamp-ring {
  fill: none;
  stroke: var(--flow-muted);
  stroke-width: 2;
}

.document-flow__scanner {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  z-index: 5;
  height: 3px;
  border-radius: 999px;
  background: var(--flow-brand);
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 0.9),
    0 0 16px rgb(249 115 22 / 0.78),
    0 0 36px rgb(249 115 22 / 0.3);
  opacity: 0;
  transform: translateY(-5rem);
  will-change: transform, opacity;
}

.document-flow__scanner::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -2rem;
  height: 2rem;
  background: linear-gradient(to bottom, transparent, rgb(249 115 22 / 0.12));
}

.document-flow__processor-node {
  position: relative;
  display: grid;
  width: clamp(4rem, 10vw, 5rem);
  height: clamp(4rem, 10vw, 5rem);
  place-items: center;
  border: 1px solid rgb(37 211 102 / 0.32);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 16px 36px -24px rgb(37 211 102 / 0.9);
  transform-origin: 50% 50%;
  will-change: transform;
}

.document-flow__processor-icon {
  width: 76%;
  height: 76%;
  overflow: visible;
}

.document-flow__processor-chip {
  fill: var(--flow-whatsapp);
}

.document-flow__processor-core {
  fill: #fff;
}

.document-flow__processor-pin {
  stroke: var(--flow-whatsapp);
  stroke-width: 3;
  stroke-linecap: round;
}

.document-flow__pulse {
  position: absolute;
  width: clamp(4.75rem, 11vw, 5.75rem);
  height: clamp(4.75rem, 11vw, 5.75rem);
  border: 1px solid rgb(37 211 102 / 0.32);
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.72);
}

.document-flow__dashboard {
  width: min(100%, 21.25rem);
  overflow: hidden;
  border: 1px solid var(--flow-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 44px -30px rgb(10 10 10 / 0.38);
  transform-origin: 50% 50%;
  will-change: transform;
}

.document-flow__dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--flow-border);
  background: #fafafa;
  padding: 0.625rem 0.75rem;
}

.document-flow__dashboard-logo {
  height: 1.375rem;
  width: auto;
  max-width: 5rem;
}

.document-flow__window-dots {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.375rem;
}

.document-flow__window-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #d4d4d4;
}

.document-flow__record {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.625rem;
  margin: 0.75rem 0.75rem 0.625rem;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  background: var(--flow-brand-soft);
  padding: 0.75rem;
}

.document-flow__record-icon {
  display: inline-grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  background: #fff;
  color: var(--flow-brand-dark);
}

.document-flow__record-icon svg {
  width: 1.65rem;
  height: 1.65rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.document-flow__document-title {
  display: block;
  max-width: 100%;
  color: var(--flow-dashboard);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.125rem;
  text-align: left;
  text-overflow: ellipsis;
}

.document-flow__analysis-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.375rem;
  padding: 0 0.75rem 0.75rem;
}

.document-flow__analysis-chip {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #ededed;
  border-radius: 10px;
  background: #fff;
  color: var(--flow-ink);
  opacity: 0;
  transform: translateY(0.5rem) scale(0.72);
  will-change: transform, opacity;
}

.document-flow__analysis-chip svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.document-flow__analysis-chip.is-highlighted {
  color: var(--flow-brand-dark);
  background: var(--flow-brand-soft);
  border-color: #fed7aa;
}

.document-flow__connector {
  position: absolute;
  top: 50%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgb(37 211 102 / 0.5), transparent);
  transform: translateY(-50%);
  z-index: 1;
}

.document-flow__connector-left {
  left: 24%;
  width: 21%;
}

.document-flow__connector-right {
  right: 27%;
  width: 20%;
}

.document-flow.is-reduced-motion .document-flow__scanner,
.document-flow.is-reduced-motion .document-flow__pulse {
  display: none;
}

.document-flow.is-reduced-motion .document-flow__doc:not(.is-active) {
  display: none;
}

.document-flow.is-reduced-motion .document-flow__analysis-chip {
  opacity: 1;
  transform: none;
}

@media (max-width: 720px) {
  .document-flow {
    min-height: 570px;
    max-width: 100%;
  }

  .document-flow__canvas {
    min-height: 512px;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
    gap: 0.875rem;
    padding: 1rem;
  }

  .document-flow__document-stage {
    width: min(10rem, 46vw);
    height: 10.5rem;
  }

  .document-flow__doc svg {
    width: min(8rem, 38vw);
    max-height: 9.5rem;
  }

  .document-flow__doc[data-document-type="id-card"] svg {
    width: min(10rem, 50vw);
  }

  .document-flow__dashboard {
    width: min(100%, 20rem);
  }

  .document-flow__analysis-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .document-flow__connector {
    left: 50%;
    width: 1px;
    height: 4.5rem;
    background: linear-gradient(to bottom, transparent, rgb(37 211 102 / 0.5), transparent);
    transform: translateX(-50%);
  }

  .document-flow__connector-left {
    top: 32%;
  }

  .document-flow__connector-right {
    top: 58%;
    right: auto;
  }
}

@media (max-width: 420px) {
  .document-flow__dashboard-logo {
    max-width: 4.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .document-flow__scanner,
  .document-flow__pulse {
    display: none;
  }

  .document-flow__doc,
  .document-flow__whatsapp-node,
  .document-flow__dashboard,
  .document-flow__analysis-chip {
    transition: none;
    animation: none;
    transform: none;
  }

  .document-flow__doc:not(.is-active) {
    display: none;
  }
}
