:root {
  --bg: #000;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --line: #1f2937;
  --panel: rgba(8, 10, 16, 0.88);
  --accent: #38bdf8;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body.exploring { overflow: hidden; }

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

/* ---------- Mapa ---------- */
#journey { position: relative; height: 100vh; height: 100svh; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #000;
}

body.exploring .stage {
  position: fixed;
  inset: 0;
  height: auto;
  z-index: 50;
}

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}
body.exploring #gl { touch-action: none; cursor: grab; }
body.exploring #gl:active { cursor: grabbing; }

#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Rótulos 3D (CSS2DRenderer) */
.node-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(229, 231, 235, 0.85);
  white-space: nowrap;
  text-shadow: 0 0 6px #000, 0 0 2px #000;
  pointer-events: none;
  transition: opacity 0.2s;
}
.node-label span { display: block; transform: translateY(14px); }
.node-label.hub {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.node-label.hub span { transform: translateY(22px); }
.node-label.core {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}
.node-label.core span { transform: translateY(-34px); }
.node-label.dim { opacity: 0.15 !important; }
.node-label.cull { opacity: 0 !important; }
.node-label.hot { color: #fff; font-weight: 700; }
@media (max-width: 640px) {
  .node-label.leaf { display: none; }
  .node-label.leaf.hot { display: block; }
  .node-label.hub { font-size: 10px; }
}

/* Botões */
.btn {
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, border-color 0.15s;
}
a.btn { text-decoration: none; display: inline-block; }
.btn:hover { background: rgba(30, 41, 59, 0.9); border-color: #475569; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(90deg, #0ea5e9, #6366f1);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  padding: 11px 22px;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.35);
}

.map-ui {
  position: absolute;
  bottom: 4vh;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  padding: 0 16px;
}
.map-ui.on { pointer-events: auto; }
.map-hint, .controls-hint {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-align: center;
}
body.exploring .map-ui { display: none; }

.explore-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: none;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
body.exploring .explore-bar { display: flex; }
.search { margin-right: auto; }
.search input {
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 9px 16px;
  width: min(300px, 60vw);
  outline: none;
}
.search input:focus { border-color: var(--accent); }

.controls-hint {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: none;
  pointer-events: none;
}
body.exploring .controls-hint { display: block; }

/* Painel de detalhes (estilo why-graph: cada conexão com o motivo) */
.panel {
  position: absolute;
  top: 72px;
  right: 16px;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100% - 130px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  z-index: 3;
}
.panel[hidden] { display: none; }
.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.panel-cat {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.panel-title { margin: 0 24px 6px 0; font-size: 18px; line-height: 1.3; }
.panel-status {
  display: inline-block;
  margin: 0 0 8px;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid #334155;
  color: #cbd5e1;
}
.panel-status:empty { display: none; }
.panel-detail { margin: 0 0 12px; color: #cbd5e1; font-size: 14px; line-height: 1.5; }
.panel-detail:empty { display: none; }
.panel-sub {
  margin: 8px 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.panel-links button {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--fg);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c, #64748b);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.panel-links button:hover { background: rgba(30, 41, 59, 0.8); }
.panel-links strong { display: block; font-size: 13px; }
.panel-links span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

@media (max-width: 640px) {
  .panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 45%;
  }
  body.exploring .panel:not([hidden]) ~ .controls-hint { display: none; }
}

.fallback[hidden] { display: none; }
.fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Lista de detalhes ---------- */
#details {
  max-width: 1080px;
  margin: 0 auto;
  padding: 96px 16px 64px;
}
#details h2 { font-size: clamp(26px, 4vw, 36px); margin: 0 0 12px; letter-spacing: -0.02em; }
#details .summary { color: #cbd5e1; line-height: 1.6; max-width: 720px; margin: 0 0 36px; }
#details h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}
#details h3:not(:first-child) { margin-top: 28px; }
.columns { display: grid; grid-template-columns: 1fr 1.3fr; gap: 40px; }
@media (max-width: 760px) { .columns { grid-template-columns: 1fr; } }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cards li {
  border: 1px solid var(--line);
  border-left: 3px solid var(--c, #facc15);
  border-radius: 10px;
  padding: 12px 14px;
  background: #07080b;
}
.cards li strong { display: block; }
.cards li span { color: var(--muted); font-size: 14px; }

.skill-group { margin-bottom: 18px; }
.skill-group h4 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chips li {
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #07080b;
}

footer {
  border-top: 1px solid #111;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  padding: 24px 16px 32px;
}
footer a { color: var(--accent); }

/* ---------- Abertura: terminal ---------- */
html.intro-on, html.intro-on body { overflow: hidden; }
.term {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4vh 16px 56px;
  background: radial-gradient(ellipse at 50% 40%, #04120b, #000 70%);
  cursor: pointer;
}
.term-win {
  position: relative;
  width: min(940px, 100%);
  height: min(78vh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(34, 255, 136, 0.28);
  border-radius: 10px;
  background: rgba(2, 10, 6, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 60px rgba(34, 255, 136, 0.12), 0 30px 80px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  will-change: transform;
}
/* linhas de varredura e brilho de monitor */
.term-win::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.28) 2px 3px),
    radial-gradient(ellipse at center, rgba(34, 255, 136, 0.05), rgba(0, 0, 0, 0.45) 85%);
  animation: termFlicker 4s infinite steps(1);
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(34, 255, 136, 0.16);
  background: rgba(34, 255, 136, 0.04);
  font: 12px var(--mono);
  color: #4ade80;
}
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #1f3b2b; }
.term-bar i:nth-child(1) { background: #f43f5e; }
.term-bar i:nth-child(2) { background: #facc15; }
.term-bar i:nth-child(3) { background: #22c55e; }
.term-bar span { flex: 1; text-align: center; margin-right: 50px; opacity: 0.8; }
.term-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 22px;
  font: 14.5px/1.65 var(--mono);
  color: #b6f5cf;
  text-shadow: 0 0 6px rgba(34, 255, 136, 0.45);
  scrollbar-width: thin;
  scrollbar-color: #14532d transparent;
}
.term-body .ln { white-space: pre-wrap; word-break: break-word; min-height: 1.65em; }
.term-body .ln.gap { margin-top: 0.7em; }
.term-body .ln.ind { padding-left: 2ch; }
/* chave e valor lado a lado; o valor quebra alinhado a si mesmo */
.term-body .ln.kv { display: grid; grid-template-columns: max-content 1fr; column-gap: 1ch; }
.term-body .p-user { color: #22ff88; font-weight: 700; }
.term-body .p-sep { color: #6ee7b7; }
.term-body .p-dir { color: #38bdf8; }
.term-body .cmd { color: #f0fdf4; }
.term-body .k { color: #34d399; }
.term-body .v { color: #d1fae5; }
.term-body .v.hi, .term-body .hi { color: #ffffff; font-weight: 700; text-shadow: 0 0 10px rgba(34, 255, 136, 0.8); }
.term-body .h { color: #22ff88; font-weight: 700; }
.term-body .m { color: #4d9a6c; }
.term-body .ok { color: #22ff88; }
.term-body .b { color: #60a5fa; }
.term-body .y { color: #facc15; }
.term-body a { color: #38bdf8; text-decoration: underline; text-underline-offset: 3px; }
.term-body .cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  margin-left: 2px;
  vertical-align: -0.22em;
  background: #22ff88;
  box-shadow: 0 0 10px #22ff88;
  animation: termBlink 1s steps(1) infinite;
}
.term-skip { position: absolute; bottom: 20px; left: 0; right: 0; margin: 0; text-align: center; font: 12px var(--mono); color: #166534; }

/* zoom: a janela cresce a partir do cursor, fica clara e some revelando o mapa */
.term.zoom { pointer-events: none; animation: termFade 1.4s ease-in forwards; }
.term.zoom .term-win { animation: termZoom 1.4s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.term.zoom .term-skip { opacity: 0; transition: opacity 0.3s; }
@keyframes termZoom {
  0% { transform: scale(1); filter: brightness(1) blur(0); }
  70% { filter: brightness(2.2) blur(1px); }
  100% { transform: scale(26); filter: brightness(4) blur(6px); }
}
@keyframes termFade {
  0%, 45% { opacity: 1; background-color: #000; }
  100% { opacity: 0; }
}
@keyframes termBlink { 50% { opacity: 0; } }
@keyframes termFlicker { 0% { opacity: 1; } 47% { opacity: 0.8; } 48% { opacity: 1; } 91% { opacity: 0.88; } 92% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .term-win::after { animation: none; }
  .term.zoom, .term.zoom .term-win { animation: none; }
  .term.zoom { opacity: 0; transition: opacity 0.35s; }
}

/* ---------- Terminal interativo ---------- */
.map-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn.mono { font-family: var(--mono); color: #86efac; border-color: rgba(34, 255, 136, 0.35); background: rgba(2, 14, 8, 0.8); }
.btn.mono:hover { border-color: #22ff88; background: rgba(4, 30, 16, 0.9); }
.map-hint kbd {
  font: inherit;
  color: #86efac;
  border: 1px solid #14532d;
  border-radius: 4px;
  padding: 0 5px;
}
.shell {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 80;
  width: min(540px, calc(100vw - 32px));
  height: min(52vh, 480px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(34, 255, 136, 0.3);
  border-radius: 10px;
  background: rgba(2, 10, 6, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 40px rgba(34, 255, 136, 0.12), 0 20px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: shellIn 0.22s ease-out;
}
.shell[hidden] { display: none; }
.shell .term-bar span { margin-right: 0; }
.shell-close {
  font: inherit;
  color: #4ade80;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0 2px;
}
.shell-close:hover { color: #fff; }
.shell .shell-out { flex: 1; padding: 12px 16px 4px; font-size: 13.5px; }
.shell .shell-out .ln.res { margin-bottom: 0.5em; }
.term-body .r { color: #fb7185; }
.shell-line {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1ch;
  padding: 6px 16px 12px;
  font-size: 13.5px;
  cursor: text;
}
.shell-line input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: #f0fdf4;
  caret-color: #22ff88;
  background: none;
  border: 0;
  outline: none;
  text-shadow: inherit;
}
/* o painel de detalhes fica à direita; com o terminal aberto, a dica de controles sai do caminho */
body.shell-open .controls-hint { opacity: 0; }
@keyframes shellIn { from { transform: translateY(14px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .shell { animation: none; } }

/* ---------- Linha do tempo ---------- */
.tl-caption {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 12px;
  background: rgba(8, 10, 16, 0.85);
  backdrop-filter: blur(6px);
  color: var(--fg);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
}
body.timeline .tl-caption { opacity: 1; transform: translate(-50%, 0); }
.tl-caption .tl-when { font-family: var(--mono); font-size: 12px; color: #facc15; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.tl-caption .tl-n { font-family: var(--mono); font-size: 12px; color: var(--muted); }
body.timeline .controls-hint { opacity: 0; }
/* com o terminal aberto no canto esquerdo, a legenda vai para a direita */
body.shell-open .tl-caption { left: auto; right: 16px; transform: none; max-width: calc(100vw - 590px); }
@media (min-width: 1100px) { body.shell-open .map-ui { padding-left: 572px; } }

/* ---------- Multiverso: links para a nave e selo dos universos de exemplo ---------- */
.btn.nave { color: #bae6fd; border-color: rgba(56, 189, 248, 0.45); background: rgba(6, 18, 36, 0.8); }
.btn.nave:hover { border-color: #38bdf8; background: rgba(12, 32, 60, 0.9); }
[data-real][hidden] { display: none !important; }
.demo-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 7px 14px;
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 999px;
  background: rgba(20, 16, 4, 0.8);
  backdrop-filter: blur(6px);
  color: #fde68a;
  font: 12px var(--mono);
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
}
.demo-badge strong { color: #facc15; text-transform: uppercase; letter-spacing: 0.1em; margin-right: 6px; }
.demo-badge[hidden] { display: none; }
body.exploring .demo-badge { top: 64px; }
#footLi[hidden] { display: none; }

/* Universo da própria pessoa e o atalho para criar o seu */
.btn.criar { color: #f5d0fe; border-color: rgba(232, 121, 249, 0.45); background: rgba(30, 6, 36, 0.8); }
.btn.criar:hover { border-color: #e879f9; background: rgba(48, 10, 58, 0.9); }
.mine-badge { border-color: rgba(34, 255, 136, 0.45); background: rgba(2, 20, 10, 0.85); color: #bbf7d0; pointer-events: auto; }
.mine-badge strong { color: #22ff88; }
.mine-badge a { color: #86efac; }
