/* meliani.xyz — the home terminal. */

html, body { min-height: 100%; }

body {
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, var(--bg-raise) 0%, var(--bg) 70%) fixed,
    var(--bg);
}

.screen {
  position: relative;
  max-width: 920px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 96px;
  font-size: clamp(19px, 1.2vw + 14px, 26px);
  line-height: 1.22;
  text-shadow: 0 0 6px var(--glow), 0 0 1px var(--fg);
  cursor: text;
  animation: flicker 6s infinite steps(1);
}

.output { white-space: pre-wrap; overflow-wrap: anywhere; }
.output p { margin: 0; min-height: 1.22em; }

.dim { color: var(--fg-dim); }
.accent { color: var(--accent); text-shadow: 0 0 6px rgba(255, 212, 71, 0.4); }
.err { color: var(--danger); text-shadow: 0 0 6px rgba(255, 107, 94, 0.45); }
.inverse { background: var(--fg); color: var(--bg); text-shadow: none; padding: 0 0.25em; }
.output a { color: var(--accent); text-underline-offset: 3px; }

/* Pixel banner (SVG built by the script). */
.banner { margin: 0.7em 0 0.3em !important; line-height: 0; }
.banner svg { display: block; width: min(100%, 560px); height: auto; overflow: visible; }
.banner-face { fill: var(--fg); }
.banner-shadow { fill: var(--fg-faint); }
.banner-sub {
  font-family: var(--pixel);
  font-size: clamp(9px, 1.4vw, 13px);
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  margin-bottom: 1em !important;
}

/* Progress bars and the modem: built from block characters by the script. */
.bar { letter-spacing: -0.02em; }

/* The prompt: a real <input> stretched invisibly over a mirror line with a block cursor. */
.prompt {
  position: relative;
  display: flex;
  align-items: baseline;
  flex-wrap: nowrap;
  gap: 0.4em;
}
.prompt-label { flex: none; color: var(--fg); white-space: pre; }
.line { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmd {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  font-size: 16px; /* below 16px, iOS zooms the page on focus */
  border: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}
.cursor {
  display: inline-block;
  width: 0.55em;
  background: var(--fg);
  box-shadow: 0 0 8px var(--glow);
  animation: blink 1.06s infinite steps(1);
}
.prompt:not(.focused) .cursor {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--fg);
  animation: none;
}
.prompt.busy .cursor { animation: none; opacity: 0.3; }

.tap-hint {
  margin: 1.4em 0 0;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--fg-dim);
  animation: blink 1.6s infinite steps(1);
}

.noscript { padding: 24px 16px; font-size: 22px; }

/* Space invader marching along the bottom edge — two-frame sprite, steps() all the way. */
.invader {
  position: fixed;
  left: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 44px;
  height: 32px;
  background-repeat: no-repeat;
  background-size: 88px 32px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 40;
  opacity: 0.85;
  filter: drop-shadow(0 0 4px var(--glow));
  animation:
    march 28s infinite steps(56),
    sprite 0.5s infinite steps(1);
}
.invader.boom { animation: none; opacity: 0; transition: opacity 0.4s steps(3); }

/* CRT power-on: a bright line draws across, then the picture opens from the middle. */
.power-on {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image: linear-gradient(var(--fg), var(--fg));
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0 2px;
  animation: power-line 0.9s forwards steps(12);
}
.power-on::before,
.power-on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  background: #000;
  animation: power-open 0.5s 0.55s forwards steps(8);
}
.power-on::before { top: 0; transform-origin: top; }
.power-on::after { bottom: 0; transform-origin: bottom; }
.power-on.done { display: none; }

@keyframes power-line {
  0% { background-size: 0 2px; }
  55% { background-size: 100% 2px; opacity: 1; }
  100% { background-size: 100% 2px; opacity: 0; }
}
@keyframes power-open {
  to { transform: scaleY(0); }
}
@keyframes blink {
  50% { opacity: 0; }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: 0.96; }
  42% { opacity: 1; }
  77% { opacity: 0.98; }
  78% { opacity: 1; }
}
@keyframes march {
  from { transform: translateX(-60px); }
  to { transform: translateX(calc(100vw + 20px)); }
}
@keyframes sprite {
  0% { background-position: 0 0; }
  50% { background-position: -44px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .power-on, .invader { display: none; }
}
