/* =========================================================================
   VT100 phosphor terminal simulator
   Design goals
   - Fixed 80×24 (or 40×24 double-width) character grid, identical to a real
     character-mode terminal: no reflow, no soft wrap unless the cursor moves.
   - Monospace cell with overscan rows hidden — only the 24 active rows show.
   - Subtle P1/P3-style green phosphor glow + persistence flicker.
   - Pure CSS scanlines + shadow mask + curvature vignette.
   - Looks like a buffer, not a chat box.
   ========================================================================= */

:root {
  /* Phosphor palette — slightly desaturated DEC VT220 "green screen" */
  --bg-room:        #0a0d0b;
  --bg-tube:        #050a05;
  --phosphor:       #b6ffd1;
  --phosphor-mid:   #5dffa0;
  --phosphor-dim:   #1f7a45;
  --phosphor-shadow:#001a08;
  --amber-alt:      #ffcc55; /* unused, kept for theming */

  /* Cell geometry. The base unit is the character cell — every dimension
     of the viewport is a multiple of these tokens. We derive the cell width
     from the viewport so the whole 80-column tube always fits horizontally
     (with margin for the bezel), and clamp to a sensible max.
     Cell height keeps the classic 2:1 DEC aspect ratio. */
  /* Cell width is bounded by BOTH the horizontal AND vertical viewport so the
     tube grows to fill the browser without ever pushing its 24-row height past
     the screen. Horizontal: 80 cells + ~120px of bezel margin. Vertical: rows×2
     (2:1 aspect) + ~180px of bezel + button rail + breathing room. We take the
     smaller of the two and clamp to a sensible max so it stays tasteful on
     ultrawide monitors. */
  --cell-w: clamp(6px, min(calc((100vw - 80px) / 82), calc((100vh - 180px) / 50)), 18px);
  --cell-h: calc(var(--cell-w) * 2);
  --cols: 80;
  --rows: 24;
  /* Font size tracks cell width. JetBrains Mono is a normal-aspect mono font
     (not the tall 1:2 VT323 bitmap), so its glyphs only need ~1.35 of the
     cell width to fill the cell properly while leaving phosphor bloom room. */
  --tty-font-size: calc(var(--cell-w) * 1.55);

  /* Inter-glyph spacing — small positive tracking gives the buffer the airy
     feel of a real terminal without disturbing the 80-col grid. */
  --tracking: 0.02em;

  /* JetBrains Mono renders razor-sharp on retina at any size, with a hint of
     warmth that pairs beautifully with the phosphor bloom. The CRT character
     comes from the scanlines, vignette, glow, and flicker — not the typeface. */
  --font-tty: "JetBrains Mono", "IBM Plex Mono", "DejaVu Sans Mono", ui-monospace, monospace;

  /* Timing */
  --flicker-period: 7.3s;
  --refresh-period: 16.67ms; /* nominal 60Hz */
}

/* ----- Reset ----- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 90% at 50% 30%, #14181a 0%, #06080a 60%, #02030a 100%);
  color: var(--phosphor);
  font-family: var(--font-tty);
  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ----- Cabinet / bezel ----- */
