/* BGP full-view graph on autonomous-system pages. */
.ce-as-bgp-graph {
  --ce-as-graph-edge: rgba(105, 139, 207, 0.28);
  --ce-as-graph-node: #7898dd;
  --ce-as-graph-root: #f2bd55;
  --ce-as-graph-selected: #ffffff;
  --ce-as-graph-label: #e6ebf7;
  margin-top: 16px;
  padding: 32px;
  border: 1px solid var(--ce-line-soft, rgb(255 255 255 / 10%));
  border-radius: var(--ce-radius-lg, 16px);
  background: var(--ce-surface, #101012);
  color: var(--ce-text, #f7f7f8);
}

.ce-as-bgp-graph [hidden] {
  display: none !important;
}

.ce-as-bgp-graph__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.ce-as-bgp-graph__heading h2 {
  margin: 0;
  font-size: clamp(29px, 3.4vw, 42px);
}

.ce-as-bgp-graph__eyebrow {
  margin: 0 0 9px;
  color: var(--ce-accent-light, #7fa5ff);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ce-as-bgp-graph__source {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--ce-line-soft, rgb(255 255 255 / 10%));
  border-radius: 999px;
  color: var(--ce-text-dim, #8f929b);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ce-as-bgp-graph__explanation {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding: 17px 19px;
  border: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  border-radius: var(--ce-radius-md, 12px);
  background: rgb(255 255 255 / 2.5%);
}

.ce-as-bgp-graph__explanation p {
  margin: 0;
  color: var(--ce-text-muted, #a7a7ae);
  font-size: 12px;
  line-height: 1.6;
}

.ce-as-bgp-graph__explanation p:first-child {
  color: var(--ce-text, #f7f7f8);
  font-size: 13px;
}

.ce-as-bgp-graph__cache-note {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ce-as-bgp-graph__cache-note::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ce-accent-light, #7fa5ff);
  content: '';
}

.ce-as-bgp-graph__depth {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.ce-as-bgp-graph__depth legend {
  width: auto;
  margin: 0;
  color: var(--ce-text-muted, #a7a7ae);
  font-size: 11px;
  font-weight: 700;
}

.ce-as-bgp-graph__depth-options {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--ce-line-soft, rgb(255 255 255 / 10%));
  border-radius: 10px;
  background: rgb(0 0 0 / 18%);
}

.ce-as-bgp-graph__depth-options label {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.ce-as-bgp-graph__depth-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ce-as-bgp-graph__depth-options span {
  display: grid;
  width: 34px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  color: var(--ce-text-muted, #a7a7ae);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  transition: background-color 120ms ease, color 120ms ease;
}

.ce-as-bgp-graph__depth-options input:checked + span {
  background: var(--ce-accent, #416fca);
  color: #fff;
}

.ce-as-bgp-graph__depth-options input:focus-visible + span {
  outline: 2px solid var(--ce-accent-light, #7fa5ff);
  outline-offset: 2px;
}

.ce-as-bgp-graph__meta {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  margin: 0 0 18px;
  border: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  border-radius: var(--ce-radius-md, 12px);
  background: rgb(0 0 0 / 12%);
}

.ce-as-bgp-graph__meta > div {
  min-width: 0;
  padding: 13px 15px;
  border-right: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
}

.ce-as-bgp-graph__meta > div:last-child {
  border-right: 0;
}

.ce-as-bgp-graph__meta dt {
  margin-bottom: 4px;
  color: var(--ce-text-dim, #8f929b);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ce-as-bgp-graph__meta dd {
  overflow: hidden;
  margin: 0;
  color: var(--ce-text, #f7f7f8);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-as-bgp-graph__cache-state dd {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgb(91 158 112 / 15%);
  color: #9bd4aa;
  font-family: inherit;
  font-weight: 700;
}

.ce-as-bgp-graph__cache-state[data-cache-status='miss'] dd {
  background: rgb(120 152 221 / 15%);
  color: #9eb5ec;
}

.ce-as-bgp-graph__cache-state[data-cache-status='stale'] dd {
  background: rgb(242 189 85 / 14%);
  color: #f2ca78;
}

.ce-as-bgp-graph__loading,
.ce-as-bgp-graph__message {
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  border-radius: var(--ce-radius-md, 12px);
  background: rgb(255 255 255 / 2.5%);
  text-align: center;
}

.ce-as-bgp-graph__loading p,
.ce-as-bgp-graph__message p {
  margin: 0;
  color: var(--ce-text-muted, #a7a7ae);
  font-size: 12px;
}

.ce-as-bgp-graph__message--error {
  flex-direction: column;
}

.ce-as-bgp-graph__spinner {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 3px solid rgba(127, 165, 255, 0.18);
  border-top-color: var(--ce-accent-light, #7fa5ff);
  border-radius: 50%;
  animation: ce-as-bgp-graph-spin 0.8s linear infinite;
}

.ce-as-bgp-graph__canvas-shell {
  position: relative;
  height: clamp(420px, 58vw, 680px);
  overflow: hidden;
  border: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  border-radius: var(--ce-radius-md, 12px);
  background:
    radial-gradient(circle at center, rgb(75 103 160 / 9%), transparent 58%),
    linear-gradient(rgb(255 255 255 / 1.5%), rgb(0 0 0 / 5%));
}

.ce-as-bgp-graph__canvas-shell::before,
.ce-as-bgp-graph__canvas-shell::after {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  border: 1px solid rgb(127 165 255 / 8%);
  border-radius: 50%;
  content: '';
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.ce-as-bgp-graph__canvas-shell::before {
  width: 42%;
  height: 42%;
}

.ce-as-bgp-graph__canvas-shell::after {
  width: 78%;
  height: 78%;
}

.ce-as-bgp-graph canvas {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  outline: none;
  touch-action: pan-y pinch-zoom;
}

.ce-as-bgp-graph canvas:focus-visible {
  outline: 2px solid var(--ce-accent-light, #7fa5ff);
  outline-offset: -3px;
}

.ce-as-bgp-graph__canvas--interactive {
  cursor: pointer;
}

.ce-as-bgp-graph__tooltip {
  position: absolute;
  z-index: 3;
  display: grid;
  min-width: 130px;
  max-width: min(230px, calc(100% - 16px));
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 9px;
  background: rgb(16 18 23 / 96%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 28%);
  color: var(--ce-text, #f7f7f8);
  font-size: 10px;
  line-height: 1.35;
  pointer-events: none;
}

.ce-as-bgp-graph__tooltip strong {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.ce-as-bgp-graph__tooltip span {
  color: var(--ce-text-dim, #8f929b);
}

.ce-as-bgp-graph__tooltip span:last-child {
  margin-top: 3px;
  color: var(--ce-accent-light, #7fa5ff);
}

.ce-as-bgp-graph__legend,
.ce-as-bgp-graph__levels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.ce-as-bgp-graph__legend {
  margin-top: 12px;
  color: var(--ce-text-dim, #8f929b);
  font-size: 10px;
}

.ce-as-bgp-graph__legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ce-as-bgp-graph__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ce-as-graph-node);
}

.ce-as-bgp-graph__dot--root {
  background: var(--ce-as-graph-root);
}

.ce-as-bgp-graph__summary {
  margin: 12px 0 0;
  color: var(--ce-text-muted, #a7a7ae);
  font-size: 11px;
}

.ce-as-bgp-graph__levels {
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.ce-as-bgp-graph__levels li {
  padding: 4px 8px;
  border: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  border-radius: 999px;
  color: var(--ce-text-dim, #8f929b);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9px;
}

.ce-as-bgp-graph__warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid rgb(242 189 85 / 20%);
  border-radius: 9px;
  background: rgb(242 189 85 / 8%);
  color: #e8c676;
  font-size: 10px;
  line-height: 1.5;
}

.ce-as-bgp-graph__sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

@keyframes ce-as-bgp-graph-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 767.98px) {
  .ce-as-bgp-graph {
    padding: 24px 20px;
  }

  .ce-as-bgp-graph__heading {
    align-items: stretch;
    flex-direction: column;
  }

  .ce-as-bgp-graph__source {
    align-self: flex-start;
  }

  .ce-as-bgp-graph__meta {
    grid-template-columns: 1fr 1fr;
  }

  .ce-as-bgp-graph__meta > div:nth-child(2) {
    border-right: 0;
  }

  .ce-as-bgp-graph__meta > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  }

  .ce-as-bgp-graph__canvas-shell {
    height: clamp(400px, 115vw, 570px);
  }
}

@media (max-width: 419.98px) {
  .ce-as-bgp-graph__depth {
    align-items: flex-start;
    flex-direction: column;
  }

  .ce-as-bgp-graph__meta {
    grid-template-columns: 1fr;
  }

  .ce-as-bgp-graph__meta > div,
  .ce-as-bgp-graph__meta > div:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--ce-line-subtle, rgb(255 255 255 / 7%));
  }

  .ce-as-bgp-graph__meta > div:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ce-as-bgp-graph__spinner {
    animation: none;
  }

  .ce-as-bgp-graph__depth-options span {
    transition: none;
  }
}
