@font-face {
  font-family: Newsreader;
  src: url("../assets/fonts/Newsreader-VF.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f3f4ef;
  --ink: #22261f;
  --muted: #6d7369;
  --line: #cfd4ca;
  --panel: rgba(250, 251, 247, .94);
  --investigation: #344b39;
  --observation: #b87135;
  --source: #628083;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body, .graph-shell { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button, input { font: inherit; }

button, a, input { -webkit-tap-highlight-color: transparent; }

.graph-shell { position: relative; isolation: isolate; overflow: hidden; }

#graph-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#graph-canvas.dragging { cursor: grabbing; }

.graph-header {
  position: absolute;
  z-index: 3;
  top: 1.35rem;
  left: 1.45rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  pointer-events: none;
  color: #3b4038;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--ink);
  font-weight: 720;
  text-decoration: none;
  pointer-events: auto;
}

.brand-mark { position: relative; width: 18px; height: 12px; }
.brand-mark i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
.brand-mark i:nth-child(1) { left: 0; top: 4px; }
.brand-mark i:nth-child(2) { left: 8px; top: 0; }
.brand-mark i:nth-child(3) { right: 0; bottom: 0; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; z-index: -1; height: 1px; background: #8a9186; transform-origin: left center; }
.brand-mark::before { left: 3px; top: 5px; width: 9px; transform: rotate(-27deg); }
.brand-mark::after { left: 10px; top: 3px; width: 8px; transform: rotate(35deg); }

.graph-name { padding-left: .75rem; border-left: 1px solid #b9beb5; font-weight: 660; }
.graph-counts, .graph-snapshot { color: #7b8178; letter-spacing: .03em; text-transform: none; }
.graph-snapshot { padding-left: .75rem; border-left: 1px solid #c5cac1; }

.graph-search {
  position: absolute;
  z-index: 4;
  top: 1rem;
  right: 1.15rem;
  display: flex;
  align-items: center;
  width: min(16.5rem, calc(100vw - 2rem));
  height: 2.3rem;
  padding: 0 .6rem;
  border: 1px solid rgba(143, 151, 138, .58);
  border-radius: 5px;
  background: rgba(249, 250, 246, .9);
  box-shadow: 0 2px 12px rgba(45, 53, 42, .06);
  color: #747a70;
  backdrop-filter: blur(8px);
}

.graph-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: .74rem;
}

.graph-search input::placeholder { color: #858b81; }
.graph-search > span { margin-right: .42rem; font-size: 1rem; }
.graph-search kbd { padding: .08rem .28rem; border: 1px solid #d2d6ce; border-radius: 3px; color: #8b9187; font-family: inherit; font-size: .58rem; }

.graph-legend, .graph-instruction, .graph-controls {
  position: absolute;
  z-index: 3;
  bottom: 1.15rem;
}

.graph-legend {
  left: 1.35rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  color: #656c62;
  font-size: .64rem;
}

.graph-legend span { display: inline-flex; align-items: center; gap: .34rem; }
.legend-node { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.legend-node.investigation { width: 9px; height: 9px; background: var(--investigation); }
.legend-node.observation { border-radius: 1px; background: var(--observation); transform: rotate(45deg); }
.legend-node.source { background: var(--source); }

.graph-instruction {
  left: 50%;
  transform: translateX(-50%);
  color: #8a9087;
  font-size: .61rem;
  white-space: nowrap;
}

.graph-controls {
  right: 1.15rem;
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(143, 151, 138, .62);
  border-radius: 5px;
  background: rgba(249, 250, 246, .9);
  box-shadow: 0 2px 12px rgba(45, 53, 42, .05);
}

.graph-controls button {
  height: 2rem;
  min-width: 2rem;
  padding: 0 .58rem;
  border: 0;
  border-right: 1px solid #d4d8d0;
  background: transparent;
  color: #555c52;
  cursor: pointer;
  font-size: .7rem;
}

.graph-controls button:last-child { border-right: 0; }
.graph-controls button:hover { background: #fff; color: #1f241d; }
.graph-controls button:disabled { color: #92988f; cursor: wait; }
.graph-controls .refresh-control { min-width: 4.5rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.graph-tooltip {
  position: absolute;
  z-index: 6;
  width: min(22rem, calc(100vw - 2rem));
  padding: .62rem .7rem;
  border: 1px solid #cbd0c6;
  border-radius: 4px;
  background: rgba(251, 252, 249, .97);
  box-shadow: 0 8px 28px rgba(36, 43, 33, .13);
  pointer-events: none;
  color: #33382f;
  font-family: Newsreader, Georgia, serif;
  font-size: .8rem;
  line-height: 1.35;
}

.graph-tooltip small { display: block; margin-bottom: .25rem; color: #777e74; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: .55rem; font-weight: 720; letter-spacing: .09em; text-transform: uppercase; }

.node-detail {
  position: absolute;
  z-index: 5;
  top: 4.15rem;
  right: 1.15rem;
  width: min(23rem, calc(100vw - 2rem));
  max-height: calc(100vh - 7.7rem);
  overflow: auto;
  padding: 1rem 1.05rem 1.05rem;
  border: 1px solid #c5cbc0;
  border-radius: 5px;
  background: var(--panel);
  box-shadow: 0 12px 38px rgba(38, 45, 35, .14);
  backdrop-filter: blur(12px);
}

.detail-close { position: absolute; top: .45rem; right: .48rem; width: 1.7rem; height: 1.7rem; border: 0; background: transparent; color: #747a70; cursor: pointer; font-size: 1.1rem; }
.detail-type { margin: 0 2rem .55rem 0; color: #747a70; font-size: .58rem; font-weight: 730; letter-spacing: .1em; text-transform: uppercase; }
.node-detail h1 { margin: 0 1.2rem .65rem 0; font-family: Newsreader, Georgia, serif; font-size: 1.18rem; font-weight: 560; line-height: 1.12; }
.detail-body { margin: 0 0 .75rem; color: #41463d; font-family: Newsreader, Georgia, serif; font-size: .9rem; line-height: 1.45; }
.detail-meta { margin: 0 0 .75rem; color: #737970; font-size: .63rem; line-height: 1.5; }
.node-detail a { color: #385e61; font-size: .68rem; font-weight: 680; text-decoration: none; }
.node-detail a:hover { text-decoration: underline; }

.loading-state {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .7rem;
  background: var(--paper);
  color: #697067;
  font-size: .67rem;
  letter-spacing: .04em;
  transition: opacity .35s ease, visibility .35s ease;
}

.loading-state.ready { visibility: hidden; opacity: 0; }
.loading-state span { width: 8px; height: 8px; border-radius: 50%; background: var(--investigation); animation: breathe 1.1s ease-in-out infinite alternate; }
.loading-state p { margin: 0; }

noscript { position: absolute; z-index: 8; inset: 1rem; padding: 1rem; background: var(--panel); }

@keyframes breathe { to { opacity: .25; transform: scale(.7); } }

@media (max-width: 1100px) {
  .graph-snapshot { display: none; }
}

@media (max-width: 850px) {
  .graph-name, .graph-counts { display: none; }
}

@media (max-width: 760px) {
  .graph-header { top: .9rem; left: .85rem; }
  .graph-name, .graph-counts, .graph-snapshot { display: none; }
  .graph-search { top: .7rem; right: .7rem; width: 10.8rem; }
  .graph-search kbd { display: none; }
  .graph-legend { left: .85rem; bottom: .85rem; gap: .55rem; }
  .graph-legend span { font-size: 0; gap: 0; }
  .legend-node { width: 8px; height: 8px; }
  .graph-instruction { display: none; }
  .graph-controls { right: .7rem; bottom: .7rem; }
  .node-detail { top: auto; right: .7rem; bottom: 3.4rem; left: .7rem; width: auto; max-height: 45vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
