/* ============================================================
   R&D room: a HUD, not a gallery.
   Phosphor terminal, codec frames, a star map of ideas.
   ============================================================ */

.rnd {
  --void:    #020604;
  --deep:    #06110C;
  --phos:    #39FF88;   /* phosphor green */
  --phos-d:  rgba(57, 255, 136, .55);
  --phos-f:  rgba(57, 255, 136, .14);
  --ice:     #22D3EE;   /* shared cyan */
  --alert:   #FF2BB0;   /* shared magenta */

  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #0A1D14 0%, var(--deep) 40%, var(--void) 100%);
  color: var(--phos);
  font-family: var(--mono);
}
.rnd[hidden] { display: none; }

/* CRT power-on and power-off */
.rnd.on  { animation: crtOn .7s cubic-bezier(.2, .8, .2, 1) both; }
.rnd.off { animation: crtOff .45s cubic-bezier(.6, 0, .8, .4) both; }
@keyframes crtOn {
  0%   { transform: scale(1, .004); filter: brightness(3); }
  45%  { transform: scale(1, .004); filter: brightness(3); }
  70%  { transform: scale(1, 1.02); filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}
@keyframes crtOff {
  0%   { transform: none; filter: none; }
  60%  { transform: scale(1, .004); filter: brightness(3); }
  100% { transform: scale(0, .004); filter: brightness(5); opacity: 0; }
}

/* Background layers */
.rnd-rain { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .22; }
.rnd-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--phos-f) 1px, transparent 1px),
    linear-gradient(90deg, var(--phos-f) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  opacity: .5;
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.28) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.scanlines::after {
  content: ""; position: absolute; left: 0; right: 0; height: 120px;
  background: linear-gradient(to bottom, transparent, rgba(57,255,136,.06), transparent);
  animation: sweep 7s linear infinite;
}
@keyframes sweep { from { top: -120px; } to { top: 100%; } }

/* HUD chrome */
.hud-top, .hud-foot {
  position: absolute; left: 0; right: 0; z-index: 4;
  display: flex; align-items: center; gap: 24px;
  padding: 18px 28px;
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
}
.hud-top { top: 0; border-bottom: 1px solid var(--phos-f); background: linear-gradient(to bottom, rgba(2,6,4,.9), transparent); }
.hud-foot { bottom: 0; justify-content: space-between; border-top: 1px solid var(--phos-f); }
.hud-title { flex: 1; text-align: center; color: var(--phos); text-shadow: 0 0 8px var(--phos-d); }
.hud-meta { display: flex; gap: 22px; color: var(--phos-d); }
.hud-meta b { color: var(--phos); font-weight: 700; }
.dim { color: var(--phos-d); }
.blink { animation: blink 1.1s steps(1) infinite; color: var(--alert); }
@keyframes blink { 50% { opacity: 0; } }

.hud-btn {
  background: transparent;
  border: 1px solid var(--phos-d);
  color: var(--phos);
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  padding: 10px 14px;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.hud-btn:hover, .hud-btn:focus-visible { background: var(--phos-f); outline: none; box-shadow: 0 0 14px var(--phos-f) inset; }

/* The star map */
.rnd-map { position: absolute; inset: 0; z-index: 2; }
.rnd-map svg { width: 100%; height: 100%; display: block; }

.ring { fill: none; stroke: var(--phos-f); stroke-width: 1; }
.ring.dash { stroke-dasharray: 2 8; stroke: var(--phos-d); opacity: .5; }
.spin      { animation: spin 90s linear infinite; transform-origin: 0 0; }
.spin.rev  { animation-duration: 140s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

.core { fill: var(--phos); filter: drop-shadow(0 0 10px var(--phos)); }
.core-pulse { fill: none; stroke: var(--phos); stroke-width: 1; transform-origin: 0 0; animation: pulse 2.6s ease-out infinite; }
@keyframes pulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(3); opacity: 0; } }
.core-label { fill: var(--phos-d); font-size: 10px; letter-spacing: .3em; }

