/* ---------- Tokens ---------- */
:root {
  --bg: #0a1a2f;
  --grid: rgba(120, 180, 255, .07);
  --line: #3b6ea8;
  --wire: #7cc4ff;
  --node: #0f2440;
  --core: #10294a;
  --panel: #0c1f38;
  --text: #dbe8f7;
  --soft: #b9cbe0;
  --dim: #7d95b3;
  --up: #5be39b;
  --amber: #ffb547;

  --sans: "Chivo", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bar: 52px;
  --drawer: min(600px, 100vw);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible { outline: 2px solid var(--wire); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 50;
  padding: 8px 12px; background: var(--amber); color: var(--bg); border-radius: 4px;
}
.skip:focus { top: 12px; }

.led {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}
.led.up { background: var(--up); box-shadow: 0 0 0 3px rgba(91, 227, 155, .15); }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  height: var(--bar);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(16px, 3vw, 32px);
  font-size: 14px;
}
.topbar .title { font-weight: 600; text-decoration: none; letter-spacing: .01em; }
.topbar nav { display: flex; gap: 20px; }
.topbar nav a { color: var(--dim); text-decoration: none; }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--wire); }

/* ---------- Map ---------- */
.map {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 620px;
  padding: var(--bar) 0 40px;
}

.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wires path { fill: none; stroke: var(--line); stroke-width: 1.5; transition: stroke .2s; }
.wires path.on { stroke: var(--wire); stroke-width: 2; }
.wires circle { fill: var(--wire); }

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

.leaves li, .core {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
}

.node {
  display: block;
  background: var(--node);
  border: 1.5px solid var(--line);
  border-radius: 6px;
}

.leaf {
  min-width: 168px;
  padding: 12px 14px;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.leaf strong { display: block; font-size: 17px; font-weight: 600; }
.leaf .meta { display: block; margin-top: 2px; font-size: 12.5px; color: var(--dim); }
.leaf:hover, .leaf.active {
  border-color: var(--wire);
  box-shadow: 0 0 0 4px rgba(124, 196, 255, .12);
}
.leaf:hover { transform: translateY(-1px); }

.core {
  width: min(380px, 86vw);
  padding: 20px 22px;
  background: var(--core);
  border: 2px solid var(--wire);
  z-index: 1;
}
.core h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: -.01em; }
.core .role { margin: 4px 0 0; color: var(--dim); font-size: 14px; }
.core .motd {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--soft);
  font-size: 15px;
}
.core .motd a { color: var(--wire); }

/* ---------- Drawer ---------- */
.drawer {
  background: var(--panel);
  border-left: 1.5px solid var(--line);
}

.js .drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 20;
  width: var(--drawer);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .3s ease, visibility 0s .3s;
  box-shadow: -20px 0 60px rgba(0, 0, 0, .35);
}
.js .drawer.open {
  transform: none;
  visibility: visible;
  transition: transform .3s ease;
}
.js .panel { display: none; }
.js .panel.current { display: block; }
.js body.drawer-open :is(.core > *, .leaf:not(.active) > *, .wires path:not(.on)) { opacity: .4; }
.js body.drawer-open :is(.core, .leaf:not(.active)) { border-color: #1d3a5f; }

.drawer-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: flex-end; align-items: center;
  height: var(--bar);
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid #1d3a5f;
  font-size: 13px;
}
.drawer-head .close {
  color: var(--dim);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid #1d3a5f;
  border-radius: 4px;
}
.drawer-head .close:hover { color: var(--text); border-color: var(--line); }

/* Without JS the drawer is just a page section */
html:not(.js) .drawer-head { display: none; }

