/* ============================================================
   IKARION — Diagramas de flujo CSS (pasos de sistemas)
   Integrados al fondo oscuro, sin caja pesada
   ============================================================ */

.system-step-flow {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 200px;
  padding: var(--space-2) 0;
}

.system-step__body {
  width: 100%;
}

/* —— Escena —— */
.fd-scene {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 200px;
  margin-inline: auto;
  background: transparent;
}

.fd-scene--tall {
  height: 280px;
}

.system-step-flow:has(.fd-scene--tall) {
  min-height: 280px;
}

.fd-scene::before {
  content: '';
  position: absolute;
  inset: 8% 10%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(146, 192, 32, 0.07) 0%,
    transparent 68%
  );
  pointer-events: none;
  z-index: 0;
}

.fd-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.fd-arrow {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 4 5;
  animation: fd-flow 1.2s linear infinite;
  opacity: 0.85;
}

.fd-arrow--slow {
  animation-duration: 3s;
  opacity: 0.65;
}

@keyframes fd-flow {
  to { stroke-dashoffset: -18; }
}

.fd-nodes {
  position: absolute;
  inset: 0;
  z-index: 3;
}

/* —— Nodos —— */
.fd-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  transition: opacity 0.25s;
  max-width: 72px;
}

.fd-node--off {
  opacity: 0.28;
}

.fd-node--off .fd-node__icon {
  filter: grayscale(0.7);
}

.fd-node--pulse .fd-node__icon {
  filter: drop-shadow(0 0 5px rgba(146, 192, 32, 0.6));
}

.fd-node__label {
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
}

.fd-node--on .fd-node__label {
  color: var(--color-text-primary);
}

.fd-node__icon {
  display: block;
  position: relative;
  flex-shrink: 0;
}

/* Escenas con muchos nodos: iconos más compactos */
.fd-scene--dense .fd-node__icon:not(.fd-panels-array) {
  transform: scale(0.82);
  transform-origin: center bottom;
}

.fd-scene--dense .fd-node__label {
  font-size: 0.54rem;
}

/* Sol — etiqueta a la derecha del icono */
.fd-node--sun {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  max-width: none;
  text-align: left;
  transform: translate(-13px, -50%);
}

.fd-node--sun .fd-node__label {
  text-transform: none;
  letter-spacing: 0.02em;
}

.fd-node--sun .fd-node__icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6a8, #ffd94d 55%, #f0b820);
  box-shadow: 0 0 12px rgba(255, 220, 80, 0.5);
}

.fd-node--sun .fd-node__icon::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 230, 120, 0.35);
  animation: fd-sun-pulse 2.5s ease-in-out infinite;
}

@keyframes fd-sun-pulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(1.04); }
}

/* Nube decorativa (días nublados) */
.fd-scene--cloudy::before {
  background: radial-gradient(
    ellipse at center,
    rgba(148, 160, 180, 0.1) 0%,
    transparent 68%
  );
}

.fd-cloud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  transform: translate(-28%, -58%);
}

.fd-cloud__shape {
  display: block;
  position: relative;
  width: 26px;
  height: 26px;
  background: #b8c8d8;
  border-radius: 50%;
  box-shadow:
    20px 5px 0 -4px #c5d3e0,
    38px 9px 0 -6px #aebfcf,
    10px -3px 0 -6px #d0dae6,
    26px -1px 0 -5px #b0c0d0;
  opacity: 0.93;
}

.fd-scene--cloudy .fd-node--sun .fd-node__icon {
  filter: brightness(0.68);
  box-shadow: 0 0 5px rgba(255, 220, 80, 0.18);
}

.fd-scene--cloudy .fd-node--sun .fd-node__icon::before {
  animation: none;
  opacity: 0.12;
}

/* Paneles — arreglo de 4 módulos verticales en línea */
.fd-node--panels {
  max-width: none;
}

.fd-panels-array {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 4px;
  width: auto;
  height: auto;
  background: none;
  border: none;
  box-shadow: none;
}

.fd-panel-unit {
  display: block;
  width: 14px;
  height: 36px;
  border-radius: 2px;
  background: linear-gradient(165deg, #0f2035 0%, #1a3350 48%, #0f2035 100%);
  border: 1.5px solid #9aa3ad;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 2px 5px rgba(0, 0, 0, 0.35);
  background-image: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.07) 0 3px,
    transparent 3px 7px
  );
}

.fd-scene--dense .fd-panel-unit {
  width: 12px;
  height: 30px;
}

.fd-scene--dense .fd-panels-array {
  gap: 2px;
}

