:root {
  --bg: #05060c;
  --fg: #dfe3ee;
  --dim: #7a8196;
  --faint: #3a3f52;
  --accent: #ff8a3d;
  --frame: rgba(255, 138, 61, 0.72);
  --fill: rgba(6, 6, 12, 0.9);
  --font: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --hud: 12px;
}

* { box-sizing: border-box; }

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

#scene {
  position: fixed;
  left: 0;
  top: 0;
  display: block;
  cursor: crosshair;
}
body.pointer #scene { cursor: pointer; }

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

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  z-index: 3;
  font-size: var(--hud);
  line-height: 1.5;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(5, 6, 12, 0.9), 0 0 2px rgba(5, 6, 12, 1);
  transition: opacity 0.6s ease;
}
body.booting .hud { opacity: 0; }
.hud-tr { top: 22px; right: 26px; text-align: right; color: var(--dim); white-space: pre; }
.hud-bl { bottom: 22px; left: 26px; color: var(--fg); white-space: pre; }
.hud-br { bottom: 22px; right: 26px; color: var(--dim); }
.hud-br .key { color: var(--fg); }

.cursor { animation: blink 1.05s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- home caption: one block of characters ---------- */
.caption {
  position: fixed;
  z-index: 3;
  top: 22px;
  left: 22px;
  pointer-events: none;
  opacity: 0;
  clip-path: inset(0 100% 0 0);
  transition: opacity 0.3s ease, clip-path 0.7s steps(24);
}
.caption.on { opacity: 1; clip-path: inset(0 0 0 0); }
.caption pre {
  margin: 0;
  font: 9.5px/1.2 var(--font);
  color: var(--fg);
}
#cap-face { position: absolute; margin: 0; font: 4.6px/1.2 var(--font); font-weight: 700; background: none; }
/* solid fill only where there are characters (each box), not the gap between boxes */
.caption pre span.c-frame, .caption pre span { background: none; }
.caption { filter: drop-shadow(0 0 0 transparent); }
.c-frame { color: var(--frame); }
.c-sub { color: #ffd2b8; }
.c-txt { color: #e6e1dc; }
.c-hint { color: var(--accent); }

/* ---------- planet labels: ascii tags ---------- */
#labels { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

.label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--fg);
  font: 700 14px/1.35 var(--font);
  text-transform: uppercase;
  white-space: pre;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.4s ease, color 0.15s ease;
  text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg), 0 0 12px var(--bg);
}
body.show-labels .label { opacity: 1; }
body:not(.show-labels) .label { pointer-events: none; }
.label .br { color: var(--frame); }
.label .idx { color: var(--accent); }
.label .lb-hint { font-weight: 400; font-size: 12px; text-transform: none; color: var(--dim); }
.label .lb-hint::before { content: "~ "; color: var(--faint); }
.label.hover, .label:focus-visible { color: #fff; outline: none; }
.label.hover .br, .label:focus-visible .br { color: var(--accent); }
.label.hover .lb-hint, .label:focus-visible .lb-hint { color: var(--fg); }

/* ---------- hover reticle ---------- */
#reticle {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.1;
}
#reticle.on { opacity: 1; }
#reticle .c { position: absolute; white-space: pre; transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
#reticle .tl { left: 0; top: 0; }
#reticle .tr { right: 0; top: 0; text-align: right; }
#reticle .bl { left: 0; bottom: 0; }
#reticle .br { right: 0; bottom: 0; text-align: right; }
#reticle:not(.on) .tl { transform: translate(-10px, -10px); }
#reticle:not(.on) .tr { transform: translate(10px, -10px); }
#reticle:not(.on) .bl { transform: translate(-10px, 10px); }
#reticle:not(.on) .br { transform: translate(10px, 10px); }
#reticle .readout { position: absolute; left: calc(100% + 10px); top: 0; color: var(--dim); white-space: pre; }

/* ---------- docked navigation: <- previous | v back | next -> ---------- */
#dock-nav {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 3ch;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#dock-nav.on { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.nav-btn {
  padding: 6px 12px;
  border: 0;
  background: var(--fill);
  color: var(--dim);
  font: 700 13px/1.2 var(--font);
  text-transform: uppercase;
  white-space: pre;
  cursor: pointer;
  transition: color 0.15s ease;
}
.nav-btn[hidden] { display: block; visibility: hidden; }
#back-btn { color: var(--fg); font-size: 14px; }
.nav-btn:hover, .nav-btn:focus-visible { color: var(--accent); outline: none; }

