/* ==========================================================================
   WORKFLOW CANVAS — TerraGrow
   A) Hero canvas : flow horizontal, connecteurs DOM, animation auto-loop
   B) Section workflow : vertical, scroll-triggered
   ========================================================================== */

/* ==========================================================================
   A — HERO CANVAS
   ========================================================================== */

.wf-hero-canvas {
  position: relative;
  z-index: 3;
  background-color: #F0F1F5;
  background-image: radial-gradient(circle, #CBCED6 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 16px 16px 0 0;
  border: 1px solid rgba(209,213,219,.4);
  border-bottom: none;
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  overflow: hidden;
  padding: 48px 32px 40px;
}

.wf-hero-canvas__flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 1000px;
  margin: 0 auto;
}

/* --- Card (Attio-style: wide, spacious, clean) --- */
.wf-hero-canvas__card {
  flex: 1 1 0;
  min-width: 120px;
  background: #fff;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.03);
  position: relative;
  overflow: visible;
  opacity: 0.45;
  transition: opacity 0.4s cubic-bezier(.22,1,.36,1),
              border-color 0.3s ease,
              box-shadow 0.3s ease;
}

.wf-hero-canvas__card.is-active {
  opacity: 1;
  border-color: var(--accent, #3B76F6);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(59,118,246,.1);
}

.wf-hero-canvas__card.is-done {
  opacity: 1;
  border-color: #86EFAC;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.03);
}

/* Card icon — Attio: 36px rounded square, colored bg */
.wf-hero-canvas__icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wf-hero-canvas__icon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.wf-hero-canvas__icon--blue { background: #EBF2FE; color: #3B76F6; }
.wf-hero-canvas__icon--green { background: #DCFCE7; color: #16A34A; }
.wf-hero-canvas__icon--purple { background: #F3E8FF; color: #9333EA; }
.wf-hero-canvas__icon--amber { background: #FEF3CD; color: #D97706; }
.wf-hero-canvas__icon--rose { background: #FFE4E6; color: #E11D48; }

/* Card text */
.wf-hero-canvas__title {
  font-size: 14px;
  font-weight: 600;
  color: #0A1A3C;
  line-height: 1.3;
  margin-bottom: 2px;
}

.wf-hero-canvas__desc {
  font-size: 12px;
  color: #9CA3AF;
  line-height: 1.35;
}

/* Badge above card — Attio: floating pill with colored dot */
.wf-hero-canvas__badge {
  position: absolute;
  top: -24px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: #F3F4F6;
  color: #9CA3AF;
  white-space: nowrap;
}

.wf-hero-canvas__badge.visible {
  opacity: 1;
  transform: translateY(0);
}

.wf-hero-canvas__badge[data-bstate="trigger"] { background: #EBF2FE; color: #3B76F6; }
.wf-hero-canvas__badge[data-bstate="running"] { background: #FEF3CD; color: #92640D; }
.wf-hero-canvas__badge[data-bstate="completed"] { background: #DCFCE7; color: #166534; }

.wf-hero-canvas__badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Wire connector (DOM element between cards) --- */
.wf-hero-canvas__wire {
  flex: 0 0 48px;
  height: 2px;
  position: relative;
  display: flex;
  align-items: center;
}

/* Gray background track */
.wf-hero-canvas__wire-bg {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: 1px;
}

/* Blue fill that animates from 0 to 100% width */
.wf-hero-canvas__wire-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: var(--accent, #3B76F6);
  border-radius: 1px;
  transition: width 0.5s cubic-bezier(.22,1,.36,1);
}

.wf-hero-canvas__wire-fill.traced {
  width: 100%;
  box-shadow: 0 0 8px rgba(59,118,246,.35);
}

/* Dot at end of wire when traced */
.wf-hero-canvas__wire-dot {
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #3B76F6);
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 0 6px rgba(59,118,246,.5);
  z-index: 1;
}

.wf-hero-canvas__wire-fill.traced ~ .wf-hero-canvas__wire-dot {
  opacity: 1;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .wf-hero-canvas__card {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .wf-hero-canvas__wire-fill {
    width: 100% !important;
    transition: none !important;
    box-shadow: none !important;
  }
  .wf-hero-canvas__wire-dot { opacity: 1 !important; }
  .wf-hero-canvas__badge { opacity: 1 !important; transform: none !important; }
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .wf-hero-canvas { padding: 36px 20px 28px; }
  .wf-hero-canvas__card { padding: 12px 14px; gap: 10px; border-radius: 10px; }
  .wf-hero-canvas__icon { width: 30px; height: 30px; min-width: 30px; border-radius: 8px; }
  .wf-hero-canvas__icon svg { width: 15px; height: 15px; }
  .wf-hero-canvas__title { font-size: 12px; }
  .wf-hero-canvas__desc { display: none; }
  .wf-hero-canvas__wire { flex: 0 0 24px; }
  .wf-hero-canvas__badge { font-size: 9px; padding: 2px 7px; top: -20px; }
}

@media (max-width: 640px) {
  .wf-hero-canvas { padding: 32px 12px 24px; }
  .wf-hero-canvas__flow {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .wf-hero-canvas__flow::-webkit-scrollbar { display: none; }
  .wf-hero-canvas__card { flex: 0 0 130px; min-width: 130px; padding: 10px 12px; }
  .wf-hero-canvas__wire { flex: 0 0 16px; }
  .wf-hero-canvas__icon { width: 26px; height: 26px; min-width: 26px; }
}

@media (max-width: 480px) {
  .wf-hero-canvas { display: none; }
}


/* ==========================================================================
   B — SECTION WORKFLOW (vertical, scroll-triggered)
   ========================================================================== */

.wf { position: relative; padding: 0; }

.wf__canvas {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
  background-image: radial-gradient(circle, rgba(209,213,219,.35) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: center;
  border-radius: 16px;
  border: 1px solid var(--border, #E5E7EB);
  padding: 40px 28px;
  min-height: 200px;
  background-color: rgba(248,249,250,.5);
}

.wf__flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.wf__connector {
  width: 24px; height: 32px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.wf__connector svg { width: 24px; height: 32px; overflow: visible; }

.wf__wire {
  stroke: var(--border, #D1D5DB); stroke-width: 2; fill: none; stroke-linecap: round;
  stroke-dasharray: var(--len, 36); stroke-dashoffset: var(--len, 36);
  transition: stroke-dashoffset 0.4s cubic-bezier(.22,1,.36,1), stroke 0.3s ease;
}

.wf__wire.traced { stroke-dashoffset: 0; stroke: var(--accent, #3B76F6); }

.wf__wire-arrow { fill: var(--border, #D1D5DB); transition: fill 0.3s ease; }
.wf__wire.traced + .wf__wire-arrow, .traced ~ .wf__wire-arrow { fill: var(--accent, #3B76F6); }

/* Node card */
.wf-node {
  width: 100%; max-width: 540px;
  background: #fff; border: 1px solid var(--border, #E5E7EB);
  border-left: 3px solid var(--border, #E5E7EB);
  border-radius: 10px; padding: 18px 22px 18px 20px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
  position: relative; opacity: 0.4;
  transform: translateY(4px) scale(0.98);
  transition: opacity 0.5s cubic-bezier(.22,1,.36,1), transform 0.5s cubic-bezier(.22,1,.36,1),
              border-color 0.3s ease, box-shadow 0.3s ease;
}

.wf-node__num {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #EBF2FE, #DBEAFE);
  color: var(--accent, #3B76F6); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.3s ease, color 0.3s ease;
}

.wf-node__content { flex: 1; min-width: 0; }
.wf-node__title { font-size: 14px; font-weight: 600; color: #0A1A3C; margin-bottom: 2px; line-height: 1.3; }
.wf-node__roles { font-size: 12px; line-height: 1.5; color: #6B7280; }
.wf-node__roles strong { font-weight: 600; color: #0A1A3C; }

.wf-node__badge {
  flex-shrink: 0; font-size: 11px; font-weight: 600; padding: 4px 12px;
  border-radius: 9999px; white-space: nowrap; align-self: center;
  transition: background 0.3s ease, color 0.3s ease;
}

.wf-node__badge[data-badge="idle"] { background: #F3F4F6; color: #9CA3AF; }
.wf-node__badge[data-badge="trigger"] { background: #EBF2FE; color: #3B76F6; }
.wf-node__badge[data-badge="running"] { background: #FEF3CD; color: #92640D; }
.wf-node__badge[data-badge="completed"] { background: #DCFCE7; color: #166534; }

/* Node states */
.wf-node[data-state="triggered"] { opacity: 1; transform: none; border-left-color: #3B76F6; }
.wf-node[data-state="running"] {
  opacity: 1; transform: none; border-left-color: #F2A32B;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(59,118,246,.08);
}
.wf-node[data-state="running"]::after {
  content: ''; position: absolute; inset: -3px; border-radius: 13px;
  border: 2px solid rgba(59,118,246,.15); pointer-events: none;
  opacity: 0; animation: wfGlow 2s ease-in-out infinite;
}
@keyframes wfGlow { 0%, 100% { opacity: .15; } 50% { opacity: .5; } }
.wf-node[data-state="running"] .wf-node__num { background: linear-gradient(135deg, #FEF3CD, #FDE68A); color: #92640D; }
.wf-node[data-state="completed"] { opacity: 1; transform: none; border-left-color: #16A34A; }
.wf-node[data-state="completed"] .wf-node__num { background: linear-gradient(135deg, #DCFCE7, #BBF7D0); color: #166534; }

.wf__loop { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; font-size: 12px; color: #9CA3AF; font-weight: 500; }
.wf__loop svg { width: 14px; height: 14px; color: #3B76F6; }
.wf__microcopy { text-align: center; font-size: 14px; font-style: italic; color: #6B7280; max-width: 520px; margin: 24px auto 0; line-height: 1.6; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wf-node { opacity: 1 !important; transform: none !important; transition: none !important; border-left-color: #16A34A !important; }
  .wf-node[data-state]::after { animation: none !important; display: none; }
  .wf__wire { stroke-dashoffset: 0 !important; stroke: #3B76F6 !important; transition: none !important; }
  .wf__wire-arrow { fill: #3B76F6 !important; }
}

/* Responsive */
@media (max-width: 768px) {
  .wf__canvas { padding: 28px 14px; max-width: 100%; border-radius: 12px; }
  .wf-node { padding: 14px 14px 14px 12px; gap: 10px; border-radius: 8px; }
  .wf-node__num { width: 26px; height: 26px; font-size: 11px; }
  .wf-node__title { font-size: 13px; }
  .wf-node__roles { font-size: 11px; }
  .wf-node__badge { font-size: 10px; padding: 3px 8px; }
  .wf__connector { height: 24px; } .wf__connector svg { height: 24px; }
}

@media (max-width: 480px) {
  .wf__canvas { padding: 20px 10px; border-radius: 8px; }
  .wf-node__roles { display: none; }
  .wf__microcopy { font-size: 13px; }
}
