/* --- 3D TRANSACTION PIPELINE (OPTIMIZED) --- */

.perspective-container {
  perspective: 1000px; /* Reduced slightly for better mobile depth */
  overflow: hidden;
  /* Safari fix for 3D contexts */
  -webkit-perspective: 1000px;
}

.transaction-pipeline {
  position: relative;
  width: 100%;
  max-width: 700px;
  height: 300px;
  /* Centering logic */
  margin: 0 auto; 
  transform: rotateX(20deg) rotateY(20deg);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d; /* Essential for Safari */
}

/* 1. The Main Stream Path (The Timeline) */
.stream-path {
  position: absolute;
  top: 50%; left: 0;
  width: 100%; height: 6px; /* Slightly thinner for elegance */
  /* Increased opacity and added gradient for visibility */
  background: linear-gradient(90deg, 
    rgba(255,255,255,0) 0%, 
    rgba(255,255,255,0.1) 10%, 
    rgba(255,255,255,0.1) 90%, 
    rgba(255,255,255,0) 100%
  );
  /* Lifted to Z(1px) to prevent Z-fighting with background */
  transform: translateY(-50%) translateZ(1px); 
  border-radius: 5px;
  box-shadow: 0 0 15px rgba(222, 200, 142, 0.1); /* Slight brand glow */
  border: 1px solid rgba(255,255,255,0.05);
}

/* 2. The Gates */
.gate {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) translateZ(20px);
  transform-style: preserve-3d;
  width: 80px; height: 120px;
  display: flex; align-items: center; justify-content: center;
}

.input-gate { left: 5%; }
.validator-gate { left: 50%; transform: translateY(-50%) translateX(-50%) translateZ(20px); } /* Centered properly */
.ledger-gate { right: 5%; } /* Pinned to right */

/* Gate Visuals */
.gate-ring {
  width: 80px; height: 80px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  transform: rotateY(90deg);
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  background: rgba(0,0,0,0.3);
}

.ring-active {
  border-color: var(--brand);
  box-shadow: 0 0 30px rgba(222, 200, 142, 0.2);
}

.scanner-laser {
  position: absolute;
  top: 0; left: 40px;
  width: 2px; height: 100%;
  background: var(--brand);
  opacity: 0.8;
  box-shadow: 0 0 15px var(--brand);
  transform: rotateY(90deg); /* Ensure laser faces correct way */
}

.gate-label {
  position: absolute;
  bottom: -30px; 
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #666;
  white-space: nowrap;
  letter-spacing: 1px;
  /* Ensure label is legible, not flat */
  transform: rotateX(-20deg); 
}

/* 3. The Ledger Stack */
.ledger-stack {
  position: relative;
  width: 60px; height: 60px;
  transform-style: preserve-3d;
}

.ledger-block {
  width: 60px; height: 10px;
  background: #222;
  border: 1px solid #444;
  margin-bottom: 2px;
  /* Slight offset for 3D stack look */
  transform: translateZ(0px);
}

/* 4. The Data Particles (The Money/Invoices) */
.data-particle {
  position: absolute;
  top: 50%; 
  /* Start OFF SCREEN left */
  left: 0; 
  width: 40px; height: 25px;
  background: #1a1a1a;
  border: 1px solid #444;
  /* Crucial: GPU hint */
  will-change: transform, opacity;
  opacity: 0;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* Timing Stagger */
.p1 { animation: transaction-flow 4s infinite linear; animation-delay: 0s; }
.p2 { animation: transaction-flow 4s infinite linear; animation-delay: 1.33s; }
.p3 { animation: transaction-flow 4s infinite linear; animation-delay: 2.66s; }

/* THE FIX: 
   Use transform: translate3d(X, Y, Z) instead of 'left'.
   This assumes the container is roughly 700px wide.
   We use percentages of the PARENT container for X movement.
*/
@keyframes transaction-flow {
  0% { 
    opacity: 0; 
    transform: translate3d(0, -50%, 20px) rotateY(90deg);
    border-color: #555;
    background: #1a1a1a;
  }
  
  5% { 
    opacity: 1; 
  }

  /* Approaching Middle (Validator) */
  40% {
    transform: translate3d(300px, -50%, 20px) rotateY(90deg) scale(1);
    background: #1a1a1a;
    border-color: #555;
  }

  /* Hit Validator */
  50% { 
    transform: translate3d(350px, -50%, 20px) rotateY(90deg) scale(1.3);
    background: var(--brand); 
    border-color: #fff; 
    box-shadow: 0 0 30px var(--brand);
  }

  /* Leaving Validator */
  60% {
    transform: translate3d(400px, -50%, 20px) rotateY(90deg) scale(1);
  }

  /* Entering Ledger */
  90% { 
    opacity: 1;
    transform: translate3d(650px, -50%, 20px) rotateY(90deg) scale(0.8);
    background: var(--brand);
  }
  
  100% { 
    opacity: 0; 
    transform: translate3d(680px, -50%, 20px) rotateY(90deg) scale(0.1);
  }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .transaction-pipeline {
    /* Scale down the whole stage for mobile */
    transform: scale(0.55) rotateX(20deg) translateY(50px);
  }
}