/* ---------------------------------------------------------------
   bbs.css — CRT phosphor terminal.

   Two rendering modes share this sheet:
     no JS  -> #content is a plain, still-styled document
     JS     -> #content is hidden and #screen holds the terminal
   --------------------------------------------------------------- */

:root {
  /* Amber is the default phosphor; the C key swaps the three below. */
  --fg:    #ffb000;
  --dim:   #a8720a;
  --hot:   #ffd479;
  --bg:    #0b0900;
  --glow:  rgba(255, 176, 0, .35);

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas,
          "DejaVu Sans Mono", "Liberation Mono", monospace;
}

:root[data-phosphor="green"] {
  --fg: #37ff6d; --dim: #1d9c43; --hot: #b8ffcb;
  --bg: #000a03; --glow: rgba(55, 255, 109, .32);
}

:root[data-phosphor="white"] {
  --fg: #e6eeff; --dim: #8e9dba; --hot: #ffffff;
  --bg: #05070c; --glow: rgba(200, 220, 255, .28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  /* The terminal is a fixed grid of characters — never reflow it into
     something proportional. */
  font-variant-ligatures: none;
  -webkit-text-size-adjust: 100%;
}

/* --- the tube ------------------------------------------------- */

#crt {
  min-height: 100dvh;
  padding: clamp(.5rem, 2.5vw, 2.5rem);
  display: flex;
  justify-content: center;
  /* Vignette: the corners of a real tube are darker than the centre. */
  background:
    radial-gradient(120% 100% at 50% 45%, transparent 42%, rgba(0,0,0,.75) 100%),
    var(--bg);
}

#glass {
  position: relative;
  width: 100%;
  max-width: 82ch;
  padding: clamp(.75rem, 2.5vw, 2rem);
  font-size: clamp(13px, .55rem + .9vw, 16px);
  line-height: 1.45;
  text-shadow: 0 0 1px currentColor, 0 0 10px var(--glow);
}

/* Scanlines. Drawn over everything, never intercepts a click. */
#glass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, .3) 0px,
    rgba(0, 0, 0, .3) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 2;
}

/* --- banner --------------------------------------------------- */

#banner {
  margin: 0 0 .35em;
  /* 68 characters wide. bbs.js measures the character cell and sets the exact
     font-size that spans the terminal; this is only the pre-measurement value. */
  font-size: clamp(4px, 1.35vw, 11px);
  line-height: 1.04;
  color: var(--hot);
  white-space: pre;
  overflow: hidden;
}

/* --- terminal output ------------------------------------------ */

#out > * { margin: 0; }
#out > .menu, #out > .keys { margin: .2em 0; }
#out { white-space: pre-wrap; overflow-wrap: break-word; }

.rule    { color: var(--dim); white-space: pre; overflow: hidden; }
/* Off-screen ruler used to measure the character cell. */
.probe   { position: absolute; visibility: hidden; white-space: pre; }
.blank   { min-height: 1.45em; }
.head    { color: var(--hot); font-weight: 700; letter-spacing: .06em; }
.sys     { color: var(--dim); }
.bullet  { padding-left: 3ch; text-indent: -3ch; }
.note    { padding-left: 3ch; }
/* Hanging indent so a wrapped value lines up under the value, not the key.
   14 = one leading space + a 10-column key + " : ". */
.kv      { color: var(--dim); padding-left: 14ch; text-indent: -14ch; }
.kv b    { color: var(--fg); font-weight: 400; }

/* Lines painted by the renderer fade in one after another. */
.ln { animation: ln .09s steps(2) both; }
@keyframes ln { from { opacity: 0 } to { opacity: 1 } }

/* --- menu ----------------------------------------------------- */

.menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17ch, 1fr));
  gap: 0 2ch;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5ch;
  padding-left: .4ch;
}

/* On a touch screen these are the only controls, and 2.2em of terminal text is
   about 29px — that clears WCAG 2.5.8's 24px minimum everywhere, but 44px is
   the comfortable thumb target. Two signals rather than one, because a device
   that misreports `pointer` usually still reports `hover: none`. */
@media (pointer: coarse), (hover: none) {
  .keys button { min-height: 44px; }
}

.menu button,
.menu a,
.keys button {
  appearance: none;
  margin: 0;
  padding: .15em .4em;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-shadow: inherit;
  cursor: pointer;
  /* Tap targets stay finger-sized on a phone. */
  min-height: 2.2em;
}

/* A button centres its own content; an anchor does not. Match them so the
   GITHUB entry sits on the same baseline as its row-mates. */
#out .menu a { text-decoration: none; display: flex; align-items: center; }
.menu button .k, .menu a .k, .keys button .k { color: var(--hot); }

/* Inverse video is how a BBS showed a selection. */
.menu button:hover,
.menu button:focus-visible,
.menu a:hover,
.menu a:focus-visible,
.keys button:hover,
.keys button:focus-visible {
  background: var(--fg);
  color: var(--bg);
  outline: none;
  text-shadow: none;
}
.menu button:hover .k,
.menu button:focus-visible .k,
.menu a:hover .k,
.menu a:focus-visible .k,
.keys button:hover .k,
.keys button:focus-visible .k { color: var(--bg); }

/* --- links ---------------------------------------------------- */

#out a, #content a {
  color: var(--hot);
  text-decoration: underline;
  text-underline-offset: .2em;
}
#out a:hover, #out a:focus-visible,
#content a:hover, #content a:focus-visible {
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

#out .hint { color: var(--dim); margin-top: 1.2em; font-size: .85em; }
#out .caller { color: var(--dim); font-size: .85em; }
/* A contact row with no destination — present, but plainly not a link. */
.na { color: var(--dim); }

/* Visually hidden, still announced. The terminal's real <h1>. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- no-JS document ------------------------------------------- */

#who { margin: 0; font-size: 1.5em; color: var(--hot); letter-spacing: .08em; }
#content h2 {
  margin: 2em 0 .5em;
  font-size: 1em;
  color: var(--hot);
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--dim);
  padding-bottom: .25em;
}
#content .tagline { margin: .3em 0 1em; color: var(--fg); }
#content dl { display: grid; grid-template-columns: 12ch 1fr; gap: .15em 1ch; margin: 0; }
#content dt { color: var(--dim); }
#content dd { margin: 0; }
#content ul { list-style: none; margin: 0; padding: 0; }
#content li { margin-bottom: .6em; }
#content .projects span { display: block; color: var(--dim); }

/* --- motion / contrast preferences ---------------------------- */

@media (prefers-reduced-motion: reduce) {
  .ln { animation: none; }
  #glass::after { display: none; }   /* scanlines can be a migraine trigger */
}

@media (prefers-contrast: more) {
  #glass { text-shadow: none; }
  #glass::after { display: none; }
  :root { --dim: var(--fg); }
}

/* Printing a CV page happens. Give them ink-on-paper. */
@media print {
  #crt { background: #fff; padding: 0; }
  #glass { text-shadow: none; max-width: none; }
  #glass::after, #banner, .menu, .keys, .hint { display: none !important; }
  #screen { display: none !important; }
  #content { display: block !important; }
  html, body, #content, #content a { background: #fff; color: #000; }
  :root { --fg: #000; --dim: #444; --hot: #000; }
}
