/* Colors are taken from an old long-persistence (P7) radar tube:
   the beam flashes blue-white, then fades to a yellow-green glow. */
:root {
  --glass: #0f1a16;        /* page: dark bottle-green glass */
  --tube: #0a120f;         /* scope interior */
  --grid: #3d5c48;         /* range rings, crosshair */
  --flash: #e4f0ff;        /* beam leading edge */
  --afterglow: #b8d86a;    /* phosphor persistence */
  --ink: #c7d6b4;          /* text */
  --ink-dim: #6f8a76;      /* secondary text */

  --scope: min(84vw, 52vh, 440px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: radial-gradient(ellipse at 50% 38%, #142420 0%, var(--glass) 60%);
  background-color: var(--glass);
  color: var(--ink);
  font-family: "B612", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.console {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 36px);
  padding: 32px 16px 40px;
}

.name {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

/* ---------- scope ---------- */

.scope {
  position: relative;
  width: var(--scope);
  height: var(--scope);
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #12201a 0%, var(--tube) 70%);
  /* the tube's glass edge */
  box-shadow:
    0 0 0 1px #24382d,
    0 0 0 6px #0c1511,
    0 0 0 7px #24382d,
    inset 0 0 60px rgba(0, 0, 0, 0.75);
}

.grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.grid circle, .grid line {
  fill: none;
  stroke: var(--grid);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
}

.grid .rings circle:first-child { stroke-width: 1; }
.grid .cross line { stroke-opacity: 0.55; }
.grid .ticks line { stroke-opacity: 0.8; }

/* Rotated from JS. The leading edge sits at 0deg; the trail fades behind it. */
.beam {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 250deg,
    rgba(184, 216, 106, 0.05) 300deg,
    rgba(184, 216, 106, 0.16) 345deg,
    rgba(184, 216, 106, 0.30) 358.6deg,
    var(--flash) 359.3deg,
    var(--flash) 360deg
  );
  will-change: transform;
}

.blip {
  position: absolute;
  width: 0;
  height: 0;
  visibility: hidden;
}

.blip.on { visibility: visible; }

.blip .glow, .blip .core {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.blip .glow {
  width: calc(var(--scope) * 0.075);
  height: calc(var(--scope) * 0.075);
  background: radial-gradient(circle, rgba(214, 236, 138, 0.95) 0%, rgba(184, 216, 106, 0.4) 40%, transparent 70%);
}

.blip .core {
  width: calc(var(--scope) * 0.03);
  height: calc(var(--scope) * 0.03);
  background: var(--flash);
  box-shadow: 0 0 12px 4px rgba(228, 240, 255, 0.7);
}

/* ---------- form ---------- */

.ask {
  display: flex;
  width: min(100%, 440px);
  border-bottom: 1px solid var(--grid);
  transition: border-color 0.2s;
}

.ask:focus-within { border-color: var(--afterglow); }

.ask input {
  flex: 1;
  min-width: 0;
  padding: 12px 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.125rem;
  caret-color: var(--afterglow);
}

.ask input::placeholder { color: var(--ink-dim); opacity: 1; }
.ask input:focus { outline: none; }

.ask button {
  flex: none;
  padding: 12px 6px 12px 16px;
  border: 0;
  background: transparent;
  color: var(--afterglow);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.ask button:hover { color: var(--flash); }
.ask button:focus-visible { outline: 1px solid var(--afterglow); outline-offset: -4px; }
.ask button:disabled { color: var(--ink-dim); cursor: default; }

/* empty question: the underline flickers like a weak signal */
.ask.nudge { animation: flicker 0.5s steps(1) 1; }

@keyframes flicker {
  0%, 40%, 80% { border-color: var(--flash); }
  20%, 60%, 100% { border-color: var(--grid); }
}

/* ---------- answer ---------- */

.answer {
  margin: 0;
  min-height: 1.15em;
  font-size: clamp(3rem, 14vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--afterglow);
  text-shadow: 0 0 18px rgba(184, 216, 106, 0.35);
  opacity: 0;
  transition: opacity 0.6s ease-out;
}

.answer.shown { opacity: 1; }

/* the readout flashes blue-white first, then settles into the afterglow */
.answer.shown.fresh { animation: settle 1.2s ease-out 1; }

@keyframes settle {
  from { color: var(--flash); text-shadow: 0 0 28px rgba(228, 240, 255, 0.8); }
  to   { color: var(--afterglow); text-shadow: 0 0 18px rgba(184, 216, 106, 0.35); }
}

.answer.error {
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
  color: var(--ink);
  text-shadow: none;
  max-width: 36ch;
  text-align: center;
}

.note {
  flex: none;
  padding: 0 16px 20px;
  text-align: center;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

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

@media (prefers-reduced-motion: reduce) {
  .beam { display: none; }
  .ask.nudge { animation: none; border-color: var(--flash); }
  .answer.shown.fresh { animation: none; }
}
