/* ==========================================================================
   Compound V — terminal shell
   Ported from the announce video (compound.translator): full-bleed phosphor
   on near-black, lime text with a soft bloom, older lines dimmed.
   ========================================================================== */

:root {
  /* surface */
  --bg: #070806;
  --bg-lit: #10130c;          /* centre of the tube, a touch warmer */

  /* phosphor */
  --ph: #eaffa5;              /* compound lime */
  --ph-dim: rgba(234, 255, 165, 0.42);
  --ph-faint: rgba(234, 255, 165, 0.22);
  --ph-glow: rgba(234, 255, 165, 0.38);
  --ph-bloom: rgba(234, 255, 165, 0.12);

  /* accent (from the flyer); used sparingly */
  --violet: #783f8a;

  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --fs: clamp(16px, 1.1vw + 11px, 20px);   /* 16px floor: stops iOS zooming into the name input */
  --lh: 1.6;

  --gutter: clamp(20px, 7vw, 88px);
  --ease-out: cubic-bezier(0.2, 0.7, 0.3, 1);
}

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

html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  font-family: var(--mono);
  font-size: var(--fs);
  line-height: var(--lh);
  color: var(--ph);
  background:
    radial-gradient(120% 90% at 50% 40%, var(--bg-lit) 0%, var(--bg) 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--ph); color: var(--bg); text-shadow: none; }

/* --------------------------------------------------------------------------
   CRT overlay: scanlines, vignette, faint flicker
   -------------------------------------------------------------------------- */

.crt {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.crt__scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px
  );
  mix-blend-mode: multiply;
}

.crt__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

.crt__flicker {
  position: absolute;
  inset: 0;
  background: var(--ph);
  opacity: 0;
  animation: flicker 6s steps(1) infinite;
}

@keyframes flicker {
  0%   { opacity: 0.012; }
  37%  { opacity: 0.02; }
  38%  { opacity: 0.008; }
  71%  { opacity: 0.016; }
  72%  { opacity: 0.03; }
  73%  { opacity: 0.012; }
}

/* --------------------------------------------------------------------------
   Screen + power-on
   -------------------------------------------------------------------------- */

.screen {
  position: relative;
  min-height: 100dvh;
  padding:
    calc(var(--gutter) * 0.9 + env(safe-area-inset-top))
    var(--gutter)
    calc(var(--gutter) + env(safe-area-inset-bottom));
  transform-origin: 50% 50%;
}

/* CRT turn-on: a bright horizontal line opens out into the picture */
.screen.is-powering {
  animation: power-on 620ms var(--ease-out) both;
}

@keyframes power-on {
  0%   { transform: scale(1, 0.004); filter: brightness(6); opacity: 0.6; }
  35%  { transform: scale(1, 0.004); filter: brightness(6); opacity: 1; }
  70%  { transform: scale(1, 1.02);  filter: brightness(1.6); }
  100% { transform: scale(1, 1);     filter: brightness(1); }
}

/* --------------------------------------------------------------------------
   Terminal lines
   -------------------------------------------------------------------------- */

.term {
  max-width: 44rem;
  transition: opacity 200ms ease, filter 200ms ease;
}

/* between screens: a quick phosphor flare-out, like the tube clearing */
.term.is-wiping {
  opacity: 0;
  filter: brightness(2.2) blur(1px);
}

/* dose meter in the question header: [■■··] 2/4 */
.meter__on  { color: var(--ph); text-shadow: 0 0 6px var(--ph-glow); }
.meter__off { color: var(--ph-faint); }

.line {
  min-height: calc(var(--fs) * var(--lh));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 0 6px var(--ph-glow), 0 0 22px var(--ph-bloom);
  transition: color 400ms ease, text-shadow 400ms ease;
}

/* lines already read fall back, like the video */
.line.is-dim {
  color: var(--ph-dim);
  text-shadow: 0 0 6px var(--ph-bloom);
}

.line--sys   { color: var(--ph-dim); text-shadow: 0 0 6px var(--ph-bloom); }
.line--gap   { height: 0.9em; min-height: 0; }
.line--reply { padding-left: 1.4ch; }

/* wrapped lines hang under the text, not under the > / → */
.line.has-prefix               { padding-left: 2ch; text-indent: -2ch; }
.line.has-prefix.line--reply   { padding-left: 3.4ch; }

.prompt,
.arrow {
  display: inline-block;
  width: 2ch;
  text-indent: 0;              /* don't inherit the hanging indent */
  color: inherit;
}

.muted { color: var(--ph-faint); }
.ok    { color: var(--ph); }

/* dotted leaders for boot checks: "label ........ ok" */
.leader {
  display: flex;
  gap: 1ch;
  max-width: 34ch;
}
.leader__dots {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  color: var(--ph-faint);
}
.leader__dots::before { content: "................................................................"; }

/* block cursor */
.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.15em;
  margin-left: 0.08em;
  vertical-align: -0.2em;
  background: var(--ph);
  box-shadow: 0 0 8px var(--ph-glow);
  animation: blink 1.05s steps(1) infinite;
}
.cursor.is-typing { animation: none; }

@keyframes blink { 50% { opacity: 0; } }

/* --------------------------------------------------------------------------
   Terminal actions: bracketed, typographic; selection = inverted phosphor
   -------------------------------------------------------------------------- */

/* options stack as a menu: one per line, reads the same at any width */
.actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin-top: 0.6rem;
  margin-left: -0.6ch;
}

