/* ---------- keyframes ---------- */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  70% {
    transform: scale(1.01);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(95, 207, 142, 0.34);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(95, 207, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(95, 207, 142, 0);
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes sway {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-7px) rotate(4deg);
  }
}

@keyframes tool-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(8deg);
  }
}

@keyframes sheen {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(220%);
  }
}

@keyframes leaf-burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.4) rotate(0deg);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--bx, 40px), var(--by, -70px)) scale(1) rotate(var(--br, 160deg));
  }
}

/* ---------- entrance utilities ---------- */

.anim-up {
  animation: fade-up 0.5s cubic-bezier(0.22, 0.68, 0.32, 1) both;
}

.anim-in {
  animation: fade-in 0.4s ease both;
}

.anim-pop {
  animation: pop-in 0.34s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.d1 {
  animation-delay: 0.06s;
}
.d2 {
  animation-delay: 0.12s;
}
.d3 {
  animation-delay: 0.18s;
}
.d4 {
  animation-delay: 0.24s;
}
.d5 {
  animation-delay: 0.3s;
}
.d6 {
  animation-delay: 0.36s;
}

.caret {
  animation: blink 1.05s steps(1) infinite;
}

.spin {
  animation: spin 0.9s linear infinite;
  transform-origin: center;
}

.pulse {
  animation: pulse-ring 2s ease-out infinite;
}

.sway {
  animation: sway 4.2s ease-in-out infinite;
}

/* ---------- deploy stage ---------- */

.deploy {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 34px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: linear-gradient(140deg, rgba(30, 44, 39, 0.85) 0%, rgba(19, 27, 24, 0.95) 70%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

@media (max-width: 900px) {
  .deploy {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px;
  }
}

.deploy-stage {
  position: relative;
  aspect-ratio: 1;
  max-height: 340px;
  display: grid;
  place-items: center;
}

.deploy-ring {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100%, 300px);
  height: min(100%, 300px);
}

.deploy-ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.deploy-ring .track {
  stroke: rgba(255, 255, 255, 0.08);
}

.deploy-ring .value {
  stroke: url(#deployGrad);
  transition: stroke-dashoffset 0.6s cubic-bezier(0.3, 0.7, 0.3, 1);
  transform: rotate(-90deg);
  transform-origin: center;
}

.deploy-core {
  position: relative;
  display: grid;
  place-items: center;
  gap: 2px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, rgba(95, 207, 142, 0.22), rgba(9, 16, 13, 0.9) 70%);
  border: 1px solid var(--accent-line);
  text-align: center;
}

.deploy-pct {
  font-size: 1.7rem;
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.deploy-pct-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.deploy-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.deploy-tool {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(16, 24, 20, 0.92);
  color: var(--text-3);
  box-shadow: var(--shadow);
  transition: color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, background 0.3s ease;
}

.deploy-tool.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(24, 44, 34, 0.95);
  animation: tool-bob 1.5s ease-in-out infinite;
}

.deploy-tool.is-done {
  color: var(--accent-2);
  border-color: var(--accent-line);
}

.deploy-log {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 300px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.deploy-log-line {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--text-3);
  animation: fade-up 0.34s ease both;
}

.deploy-log-line.is-active {
  color: var(--text);
}

.deploy-log-line.is-done {
  color: var(--text-2);
}

.deploy-log-line .mark {
  display: grid;
  place-items: center;
  height: 18px;
  color: var(--accent);
}

.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.burst i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  color: var(--accent);
  animation: leaf-burst 1.15s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.sheen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.sheen::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 42%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  animation: sheen 2.6s ease-in-out infinite;
}

/* ---------- hero terminal preview ---------- */

.hero-visual {
  position: relative;
}

.hero-visual .terminal {
  transform: perspective(1400px) rotateY(-6deg) rotateX(2deg);
}

.hero-visual .terminal-body {
  height: 296px;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }

  #leaf-canvas {
    display: none;
  }

  .hero-visual .terminal {
    transform: none;
  }
}
