/* VT100: an old console terminal. Phosphor green on black, monospace
   everywhere with a soft phosphor glow, scanlines and a faint flicker,
   square boxes, reverse-video buttons, and a prompt and blinking cursor
   on the headings. Meets 4.5:1 like every theme; the motion stops for
   reduced motion. */
:root[data-theme="vt100-dark"] {
  --ps-bg-primary: #000000;
  --ps-bg-secondary: #020c03;
  --ps-bg-tertiary: #061a09;
  --ps-border: #1c7a30;
  --ps-text-primary: #41ff6e;
  --ps-text-secondary: #2fcc56;
  --ps-text-inverse: #000000;
  --ps-accent: #41ff6e;
  --ps-accent-hover: #8affa6;
  --ps-accent-subtle: #04260d;
  --ps-success: #41ff6e;
  --ps-warning: #ffcc33;
  --ps-danger: #ff6655;
  --ps-info: #7dffd0;
  --ps-nav-bg: #000000;
  --ps-nav-text: #41ff6e;
  --ps-input-bg: #000000;
  --ps-input-border: #1c7a30;
  --ps-table-header-bg: #061a09;
  /* The LCDs are green-on-black screens too */
  --lcd-bg: #010d03;
  --lcd-ink: #41ff6e;
  /* The accent and state colours as text, and the buttons: readable
     (4.5:1) on this theme; buttons are reverse video */
  --ps-accent-text: #41ff6e;
  --ps-info-text: #7dffd0;
  --ps-success-text: #41ff6e;
  --ps-warning-text: #ffcc33;
  --ps-danger-text: #ff6655;
  --ps-on-accent: #000000;
  --ps-accent-btn: #41ff6e;
  --ps-accent-btn-hover: #8affa6;
}

/* Monospace everywhere, glowing like phosphor */
:root[data-theme="vt100-dark"] body,
:root[data-theme="vt100-dark"] input,
:root[data-theme="vt100-dark"] select,
:root[data-theme="vt100-dark"] textarea,
:root[data-theme="vt100-dark"] button {
  font-family: var(--ps-font-mono, "JetBrains Mono", monospace);
}
:root[data-theme="vt100-dark"] body {
  text-shadow: 0 0 3px rgba(65, 255, 110, 0.45);
}

/* Square boxes, drawn in green, like a terminal's frames */
:root[data-theme="vt100-dark"] .card,
:root[data-theme="vt100-dark"] .lcd-bezel,
:root[data-theme="vt100-dark"] .lcd-screen,
:root[data-theme="vt100-dark"] input,
:root[data-theme="vt100-dark"] select,
:root[data-theme="vt100-dark"] .btn,
:root[data-theme="vt100-dark"] button {
  border-radius: 0;
}
:root[data-theme="vt100-dark"] .card {
  border: 1px solid var(--ps-border);
  box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px rgba(65, 255, 110, 0.25);
}
:root[data-theme="vt100-dark"] .lcd-bezel {
  background: #000;
  border: 1px solid var(--ps-border);
  box-shadow: none;
}
:root[data-theme="vt100-dark"] header[role="banner"] {
  border-bottom: 1px solid var(--ps-border);
}

/* Headings: a prompt before, a blinking block cursor after */
:root[data-theme="vt100-dark"] .card h2::before,
:root[data-theme="vt100-dark"] main h1::before {
  /* "/ \"\"": decoration, not read out by screen readers */
  content: "> " / "";
}
:root[data-theme="vt100-dark"] .card h2::after,
:root[data-theme="vt100-dark"] main h1::after {
  content: "\2588" / "";
  margin-left: 0.25em;
  animation: ps-cursor 1.06s steps(1) infinite;
}
@keyframes ps-cursor { 50% { opacity: 0; } }

/* Scanlines, a dark edge like a curved tube, and a faint flicker */
:root[data-theme="vt100-dark"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.45) 100%);
  animation: ps-crt 5s steps(1) infinite;
}
@keyframes ps-crt {
  0%, 100% { opacity: 1; }
  37% { opacity: 0.92; } 38% { opacity: 1; }
  71% { opacity: 0.95; } 72% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="vt100-dark"] .card h2::after,
  :root[data-theme="vt100-dark"] main h1::after,
  :root[data-theme="vt100-dark"] body::after { animation: none; }
}

/* A new call in Recent Activity: a block cursor races across the row,
   cell by cell, like holding the space bar down, leaving the phosphor
   glowing behind it; the row glows while the call lasts, then fades
   back to the others. */
:root[data-theme="vt100-dark"] #ra-table td {
  transition: background-color 1.6s ease-out, text-shadow 1.6s ease-out;
}
:root[data-theme="vt100-dark"] #ra-table tr.ra-active {
  animation: none;
  background: none;
}
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td {
  background-color: rgba(65, 255, 110, 0.16);
  text-shadow: 0 0 6px rgba(65, 255, 110, 0.9);
  background-image: linear-gradient(90deg, rgba(65, 255, 110, 0.16) 0 calc(100% - 0.6em), #41ff6e calc(100% - 0.6em) 100%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  animation: ps-vt-sweep 0.11s linear backwards;
}
/* One cell after another, left to right */
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(2) { animation-delay: 0.11s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(3) { animation-delay: 0.22s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(4) { animation-delay: 0.33s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(5) { animation-delay: 0.44s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(6) { animation-delay: 0.55s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(7) { animation-delay: 0.66s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(8) { animation-delay: 0.77s; }
:root[data-theme="vt100-dark"] #ra-table tr.ra-active td:nth-child(9) { animation-delay: 0.88s; }
@keyframes ps-vt-sweep {
  /* Dark until the cursor arrives, then filled behind it as it passes */
  0% { background-size: 0% 100%; background-color: transparent; text-shadow: none; color: transparent; }
  99% { background-size: 100% 100%; background-color: transparent; color: transparent; }
  100% { background-size: 0% 100%; }
}

/* Headings typing themselves in (pistar.js) */
:root[data-theme="vt100-dark"] .vt-typing::after {
  animation: none;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="vt100-dark"] #ra-table tr.ra-active td { animation: none; background-image: none; }
}
