/* TERM.09 — a terminal for a station nobody staffs.
   Phosphor blue on near-black. One colour, one typeface, one idea. */

:root {
  --void: #07070D;
  --phos: #7A8CFF;   /* the phosphor */
  --dim:  #4E579E;   /* what it says when it is not shouting */
  --deep: #2B3061;   /* the far side of the canopy */
  --on:   #07070D;   /* ink on a lit tag */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--void);
  color: var(--dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.7;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--phos); color: var(--on); }

:focus-visible { outline: 1px solid var(--phos); outline-offset: 3px; }

/* ---------- the four corner tags ---------- */
.hud {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}

.tag {
  position: absolute;
  background: var(--phos);
  color: var(--on);
  padding: 3px 9px;
  white-space: nowrap;
  max-width: calc(50vw - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl { top: 12px; left: 12px; }
.tr { top: 12px; right: 12px; }
.bl { bottom: 12px; left: 12px; }
.br { bottom: 12px; right: 12px; }

.mute {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  pointer-events: auto;
}

.mute[aria-pressed="true"] {
  background: none;
  color: var(--dim);
  box-shadow: inset 0 0 0 1px var(--deep);
}

/* ---------- stage one: the connection ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
  text-align: center;
  transition: opacity 0.7s ease;
}

.boot.off { opacity: 0; pointer-events: none; }

.boot-line {
  color: var(--phos);
  letter-spacing: 0.16em;
  text-shadow: 0 0 10px color-mix(in srgb, var(--phos) 30%, transparent);
  min-height: 1.7em;
}

.boot-log {
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.95;
  color: var(--dim);
  white-space: pre-wrap;
  text-align: left;
  min-height: 11em;
  margin: 0;
}

.boot-act { min-height: 40px; }

.caret {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  vertical-align: text-bottom;
  background: var(--phos);
  animation: blink 1.1s ease-in-out infinite;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.12; } }

.btn {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.18em;
  padding: 10px 22px;
  background: none;
  border: 1px solid var(--phos);
  color: var(--phos);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover, .btn:focus-visible {
  background: var(--phos);
  color: var(--on);
  box-shadow: 0 0 22px color-mix(in srgb, var(--phos) 40%, transparent);
}

/* ---------- stage two: the array ---------- */
.array { position: fixed; inset: 0; }

#sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#sky.held { cursor: grabbing; }

.legend {
  position: absolute;
  left: 50%;
  bottom: 210px;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--dim);
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.legend.gone { opacity: 0; }

/* ---------- the console ---------- */
.console {
  position: absolute;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 40px));
  background: color-mix(in srgb, var(--void) 82%, transparent);
  backdrop-filter: blur(3px);
  border: 1px solid var(--deep);
  padding: 12px 14px;
}

.out {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.75;
  color: var(--dim);
  white-space: pre-wrap;
  max-height: 132px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 8px;
}

.out:empty { display: none; }

.out b { color: var(--phos); font-weight: 500; }

.in { display: flex; align-items: baseline; gap: 9px; }

.prompt { color: var(--phos); }

#cmd {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  font: inherit;
  color: var(--phos);
  caret-color: var(--phos);
}

#cmd::placeholder { color: var(--deep); }
#cmd:focus { outline: none; }

/* ---------- the glass ---------- */
.scan, .grain {
  position: fixed;
  pointer-events: none;
}

.scan {
  inset: 0;
  z-index: 45;
  opacity: 0.5;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0 2px, rgba(0, 0, 0, 0.42) 2px 3px),
    radial-gradient(ellipse at center,
      transparent 52%, rgba(0, 0, 0, 0.6) 100%);
}

.grain {
  inset: -60%;
  width: 220%;
  height: 220%;
  z-index: 50;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.7s steps(5) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -2%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0, 0); }
}

.nojs {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 24px;
  text-align: center;
  color: var(--phos);
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .caret { animation: none; }
  .boot { transition: none; }
}

@media (max-width: 620px) {
  .hud { font-size: 9.5px; }
  .bl, .br { max-width: calc(50vw - 16px); }
  .scan { display: none; }
  .console { bottom: 40px; padding: 10px 12px; }
  /* a whole number of lines, so the log never ends on a sliced one */
  .out { max-height: 105px; }
  .legend { bottom: 190px; }
}
