@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/schibsted-grotesk-latin.woff2) format("woff2");
}

:root {
  --paper: #f5f6f2;
  --card: #ffffff;
  --ink: #111111;
  --muted: #8b8d86;
  --faint: #c3c5be;
  --accent: #ff2e93;
  --acid: #c6f432;
  --current: #7d8c3c;
  --panel-width: 370px;
  --panel-right: max(24px, 5vw);
  --font: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- map ---------- */

.map {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.map.is-panning { cursor: grabbing; }
.map.is-dragging-node, .map.is-dragging-node .node { cursor: grabbing; }

.map-layer {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.edges {
  position: absolute;
  overflow: visible;
}

.edge {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  animation: edge-in 600ms ease both;
}

.edge-dashed { stroke-dasharray: 4 4; }
.edge-faint { stroke: var(--faint); stroke-dasharray: 2 4; }

@keyframes edge-in { from { opacity: 0; } }

/* ---------- nodes ---------- */

.node {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 400ms ease;
  -webkit-tap-highlight-color: transparent;
}

.node.is-hidden { opacity: 0; pointer-events: none; }
.node:focus-visible { outline: none; }
.node:focus-visible .glyph-wrap { outline: 1px dashed var(--ink); outline-offset: 4px; }

.glyph-wrap {
  position: absolute;
  left: -12px;
  top: -12px;
  width: 24px;
  height: 24px;
  transition: transform 200ms cubic-bezier(.3, 1.6, .5, 1);
}

.node:hover .glyph-wrap, .map.is-dragging-node .node:active .glyph-wrap { transform: scale(1.2); }

.glyph { display: block; width: 24px; height: 24px; overflow: visible; }
.glyph .shape { fill: var(--paper); stroke: var(--ink); stroke-width: 1; }
.glyph .dot { fill: var(--ink); opacity: 0; }
.glyph .dot-always { opacity: 1; }
.glyph text {
  font: 500 9px var(--font);
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: middle;
}
.fill-accent { fill: var(--accent); stroke: var(--ink); stroke-width: 1; }
.fill-ink { fill: var(--ink); }
.fill-paper { fill: var(--paper); }

/* the home eye */

.type-home .glyph-wrap { left: -42px; top: -42px; width: 84px; height: 84px; }
.type-home .glyph { width: 84px; height: 84px; }
.type-home .label { top: 46px; }
.type-home:hover .glyph-wrap { transform: scale(1.06) rotate(-4deg); }

.eye-socket { fill: var(--ink); }
.eye-white { fill: #fff; }
.eye-outline { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.eye-glint { fill: #fff; }
.fill-accent-flat { fill: var(--accent); }
.eye-iris { transition: transform 90ms linear; }
.eye-ball { transform-origin: 50px 50px; transition: transform 110ms ease-out; }
.type-home.is-blinking .eye-ball { transform: scaleY(.06); }
.type-home.is-poked .eye-ball { transform: scale(1.12, .3); }

.type-home .label-sub { opacity: 1; }
.type-home.is-glitching .label-sub { animation: glitch 420ms steps(6) both; }

@keyframes glitch {
  0% { transform: translate(-3px, 1px); text-shadow: 2px 0 var(--accent), -2px 0 var(--acid); }
  33% { transform: translate(2px, -1px); text-shadow: -2px 0 var(--accent), 2px 0 var(--acid); }
  66% { transform: translate(-1px, 0); text-shadow: 1px 0 var(--accent), -1px 0 var(--acid); }
  100% { transform: none; text-shadow: none; }
}

::selection { background: var(--accent); color: #fff; }

.node.is-current:not(.type-home):not(.type-info) .shape { fill: var(--current); }
.node.is-current .dot { opacity: 1; }
.node.is-flagged .dot { opacity: 1; }

.node.is-secondary .shape { stroke: var(--faint); }
.node.is-secondary .dot, .node.is-secondary text { fill: var(--faint); }
.node.is-secondary .label { color: var(--muted); }
.node.is-secondary.type-info .fill-ink { fill: var(--faint); }

.node.is-flagged:not(.is-current) .glyph-wrap::after {
  content: "✶";
  position: absolute;
  right: -13px;
  top: -9px;
  color: var(--accent);
  font-size: 12px;
  animation: blink 1s steps(2, jump-none) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.label {
  position: absolute;
  top: 15px;
  left: -75px;
  width: 150px;
  text-align: center;
  pointer-events: none;
}

.label-title, .label-sub {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background: var(--paper);
  padding: 0 3px;
}

.label-title { font-size: 14px; line-height: 1.3; }
.label-sub { display: table; margin-left: auto; margin-right: auto; }

.label-sub {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transition: opacity 200ms;
}

.node.is-current .label-sub, .node:hover .label-sub { opacity: 1; }

/* ---------- map tools ---------- */

.map-tools {
  position: fixed;
  left: 24px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.map-tools button {
  height: 30px;
  min-width: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: 14px var(--font);
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(17, 17, 17, .06);
}

.map-tools button:hover { background: var(--ink); color: var(--card); }
.map-tools .wander { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.hint { margin-left: 10px; color: var(--muted); font-size: 12px; }

kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--faint);
  border-radius: 4px;
  font: 11px var(--font);
}

/* ---------- panel ---------- */

.panel {
  position: fixed;
  right: var(--panel-right);
  top: 50%;
  transform: translateY(-50%);
  width: var(--panel-width);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
  scrollbar-width: thin;
}

.card {
  background: var(--card);
  border-radius: 8px;
  padding: 6px 24px 10px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 12px;
  border-bottom: 1px dashed var(--ink);
  text-decoration: none;
}

.index-card.is-collapsed .card-head { border-bottom: 0; padding-bottom: 10px; }

.card-title, .tab-title {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card-action { font-size: 16px; line-height: 1; text-decoration: none; padding: 2px 4px; }

.icon { width: 10px; height: 10px; flex: none; fill: var(--ink); }
.icon .fill-accent { stroke: none; }
.icon .fill-paper { fill: var(--card); }

.card-body { padding: 16px 0 16px; }
.card-body p { margin: 0 0 10px; }
.card-body p:last-child { margin-bottom: 0; }

.node-head { margin-bottom: 14px; }
.node-title { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.25; }
.card-body .node-sub { margin: 2px 0 0; color: var(--muted); }
.card-body .node-meta {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.node-links { list-style: none; margin: 12px 0 2px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }

.tab { border-top: 1px dashed var(--ink); }

.tab summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  list-style: none;
  cursor: pointer;
}

.tab summary::-webkit-details-marker { display: none; }
.tab-count { color: var(--muted); font-size: 12px; }
.indicator::before { content: "+"; font-size: 16px; }
.tab[open] .indicator::before { content: "–"; }

.list { list-style: none; margin: 0 0 10px; padding: 0; }

.list-group {
  padding: 10px 0 4px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.item {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  padding: 6px 0;
  text-decoration: none;
}

.item-compact { grid-template-columns: 14px 1fr; gap: 12px; }

.item:hover b { text-decoration: underline; text-underline-offset: 3px; }

.item-id { font-size: 11px; color: var(--muted); padding-top: 2px; }
.item-id .icon { margin-top: 2px; }
.item-id.is-now { color: var(--accent); }
.item-title b { display: block; font-weight: 500; }
.item-title span { color: var(--muted); }

.noscript { max-width: 560px; margin: 15vh auto; padding: 0 16px; }

/* ---------- small screens: map on top, panel below ---------- */

@media (max-width: 899px) {
  .map { bottom: 45svh; }

  .map-tools { left: 12px; bottom: calc(45svh + 10px); }
  .hint { display: none; }

  .panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    transform: none;
    width: auto;
    height: 45svh;
    max-height: none;
    padding: 0 12px 12px;
    background: var(--paper);
    border-top: 1px solid rgba(17, 17, 17, .08);
  }

  .card { padding: 4px 16px 8px; }
  .panel > .card:first-child { margin-top: 12px; }
  .item:not(.item-compact) { grid-template-columns: 72px 1fr; }


}

@media (prefers-reduced-motion: reduce) {
  .node.is-flagged .glyph-wrap::after, .edge { animation: none; }
}