.sys { cursor: pointer; outline: none; }
.sys .sys-body { fill: var(--deep); stroke: var(--phos); stroke-width: 1.5; transition: fill .3s; }
.sys .sys-glow { fill: var(--phos); opacity: .12; transition: opacity .3s; }
.sys .sys-code { fill: var(--phos); font-size: 10px; font-weight: 700; letter-spacing: .12em; pointer-events: none; }
.sys .sys-name { fill: var(--phos); font-size: 14px; letter-spacing: .24em; text-transform: uppercase; pointer-events: none; text-shadow: 0 0 6px var(--phos-d); }
.sys .sys-tag  { fill: var(--alert); font-size: 9px; letter-spacing: .3em; pointer-events: none; }
.sys .tether { stroke: var(--phos-f); stroke-dasharray: 1 5; }
.sys:hover .sys-glow, .sys:focus-visible .sys-glow { opacity: .3; }
.sys:hover .sys-body, .sys:focus-visible .sys-body { fill: #0D2A1C; }

.moon circle { fill: var(--void); stroke: var(--phos-d); stroke-width: 1; }
.moon text   { fill: var(--phos-d); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; }
.moon.redacted circle { stroke: var(--alert); }
.moon.redacted text   { fill: var(--alert); }
.moon-line { stroke: var(--phos-f); }

/* Lock-on brackets around the selected system */
.lock { fill: none; stroke: var(--ice); stroke-width: 2; opacity: 0; }
.sys.locked .lock { opacity: 1; animation: lockOn .6s cubic-bezier(.2, .8, .2, 1) both, spin 12s linear .6s infinite; transform-origin: 0 0; }
@keyframes lockOn { from { transform: scale(2.4) rotate(-45deg); opacity: 0; } to { transform: none; opacity: 1; } }
.sys.locked .sys-glow { opacity: .4; }
.has-lock .sys:not(.locked) { opacity: .3; }
.has-lock .moon-set:not(.lit) { opacity: .2; }

/* The codec card */
.codec {
  position: absolute;
  top: 76px; right: 28px; bottom: 64px;
  width: min(460px, calc(100vw - 56px));
  z-index: 6;
  display: flex; flex-direction: column;
  background: rgba(3, 12, 8, .88);
  border: 1px solid var(--phos-d);
  box-shadow: 0 0 0 1px rgba(57,255,136,.08), 0 0 40px rgba(57,255,136,.12) inset;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  transform: translateX(110%);
  opacity: 0;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .3s;
}
.codec.open { transform: none; opacity: 1; }
.codec-scroll { flex: 1; overflow-y: auto; padding: 26px 28px; }
.codec-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: .28em; color: var(--phos-d);
  padding-bottom: 12px; border-bottom: 1px solid var(--phos-f);
}
.codec-head b { color: var(--phos); }
.codec-close {
  background: none; border: 1px solid var(--phos-d); color: var(--phos);
  width: 30px; height: 30px; cursor: pointer; font: inherit; font-size: 14px;
}
.codec-close:hover { background: var(--phos-f); }
.codec h2 {
  margin: 22px 0 6px;
  font-family: var(--mono);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--phos);
  text-shadow: 0 0 12px var(--phos-d);
}
/* Typed-in effect on the title */
.codec h2 .type {
  display: inline-block; overflow: hidden; white-space: nowrap; vertical-align: bottom;
  border-right: 2px solid var(--phos); padding-right: 4px;
  width: calc(var(--n) * 1.04ch + 6px); max-width: 100%;
  animation: type 1s steps(var(--n)) both, caret .8s steps(1) 1s 4;
}
@keyframes type { from { width: 0; } }
@keyframes caret { 50% { border-color: transparent; } }

.maturity {
  display: inline-block;
  margin: 10px 0 18px;
  padding: 5px 10px;
  border: 1px solid var(--alert);
  color: var(--alert);
  font-size: 10px; font-weight: 700; letter-spacing: .34em;
  text-transform: uppercase;
  box-shadow: 0 0 12px rgba(255, 43, 176, .25);
}
.maturity.plausible   { border-color: var(--ice); color: var(--ice); box-shadow: 0 0 12px rgba(34,211,238,.25); }
.maturity.established { border-color: var(--phos); color: var(--phos); box-shadow: 0 0 12px var(--phos-f); }

.abstract { margin: 0 0 14px; font-family: var(--sans); font-size: 16px; line-height: 1.55; color: #CFFFE2; }
.codec-sec { padding: 14px 0; border-top: 1px dashed var(--phos-f); }
.codec-sec h3 { margin: 0 0 6px; font-size: 10px; letter-spacing: .3em; color: var(--phos-d); font-weight: 600; }
.codec-sec p  { margin: 0; font-family: var(--sans); font-size: 14.5px; line-height: 1.6; color: #BDEFD2; }
.codec-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.codec-chips span {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  padding: 4px 8px; border: 1px solid var(--phos-f); color: var(--phos-d);
}
.codec-chips span.redacted { border-color: var(--alert); color: var(--alert); }

.repo-btn {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0; padding: 18px 28px;
  border-top: 1px solid var(--phos-d);
  color: var(--void); background: var(--phos);
  font-size: 12px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase;
  text-decoration: none;
}
.repo-btn:hover, .repo-btn:focus-visible { background: var(--ice); outline: none; }

/* Gallery nav link to the room */
.nav .rnd-link { color: var(--graphite); }
.nav .rnd-link:hover { color: #0b7a3f; text-decoration-color: #39FF88; }

/* Small screens: the codec becomes a bottom sheet */
@media (max-width: 720px) {
  .hud-meta { display: none; }
  .hud-title { text-align: right; font-size: 10px; }
  .hud-top { padding: 14px 16px; gap: 10px; }
  .codec { top: auto; left: 12px; right: 12px; width: auto; height: 70vh; bottom: 12px; transform: translateY(110%); }
  .codec.open { transform: none; }
  .hud-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rnd-rain { display: none; }
}
