/* ============================================================
   THE CYCLE — methodology section
   Shares the design language of the hero (css/hero.css vars):
   same background, grid, glass, mono labels, cyan glow.
   Structure: header → node flow → return loop back to PROBLEM.
   Animation states are driven by js/cycle.js:
   - .revealed on .cycle      → staggered entrance
   - .current on a .c-node    → the pulse travels the loop
   - .returning on .cycle     → the return curve lights up
   ============================================================ */

.cycle {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 110px 32px 140px;
}

/* faint engineering grid, same treatment as the monitor stage */
.cycle::before {
  content: '';
  position: absolute;
  inset: 40px 0 40px;
  background:
    linear-gradient(rgba(125, 180, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 180, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 55%, black 20%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 55%, black 20%, transparent 100%);
  pointer-events: none;
}

.cycle-inner { position: relative; }

/* ---------- header ---------- */

.cycle-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--cyan);
}

.cycle-eyebrow .eyebrow-dim { color: var(--muted); letter-spacing: 0.14em; }

.cycle-title {
  margin-top: 22px;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--text);
}

.cycle-title-grad {
  background: linear-gradient(90deg, #7dd3fc, #38bdf8, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cycle-sub {
  margin-top: 18px;
  max-width: 560px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--muted);
}

/* entrance: header pieces rise in sequence */
.cycle-eyebrow,
.cycle-title,
.cycle-sub {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.cycle.revealed .cycle-eyebrow { opacity: 1; transform: none; }
.cycle.revealed .cycle-title   { opacity: 1; transform: none; transition-delay: 0.12s; }
.cycle.revealed .cycle-sub     { opacity: 1; transform: none; transition-delay: 0.24s; }

/* ---------- stage ---------- */

.cycle-stage {
  position: relative;
  margin-top: 76px;
  will-change: transform;
}

.cycle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* the forward flow line, drawn on reveal, with a travelling light */
.cycle-line {
  position: absolute;
  left: 2%;
  right: 2%;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: rgba(125, 180, 255, 0.14);
  border-radius: 2px;
  overflow: hidden;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.45s;
}

.cycle.revealed .cycle-line { transform: scaleX(1); }

.cycle-line-flow {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -160px;
  width: 160px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.95), transparent);
  box-shadow: 0 0 12px var(--cyan-glow);
  opacity: 0;
}

.cycle.revealed .cycle-line-flow {
  opacity: 1;
  animation: cycleLineFlow 4.2s linear 1.4s infinite;
}

@keyframes cycleLineFlow {
  from { left: -160px; }
  to   { left: 100%; }
}

/* ---------- nodes ---------- */

.c-node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px;
  border-radius: 100px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
  background: linear-gradient(160deg, rgba(10, 13, 19, 0.92), rgba(6, 8, 12, 0.92));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: color 0.4s, border-color 0.4s, box-shadow 0.4s;
  white-space: nowrap;
}

.c-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(125, 180, 255, 0.3);
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

/* the pulse resting on a node */
.c-node.current {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 4px rgba(56, 189, 248, 0.08),
    0 0 28px rgba(56, 189, 248, 0.22);
}

.c-node.current .c-dot {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* entrance stagger */
.c-node {
  opacity: 0;
  transform: translateY(16px);
}

.cycle.revealed .c-node {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.4s, border-color 0.4s, box-shadow 0.4s;
}

.cycle.revealed .c-node[data-node="0"] { transition-delay: 0.35s, 0.35s, 0s, 0s, 0s; }
.cycle.revealed .c-node[data-node="1"] { transition-delay: 0.5s, 0.5s, 0s, 0s, 0s; }
.cycle.revealed .c-node[data-node="2"] { transition-delay: 0.65s, 0.65s, 0s, 0s, 0s; }
.cycle.revealed .c-node[data-node="3"] { transition-delay: 0.8s, 0.8s, 0s, 0s, 0s; }
.cycle.revealed .c-node[data-node="4"] { transition-delay: 0.95s, 0.95s, 0s, 0s, 0s; }

/* ---------- the OUTPUT node: hero of the row ---------- */

.c-output {
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 18px 30px;
  min-width: 220px;
  border-radius: 18px;
  border-color: rgba(56, 189, 248, 0.35);
  /* same rendered colors as before, but fully opaque so the
     workflow line terminates at the card instead of showing through */
  background: linear-gradient(165deg, #07121a, #06080d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 44px rgba(56, 189, 248, 0.14);
}

.c-output-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--cyan);
}

