@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansregular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansbold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansitalic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansbolditalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #050816;
  --bg-deep: #03050f;
  --ink: #e8edf5;
  --ink-dim: #9ba3b8;
  --ink-faint: #6c7591;
  --line: #1c2440;
  --line-strong: #2a3550;
  --accent: #7aa2ff;
  --accent-warm: #f0c987;
  --highlight: #ffffff;
  --panel: rgba(8, 12, 28, 0.88);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Sana Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  position: relative;
}

/* Faint dotted grid background */
.grid-overlay {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at center, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.grid-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, var(--bg-deep) 90%);
  pointer-events: none;
}

/* Masthead */
.masthead {
  position: absolute;
  top: clamp(20px, 4vw, 48px);
  left: clamp(20px, 4vw, 48px);
  z-index: 10;
  max-width: 480px;
  pointer-events: none;
}

.masthead__mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.12em;
  margin-bottom: 18px;
  text-transform: uppercase;
}

.masthead__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 3.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.masthead__title {
  font-size: clamp(38px, 6.5vw, 84px);
  font-weight: 300;
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0 0 14px 0;
  color: var(--highlight);
}

.masthead__subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-dim);
  letter-spacing: 0.01em;
  margin: 0;
  max-width: 360px;
  line-height: 1.5;
}

/* Stage / SVG canvas */
.stage {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.constellation {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.constellation:active { cursor: grabbing; }

/* Links between nodes */
.link {
  stroke: var(--line);
  stroke-width: 0.6;
  fill: none;
  transition: stroke 200ms ease, stroke-width 200ms ease, opacity 200ms ease;
}

.link--membership {
  stroke-dasharray: 2 4;
  stroke-opacity: 0.55;
}

.link.is-related {
  stroke: var(--accent);
  stroke-opacity: 0.85;
  stroke-width: 1;
}

.link.is-dim {
  stroke-opacity: 0.1;
}

/* Node groups */
.node {
  cursor: pointer;
  transition: opacity 250ms ease;
}

.node circle.core {
  fill: var(--ink);
  transition: r 250ms ease, fill 200ms ease, stroke 200ms ease;
}

/* Libraries: hollow ring instead of filled dot */
.node.is-library circle.core {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
}

.node.is-library:hover circle.core {
  fill: var(--ink);
}

.node circle.halo {
  fill: url(#node-glow);
  opacity: 0;
  transition: opacity 250ms ease;
}

.node circle.ring {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 0.8;
  opacity: 0;
  transition: opacity 250ms ease, r 250ms ease;
}

.node.is-cluster circle.core {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.85;
}

.node.is-cluster circle.glow {
  fill: url(#cluster-glow);
}

.node.is-cluster circle.ring {
  opacity: 0.4;
  stroke: var(--accent);
  stroke-dasharray: 1.5 3;
}

.node:hover circle.halo,
.node.is-active circle.halo {
  opacity: 1;
}

.node:hover circle.ring,
.node.is-active circle.ring {
  opacity: 1;
}

.node.is-active circle.core {
  fill: var(--highlight);
}

.node.is-cluster.is-active circle.core {
  stroke: var(--highlight);
  opacity: 1;
}

.node.is-dim {
  opacity: 0.18;
}

.node.is-related circle.core {
  fill: var(--accent);
}

.node.is-cluster.is-related circle.core {
  stroke: var(--accent-warm);
  opacity: 1;
}

/* Labels */
.node-label {
  font-family: 'Sana Sans', sans-serif;
  font-size: 11px;
  font-weight: 400;
  fill: var(--ink-dim);
  letter-spacing: 0.01em;
  pointer-events: none;
  user-select: none;
  transition: fill 200ms ease, opacity 250ms ease;
}

.node.is-cluster .node-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  fill: var(--accent);
  opacity: 0.8;
}

.node:hover .node-label,
.node.is-active .node-label {
  fill: var(--highlight);
  opacity: 1;
}

.node.is-cluster:hover .node-label,
.node.is-cluster.is-active .node-label {
  fill: var(--accent-warm);
}

.node.is-dim .node-label {
  opacity: 0.1;
}

/* Axis ticks at the edges */
.axis {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: 80px 100%;
  opacity: 0.5;
}

.axis--bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  border-top: 1px solid var(--line);
}

.axis--left {
  top: 0;
  bottom: 0;
  left: 0;
  width: 12px;
  border-right: 1px solid var(--line);
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 100% 80px;
}

/* Corner monospace annotations */
.corner {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 3;
}

.corner--tl { top: 16px; right: 24px; }
.corner--br { bottom: 22px; right: 24px; }

/* Legend */
.legend {
  position: absolute;
  bottom: clamp(20px, 3vw, 48px);
  left: clamp(20px, 3vw, 48px);
  z-index: 10;
  max-width: 320px;
}

.legend__title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin: 0 0 12px 0;
}

.legend__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 0;
  letter-spacing: 0.01em;
  transition: color 200ms ease, opacity 200ms ease;
}

