/**
 * Impulse Network block — frontend styles.
 *
 * Singleton-enqueued by includes/element-renderers/network.php on first use.
 * The renderer sets the palette (--net-c1..4), idle card colours, and grid
 * sizing as inline custom properties / data attributes; the engine
 * (assets/js/impulse-network.js) positions cards and draws the route lines.
 *
 * Cards are always fully opaque (the gradient fill is a separate layer that
 * fades in over an opaque base) so a route line is never visible beneath a
 * card. All transitions use ease-in-out; the only linear motion is the
 * continuous gradient-fill spin (a spin loop, per the project easing rule).
 */

.impulse-network {
  position: relative;
  width: 100%;
  margin: 0 auto;
  /* No parent perspective: the decompose depth is baked into each card's own
     transform (see @keyframes impulse-network-reveal). A parent perspective is
     dropped on the cards' GPU animation layers, and would double-apply on the
     browsers that don't drop it. */
  --net-c1: #22d3ee;
  --net-c2: #3b82f6;
  --net-c3: #8b5cf6;
  --net-c4: #d946ef;
  --net-card-bg: #0e1426;
  --net-card-border: rgba(255, 255, 255, 0.10);
  --net-icon: rgba(255, 255, 255, 0.42);
  --net-rot: 5s;
}

/* Card entrance is driven entirely by the screen/section reveal (decompose) engine,
   not by the block itself (see impulse-network.js). No self-animation here. v2.1.1994. */

.impulse-network-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.impulse-network-line {
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.impulse-network-line.is-on { opacity: 0.95; }

/* Scan: a bright pulse of light travels along each connection while it's held.
   A short dash on a sibling overlay path, swept by an infinite linear loop (a
   flow loop, like the gradient spin — the one place linear motion is correct).
   The overlay is invisible until the trace flags .is-flowing during the hold,
   so the pulse never shows on an undrawn or retracting segment. */
.impulse-network-flow {
  fill: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-dasharray: 14 460;
  opacity: 0;
  filter: drop-shadow(0 0 4px rgba(173, 216, 255, 0.75));
  animation: impulse-network-scan 1.15s linear infinite;
  transition: opacity 0.3s ease-in-out;
}
.impulse-network-flow.is-flowing { opacity: 0.85; }
@keyframes impulse-network-scan {
  from { stroke-dashoffset: 474; } /* one full 14+460 period */
  to   { stroke-dashoffset: 0; }
}

.impulse-network-card {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  border: 1px solid var(--net-card-border);
  background: var(--net-card-bg);
  color: var(--net-icon);
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
  z-index: 2;
  transition: transform 0.35s ease-in-out, box-shadow 0.35s ease-in-out,
    color 0.35s ease-in-out, border-color 0.35s ease-in-out;
}

.impulse-network-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 165%;
  height: 165%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, var(--net-c1), var(--net-c2), var(--net-c3), var(--net-c4));
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
  z-index: 0;
}
.impulse-network-card.is-lit::before {
  opacity: 1;
  animation: impulse-network-spin var(--net-rot) linear infinite;
}
@keyframes impulse-network-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.impulse-network-ico {
  position: relative;
  z-index: 1;
  line-height: 1;
  display: inline-flex;
}
.impulse-network-ico svg { display: block; }
.impulse-network-card.is-lit .impulse-network-ico {
  animation: impulse-network-pop 0.6s ease-in-out;
}
@keyframes impulse-network-pop {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.35); }
  50%  { transform: scale(0.9); }
  70%  { transform: scale(1.1); }
  85%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.impulse-network-label {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  overflow: hidden;
  text-align: center;
  white-space: normal;          /* wrap to a second line when a label is long */
  overflow-wrap: break-word;
  transition: opacity 0.35s ease-in-out, max-height 0.35s ease-in-out, margin-top 0.35s ease-in-out;
}

.impulse-network-card.is-lit {
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 28px rgba(124, 90, 246, 0.5);
  /* No scale here. The idle line trace toggles .is-lit on cards continuously, and a transform
     scale changes the pointer hit-area — a card under the cursor grows/shrinks and crosses the
     cursor boundary, making the hover quick-card + modal flicker and hard to trigger. The glow
     and the icon pop give the "lit" feel without resizing the hit box. v2.1.1999. */
}
.impulse-network-card.is-lit .impulse-network-label {
  max-height: 40px; /* room for up to two lines */
  margin-top: 6px;
  opacity: 1;
}

/* Hover quick-card (anchored to the hovered tile). */
.impulse-network-pop {
  position: absolute;
  z-index: 5;
  max-width: 220px;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(13, 18, 33, 0.96);
  border: 1px solid rgba(124, 90, 246, 0.5);
  color: #e7e9f2;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease-in-out, transform 0.22s ease-in-out;
}
.impulse-network-pop.is-shown { opacity: 1; transform: translateY(0); }
.impulse-network-pop span { display: block; font-size: 12px; line-height: 1.5; color: rgba(231, 233, 242, 0.86); }

/* Click modal (full description + CTA). */
.impulse-network-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 9, 18, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}
.impulse-network-modal.is-shown { opacity: 1; }
.impulse-network-modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 28px 26px;
  border-radius: 16px;
  background: #0e1426;
  border: 1px solid rgba(124, 90, 246, 0.4);
  color: #e7e9f2;
  text-align: center;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.25s ease-in-out;
}
.impulse-network-modal.is-shown .impulse-network-modal-card { transform: translateY(0) scale(1); }
.impulse-network-modal-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 500; color: #fff; }
.impulse-network-modal-card p { margin: 0; font-size: 14px; line-height: 1.6; color: rgba(231, 233, 242, 0.78); }
.impulse-network-modal-cta {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--net-c1), var(--net-c3));
  transition: opacity 0.2s ease-in-out;
}
.impulse-network-modal-cta:hover { opacity: 0.9; }
.impulse-network-modal-x {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(231, 233, 242, 0.6);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.impulse-network-modal-x:hover { color: #fff; }

/* Editor: drag-to-place affordances. */
.impulse-network-editing .impulse-network-card { cursor: grab; user-select: none; -webkit-user-select: none; }
.impulse-network-editing .impulse-network-card.is-dragging {
  cursor: grabbing;
  z-index: 6;
  opacity: 0.92;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  transition: none;
}
.impulse-network-drophint {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(124, 90, 246, 0.85);
  border-radius: 15px;
  background: rgba(124, 90, 246, 0.10);
  pointer-events: none;
  z-index: 1;
  display: none;
}