/* ---------- info panel: a box drawn with characters ---------- */
#panel {
  position: fixed;
  z-index: 4;
  top: 50%;
  font: 14px/1.55 var(--font);
  background: var(--fill);
  opacity: 0;
  transform: translate(0, -50%);
  clip-path: inset(0 0 100% 0);
  transition: opacity 0.25s ease, clip-path 0.55s steps(18);
}
#panel.open { opacity: 1; clip-path: inset(0 0 0 0); }

.abox-top, .abox-bot { display: flex; white-space: pre; color: var(--frame); }
.abox-top h2 { margin: 0; font: inherit; font-weight: 700; color: #fff; }
.abox-top .panel-idx { color: var(--accent); }
#panel-close { border: 0; padding: 0; background: none; font: inherit; color: var(--fg); cursor: pointer; }
#panel-close:hover, #panel-close:focus-visible { color: var(--accent); outline: none; }

.abox-mid { position: relative; padding: 0 2ch; }
.abox-side {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1ch;
  overflow: hidden;
  white-space: normal;
  word-break: break-all;
  color: var(--frame);
}
.abox-side.l { left: 0; }
.abox-side.r { right: 0; }

.panel-body {
  max-height: calc(82vh - 3em);
  overflow-y: auto;
  padding: 0.75em 0 0.9em;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}
.panel-body p { margin: 0 0 1.5em; }
.panel-body .lead { color: #fff; font-weight: 700; }
.panel-body .dim { color: var(--dim); }
.panel-body a { color: #fff; text-decoration: none; }
.panel-body a:hover, .panel-body a:focus-visible { color: var(--accent); outline: none; }

.panel-body ul { list-style: none; margin: 0 0 1.5em; padding: 0; }
.panel-body .kicker { margin: 0 0 0.75em; color: var(--accent); text-transform: uppercase; }
.panel-body .kicker::before { content: "== "; color: var(--frame); }
.panel-body .kicker::after { content: " =="; color: var(--frame); }

.panel-body .list li { margin: 0 0 1.5em; }
.panel-body .list li:last-child { margin-bottom: 0; }
.panel-body .list .row, .panel-body .list a { display: flex; align-items: flex-start; }
.panel-body .list .leader, .panel-body .list .m { align-self: flex-end; }
.panel-body .list .row::before, .panel-body .list a::before { content: "> "; color: var(--accent); white-space: pre; }
.panel-body .list .t { font-weight: 700; }
.panel-body .list a .t::after { content: " ->"; color: var(--accent); }
.panel-body .leader { flex: 1; min-width: 2ch; overflow: hidden; white-space: nowrap; color: var(--faint); padding: 0 1ch; }
.panel-body .leader::before { content: "........................................................................................................................"; }
.panel-body .m { white-space: nowrap; color: var(--dim); }
.panel-body .list .sub { margin-left: 2ch; color: #c9c4cf; }
.panel-body .list p { margin: 0 0 0 2ch; color: var(--dim); }
.panel-body .list li.has-logo { display: grid; grid-template-columns: auto 1fr; column-gap: 2ch; align-items: start; }
/* logo holograms: real logo floating in 3D, blue glow, scanline shimmer */
.holo { position: relative; width: 92px; height: 80px; perspective: 240px; margin-top: 0.15em; }
.holo.empty { visibility: hidden; }
.holo-img {
  position: absolute;
  left: 11px;
  top: 2px;
  width: 70px;
  height: 70px;
  transform-origin: 50% 100%;
  animation: holo-sway 7s ease-in-out infinite, holo-flicker 6.1s steps(1) infinite;
  animation-delay: var(--d, 0s);
}
.hl { position: absolute; inset: 0; background: var(--img) center / contain no-repeat; }
.hl:not(.r):not(.c) { filter: brightness(1.12) drop-shadow(0 0 1px rgba(210, 245, 255, 0.9)) drop-shadow(0 0 6px rgba(110, 210, 255, 0.6)); }
.hl.r { transform: translateX(-1.6px); opacity: 0.4; mix-blend-mode: screen; filter: sepia(1) saturate(9) hue-rotate(-45deg); }
.hl.c { transform: translateX(1.6px); opacity: 0.4; mix-blend-mode: screen; filter: sepia(1) saturate(9) hue-rotate(155deg); }
.hs {
  position: absolute;
  inset: 0;
  -webkit-mask: var(--img) center / contain no-repeat;
  mask: var(--img) center / contain no-repeat;
  background:
    repeating-linear-gradient(0deg, rgba(5, 6, 12, 0.55) 0 1px, transparent 1px 3px),
    linear-gradient(to bottom, transparent, rgba(170, 235, 255, 0.45), transparent) 0 0 / 100% 35% no-repeat;
  animation: holo-band 2.6s linear infinite;
  animation-delay: var(--d, 0s);
}
@keyframes holo-sway {
  0%, 100% { transform: rotateY(-20deg) rotateX(10deg) translateY(2px); }
  50% { transform: rotateY(-6deg) rotateX(5deg) translateY(-4px); }
}
@keyframes holo-flicker {
  0%, 90%, 100% { opacity: 0.94; }
  91% { opacity: 0.45; }
  92% { opacity: 0.9; }
  94% { opacity: 0.6; }
  95% { opacity: 0.94; }
}
@keyframes holo-band { from { background-position: 0 0, 0 -80%; } to { background-position: 0 0, 0 280%; } }
/* publication visuals: hologram screens */
.holo-media { margin: 0.9em 0 0.3em 2ch; perspective: 700px; max-width: calc(100% - 2ch); }
.holo-media .hm {
  position: relative;
  width: fit-content;
  max-width: 100%;
  transform-origin: 50% 100%;
  animation: media-float 8s ease-in-out infinite, holo-flicker 7.3s steps(1) infinite;
}
.holo-media img { display: block; max-width: 100%; height: auto; }
.holo-media.screen img {
  width: 370px;
  filter: brightness(0.8) contrast(1.08) saturate(1.1);
  box-shadow: 0 0 0 1px rgba(140, 220, 255, 0.4), 0 0 22px rgba(110, 210, 255, 0.28);
}
.holo-media.robot .hm { animation: robot-turn 9s ease-in-out infinite, holo-flicker 7.3s steps(1) infinite; }
@keyframes robot-turn {
  0%, 100% { transform: rotateX(8deg) rotateY(-22deg) translateY(0); }
  50% { transform: rotateX(4deg) rotateY(16deg) translateY(-5px); }
}
.holo-media.float img { width: 480px; filter: brightness(1.05) drop-shadow(0 0 1px rgba(210, 245, 255, 0.7)) drop-shadow(0 0 7px rgba(110, 210, 255, 0.45)); }
.holo-media.float.robot img { width: 160px; }
.hm-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(5, 6, 12, 0.32) 0 1px, transparent 1px 3px),
    linear-gradient(to bottom, transparent, rgba(170, 235, 255, 0.12), transparent) 0 0 / 100% 30% no-repeat;
  animation: holo-band 4.5s linear infinite;
}
.holo-media.screen .hm-scan { background-color: rgba(60, 150, 255, 0.07); }
@keyframes media-float {
  0%, 100% { transform: rotateX(6deg) rotateY(-9deg) translateY(0); }
  50% { transform: rotateX(3deg) rotateY(-3deg) translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) { .holo-img, .hs, .holo-media .hm, .holo-media.robot .hm, .hm-scan { animation: none; } }
.entry-body { min-width: 0; }
.panel-body .links li { display: flex; }
.panel-body .links .m { order: 0; }
.panel-body .links .leader { order: 1; }
.panel-body .links li > :not(.m):not(.leader) { order: 2; }
.panel-body .links + .dim { margin-top: 1.5em; }

/* ---------- fallback ---------- */
#fallback { position: fixed; inset: 0; padding: 40px; overflow: auto; z-index: 5; background: var(--bg); font-size: 14px; line-height: 1.7; }
#fallback section { margin: 0 0 32px; max-width: 640px; }
#fallback h2 { font-size: 14px; text-transform: uppercase; color: var(--accent); }

#debug { position: fixed; left: 8px; bottom: 60px; z-index: 9; color: #f66; font-size: 11px; white-space: pre-wrap; max-width: 90vw; }

/* ---------- small screens ---------- */
@media (max-aspect-ratio: 19/20) {
  .caption { top: 12px; left: 12px; }
  .caption pre { font-size: 10px; }
  .label { font-size: 12px; }
  .label .lb-hint { font-size: 10px; }
  .hud-bl { bottom: 16px; left: 16px; }
  .hud-br, .hud-tr { display: none; }
  #reticle .readout { display: none; }
  /* phone: the box takes ~70% of the screen, the planet sits in the top 30% */
  #panel { left: 12px; right: auto; top: 30vh; bottom: 58px; transform: none; font-size: 12px; display: flex; flex-direction: column; }
  .abox-mid { flex: 1; min-height: 0; }
  #dock-nav { bottom: 14px; gap: 1ch; }
  .nav-btn { font-size: 11px; padding: 6px 6px; }
  .panel-body { max-height: none; height: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

/* screenshots / debug: no transitions */
body.sim *, body.sim *::before, body.sim *::after { transition: none !important; }