#stage {
  width: 100%;
  max-width: 1680px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  gap: 14px;
}
.bezel {
  position: relative;
  padding: clamp(14px, 2.5vw, 28px) clamp(14px, 2.5vw, 28px) 16px;
  max-width: 100%;
  border-radius: 22px;
  background:
    linear-gradient(180deg, #2a2622 0%, #1c1916 50%, #0f0d0b 100%);
  box-shadow:
    inset 0 1px 0 #4a423a,
    inset 0 -2px 0 #000,
    0 30px 80px rgba(0,0,0,.6),
    0 4px 12px rgba(0,0,0,.5);
}
.bezel::before {
  /* subtle plastic grain */
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background-image:
    radial-gradient(rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* ----- The CRT tube ----- */
.screen {
  position: relative;
  /* Width and height are *derived from the cell grid* so glyphs map 1:1.
     We add a small overscan margin (~1 cell each side) like a real CRT. */
  width:  calc(var(--cell-w) * var(--cols) + 32px);
  height: calc(var(--cell-h) * var(--rows) + 32px);
  background:
    radial-gradient(110% 80% at 50% 45%, #030604 0%, #010301 70%, #000 100%);
  border-radius: 18px / 22px;  /* slight ellipse — CRT face */
  overflow: hidden;
  isolation: isolate;
  outline: 1px solid #000;
  /* Inset bezel edges — black tube interior, no green bloom on the surface. */
  box-shadow:
    inset 0 0 0 2px #1b1812,
    inset 0 0 40px rgba(0,0,0,.95),
    inset 0 0 120px rgba(0,0,0,.6),
    0 0 60px rgba(40,220,120,.04);
}

/* The buffer is a <pre> — exactly 80×24 monospace cells. No wrap, no flex. */
.buffer {
  position: absolute;
  inset: 16px;                              /* overscan */
  z-index: 8;                               /* sits ABOVE the scan beam so the beam reads against dark bg, not added on top of glyphs */
  margin: 0;
  padding: 0;
  font-family: var(--font-tty);
  font-size: var(--tty-font-size);
  /* line-height set so each row = --cell-h exactly */
  line-height: var(--cell-h);
  letter-spacing: var(--tracking);
  color: var(--phosphor);
  white-space: pre;                          /* preserve every space */
  overflow: hidden;
  caret-color: transparent;
  /* Phosphor glow — slightly tighter inner halo + a softer outer bloom so
     antialiased edges read as "glowing CRT phosphor" rather than blurry text. */
  text-shadow:
    0 0 0.5px rgba(220,255,230,.85),
    0 0 2px rgba(110,255,170,.25);
  /* Crisp antialiasing for retina — the CRT look comes from the scanlines
     and bloom, not from aliased pixel glyphs. Force grayscale AA so the
     phosphor color stays pure (no rainbow subpixel fringes through the bloom). */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: always;
  text-rendering: geometricPrecision;
  font-weight: 500;
  font-variant-ligatures: none;
  /* Behaviour: pure text buffer */
  cursor: default;
  outline: none;
}

/* Double-width / 40×24 mode — DEC DECSWL: each glyph stretched 2× horizontally.
   We achieve this by transform-scaling the buffer's X dimension and halving
   the column count. The text still occupies the same physical area. */
.screen[data-cols="40"] {
  --cols: 40;
  --cell-w: clamp(12px, calc((100vw - 120px) / 40), 22px);
}
.screen[data-cols="40"] .buffer {
  /* Stretch each character horizontally to mimic DECDWL */
  transform: scaleX(2);
  transform-origin: 0 0;
  width: calc(50% - 16px);                /* compensate so 40 chars fill the tube */
}

/* ----- CRT visual layers (purely decorative, behind/in front of glyphs) ----- */

/* Curvature: faint pincushion-like dark edges */
.crt-curvature {
  position: absolute; inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,.45) 85%, rgba(0,0,0,.9) 100%);
  pointer-events: none;
  z-index: 4;
}

/* Fine scanlines: light multiplicative pattern that reads as CRT texture
   without degrading glyph edges. Period = 3px, alpha = .18 so the text
   above stays crisp on retina. */
.crt-scanlines {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0)    0px,
    rgba(0,0,0,0)    2px,
    rgba(0,0,0,.18)  3px
  );
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 3;
  opacity: 1;
}

/* Hero effect: a slow bright scan beam that crawls top → bottom every 9s,
   like the vertical retrace on a real CRT. Lives on its own layer above
   everything (text, mask, vignette) so it always reads, with a hard bright
   line at the center and soft halos above/below. */
.crt-scan-beam {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  height: 130px;
  pointer-events: none;
  z-index: 7;
  mix-blend-mode: screen;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(120,255,170,.02) 18%,
    rgba(180,255,210,.07) 40%,
    rgba(230,255,240,.16) 50%,
    rgba(180,255,210,.07) 60%,
    rgba(120,255,170,.02) 82%,
    transparent 100%
  );
  filter: blur(0.4px);
  will-change: transform;
  animation: scan-beam-travel 9s linear infinite;
}
@keyframes scan-beam-travel {
  0%   { transform: translateY(-150px); opacity: 0; }
  6%   { opacity: 0.3; }
  94%  { opacity: 0.3; }
  100% { transform: translateY(calc(var(--cell-h) * var(--rows) + 80px)); opacity: 0; }
}

