/**
 * Страница 404 — граф разделов на один экран
 */

body.neuroege-guide-graph-page {
  overflow: hidden;
  height: 100dvh;
}

body.neuroege-guide-graph-page .page--not-found {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body.neuroege-guide-graph-page .not-found-main {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  width: min(76rem, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 0 clamp(0.5rem, 1.5vw, 1.25rem) clamp(0.35rem, 1vw, 0.65rem);
  overflow: hidden;
}

.not-found-graph__title {
  flex-shrink: 0;
  margin: 0;
  padding: clamp(0.35rem, 1.2vw, 0.65rem) 0 clamp(0.25rem, 0.8vw, 0.45rem);
  text-align: center;
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight: 600;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--white) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.not-found-graph {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.not-found-graph__frame {
  --nf-cluster-w: clamp(11rem, 14vmin, 13.5rem);
  --nf-gap: clamp(0.45rem, 1.2vmin, 0.8rem);
  --nf-leaf-gap: 0.26rem;
  container-type: inline-size;
  container-name: nf-frame;
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: clamp(0.35rem, 1vw, 0.75rem);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(5, 184, 125, 0.08) 0%, transparent 50%),
    linear-gradient(165deg, rgba(22, 28, 36, 0.92) 0%, rgba(14, 18, 24, 0.96) 100%);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.not-found-graph__frame::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.35) 0%,
    rgba(255, 255, 255, 0.06) 40%,
    rgba(5, 184, 125, 0.3) 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

[data-theme="light"] .not-found-graph__frame {
  border-color: rgba(15, 23, 42, 0.08);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 55%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.95) 100%);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

.not-found-graph__fit {
  position: relative;
  width: max-content;
  max-width: 100%;
  transform-origin: center center;
}

.not-found-graph__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.not-found-graph__edge {
  stroke-dasharray: 6 5;
  animation: nf-edge-flow 2.8s linear infinite;
  opacity: 0.72;
}

.not-found-graph__edge--hub {
  stroke-dasharray: 10 7;
  opacity: 0.9;
}

@keyframes nf-edge-flow {
  to {
    stroke-dashoffset: -24;
  }
}

.not-found-graph__stage {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: max-content auto max-content;
  grid-template-rows: repeat(3, max-content);
  grid-template-areas:
    "ege    .      oge"
    "tools  hub    account"
    ".      info   .";
  gap: var(--nf-gap);
  align-items: start;
  justify-items: center;
  width: max-content;
}

.not-found-graph__hub {
  grid-area: hub;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  justify-self: center;
  flex-shrink: 0;
  width: clamp(5rem, 10.5vmin, 6.5rem);
  height: clamp(5rem, 10.5vmin, 6.5rem);
}

.not-found-graph__hub-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.not-found-graph__hub-ring--outer {
  inset: 0;
  animation: nf-hub-pulse 3.5s ease-in-out infinite;
}

.not-found-graph__hub-ring--inner {
  inset: 12%;
  border-color: rgba(99, 102, 241, 0.35);
  animation: nf-hub-pulse 3.5s ease-in-out infinite reverse;
}

@keyframes nf-hub-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

.not-found-graph__hub-core {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  text-align: center;
  background: linear-gradient(145deg, #4f46e5 0%, #7c3aed 48%, #db2777 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.2) inset,
    0 12px 32px rgba(79, 70, 229, 0.4),
    0 0 40px rgba(124, 58, 237, 0.22);
}

.not-found-graph__hub-code {
  font-family: var(--font-heading);
  font-size: clamp(1.15rem, 2.4vmin, 1.45rem);
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.not-found-graph__hub-label {
  margin-top: 0.1rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
}

.not-found-graph__hub-hint {
  margin-top: 0.12rem;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.7);
}

.not-found-graph__cluster {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  width: var(--nf-cluster-w);
  min-width: var(--nf-cluster-w);
  flex-shrink: 0;
}

.not-found-graph__cluster--ege { grid-area: ege; }
.not-found-graph__cluster--oge { grid-area: oge; }
.not-found-graph__cluster--tools { grid-area: tools; }
.not-found-graph__cluster--account { grid-area: account; }
.not-found-graph__cluster--info { grid-area: info; }

.not-found-graph__cluster-core {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.45rem 0.6rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
}

[data-theme="light"] .not-found-graph__cluster-core {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.not-found-graph__cluster-core--ege {
  border-color: rgba(5, 184, 125, 0.35);
}

.not-found-graph__cluster-core--oge {
  border-color: rgba(219, 39, 119, 0.35);
}

.not-found-graph__cluster-core--tools {
  border-color: rgba(99, 102, 241, 0.35);
}

.not-found-graph__cluster-core--account {
  border-color: rgba(20, 184, 166, 0.35);
}

.not-found-graph__cluster-core--info {
  border-color: rgba(148, 163, 184, 0.35);
}

.not-found-graph__cluster-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.not-found-graph__cluster-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(0.7rem, 1.65vmin, 0.78rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.not-found-graph__leaves {
  display: flex;
  flex-direction: column;
  gap: var(--nf-leaf-gap);
  width: 100%;
  flex-shrink: 0;
}

.not-found-graph__leaf {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 1.85rem;
  padding: 0.32rem 0.5rem;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
  flex-shrink: 0;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

[data-theme="light"] .not-found-graph__leaf {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(15, 23, 42, 0.06);
}

.not-found-graph__leaf:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.not-found-graph__leaf--ege:hover {
  border-color: rgba(5, 184, 125, 0.45);
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.16);
  background: rgba(5, 184, 125, 0.08);
}

.not-found-graph__leaf--oge:hover {
  border-color: rgba(219, 39, 119, 0.45);
  box-shadow: 0 4px 14px rgba(219, 39, 119, 0.14);
  background: rgba(219, 39, 119, 0.08);
}

.not-found-graph__leaf--tools:hover {
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.14);
}

.not-found-graph__leaf--account:hover {
  border-color: rgba(20, 184, 166, 0.45);
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.14);
}

.not-found-graph__leaf--info:hover {
  border-color: rgba(148, 163, 184, 0.5);
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.12);
}

.not-found-graph__leaf-dot {
  flex-shrink: 0;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
  box-shadow: 0 0 6px currentColor;
}

.not-found-graph__leaf--ege { color: #05b87d; }
.not-found-graph__leaf--oge { color: #db2777; }
.not-found-graph__leaf--tools { color: #818cf8; }
.not-found-graph__leaf--account { color: #2dd4bf; }
.not-found-graph__leaf--info { color: #94a3b8; }

.not-found-graph__leaf-body {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.not-found-graph__leaf-label {
  display: block;
  font-size: clamp(0.7rem, 1.55vmin, 0.78rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.not-found-graph__leaf-hint {
  display: none;
}

/* Узкая рамка — вертикальный граф без рёбер (рисуются только на широкой) */
@container nf-frame (max-width: 52rem) {
  .not-found-graph__frame {
    --nf-cluster-w: 100%;
    --nf-gap: 0.38rem;
    --nf-leaf-gap: 0.2rem;
    padding: 0.4rem;
  }

  .not-found-graph__fit {
    width: min(100%, 20rem);
    max-width: 100%;
  }

  .not-found-graph__stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "hub"
      "ege"
      "oge"
      "tools"
      "account"
      "info";
    width: 100%;
    gap: var(--nf-gap);
  }

  .not-found-graph__hub {
    width: clamp(4.25rem, 16cqw, 5.25rem);
    height: clamp(4.25rem, 16cqw, 5.25rem);
    margin: 0 auto 0.1rem;
  }

  .not-found-graph__cluster {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .not-found-graph__cluster-core {
    min-height: 2.05rem;
    padding: 0.36rem 0.48rem;
  }

  .not-found-graph__leaf {
    min-height: 1.65rem;
    padding: 0.26rem 0.42rem;
  }
}

@media (max-width: 900px) {
  body.neuroege-guide-graph-page .not-found-main {
    padding-inline: clamp(0.35rem, 2vw, 0.75rem);
  }

  .not-found-graph__title {
    font-size: clamp(1.15rem, 5.5vw, 1.45rem);
    padding-bottom: 0.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .not-found-graph__edge,
  .not-found-graph__hub-ring {
    animation: none;
  }

  .not-found-graph__fit {
    will-change: auto;
  }
}