/* Inversor */
.fd-node--inverter .fd-node__icon {
  width: 22px;
  height: 32px;
  background: linear-gradient(180deg, #e8eaed, #d4d8dc);
  border: 1.5px solid #9aa3ad;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.fd-node--inverter .fd-node__icon::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 6px;
  background: #f0781a;
  border-radius: 1px;
}

.fd-node--inverter .fd-node__icon::after {
  content: '';
  position: absolute;
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 8px;
  background: #1a2a3a;
  border-radius: 2px;
  border: 1px solid #4a5560;
}

/* Casa */
.fd-node--house .fd-node__icon {
  width: 44px;
  height: 36px;
}

.fd-node--house .fd-node__icon::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 3px;
  width: 38px;
  height: 22px;
  background: #e8eaed;
  border: 1.5px solid #9aa3ad;
  border-radius: 2px;
}

.fd-node--house .fd-node__icon::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-bottom: 15px solid #5c636b;
}

.fd-scene--dense .fd-node--house .fd-node__icon {
  transform: scale(1);
  transform-origin: center bottom;
}

/* Cabaña — sitios remotos */
.fd-node--cabin .fd-node__icon {
  width: 40px;
  height: 34px;
}

.fd-node--cabin .fd-node__icon::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 5px;
  width: 30px;
  height: 17px;
  background: linear-gradient(180deg, #7a5840 0%, #5c4030 100%);
  border: 1.5px solid #3d2a1f;
  border-radius: 2px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.fd-node--cabin .fd-node__icon::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 19px solid transparent;
  border-right: 19px solid transparent;
  border-bottom: 16px solid #3d4a38;
}

.fd-scene--dense .fd-node--cabin .fd-node__icon {
  transform: scale(1);
  transform-origin: center bottom;
}

/* CFE / red */
.fd-node--grid .fd-node__icon {
  width: 26px;
  height: 30px;
  background: #3f7340;
  border: 1.5px solid #2f5831;
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.fd-node--grid .fd-node__icon::before {
  content: '⚡';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  line-height: 1;
}

/* Baterías */
.fd-node--battery .fd-node__icon {
  width: 28px;
  height: 32px;
}

.fd-node--battery .fd-node__icon::before,
.fd-node--battery .fd-node__icon::after {
  content: '';
  position: absolute;
  left: 2px;
  width: 24px;
  height: 8px;
  background: #d7dde3;
  border: 1.5px solid #9aa3ad;
  border-radius: 2px;
}

.fd-node--battery .fd-node__icon::before {
  top: 0;
  box-shadow: 0 10px 0 #d7dde3, 0 10px 0 0 #9aa3ad, 0 20px 0 #d7dde3, 0 20px 0 0 #9aa3ad;
}

.fd-node--battery.fd-node--on .fd-node__icon::after {
  top: 2px;
  height: 3px;
  width: 18px;
  left: 5px;
  background: var(--color-accent);
  border: none;
  border-radius: 1px;
  box-shadow: 0 10px 0 var(--color-accent), 0 20px 0 var(--color-accent);
}

.fd-node--battery.fd-node--pulse .fd-node__icon {
  animation: fd-bat-glow 1.8s ease-in-out infinite;
}

@keyframes fd-bat-glow {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(0 0 5px rgba(146, 192, 32, 0.65)); }
}

/* Van */
.fd-node--van .fd-node__icon {
  width: 52px;
  height: 28px;
  background: #e0e5ea;
  border: 1.5px solid #9aa3ad;
  border-radius: 3px 5px 2px 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.fd-node--van .fd-node__icon::before {
  content: '';
  position: absolute;
  right: -9px;
  top: 4px;
  width: 14px;
  height: 16px;
  background: #e0e5ea;
  border: 1.5px solid #9aa3ad;
  border-radius: 2px 4px 2px 2px;
}

.fd-node--van .fd-node__icon::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a1d20;
  box-shadow: 26px 0 0 #1a1d20;
}

.fd-scene--dense .fd-node--van .fd-node__icon {
  transform: scale(1);
  transform-origin: center bottom;
}

.fd-node--van.fd-node--pulse .fd-node__icon {
  animation: fd-van-drive 0.6s ease-in-out infinite alternate;
}

@keyframes fd-van-drive {
  from { transform: translateX(-2px); }
  to { transform: translateX(2px); }
}

/* Equipos (móvil) */
.fd-node--loads .fd-node__icon {
  width: 24px;
  height: 24px;
  background: #e8eaed;
  border: 1.5px solid #9aa3ad;
  border-radius: 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.fd-node--loads .fd-node__icon::before {
  content: '🔌';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  line-height: 1;
}

@media (max-width: 768px) {
  .system-step-flow {
    min-height: 180px;
  }

  .fd-scene {
    max-width: 100%;
    height: 180px;
  }
}