/* Shadow mask: tiny RGB-triad pattern, very subtle */
.crt-mask {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(
      to right,
      rgba(255,0,0,.04)  0,
      rgba(255,0,0,.04)  1px,
      rgba(0,255,0,.04)  1px,
      rgba(0,255,0,.04)  2px,
      rgba(0,0,255,.04)  2px,
      rgba(0,0,255,.04)  3px
    );
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 3;
  opacity: .22; /* low — just enough mask texture, no rainbow fringing on text */
}

/* Vignette: dark top/bottom edges only, no green tint */
.crt-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(80% 60% at 50% 100%, rgba(0,0,0,.35), transparent 60%),
    radial-gradient(80% 60% at 50% 0%,   rgba(0,0,0,.45), transparent 60%);
  pointer-events: none;
  z-index: 5;
}

/* Persistent phosphor glow over everything — a proper inner bloom that you
   can see breathe. Cinematic but doesn't wash out the text. */
.crt-glow {
  /* Glow disabled — green-on-green was reducing text legibility.
     Layer kept (empty) so the flicker animation hook still exists. */
  display: none;
  position: absolute; inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 6;
}
.no-flicker .crt-glow { animation: none; }
.no-flicker .buffer { animation: none !important; }

/* Phosphor breathe — noticeable opacity + brightness wobble so you can see
   the tube is "alive". Period ~7s, gentle. */
@keyframes phosphor-flicker {
  0%, 100% { opacity: .85; filter: brightness(1.00); }
  12%      { opacity: 1.05; filter: brightness(1.08); }
  18%      { opacity: .72; filter: brightness(0.93); }
  41%      { opacity: 1.02; filter: brightness(1.06); }
  47%      { opacity: .78; filter: brightness(0.96); }
  73%      { opacity: 1.08; filter: brightness(1.10); }
  79%      { opacity: .74; filter: brightness(0.95); }
}

/* Buffer micro-flicker only — no `filter` on the buffer (filter forces
   re-rasterization every frame, which softens text edges in Safari). The
   breathing effect lives entirely in the .crt-glow layer above the text. */
.buffer {
  animation: tube-jitter 60ms steps(2,end) infinite;
}
.no-flicker .buffer { animation: none !important; }

@keyframes tube-jitter {
  0%, 100% { text-shadow:
    0 0 1px rgba(180,255,210,.85),
    0 0 6px rgba(80,255,150,.55),
    0 0 18px rgba(40,220,110,.35); }
  50%      { text-shadow:
    0 0 1px rgba(180,255,210,.80),
    0 0 5px rgba(80,255,150,.50),
    0 0 16px rgba(40,220,110,.32); }
}

/* Cursor: rendered as a single character cell inverted background */
.cursor {
  display: inline-block;
  background: var(--phosphor-mid);
  color: var(--bg-tube);
  width: 1ch;                /* in 80-col mode, exactly one cell */
  text-shadow: none;
  animation: cursor-blink 1.04s steps(2,end) infinite;
}
@keyframes cursor-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Inverted text for ANSI inverse video (SGR 7) */
.inv {
  background: var(--phosphor);
  color: var(--bg-tube);
  text-shadow: none;
}
.dim { color: var(--phosphor-dim); text-shadow: 0 0 4px rgba(40,220,110,.15); }
.bold { color: #d8ffe6; text-shadow:
  0 0 2px rgba(200,255,220,.95),
  0 0 10px rgba(120,255,180,.6),
  0 0 22px rgba(60,230,130,.45); }

/* ----- OSD: bottom-right status, mimics VT100 setup line ----- */
.osd {
  position: absolute;
  right: 16px; bottom: 4px;
  font-family: var(--font-tty);
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--phosphor-dim);
  display: flex;
  gap: 12px;
  z-index: 7;
  pointer-events: none;
  text-transform: uppercase;
}

/* ----- Hardware control panel ----- */
.panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 6px 4px 0;
}
.logo {
  color: #8a7a6c;
  display: flex; align-items: center; gap: 10px;
}
.citizen-mark { color: #a89684; flex-shrink: 0; }
/* Two-line lockup so PROTECTOS reads as the brand and
   HUMAN VELOCITY MODULE reads as the subtitle beneath it. */
.logo-tag {
  font-family: "IBM Plex Mono", monospace;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  color: #8a7a6c;
}
.logo-tag .brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .28em;
  color: #b8a690;
}
.logo-tag .brand-sub {
  font-size: 8.5px;
  letter-spacing: .32em;
  color: #7a6b5e;
  margin-top: 2px;
}
.controls { display: flex; gap: 6px; flex-wrap: wrap; }

