/* Everything is text on a character grid. Colors are the UCLAISI brand palette, dark variant. */
:root {
  --bg: #16121A;
  --bg-user: #221C28;
  --strong: #F4F0F7; /* headings, titles */
  --text: #D9D3DE;   /* body copy */
  --t2: #B5AEBC;
  --dim: #8B8492;
  --rule: #4F4856;
  --acc: #B98FD6;
  --acc-2: #CBB0E0;
  --ok: #8BCF9F;
  --err: #E58590;
  --warn: #E2B45C; /* draft / todo tags, only shown locally */
  /* The fonts terminals use. All of them have box-drawing characters that line up. */
  --font: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  /* Grid text is small like a real terminal; ASCII art keeps a larger size so it stays legible. */
  --art-size: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Line height close to the font's own, so vertical box lines and block characters join up. */
  font: 13px/1.15 var(--font);
  font-variant-ligatures: none;
  font-kerning: none;
}

::selection { background: #500778; color: #fff; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.screen { padding: 16px 20px 0; overflow-x: clip; }

.ln { white-space: pre; min-height: 1.15em; }

/* Text styles. Hierarchy comes from weight and brightness only, like a real terminal:
   strong (headings) > text (body) > t2 (secondary) > dim (meta). Lilac means clickable. */
.b { font-weight: 700; color: var(--strong); }
.t2 { color: var(--t2); }
.dim { color: var(--dim); }
.acc { color: var(--acc); }
.acc2 { color: var(--acc-2); }
.ok { color: var(--ok); }
.err { color: var(--err); }
.warn { color: var(--warn); }
.bd, .art { color: var(--acc); }
.bt { color: var(--acc); font-weight: 700; }
.vr { color: var(--rule); }
.qr { color: #fff; }
.glyph { display: inline-block; width: 1ch; } /* symbols from a fallback font stay one column wide */

/* ASCII art at its own size (see artSlot in script.js) */
.art { font-size: var(--art-size); line-height: 1.15; white-space: pre; }
.art-slot { position: relative; }
.art-box { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; }
.art-block { padding-left: 2ch; }
.art-block .art { display: block; }

a { color: inherit; }
a.cmd { color: var(--acc); text-decoration: none; }
a.cmd.dim { color: var(--dim); }
a.cmd.t2 { color: var(--t2); }
a.cmd:hover, a.cmd.hl { color: var(--acc-2); text-decoration: underline; }
a.link { color: var(--t2); text-decoration: underline; text-underline-offset: 2px; }
a.link:hover, a.link.hl { color: var(--text); }
a:focus-visible { outline: 1px solid var(--acc); outline-offset: 1px; }

/* Conversation */
.turn { scroll-margin-top: 12px; }
.turn:last-child { min-height: calc(100vh - 110px); min-height: calc(100svh - 110px); }
.ln.user { background: var(--bg-user); }
.pending { display: none !important; }

/* Prompt */
.dock { position: sticky; bottom: 0; padding: 1.15em 0 12px; background: var(--bg); }
/* Half a row of space between each line and the text: where a row of ─ characters would sit,
   like a real terminal input box. */
.prompt { position: relative; display: flex; padding: 0.575em 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.ps { flex: none; width: 2ch; color: var(--strong); } /* ❯ is from a fallback font, so pin it to 2 columns */
/* Splash line sitting on the right end of the top border: ──── Mind the (alignment) gap ── */
.splash {
  position: absolute;
  top: -0.5px;
  right: 2ch;
  transform: translateY(-50%);
  max-width: calc(100% - 6ch);
  padding: 0 1ch;
  overflow: hidden;
  background: var(--bg);
  color: var(--dim);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#below { padding-top: 0.575em; }
/* white-space: normal so the HTML's own line breaks around the input aren't drawn as blank rows
   (every .ln row uses `pre`, which would keep them). .mirror sets `pre` again for the typed text. */
.field { position: relative; flex: 1; min-width: 0; white-space: normal; }

/* The real input is invisible; .mirror draws its text and a block cursor. */
#prompt {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
}
#prompt::placeholder { color: transparent; }
#prompt::selection { background: rgba(185, 143, 214, 0.35); color: transparent; }

.mirror { position: relative; overflow: hidden; white-space: pre; pointer-events: none; }
.cur { background: var(--text); color: var(--bg); }

@media (prefers-reduced-motion: no-preference) {
  .cur { animation: blink 1.1s steps(1) 0.6s infinite; }
}
@keyframes blink { 50% { background: transparent; color: var(--text); } }

/* ---------- CRT effect (html.crt; turned on and off with /crt) ---------- */

/* Brighter phosphor: the light text colours are lifted a step (dim text stays put, so the
   hierarchy holds), and every piece of text blooms in its own colour. */
html.crt {
  --strong: #FFFFFF;
  --text: #EAE5EE;
  --t2: #C6BFCD;
  --acc: #C9A2E6;
  --acc-2: #D9C2EC;
}
html.crt .screen {
  text-shadow:
    0 0 1px color-mix(in srgb, currentColor 70%, transparent),
    0 0 8px color-mix(in srgb, currentColor 40%, transparent);
}
html.crt .qr { text-shadow: none; } /* keep the QR code crisp enough to scan */
html.crt .cur { box-shadow: 0 0 8px color-mix(in srgb, var(--text) 45%, transparent); }
html.crt .prompt { box-shadow: 0 -2px 6px -4px var(--rule), 0 2px 6px -4px var(--rule); }

/* Glass over the screen: glare, scanlines, darker edges, rounded corners in a dark frame. */
.crt-glass { display: none; }
html.crt .crt-glass {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 28% 12%, rgba(255, 255, 255, 0.035), transparent 45%),
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.16) 2px 3px),
    radial-gradient(ellipse at center, transparent 72%, rgba(0, 0, 0, 0.1) 100%);
  box-shadow: 0 0 0 40px #0A080D, inset 0 0 30px rgba(0, 0, 0, 0.08);
}

/* Bulge (html.crt-warp; desktop Chrome, Edge and Firefox only). The screen becomes a fixed
   window that scrolls inside itself, so the curve stays put while the text scrolls. */
.crt-defs { position: absolute; }
html.crt-warp, html.crt-warp body { height: 100%; overflow: hidden; }
html.crt-warp { scrollbar-gutter: auto; } /* the screen scrolls now, not the page */
html.crt-warp .screen { height: 100%; overflow-y: auto; scrollbar-gutter: stable; filter: url(#crt-warp); }

@media (max-width: 600px) {
  :root { --art-size: 12.5px; }
  body { font-size: 12px; }
  .screen { padding: 12px 12px 0; }
  #prompt { font-size: 16px; } /* stops iOS zooming in on focus */
  .splash { display: none; } /* no room for it on a phone; it crowds the prompt */
}
