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

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --paper: #f0f2f4;
  --paper-2: #e6eaee;
  --ink: #15171c;
  --muted: #525a66;
  --line: #d8dde3;
  --accent: #0c6b4f;
  --accent-ink: #f0f2f4;
  --accent-soft: #e0e8e3;
  --maxw: 1240px;
  --gutter: clamp(1.25rem, 4vw, 4rem);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  --paper: #12161c;
  --paper-2: #1a2028;
  --ink: #e7ebf1;
  --muted: #98a2b1;
  --line: #2a3140;
  --accent: #3ddc97;
  --accent-ink: #0b1511;
  --accent-soft: #16281f;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.25s ease, color 0.25s ease;
}

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

/* ---- Top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.5rem var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wordmark {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.social { display: flex; align-items: center; gap: 0.15rem; }
.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.social-link svg { width: 17px; height: 17px; fill: currentColor; }
.social-link:hover { background: var(--accent-soft); color: var(--accent); }
.social-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* ---- Labyrinth background ---- */

#labyrinth {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
main, .footer { position: relative; z-index: 1; }

/* ---- Masthead ---- */

.masthead,
main > * { max-width: var(--maxw); margin-left: auto; margin-right: auto; }

.masthead {
  padding-top: clamp(2rem, 4vw, 3.5rem);
  padding-bottom: clamp(2rem, 4vw, 3.5rem);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: clamp(1.5rem, 3vw, 3rem);
  align-items: start;
}

.name {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 5.25rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-weight: 800;
  max-width: 14ch;
}

.role {
  margin: 0.75rem 0 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.lede {
  margin: 0.9rem 0 0;
  max-width: 66ch;
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.5;
  color: var(--muted);
}

.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;
}

.hero-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: stretch;
  gap: 0.75rem;
  min-width: 0;
}
.hero-actions > * { min-height: 2.6rem; }

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 2px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-ghost:hover { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); filter: none; }

/* ---- Terminal command ---- */

.try-box {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper-2);
  min-width: 0;
  max-width: 100%;
}
.try-cmd {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.88rem;
  padding: 0 0.75rem;
  white-space: nowrap;
}
.try-cmd .prompt { color: var(--accent); user-select: none; margin-right: 1ch; }
.copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  padding: 0;
  border: none;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.copy svg { width: 15px; height: 15px; }
.copy:hover { color: var(--accent); }
.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.copy-done { display: none; color: var(--accent); }
.copy[data-state="copied"] .copy-idle { display: none; }
.copy[data-state="copied"] .copy-done { display: block; }

/* ---- Sections ---- */

.block {
  padding-top: clamp(1.5rem, 2.5vw, 2.25rem);
  padding-bottom: clamp(1.5rem, 2.5vw, 2.25rem);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  border-top: 1px solid var(--line);
}

.highlights {
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}
.highlights li {
  position: relative;
  padding-left: 1.3rem;
  max-width: 72ch;
}
.highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
}

/* ---- Tabs ---- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}
.tab {
  position: relative;
  padding: 0.6rem 0.9rem;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--muted);
  text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab:focus-visible, .subtab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.subtabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.subtab {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: var(--paper);
}
.subtab:hover { color: var(--ink); border-color: var(--muted); }
.subtab[aria-selected="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.panel.inactive, .subpanel.inactive { display: none; }
.panel-title, .subpanel-title { display: none; }

/* ---- Trees ---- */

.tree, .tree-children, .leaves, .chips, .research, .cards, .stack {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree { display: grid; gap: 0.15rem; max-width: 980px; }
.tree-children { margin: 0.35rem 0 0 0.6rem; padding-left: 0.9rem; border-left: 1px solid var(--line); display: grid; gap: 0.1rem; }

.branch > summary { list-style: none; }
.branch > summary::-webkit-details-marker { display: none; }
.tree-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
}
.tree-row.static { cursor: default; padding-left: 0; }
.branch > .tree-row:hover { background: var(--accent-soft); }
.tree-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.caret {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-0.12em) rotate(-45deg);
  transition: transform 0.15s ease;
}
.branch[open] > summary .caret { transform: translateY(-0.2em) rotate(45deg); border-color: var(--accent); }

/* Smooth hover-expand: the branch content eases its height and fades in/out
   instead of snapping. `interpolate-size` lets the block-size go 0 -> auto. */
.branch[data-hover] { interpolate-size: allow-keywords; }
.branch[data-hover]::details-content {
  block-size: 0;
  opacity: 0;
  overflow: clip;
  transition:
    block-size 0.22s ease,
    opacity 0.18s ease,
    content-visibility 0.22s allow-discrete;
}
.branch[data-hover][open]::details-content {
  block-size: auto;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .branch[data-hover]::details-content { transition: none; }
}