.key {
  appearance: none;
  border: 0;
  background: linear-gradient(180deg, #d6cfc4 0%, #9a9388 100%);
  color: #1a1612;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  font-size: 9.5px;
  letter-spacing: .14em;
  padding: 7px 10px 8px;
  border-radius: 3px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 #ffffffaa,
    inset 0 -2px 0 #00000044,
    0 1px 0 #000;
  transition: transform 60ms ease, box-shadow 60ms ease, background 120ms ease;
}
.key:hover { background: linear-gradient(180deg, #e6dfd2 0%, #aaa295 100%); }
.key:active, .key[aria-pressed="true"] {
  transform: translateY(1px);
  background: linear-gradient(180deg, #8a8377 0%, #c2bbad 100%);
  box-shadow:
    inset 0 1px 0 #ffffff66,
    inset 0 -1px 0 #00000088,
    0 0 0 #000;
}

/* Anonymous key turns amber when armed — a visible signal that
   the next answer will be detached from the user's identity. */
.key-anon[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffd57a 0%, #c98a2a 100%);
  color: #1a0e02;
  box-shadow:
    inset 0 1px 0 #fff2c4,
    inset 0 -1px 0 #00000088,
    0 0 12px rgba(255,180,60,.55);
}

/* Microphone key glows red and pulses while listening — visual record light. */
.key-mic[aria-pressed="true"] {
  background: linear-gradient(180deg, #ff7a7a 0%, #c92a2a 100%);
  color: #1a0202;
  box-shadow:
    inset 0 1px 0 #ffc4c4,
    inset 0 -1px 0 #00000088,
    0 0 14px rgba(255,60,60,.65);
  animation: micPulse 1.4s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: inset 0 1px 0 #ffc4c4, inset 0 -1px 0 #00000088, 0 0 10px rgba(255,60,60,.45); }
  50%      { box-shadow: inset 0 1px 0 #ffc4c4, inset 0 -1px 0 #00000088, 0 0 18px rgba(255,60,60,.85); }
}

/* Hidden TTY input — focuses on click anywhere on the tube */
#tty {
  position: absolute;
  left: -9999px;
  width: 1px; height: 1px;
  opacity: 0;
}

/* Powered-off state */
.off .buffer,
.off .osd { opacity: 0; }
.off .screen {
  background: #020403;
  box-shadow:
    inset 0 0 0 2px #1b1812,
    inset 0 0 60px rgba(0,0,0,1);
}
.off .crt-glow { animation: none; opacity: 0; }

/* Boot warm-up: the classic CRT horizontal-line collapse, reversed */
.warmup .buffer { opacity: 0; }
.warmup .screen::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: var(--phosphor-mid);
  box-shadow: 0 0 18px var(--phosphor-mid), 0 0 60px var(--phosphor);
  animation: warmup 700ms ease-out forwards;
  z-index: 10;
}
@keyframes warmup {
  0%   { transform: scaleX(0); opacity: 0; }
  15%  { transform: scaleX(1); opacity: 1; height: 2px; top: 50%; }
  60%  { transform: scaleX(1); opacity: 1; height: 100%; top: 0; }
  100% { transform: scaleX(1); opacity: 0; height: 100%; top: 0; }
}

/* Responsive cell sizing is now handled by the clamp() in :root, so cells
   shrink continuously instead of in stepped media-query jumps. The tube,
   cabinet, and control panel all scale together because their dimensions
   are derived from --cell-w. */

@media (prefers-reduced-motion: reduce) {
  .buffer, .crt-glow, .cursor { animation: none !important; }
}

/* ============================================================
   Google sign-in modal (simulated Google Identity Services)
   Visually mirrors the real GIS account chooser so the
   transition to real OAuth later is invisible to the user.
   ============================================================ */
.signin-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: "Google Sans", "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
.signin-modal.open { display: flex; }
.signin-scrim {
  position: absolute; inset: 0;
  background: rgba(8, 10, 14, .55);
  backdrop-filter: blur(2px);
}
.signin-card {
  position: relative;
  width: 400px;
  max-width: calc(100vw - 32px);
  background: #fff;
  color: #202124;
  border-radius: 12px;
  box-shadow:
    0 1px 3px rgba(0,0,0,.18),
    0 16px 48px rgba(0,0,0,.32);
  overflow: hidden;
  animation: signinIn 180ms cubic-bezier(.2,.7,.3,1);
}
.signin-card--narrow { width: 380px; }
@keyframes signinIn {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.signin-head {
  display: flex; align-items: center; gap: 14px;
  padding: 22px 24px 14px;
}
.signin-title-block { line-height: 1.25; }
.signin-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -.1px;
}
.signin-sub {
  font-size: 13px;
  color: #5f6368;
  margin-top: 2px;
}
.signin-body { padding: 4px 0 8px; }
.signin-chooser-label {
  font-size: 13px;
  color: #5f6368;
  padding: 8px 24px 6px;
}
.signin-accounts {
  list-style: none;
  margin: 0; padding: 0;
}
.signin-account {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 24px;
  cursor: pointer;
  user-select: none;
  transition: background 80ms ease;
}
.signin-account:hover,
.signin-account:focus { background: #f1f3f4; outline: none; }
.signin-account .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.signin-account .who {
  display: flex; flex-direction: column;
  min-width: 0;
}
.signin-account .who .name {
  font-size: 14px;
  color: #202124;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.signin-account .who .email {
  font-size: 12px;
  color: #5f6368;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.signin-account--other .avatar {
  background: transparent;
  color: #5f6368;
  border: 1px dashed #bdc1c6;
}
.signin-account--other .name { color: #1a73e8; font-weight: 500; }
.signin-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px 18px;
  border-top: 1px solid #e8eaed;
  font-size: 12px;
  color: #5f6368;
}
.signin-domain strong { color: #202124; font-weight: 500; }
.signin-sim {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: .15em;
  padding: 2px 6px;
  border: 1px solid #fbbc05;
  background: #fef7e0;
  color: #8a6d00;
  border-radius: 3px;
}

/* Email entry sub-modal */
.signin-field {
  display: block;
  padding: 8px 24px 12px;
}
.signin-field > span {
  display: block;
  font-size: 12px;
  color: #5f6368;
  margin-bottom: 4px;
}
.signin-field input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.signin-field input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 1px #1a73e8;
}
.signin-error {
  padding: 0 24px 8px;
  font-size: 12px;
  color: #d93025;
}
.signin-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 8px 16px 18px;
}
.signin-btn {
  font: inherit;
  font-size: 14px; font-weight: 500;
  padding: 8px 16px;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
  transition: background 100ms ease, box-shadow 100ms ease;
}
.signin-btn--primary {
  background: #1a73e8; color: #fff;
}
.signin-btn--primary:hover { background: #1765cc; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.signin-btn--ghost {
  background: transparent; color: #1a73e8;
}
.signin-btn--ghost:hover { background: rgba(26,115,232,.08); }

/* Bezel "signed in as" pill — added once authenticated. */
.signed-in-as {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: .12em;
  color: #6f8a72;
  margin-left: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.signed-in-as::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #33ff66;
  box-shadow: 0 0 6px rgba(80,255,120,.7);
}

/* Music autoplay-blocked hint: pulse the MUSIC button so the user knows to tap it. */
.key.needs-tap {
  background: #2a1a05;
  color: #ffb84d;
  border-color: #ffb84d;
  animation: musicPulse 1.4s ease-in-out infinite;
}
@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,184,77,.45); }
  50%      { box-shadow: 0 0 0 8px rgba(255,184,77,0); }
}


/* =========================================================================
   Andrew transmission — urgent banner only
   The Andrew narrative renders its header as inverse-video (.inv) cells.
   While the narrative is running, the screen carries `.andrew-urgent`,
   which makes those inverted cells pulse — a slow, attention-grabbing
   blink that reads as "priority dispatch incoming" without touching the
   tube's color, typeface, or any other text. Body copy stays in the
   standard green phosphor with JetBrains Mono.
   ========================================================================= */
/* Drive the strobe via custom properties on the STABLE .screen container,
   not on the .inv cells themselves — the buffer re-renders on every typing
   frame and destroys/recreates inv spans, which would otherwise reset the
   keyframe back to 0% continuously (resulting in no visible blink while
   typing). By animating variables on the parent, new inv spans inherit
   whatever value the strobe currently holds the moment they appear. */
@property --andrew-bg {
  syntax: "<color>";
  inherits: true;
  initial-value: #b6ffd1;
}
@property --andrew-fg {
  syntax: "<color>";
  inherits: true;
  initial-value: #050a05;
}
@property --andrew-glow {
  syntax: "<length>";
  inherits: true;
  initial-value: 18px;
}
.screen.andrew-urgent {
  animation: andrew-urgent-strobe 5s steps(1, end) infinite;
}
.screen.andrew-urgent .inv {
  background: var(--andrew-bg);
  color: var(--andrew-fg);
  box-shadow: 0 0 var(--andrew-glow) rgba(120,255,180,.9);
}
@keyframes andrew-urgent-strobe {
  0% {
    --andrew-bg: var(--phosphor);
    --andrew-fg: var(--bg-tube);
    --andrew-glow: 20px;
  }
  35% {
    --andrew-bg: var(--bg-tube);
    --andrew-fg: var(--phosphor);
    --andrew-glow: 2px;
  }
  50% {
    --andrew-bg: var(--phosphor-mid);
    --andrew-fg: var(--bg-tube);
    --andrew-glow: 24px;
  }
  85% {
    --andrew-bg: var(--phosphor-dim);
    --andrew-fg: var(--phosphor);
    --andrew-glow: 4px;
  }
  100% {
    --andrew-bg: var(--phosphor);
    --andrew-fg: var(--bg-tube);
    --andrew-glow: 20px;
  }
}
.no-flicker .screen.andrew-urgent { animation: none; }
.no-flicker .screen.andrew-urgent .inv {
  background: var(--phosphor);
  color: var(--bg-tube);
  box-shadow: 0 0 8px rgba(120,255,180,.55);
}

/* =========================================================================
   Mobile gate
   The 80x24 phosphor tube is built for laptop/desktop viewports. Below
   ~900px it can't render at full fidelity (cell math forces overflow).
   Rather than ship a degraded mobile experience, we present a clean
   "open on a laptop" screen and hide the terminal entirely. The boundary
   sits at 900px so iPad portrait still gets the terminal; iPhones, small
   tablets, and small browser windows get the gate.
   ========================================================================= */
#mobileGate {
  display: none;                /* hidden on desktop */
  position: fixed;
  inset: 0;
  z-index: 1000;
  background:
    radial-gradient(120% 90% at 50% 30%, #14181a 0%, #06080a 60%, #02030a 100%);
  color: var(--phosphor);
  font-family: var(--font-tty);
  padding: 24px;
  overflow: auto;
  -webkit-text-size-adjust: 100%;
}
#mobileGate .mg-card {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 28px 4px;
  text-align: left;
}
#mobileGate .mg-mark {
  color: var(--phosphor);
  filter: drop-shadow(0 0 6px rgba(120,255,180,.45));
}
#mobileGate .mg-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(120,255,180,.18);
  border-bottom: 1px solid rgba(120,255,180,.18);
  padding: 10px 0;
  letter-spacing: .14em;
}
#mobileGate .mg-brand-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--phosphor);
}
#mobileGate .mg-brand-sub {
  font-size: 10px;
  color: var(--phosphor-dim);
  letter-spacing: .18em;
}
#mobileGate .mg-title {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: .02em;
  color: #d8ffe6;
  text-shadow:
    0 0 2px rgba(200,255,220,.85),
    0 0 12px rgba(120,255,180,.55);
}
#mobileGate .mg-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--phosphor);
  margin: 0;
  /* slightly de-emphasized so the strong line below it pops */
  opacity: .9;
}
#mobileGate .mg-body-strong {
  opacity: 1;
  color: #d8ffe6;
}
#mobileGate .mg-url {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(120,255,180,.10);
  border: 1px solid rgba(120,255,180,.30);
  border-radius: 4px;
  color: #d8ffe6;
  white-space: nowrap;
  font-weight: 600;
}
#mobileGate .mg-footer {
  margin-top: auto;
  padding-top: 24px;
  font-size: 10px;
  letter-spacing: .24em;
  color: var(--phosphor-dim);
  border-top: 1px solid rgba(120,255,180,.10);
}

/* Activate gate at <900px: hide terminal, show gate. We disable user-select
   on the gate so it doesn't feel like a chat box, but keep the URL selectable
   in case anyone wants to copy it. */
@media (max-width: 900px) {
  body { display: block; min-height: 100vh; }
  #stage { display: none !important; }
  #mobileGate { display: block; }
  #mobileGate .mg-url { user-select: text; -webkit-user-select: text; }
}
