/* ============================================================
   VAI Terminal — Rust + Leptos + WASM
   Aesthetic: an old CRT monitor. Dark-red + dark-purple accents,
   laconic white on black. Phosphor glow, scanlines, rolling beam.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

:root {
  --room:    #0a090c;
  --plastic: #201d24;
  --plastic2:#151318;
  --tube:    #050406;
  --screen:  #0a0810;
  --ink:     #ece8ee;
  --dim:     #6a6470;
  --red:     #e0475e;
  --red-deep:#7a1226;
  --purple:  #a86cf0;
  --purple-deep:#3a1466;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
}

body {
  font-family: var(--mono);
  background:
    radial-gradient(900px 600px at 50% 42%, #191521 0%, transparent 60%),
    var(--room);
  color: var(--ink);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: clamp(0.8rem, 3vw, 2.4rem);
}

/* ── the monitor ── */
.device {
  width: min(940px, 100%);
  background:
    linear-gradient(165deg, #2a2630 0%, var(--plastic) 40%, var(--plastic2) 100%);
  border: 1px solid #000;
  border-radius: 26px;
  padding: 22px 22px 0;
  box-shadow:
    0 50px 100px -30px rgba(0,0,0,0.85),
    inset 0 2px 0 rgba(255,255,255,0.06),
    inset 0 -3px 8px rgba(0,0,0,0.6);
}

/* black tube frame around the glass */
.screen-wrap {
  background: var(--tube);
  border-radius: 20px;
  padding: 20px;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 40px rgba(0,0,0,0.9);
}

/* ── the glass ── */
.screen {
  position: relative;
  height: clamp(340px, 60vh, 600px);
  overflow: hidden;               /* clips the rolling CRT beam — no phantom scroll */
  border-radius: 14px / 20px;      /* subtly curved corners = tube bulge */
  background:
    radial-gradient(130% 135% at 50% 45%, #14101c 0%, var(--screen) 62%, #050308 100%);
  color: var(--ink);
  font-size: 0.86rem; line-height: 1.55;
  text-shadow: 0 0 5px rgba(236,232,238,0.28);
  cursor: text;
  box-shadow: inset 0 0 90px rgba(168,108,240,0.05);
}
/* only the content scrolls; CRT overlays live outside it */
.screen-scroll {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto; overflow-x: hidden;
  padding: 1.2rem 1.35rem 1.4rem;
}
.screen-scroll::-webkit-scrollbar { width: 8px; }
.screen-scroll::-webkit-scrollbar-thumb { background: #2a2530; border-radius: 6px; }

.feed { position: relative; z-index: 1; }
.blk { margin-bottom: 0.5rem; }
.cmd { display: flex; gap: 0.55rem; margin-bottom: 0.1rem; }
.pr { color: var(--red); flex: 0 0 auto; text-shadow: 0 0 7px rgba(224,71,94,0.4); }
.ct { color: var(--ink); word-break: break-word; }

.l { white-space: pre-wrap; word-break: break-word; }
.l.h  { color: var(--purple); font-weight: 700; text-shadow: 0 0 8px rgba(168,108,240,0.35); }
.l.pu { color: var(--purple); text-shadow: 0 0 7px rgba(168,108,240,0.3); }
.l.rd { color: var(--red); text-shadow: 0 0 7px rgba(224,71,94,0.3); }
.l.dim { color: var(--dim); text-shadow: none; }
.l.err { color: var(--red); font-weight: 500; text-shadow: 0 0 7px rgba(224,71,94,0.3); }
.l.ok  { color: var(--purple); text-shadow: 0 0 7px rgba(168,108,240,0.3); }
.l.link { color: var(--red); text-shadow: 0 0 6px rgba(224,71,94,0.3); }
.l.art { color: var(--purple); font-weight: 700; white-space: pre; text-shadow: 0 0 10px rgba(168,108,240,0.4); }

/* ── prompt row ── */
.prompt { position: relative; z-index: 1; display: flex; align-items: center; gap: 0.55rem; margin-top: 0.2rem; }
.cin {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: var(--mono); font-size: 0.86rem; color: var(--ink);
  caret-color: var(--red); text-shadow: 0 0 5px rgba(236,232,238,0.28); padding: 0;
}

/* ── CRT overlays ── */
.crt-scan, .crt-beam, .crt-vignette, .crt-flicker {
  position: absolute; inset: 0; pointer-events: none; border-radius: 14px / 20px;
}
.crt-scan {
  z-index: 4; mix-blend-mode: multiply; opacity: 0.55;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.35) 0 1px, transparent 1px 3px);
}
.crt-vignette {
  z-index: 5;
  background: radial-gradient(125% 125% at 50% 50%, transparent 58%, rgba(0,0,0,0.55) 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
}
.crt-beam {
  z-index: 3; opacity: 0.5;
  background: linear-gradient(to bottom, transparent, rgba(168,108,240,0.10) 46%, rgba(224,71,94,0.10) 54%, transparent);
  height: 34%;
  animation: beam 7s linear infinite;
}
@keyframes beam { 0% { transform: translateY(-120%); } 100% { transform: translateY(360%); } }
.crt-flicker {
  z-index: 6; background: rgba(168,108,240,0.015);
  animation: flicker 5.5s steps(60) infinite;
}
@keyframes flicker { 0%,100% { opacity: 0.10; } 50% { opacity: 0.02; } 92% { opacity: 0.14; } }

/* ── chin (bottom bezel) ── */
.chin {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 0.6rem 1rem;
}
.brand {
  display: flex; align-items: baseline; gap: 0.5rem;
  font-weight: 800; letter-spacing: 0.14em; font-size: 0.82rem; color: #6f6878;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
.brand .model { font-weight: 400; letter-spacing: 0.08em; font-size: 0.62rem; color: #4a4550; }
.ctrls { display: flex; align-items: center; gap: 0.55rem; }
.lang-seg { display: flex; border: 1px solid #000; border-radius: 7px; overflow: hidden; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
.lang-seg button {
  border: none; background: #14121a; color: #7c7488; cursor: pointer;
  font-family: var(--mono); font-weight: 700; font-size: 0.64rem; letter-spacing: 0.05em;
  padding: 0.34rem 0.48rem; border-right: 1px solid #000; transition: color 0.12s, background 0.12s;
}
.lang-seg button:last-child { border-right: none; }
.lang-seg button:hover { color: var(--ink); }
.lang-seg button.on { color: #fff; background: var(--red-deep); }
.mini {
  display: grid; place-items: center; text-decoration: none;
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
  border: 1px solid #000; background: #14121a; color: #9a92a6; font-size: 0.85rem;
  transition: color 0.12s, transform 0.12s;
}
.mini:hover { color: var(--purple); transform: translateY(-1px); }
.led {
  width: 9px; height: 9px; border-radius: 50%; margin-left: 0.25rem;
  background: radial-gradient(circle at 35% 35%, #ff6b7e, var(--red-deep));
  box-shadow: 0 0 8px rgba(224,71,94,0.8), inset 0 0 2px rgba(0,0,0,0.4);
  animation: pulse 3.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.foot {
  margin: 0; color: #4f4a58; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
}

/* ── light theme: a "daylight" CRT ── */
.page.light {
  background: radial-gradient(900px 600px at 50% 42%, #f1eef4 0%, #dcd8e4 60%, #cfc9da 100%);
}
.page.light .device { background: linear-gradient(165deg, #efe9e0, #e2dbd0 45%, #d3ccc0); border-color: #b3aca0; }
.page.light .screen-wrap { background: #cfc7bb; box-shadow: inset 0 0 0 2px #b7afa2, inset 0 0 30px rgba(0,0,0,0.15); }
.page.light .screen {
  background: radial-gradient(130% 135% at 50% 45%, #fffdf9 0%, #f4f0e8 62%, #e9e3d8 100%);
  color: #33303a; text-shadow: none;
  box-shadow: inset 0 0 40px rgba(120,90,160,0.04);
}
.page.light .crt-scan { opacity: 0.14; }
.page.light .crt-flicker { display: none; }
.page.light .crt-beam { opacity: 0.14; }
.page.light .crt-vignette { background: radial-gradient(125% 125% at 50% 50%, transparent 66%, rgba(90,70,40,0.10) 100%); box-shadow: none; }
.page.light .pr { color: #b21e35; text-shadow: none; }
.page.light .ct, .page.light .cin { color: #2a2732; text-shadow: none; }
.page.light .cin { caret-color: #b21e35; }
.page.light .l.h, .page.light .l.pu, .page.light .l.art, .page.light .l.ok { color: #6b21c4; text-shadow: none; }
.page.light .l.rd, .page.light .l.err, .page.light .l.link { color: #b21e35; text-shadow: none; }
.page.light .l.dim { color: #8a8494; }
.page.light .brand { color: #6a6472; }
.page.light .lang-seg, .page.light .mini { border-color: #b7afa2; }
.page.light .lang-seg button { background: #eae5dd; color: #6a6472; border-right-color: #b7afa2; }
.page.light .lang-seg button.on { background: #b21e35; color: #fff; }
.page.light .mini { background: #eae5dd; color: #5b5566; }
.page.light .foot { color: #8a8494; }

@media (prefers-reduced-motion: reduce) {
  .crt-beam, .crt-flicker, .led { animation: none; }
}

@media (max-width: 560px) {
  .device { border-radius: 18px; padding: 14px 14px 0; }
  .screen-wrap { padding: 12px; border-radius: 14px; }
  .screen { height: 66vh; font-size: 0.8rem; }
  .brand .model { display: none; }
}
