/* ==========================================================================
   Схема сети: точки подключения → маршрутизация по задаче → направления
   ========================================================================== */

.visual--net {
  max-width: 40rem;
  container-type: inline-size;
}

.net {
  position: relative;
  display: grid;
  grid-template-areas:
    "src"
    "hub"
    "dst";
  gap: 3rem;
}

.net-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.net-src {
  grid-area: src;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.net-dst {
  grid-area: dst;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.net-dst .net-node { width: calc((100% - 1rem) / 3); }

.net-hub {
  grid-area: hub;
  display: grid;
  justify-items: center;
  gap: 0.6rem;
}

@container (min-width: 32rem) {
  .net {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.2fr);
    grid-template-areas: "src hub dst";
    align-items: center;
    gap: 0 3rem;
  }

  .net-src,
  .net-dst {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }

  .net-dst .net-node { width: auto; }
}

/* узлы */
.net-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.35rem;
  text-align: center;
  background: linear-gradient(160deg, rgb(40 48 56 / 0.92), rgb(22 27 32 / 0.92));
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 12px;
  transition: border-color 0.35s ease, box-shadow 0.35s ease, opacity 0.35s ease;
}

@container (min-width: 32rem) {
  .net-node {
    flex-direction: row;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem 0.45rem 0.45rem;
    text-align: left;
  }
}

.net-ico {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  background: var(--accent-soft);
  border-radius: 8px;
}

.net-ico svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.net-node--dst .net-ico { background: rgb(110 150 230 / 0.14); }
.net-node--dst .net-ico svg { stroke: #9fb4ff; }

.net-name {
  color: var(--text);
  font-size: 0.74rem;
  line-height: 1.2;
}

@container (min-width: 32rem) {
  .net-name { font-size: 0.84rem; }
}

.net-node.is-hit,
.net-node.is-target {
  border-color: var(--c);
  box-shadow: 0 0 1.25rem -0.25rem var(--c);
}

.net.is-focus .net-node--dst:not(.is-target) { opacity: 0.35; }

/* узел маршрутизации */
.net-core {
  position: relative;
  display: grid;
  place-items: center;
  width: 5rem;
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 40%, #183a40, #0c181b 70%);
  border: 1px solid rgb(79 209 197 / 0.4);
  border-radius: 50%;
  box-shadow: 0 0 2rem -0.5rem rgb(79 209 197 / 0.5), inset 0 0 1rem rgb(79 209 197 / 0.25);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.net-core.is-flash {
  border-color: var(--c);
  box-shadow: 0 0 2.5rem -0.25rem var(--c), inset 0 0 1.25rem var(--c);
}

.net-core-ring {
  position: absolute;
  inset: -0.55rem;
  border: 1px dashed rgb(79 209 197 / 0.4);
  border-radius: 50%;
}

/* в центре — название MikroTik или его логотип, если он указан в logos/logos.js */
.net-core-mark {
  position: relative;
  display: grid;
  place-items: center;
}

.net-core-name {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: color 0.3s ease;
}

.net-core.is-flash .net-core-name { color: var(--c); }
.net-core-mark .logo { width: 3.3rem; height: 2.2rem; }
.net-core-mark.has-logo .net-core-name { display: none; }

.net-rule {
  min-width: 8rem;
  color: var(--c, var(--muted));
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: center;
  transition: color 0.3s ease;
}

/* связи: туннель — «труба» и провод с замком, прямой выход — пунктир */
.net-pipe {
  fill: none;
  stroke: rgb(255 255 255 / 0.05);
  stroke-width: 7;
  stroke-linecap: round;
}

.net-wire {
  fill: none;
  stroke: rgb(120 200 210 / 0.3);
  stroke-width: 1.25;
  transition: stroke 0.3s ease;
}

.net-link--direct .net-pipe { display: none; }
.net-link--direct .net-wire { stroke-dasharray: 3 5; }
.net-link.is-hot .net-wire,
.net-link.is-path .net-wire { stroke: var(--c); }
.net-link.is-path .net-pipe { stroke: rgb(255 255 255 / 0.09); }

.net-lock rect {
  fill: #12161a;
  stroke: rgb(120 200 210 / 0.6);
  stroke-width: 1;
}

.net-lock path {
  fill: none;
  stroke: rgb(120 200 210 / 0.6);
  stroke-width: 1;
}

.net-packet {
  fill: var(--c);
  filter: drop-shadow(0 0 4px var(--c));
}

/* легенда задач */
.net-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.5rem;
  padding: 0;
  list-style: none;
}

.net-task {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  color: var(--text-2);
  font: inherit;
  font-size: 0.8rem;
  background: rgb(255 255 255 / 0.04);
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
}

html:not(.js) .net-task { cursor: default; }

.net-task:hover,
.net-task.is-active {
  color: var(--text);
  background: rgb(255 255 255 / 0.07);
  border-color: var(--c);
}

.net-dot {
  width: 0.55rem;
  height: 0.55rem;
  background: var(--c);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--c);
}

@media (prefers-reduced-motion: no-preference) {
  .net-core-ring { animation: spin 14s linear infinite; }
}