.cmd {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--ph);
  text-shadow: 0 0 6px var(--ph-glow), 0 0 22px var(--ph-bloom);
  min-height: 44px;
  padding: 0 0.6ch;
  cursor: pointer;
  text-align: left;
  white-space: pre-wrap;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
  opacity: 0;
  animation: cmd-in 260ms var(--ease-out) forwards;
}

/* hover only for real pointers (no sticky hover on phones), and only once the
   mouse has moved on this screen, so a resting cursor doesn't pre-select */
@media (hover: hover) {
  .actions:not(.is-resting) .cmd:hover {
    background: var(--ph);
    color: var(--bg);
    text-shadow: none;
    box-shadow: 0 0 18px var(--ph-glow);
  }
  .actions:not(.is-resting) .cmd:hover .cmd__key { color: inherit; }
}

.cmd:focus-visible {
  outline: none;
  background: var(--ph);
  color: var(--bg);
  text-shadow: none;
  box-shadow: 0 0 18px var(--ph-glow);
}

.cmd:active { transform: scale(0.97); }

/* menu rows (quiz answers): "a) answer" with a full-width selection bar */
.actions--menu {
  align-items: stretch;
  gap: 0.1rem;
  margin-left: -1ch;
  margin-top: 0.9rem;
}

.cmd--menu {
  display: flex;
  gap: 1ch;
  width: 100%;
  padding: 0.5em 1ch;
  white-space: normal;
}

.cmd__key {
  flex: none;
  color: var(--ph-dim);
  text-shadow: none;
}
.cmd:focus-visible .cmd__key,
.cmd.is-chosen .cmd__key { color: inherit; }

/* the picked option holds lit for a beat before it's echoed into the log */
.cmd.is-chosen {
  transition: none;            /* lands instantly */
  background: var(--ph);
  color: var(--bg);
  text-shadow: none;
  box-shadow: 0 0 18px var(--ph-glow);
}
.cmd:disabled { cursor: default; }
.cmd:disabled:not(.is-chosen) { opacity: 0.3; }

@keyframes cmd-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Inline prompt: "resident: uche▊" (a real input dressed as terminal text)
   -------------------------------------------------------------------------- */

.ask__line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  cursor: text;
  min-height: 44px;            /* whole line is the tap target */
}

.ask__label {
  color: var(--ph-dim);
  text-shadow: 0 0 6px var(--ph-bloom);
  margin-right: 1ch;
}

.ask__field {
  display: inline-grid;
  max-width: 100%;
}

.ask__mirror,
.ask__input {
  grid-area: 1 / 1;
  font: inherit;
  letter-spacing: inherit;
  white-space: pre;
}

.ask__mirror { visibility: hidden; }

.ask__input {
  width: 100%;
  min-width: 0;
  appearance: none;
  border: 0;
  outline: none;
  padding: 0;
  background: transparent;
  color: var(--ph);
  caret-color: transparent;    /* the block cursor stands in for the caret */
  text-shadow: 0 0 6px var(--ph-glow), 0 0 22px var(--ph-bloom);
}

/* rejected name: the reason, in place, until they type again */
.ask__error:empty { display: none; }
.ask__error { color: var(--ph-dim); }

/* unfocused: cursor goes hollow, like an inactive terminal window */
.cursor.is-idle {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ph-dim);
  animation: none;
}

/* --------------------------------------------------------------------------
   Sound toggle: a thin-line speaker in the top-right corner. It names
   itself ("sound on") for a few seconds, then settles to just the icon.
   -------------------------------------------------------------------------- */

.sound-toggle {
  position: fixed;
  top: calc(6px + env(safe-area-inset-top));
  right: calc(6px + env(safe-area-inset-right));
  z-index: 12;                  /* above the CRT overlay */
  display: inline-flex;
  align-items: center;
  flex-direction: row-reverse;
  gap: 8px;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 22px;
  background: rgba(7, 8, 6, 0.85);
  color: var(--ph);
  font: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 500ms ease, color 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.sound-toggle.is-shown { opacity: 1; }
.sound-toggle svg { flex: none; filter: drop-shadow(0 0 4px var(--ph-glow)); }
.sound-toggle .off { display: none; }
.sound-toggle.is-off { color: var(--ph-dim); }
.sound-toggle.is-off svg { filter: none; }
.sound-toggle.is-off .on { display: none; }
.sound-toggle.is-off .off { display: inline; }

.sound-toggle__hint {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ph-dim);
  white-space: nowrap;
  max-width: 12ch;
  overflow: hidden;
  transition: max-width 500ms var(--ease-out), opacity 300ms ease;
}
.sound-toggle.is-settled .sound-toggle__hint { max-width: 0; opacity: 0; }
@media (hover: hover) {
  .sound-toggle.is-settled:hover .sound-toggle__hint { max-width: 12ch; opacity: 1; }
}
.sound-toggle:focus-visible { outline: 1px solid var(--ph); outline-offset: 2px; }

/* keep the first lines clear of the toggle */
body.has-sound .screen { padding-top: calc(56px + env(safe-area-inset-top)); }

/* small print along the bottom of the tube */
.hint {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 5;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ph-faint);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  opacity: 0;
  transition: opacity 600ms ease;
}
.hint.is-on { opacity: 1; }

/* --------------------------------------------------------------------------
   Reduced motion: keep the look, drop the movement
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .screen.is-powering,
  .crt__flicker,
  .cmd { animation: none; opacity: 1; }
  .cursor { animation: none; }
}