.c-word {
  display: block;
  font-family: var(--font);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
  background: linear-gradient(90deg, #7dd3fc, #38bdf8, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.c-word.word-in { animation: wordMorph 0.6s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes wordMorph {
  from { opacity: 0; transform: translateY(12px) scale(0.96); filter: blur(7px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* the card breathes when a new output lands */
.c-output.pop { animation: outputPop 0.9s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes outputPop {
  0%   { transform: scale(1); }
  30%  {
    transform: scale(1.04);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 0 0 5px rgba(56, 189, 248, 0.1),
      0 0 70px rgba(56, 189, 248, 0.35);
    border-color: rgba(56, 189, 248, 0.7);
  }
  100% { transform: scale(1); }
}

/* ---------- return loop: INSIGHT → PROBLEM ---------- */

.cycle-loop {
  position: relative;
  height: 84px;
  margin: 10px 2% 0;
  opacity: 0;
  transition: opacity 0.9s ease 1.15s;
}

.cycle.revealed .cycle-loop { opacity: 1; }

.cycle-loop svg:first-of-type {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.loop-base {
  stroke: rgba(125, 180, 255, 0.22);
  stroke-width: 1.5;
  stroke-dasharray: 5 7;
}

.loop-flow {
  stroke: var(--cyan);
  stroke-width: 1.5;
  stroke-dasharray: 46 1500;
  stroke-dashoffset: 0;
  opacity: 0.85;
  filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.7));
  animation: loopTravel 5.2s linear infinite;
}

@keyframes loopTravel {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -1546; }
}

.loop-arrow {
  position: absolute;
  left: calc(1.7% - 7px);
  top: 4px;
  color: rgba(56, 189, 248, 0.7);
}

.cycle-loop-label {
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.26em;
  color: var(--dim);
  white-space: nowrap;
  transition: color 0.5s, text-shadow 0.5s;
}

/* the return moment: curve + label brighten together */
.cycle.returning .cycle-loop-label {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.4);
}

.cycle.returning .loop-base { stroke: rgba(56, 189, 248, 0.35); transition: stroke 0.5s; }

/* mobile-only closing chip */
.cycle-loop-mobile {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--dim);
  transition: color 0.5s;
}

.cycle.returning .cycle-loop-mobile { color: var(--cyan); }

/* ============ MOBILE ============ */

@media (max-width: 1080px) {
  .cycle { padding: 80px 16px 96px; }

  .cycle-stage { margin-top: 52px; }

  .cycle-row {
    flex-direction: column;
    gap: 20px;
  }

  /* vertical spine replaces the horizontal line */
  .cycle-line {
    left: 50%;
    right: auto;
    top: 4%;
    bottom: 4%;
    height: auto;
    width: 2px;
    margin: 0 0 0 -1px;
    transform: scaleY(0);
    transform-origin: top center;
  }

  .cycle.revealed .cycle-line { transform: scaleY(1); }

  .cycle-line-flow {
    left: 0;
    right: 0;
    width: auto;
    top: -160px;
    bottom: auto;
    height: 160px;
    background: linear-gradient(180deg, transparent, rgba(56, 189, 248, 0.95), transparent);
  }

  .cycle.revealed .cycle-line-flow { animation: cycleLineFlowV 4.2s linear 1.4s infinite; }

  .c-node { padding: 12px 22px; }
  .c-output { min-width: 200px; padding: 16px 26px; }
  .c-word { font-size: 17px; }

  .cycle-loop { display: none; }
  .cycle-loop-mobile { display: flex; }
}

/* phones: breathing room under the INSIGHT node (matches the 20px node gap) */
@media (max-width: 640px) {
  .cycle-loop-mobile { margin-top: 20px; }
}

@keyframes cycleLineFlowV {
  from { top: -160px; }
  to   { top: 100%; }
}

/* ============ REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  .cycle-line-flow, .loop-flow { animation: none !important; }
  .cycle-eyebrow, .cycle-title, .cycle-sub, .c-node, .cycle-line, .cycle-loop {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