.legend__item:hover { color: var(--accent-warm); }
.legend__item.is-dim { opacity: 0.4; }

.legend__swatch {
  width: 8px;
  height: 8px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.legend__hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin: 14px 0 0 0;
}

.legend__kinds {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.legend__kind {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend__glyph {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend__glyph--program {
  background: var(--ink);
}

.legend__glyph--library {
  background: transparent;
  border: 1px solid var(--ink);
}

/* Detail panel */
.detail {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 360ms cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 20;
  overflow-y: auto;
  padding: 56px 40px 40px 40px;
}

.detail.is-open {
  transform: translateX(0);
}

.detail__close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 26px;
  font-weight: 300;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 200ms ease, background 200ms ease;
}

.detail__close:hover {
  color: var(--highlight);
  background: rgba(255,255,255,0.05);
}

.detail__kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail__kicker-dot {
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.detail__title {
  font-size: 32px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 8px 0;
  color: var(--highlight);
}

.detail__tagline {
  font-size: 13px;
  color: var(--ink-dim);
  margin: 0 0 28px 0;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.detail__description {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  font-weight: 400;
  margin: 0 0 24px 0;
}

.detail__meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail__meta-row {
  display: flex;
  gap: 14px;
  font-size: 12px;
  align-items: baseline;
}

.detail__meta-key {
  width: 88px;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  font-size: 10px;
}

.detail__meta-val {
  color: var(--ink);
  letter-spacing: 0.01em;
}

.detail__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail__chip {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.detail__chip.is-accent {
  border-color: var(--accent);
  color: var(--accent);
}

.detail__links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.detail__link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  transition: border-color 200ms ease, color 200ms ease, background 200ms ease;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.detail__link:hover {
  border-color: var(--accent);
  color: var(--highlight);
  background: rgba(122, 162, 255, 0.04);
}

.detail__link-arrow {
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 14px;
}

.detail__section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  margin: 0 0 12px 0;
}

.detail__related {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail__related-item {
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  transition: color 200ms ease, padding 200ms ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail__related-item:hover {
  color: var(--accent);
  padding-left: 4px;
}

.detail__related-item:last-child { border-bottom: none; }

.detail__related-arrow {
  margin-left: auto;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
}

.detail__related-kind {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

/* Colophon */
.colophon {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  gap: 14px;
  align-items: center;
  pointer-events: auto;
}

.colophon a {
  color: var(--ink-faint);
  text-decoration: none;
  transition: color 200ms ease;
}

.colophon a:hover { color: var(--accent); }
.colophon__dot { opacity: 0.4; }

/* Responsive */
@media (max-width: 900px) {
  .masthead { max-width: 78vw; }
  .legend {
    bottom: 12px;
    left: 12px;
    max-width: 60vw;
  }
  .colophon { display: none; }
  .corner--br { display: none; }
  .detail { padding: 56px 24px 32px 24px; }
}

@media (max-width: 700px) {
  /* On phones, the legend overlaps the graph — hide it and show the colophon instead. */
  .legend { display: none; }
  .colophon {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
    bottom: 14px;
    font-size: 9px;
    letter-spacing: 0.1em;
    max-width: 92vw;
    text-align: center;
  }
}

@media (max-width: 600px) {
  .legend__list { max-height: 140px; overflow-y: auto; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