.row-main { flex: 1; min-width: 0; font-weight: 600; }
.row-meta { flex: none; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.org > summary .row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.75rem; }
.org-name { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.org-role { font-weight: 500; color: var(--muted); }
.node-note { margin: 0.1rem 0 0.4rem 1.7rem; max-width: 70ch; color: var(--muted); }
.private-h { margin: 0.7rem 0 0.15rem 1.7rem; font-family: var(--mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.org { margin-bottom: 0.75rem; }

.leaves { display: grid; gap: 0.4rem; padding: 0.35rem 0 0.75rem 1.7rem; max-width: 76ch; }
.leaves li { position: relative; padding-left: 1.1rem; }
.leaves li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--accent);
}

/* ---- Depth levels ---- */

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.dot[data-level="production"] { background: var(--accent); }
.dot[data-level="built"] { box-shadow: inset 0 0 0 2px var(--accent); }
.dot[data-level="used"] { background: var(--muted); }
.dot[data-level="researched"] { box-shadow: inset 0 0 0 1.5px var(--muted); opacity: 0.8; }
.mix { display: inline-flex; gap: 3px; flex-wrap: wrap; max-width: 40%; justify-content: flex-end; }
.mix .dot { width: 6px; height: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0.4rem 0 0.9rem 1.7rem; }
.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  font-size: 0.92rem;
}
.tool[data-level="researched"] { color: var(--muted); border-style: dashed; }
.tool .since { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.tool.filtered { display: none; }

.research { display: grid; gap: 0.45rem; padding: 0.35rem 0 0.9rem 1.7rem; max-width: 900px; }
.research li { display: flex; align-items: baseline; gap: 0.7rem; }
.research-title { flex: 1; }
.research .since { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }

.badge {
  flex: none;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: lowercase;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge[data-outcome="adopted"], .badge[data-status="live"] { color: var(--accent); border-color: var(--accent); }
.badge[data-outcome="planned"], .badge[data-outcome="ongoing"] { color: var(--ink); }

/* ---- Toolbar: filter + sort ---- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0.75rem;
  max-width: 980px;
}
.filters, .sort { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.chip, .seg {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.chip .n { font-family: var(--mono); font-size: 0.72rem; }
.chip:hover, .seg:hover { color: var(--ink); border-color: var(--muted); }
.chip[aria-pressed="true"], .seg[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
.chip:focus-visible, .seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sort-label { font-size: 0.78rem; color: var(--muted); margin-right: 0.15rem; }
.legend { margin: 0; font-size: 0.88rem; color: var(--muted); }

/* ---- Project cards ---- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0.9rem; max-width: 1100px; }
.card {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.card-name { font-weight: 700; color: var(--ink); text-decoration: none; }
a.card-name:hover { color: var(--accent); }
.card-text { margin: 0; color: var(--muted); font-size: 0.93rem; }
.stack { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.stack li { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); padding: 0.1rem 0.4rem; border: 1px solid var(--line); border-radius: 2px; }

/* ---- How this site runs ---- */

.flow {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
  gap: 2.25rem;
}
.node {
  position: relative;
  flex: 1;
  display: grid;
  gap: 0.2rem;
  align-content: start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper-2);
}
.node + .node::before {
  content: "→";
  position: absolute;
  left: -1.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-family: var(--mono);
}
.node-title { font-weight: 700; }
.node-sub { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.runs { margin-top: 1.4rem; }
.runs code, .exp-summary code { font-family: var(--mono); font-size: 0.88em; color: var(--accent); }

/* ---- Footer ---- */

.footer {
  margin-top: clamp(2rem, 3vw, 2.5rem);
  background: var(--accent);
  color: var(--accent-ink);
  padding-top: clamp(1.5rem, 2.5vw, 2rem);
  padding-bottom: clamp(1.5rem, 2.5vw, 2rem);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; }
.colophon {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}
.footer-meta {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  opacity: 0.85;
}
.footer-meta a { color: inherit; }

/* ---- 404 ---- */

.notfound .name { max-width: none; }

@media (max-width: 1080px) {
  .masthead { grid-template-columns: 1fr; }
  .hero-actions { justify-content: flex-start; margin-top: 1.5rem; }
}

/* ---- Responsive ---- */

@media (max-width: 760px) {
  .mix { display: none; }
  .tab { padding: 0.5rem 0.6rem; }
  .tab[aria-selected="true"]::after { left: 0.6rem; right: 0.6rem; }
  .chips, .leaves, .research, .node-note { padding-left: 0.4rem; margin-left: 0; }
  .research li { flex-wrap: wrap; }
  .wordmark { font-size: 0.9rem; }
  .flow { flex-direction: column; gap: 1.6rem; }
  .node + .node::before { content: "↓"; left: 1rem; top: -1.35rem; transform: none; }
}
