/* ==========================================================================
   AGRIYANA - "The Agriyana Line"

   The signature section. A closed-loop supply diagram in the architecture
   -diagram idiom, drawn out of farm artefacts instead of cloud icons.
   Nodes are real HTML buttons on a CSS grid; the wires are one SVG layer
   behind them whose paths are computed from live node geometry, so the whole
   thing reflows properly instead of being a fixed drawing.
   ========================================================================== */

.flow {
  --node-h: 106px;
  --wire: #234834;
  --wire-live: var(--band-sprout);
  position: relative;
  overflow: hidden;
}

.flow-head {
  display: grid;
  gap: var(--s-6);
  align-items: end;
  margin-bottom: var(--s-9);
}
@media (min-width: 900px) {
  .flow-head { grid-template-columns: minmax(0, 1fr) auto; }
}

.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  color: var(--band-fg-muted);
}
.flow-legend span { display: inline-flex; align-items: center; gap: 7px; }
.flow-legend i {
  width: 16px; height: 2px;
  border-radius: 2px;
  background: var(--wire);
  flex: none;
}
.flow-legend .lg-out i { background: var(--band-sprout); }
.flow-legend .lg-in  i { background: var(--band-accent); }
.flow-legend .lg-cold i { background: var(--band-chill); }

/* ------------------------------------------------------------------ stage */
.flow-stage {
  position: relative;
  display: grid;
  gap: var(--s-5);
  grid-template-columns: 1fr;
}

.flow-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: var(--z-base);
}

.wire {
  fill: none;
  stroke: var(--wire);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.wire.is-drawn { opacity: 1; }
.wire.is-return { stroke-dasharray: 3 7; opacity: 0; }
.wire.is-return.is-drawn { opacity: .85; }
.wire.wire-head { stroke-dasharray: none; }

/* the animated overlay stroke that traces each wire once, on reveal */
.wire-trace {
  fill: none;
  stroke: var(--band-sprout);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .95;
}
.wire-trace.is-input { stroke: var(--band-accent); }

.packet {
  fill: var(--band-sprout);
  filter: drop-shadow(0 0 6px rgba(141, 198, 63, .85));
  opacity: 0;
}
.packet.is-input { fill: var(--band-accent); filter: drop-shadow(0 0 6px rgba(224, 166, 68, .85)); }
.packet.is-on { opacity: 1; }

/* ------------------------------------------------------------------ node */
.flow-node {
  position: relative;
  z-index: var(--z-raised);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: var(--node-h);
  padding: var(--s-4);
  text-align: left;
  text-decoration: none;
  background: var(--band-bg-2);
  border: 1px solid var(--band-border);
  border-radius: var(--r-card);
  color: var(--band-fg);
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 460ms var(--ease-out),
              transform 460ms var(--ease-out),
              border-color var(--dur-1) var(--ease-out),
              background-color var(--dur-1) var(--ease-out);
}
.flow-node.is-on { opacity: 1; transform: none; }

.flow-node::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid transparent;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
  pointer-events: none;
}
.flow-node:hover,
.flow-node:focus-visible,
.flow-node.is-active {
  background: #0E2718;
  border-color: var(--node-tint, var(--band-sprout));
}
.flow-node:hover::before,
.flow-node:focus-visible::before,
.flow-node.is-active::before {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--node-tint, #8DC63F) 18%, transparent);
}
.flow-node:focus-visible { outline: none; }

.flow-node[data-tint='chill'] { --node-tint: var(--band-chill); }
.flow-node[data-tint='gold']  { --node-tint: var(--band-accent); }

.fn-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }

.fn-step {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: var(--tr-mono);
  color: var(--band-fg-muted);
}
.fn-icon {
  width: 22px; height: 22px;
  stroke: var(--node-tint, var(--band-sprout));
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.fn-label {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.24;
}
.fn-sub {
  font-size: 11px;
  line-height: 1.35;
  color: var(--band-fg-muted);
}

/* ------------------------------------------------------------------ readout */
.flow-readout {
  position: relative;
  z-index: var(--z-raised);
  margin-top: var(--s-8);
  display: grid;
  gap: var(--s-5);
  padding: var(--s-6);
  background: var(--band-bg-2);
  border: 1px solid var(--band-border);
  border-radius: var(--r-panel);
  border-left: 3px solid var(--band-sprout);
  min-height: 132px;
  align-content: start;
}
@media (min-width: 860px) {
  .flow-readout { grid-template-columns: 210px minmax(0, 1fr) auto; align-items: center; }
}
.flow-readout[data-tint='chill'] { border-left-color: var(--band-chill); }
.flow-readout[data-tint='gold']  { border-left-color: var(--band-accent); }

.fr-key {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--band-fg);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.fr-key .ico { color: var(--band-sprout); }
.flow-readout[data-tint='chill'] .fr-key .ico { color: var(--band-chill); }
.flow-readout[data-tint='gold'] .fr-key .ico { color: var(--band-accent); }

.fr-body { color: var(--band-fg-muted); font-size: var(--t-md); line-height: 1.5; margin: 0; max-width: 62ch; }
.fr-body b { color: var(--band-fg); font-weight: 600; }

.fr-go {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 1px solid var(--band-border);
  border-radius: var(--r-ctl);
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--band-fg);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.fr-go:hover { background: rgba(255, 255, 255, .07); border-color: var(--band-fg-muted); color: var(--band-fg); }

/* ------------------------------------------------------------------ desktop loop layout */
@media (min-width: 1100px) {
  .flow-stage {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: auto 112px auto;
    gap: var(--s-6) clamp(26px, 4vw, 66px);
  }
  .flow-node[data-node='farm']      { grid-area: 1 / 1; }
  .flow-node[data-node='harvest']   { grid-area: 1 / 2; }
  .flow-node[data-node='grading']   { grid-area: 1 / 3; }
  .flow-node[data-node='coldchain'] { grid-area: 1 / 4; }
  .flow-node[data-node='hub']       { grid-area: 1 / 5; }
  .flow-node[data-node='home']      { grid-area: 1 / 6; }

  .flow-node[data-node='seed']      { grid-area: 3 / 3; }
  .flow-node[data-node='bio']       { grid-area: 3 / 4; }
  .flow-node[data-node='machinery'] { grid-area: 3 / 5; }
  .flow-node[data-node='agriyana']  { grid-area: 3 / 6; }

  .flow-caption {
    grid-area: 3 / 1 / 4 / 3;
    align-self: center;
    padding-right: var(--s-6);
  }
}

.flow-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--band-fg-muted);
  border-left: 2px solid var(--band-border);
  padding-left: var(--s-4);
}
.flow-caption b { color: var(--band-sprout); font-weight: 600; }

/* mobile and tablet: one column, journey order, wires run vertically */
@media (max-width: 1099px) {
  .flow-stage { gap: var(--s-7); }
  .flow-node { padding-left: var(--s-6); }
  .flow-caption { order: 99; border-left: 0; border-top: 1px solid var(--band-border); padding: var(--s-5) 0 0; }
}

/* ------------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  .flow-node { opacity: 1; transform: none; transition: none; }
  .wire { opacity: 1; }
  .wire.is-return { opacity: .85; }
  .wire-trace, .packet { display: none; }
}