.panel { padding: 28px 28px 48px; }
html:not(.js) .panel { max-width: 720px; border-bottom: 1px solid #1d3a5f; }

.panel h2 { margin: 0; font-size: 28px; font-weight: 600; outline: none; }
.panel .lead { margin: 6px 0 24px; color: var(--soft); font-size: 17px; }
.panel .lead a { color: var(--wire); }
.panel p { color: var(--soft); }

/* Work: each role as a port */
.ports { list-style: none; margin: 0; padding: 0; }
.ports > li {
  position: relative;
  padding: 0 0 26px 22px;
  border-left: 1.5px solid #1d3a5f;
}
.ports > li:first-child { border-left-color: var(--line); }
.ports > li:last-child { padding-bottom: 0; }
.ports .port-head {
  display: flex; align-items: center; gap: 8px;
  margin-left: -26.5px;
  font-size: 13px; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.ports .port-head .led { box-shadow: 0 0 0 4px var(--panel); }
.ports .port-head .led:not(.up) { background: var(--line); }
.ports h3 { margin: 6px 0 0; font-size: 19px; font-weight: 600; }
.ports .where { margin: 2px 0 8px; color: var(--dim); font-size: 14px; }
.ports p { margin: 0 0 8px; font-size: 15px; }
.ports ul { margin: 0; padding-left: 18px; color: var(--soft); font-size: 15px; }
.ports ul li { margin: 2px 0; }
.ports ul li::marker { color: var(--line); }

/* Photography */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.gallery figure {
  margin: 0;
  aspect-ratio: 4 / 5;
  border: 1px solid #1d3a5f;
  border-radius: 6px;
  overflow: hidden;
  background: var(--node);
}
.gallery figure:first-child { grid-column: span 2; aspect-ratio: 3 / 2; }
.gallery a { display: block; height: 100%; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .15s; }
.gallery a:hover img { opacity: .85; }
.gallery .empty {
  display: grid; place-items: center;
  height: 100%;
  font-size: 13px; color: var(--dim);
  background: repeating-linear-gradient(0deg, rgba(124, 196, 255, .04) 0 2px, transparent 2px 4px);
}
.cta { color: var(--wire); font-size: 14px; text-decoration: none; }
.cta:hover { text-decoration: underline; }

/* Stack */
.spec { margin: 0; }
.spec > div { padding: 16px 0; border-top: 1px solid #1d3a5f; }
.spec dt { margin-bottom: 10px; font-size: 13px; color: var(--amber); }
.spec dd { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--node);
  font-size: 14px;
}

/* About */
.facts { margin: 28px 0 0; }
.facts > div {
  display: grid; grid-template-columns: 120px 1fr; gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #1d3a5f;
}
.facts dt { font-size: 13px; color: var(--dim); padding-top: 1px; }
.facts dd { margin: 0; }

/* Contact */
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.links a {
  display: flex; align-items: baseline; gap: 16px;
  padding: 14px 16px;
  background: var(--node);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  font-size: 17px;
  transition: border-color .15s;
}
.links a:hover { border-color: var(--wire); }
.links a span { width: 84px; flex: none; font-size: 13px; color: var(--dim); }

/* ---------- Status bar ---------- */
.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  height: 40px;
  padding: 0 clamp(16px, 3vw, 32px);
  font-size: 13px;
  color: var(--dim);
}

/* ---------- Phone: the map becomes a tree ---------- */
@media (max-width: 760px) {
  .topbar { position: static; }
  .topbar nav { display: none; }

  .map {
    height: auto; min-height: 0;
    padding: 8px 16px 32px;
  }
  .wires { display: none; }

  .core, .leaves li { position: relative; left: auto; top: auto; transform: none; }
  .core { width: auto; }
  .core h1 { font-size: 30px; }

  .leaves { position: relative; margin-left: 22px; padding: 18px 0 0 22px; }
  .leaves li { margin-bottom: 12px; }
  .leaves li:last-child { margin-bottom: 0; }
  .leaves li::before, .leaves li::after { content: ""; position: absolute; left: -22px; }
  .leaves li::before { top: 50%; width: 22px; border-top: 1.5px solid var(--line); }
  .leaves li::after { top: -12px; bottom: 0; border-left: 1.5px solid var(--line); }
  .leaves li:first-child::after { top: -18px; }
  .leaves li:last-child::after { bottom: 50%; }
  .leaf { min-width: 0; }

  .statusbar { position: static; }
  .statusbar .hint { display: none; }
  .js body.drawer-open :is(.core > *, .leaf:not(.active) > *) { opacity: 1; }
  .js body.drawer-open .core { border-color: var(--wire); }
  .js body.drawer-open .leaf:not(.active) { border-color: var(--line); }

  .panel { padding: 24px 20px 40px; }
  .drawer-head { padding: 0 20px; }
}

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