/* ====================================================
   Energy Flow Diagram — "Tak działa Twoja energia"
   ==================================================== */

.flow {
  position: relative;
  padding: 6rem 0 7rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(245, 158, 11, 0.10), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(14, 165, 233, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-elev-1) 100%);
  isolation: isolate;
}

/* Wave divider sitting on TOP of this section (cuts from hero) */
.flow__wave-top {
  position: absolute; top: -1px; left: 0; right: 0;
  width: 100%; height: 80px;
  z-index: 1;
  transform: scaleY(-1);
}
.flow__wave-top svg { width: 100%; height: 100%; display: block; }

.flow__intro {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
  position: relative;
  z-index: 2;
}
.flow__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  margin: 1rem 0 1rem;
  color: var(--heading);
  line-height: 1.05;
}
.flow__title em {
  font-style: normal;
  background: linear-gradient(135deg, var(--solar-light), var(--emerald-light));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.flow__lead {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Diagram container — SVG handles the layout responsively */
.flow__diagram {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  z-index: 2;
}
.flow__diagram svg { width: 100%; height: auto; display: block; overflow: visible; }

/* Animated dashed cables — emerald pulses moving left → right */
.cable-pulse {
  stroke-dasharray: 6 12;
  animation: cableFlow 1.8s linear infinite;
}
@keyframes cableFlow { to { stroke-dashoffset: -36; } }

/* Stations (sun, panel, inverter, grid, home) */
.station {
  cursor: pointer;
  transition: transform 200ms var(--ease-out);
}
.station__hit { fill: transparent; }
.station__bg {
  fill: rgba(255, 255, 255, 0.95);
  stroke: rgba(15, 23, 42, 0.1);
  stroke-width: 1.5;
  transition: stroke 240ms var(--ease-out), filter 240ms var(--ease-out);
}
.station:hover .station__bg,
.station.is-active .station__bg {
  stroke: var(--emerald-light);
  filter: drop-shadow(0 0 14px rgba(16, 185, 129, 0.55));
}
.station__icon-bg {
  fill: rgba(16, 185, 129, 0.14);
  stroke: rgba(16, 185, 129, 0.30);
  stroke-width: 1.2;
}
.station__icon-bg--sun {
  fill: rgba(245, 158, 11, 0.20);
  stroke: rgba(245, 158, 11, 0.50);
}
.station__icon-bg--home {
  fill: rgba(14, 165, 233, 0.18);
  stroke: rgba(14, 165, 233, 0.45);
}
.station__label {
  fill: var(--white);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-anchor: middle;
}
.station__value {
  fill: var(--emerald-bright);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  text-anchor: middle;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
}
.station__value--gold { fill: var(--solar-light); filter: drop-shadow(0 0 8px var(--solar-glow)); }
.station__value--sky  { fill: var(--sky-light); filter: drop-shadow(0 0 8px var(--sky-glow)); }

/* Sun rays animation */
.sun-rays {
  transform-origin: 140px 130px;
  animation: sunSpin 22s linear infinite;
}
@keyframes sunSpin { to { transform: rotate(360deg); } }

/* Tooltip */
.flow__tooltip {
  position: absolute;
  min-width: 240px;
  max-width: 320px;
  padding: 14px 16px 12px;
  background: rgba(248, 250, 252, 0.97);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--glass-border-emerald);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.099), 0 0 40px rgba(16, 185, 129, 0.20);
  color: var(--text-primary);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  z-index: 10;
}
.flow__tooltip h4 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--heading);
  letter-spacing: -0.02em;
}
.flow__tooltip .tip-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--emerald-dark);
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}
.flow__tooltip p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Bottom stats strip */
.flow__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  max-width: 1000px;
  margin: 4rem auto 0;
  padding: 0 1.5rem;
  position: relative;
  z-index: 2;
}
.flow__stat {
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--glass-border);
  text-align: center;
  backdrop-filter: blur(12px);
}
.flow__stat:first-child  { border-radius: 12px 0 0 12px; }
.flow__stat:last-child   { border-radius: 0 12px 12px 0; }
.flow__stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--emerald-dark);
  letter-spacing: var(--tracking-mono);
  text-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.flow__stat-label {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .flow { padding: 4rem 0 5rem; }
  .flow__stats { grid-template-columns: repeat(2, 1fr); gap: 1px; }
  .flow__stat:first-child  { border-radius: 12px 0 0 0; }
  .flow__stat:nth-child(2) { border-radius: 0 12px 0 0; }
  .flow__stat:nth-child(3) { border-radius: 0 0 0 12px; }
  .flow__stat:last-child   { border-radius: 0 0 12px 0; }
}
