/* TERMYNAL: a phosphor terminal. VT323 (SIL OFL, see fonts/OFL.txt) is served
   from here like everything else; the page asks nothing of anyone else. */

@font-face {
  font-family: 'VT323';
  src: url('/fonts/vt323.woff2') format('woff2');
  font-display: block;
}

:root {
  --fg: #41ff7e;
  --hi: #c8ffd9;
  --dim: #22a04c;
  --bg: #020b05;
  --glow: rgba(65, 255, 126, 0.42);
  color-scheme: dark;
}

:root[data-color='amber'] {
  --fg: #ffb73d;
  --hi: #ffe4b3;
  --dim: #b07818;
  --bg: #0c0601;
  --glow: rgba(255, 183, 61, 0.4);
}

:root[data-color='white'] {
  --fg: #dce6ff;
  --hi: #ffffff;
  --dim: #8189a0;
  --bg: #04060a;
  --glow: rgba(205, 220, 255, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

body {
  color: var(--fg);
  font-family: 'VT323', ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(18px, 16px + 0.45vw, 24px);
  line-height: 1.2;
  -webkit-text-size-adjust: 100%;
}

#crt {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vt, 0);
  height: var(--vh, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(130% 100% at 50% 40%, color-mix(in srgb, var(--fg) 6%, var(--bg)) 0%, var(--bg) 58%, #000 100%);
  text-shadow: 0 0 1px var(--fg), 0 0 7px var(--glow);
  transform-origin: 50% 50%;
  animation: power-on 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

/* Scanlines. */
#crt::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.32) 2px 3px);
}

/* The tube: darker at the edges. */
#crt::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  box-shadow: inset 0 0 16vmin rgba(0, 0, 0, 0.8);
  background: color-mix(in srgb, var(--fg) 3%, transparent);
}

#screen {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 8px
    max(18px, env(safe-area-inset-left));
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}

#out > div,
#line {
  min-height: 1.2em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#line {
  position: relative;
  margin: 0;
}

/* "HH:MM " is six columns; continuation lines start under the message. */
#out > .stamped {
  padding-left: 6ch;
  text-indent: -6ch;
}

/* The real input: on top of the prompt line, invisible. Its font size keeps
   iOS from zooming in on focus. */
#in {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  opacity: 0;
  font: inherit;
  font-size: max(16px, 1em);
  color: transparent;
  caret-color: transparent;
  background: transparent;
}

.cursor {
  color: var(--bg);
  background: var(--fg);
  text-shadow: none;
  box-shadow: 0 0 8px var(--glow);
  animation: blink 1.06s steps(1) infinite;
}

#line:not(:focus-within) .cursor {
  color: inherit;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--fg);
  animation: none;
}

#status {
  position: relative;
  z-index: 2;
  padding: 1px max(14px, env(safe-area-inset-right)) max(1px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--bg);
  background: var(--fg);
  text-shadow: none;
  box-shadow: 0 0 14px var(--glow);
}

.ts,
.sys,
.dim {
  color: var(--dim);
}

.nick,
.act,
.cmd {
  color: var(--hi);
}

.nick.me {
  color: var(--fg);
}

.err,
.code {
  color: var(--bg);
  background: var(--fg);
  text-shadow: none;
}

.code {
  padding: 0 0.35em;
  user-select: all;
}

.hl {
  background: color-mix(in srgb, var(--fg) 15%, transparent);
}

/* 49 columns of logo at 0.4em each: shrink it on narrow screens rather than wrap. */
.logo {
  display: block;
  white-space: pre;
  color: var(--hi);
  font-size: min(1em, calc((100vw - 40px) / 19.8));
  line-height: 1.05;
}

::selection {
  color: var(--bg);
  background: var(--fg);
  text-shadow: none;
}

@keyframes blink {
  50% {
    color: var(--fg);
    background: transparent;
    box-shadow: none;
  }
}

@keyframes power-on {
  0% {
    transform: scale(1.02, 0.004);
    filter: brightness(4);
  }
  40% {
    transform: scale(1, 0.01);
    filter: brightness(3);
  }
  100% {
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #crt,
  .cursor {
    animation: none;
  }
}
