/* christopherha.com — a beige CRT that boots into a green terminal. */

@font-face {
  font-family: "VT323";
  src: url("/fonts/vt323.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --room-hi: #1c1711;
  --room-lo: #070605;
  --beige-hi: #efe6d0;
  --beige: #d8cdb4;
  --beige-mid: #bfb39a;
  --beige-lo: #8c806c;
  --beige-deep: #574e40;
  --tube: #061a0c;
  --tube-hi: #0c2c16;
  --tube-off: #050806;
  --phosphor: #33ff33;
  --phosphor-dim: #27c427;
  --glow: rgba(51, 255, 51, 0.45);
  --led: #ffb347;
  --font-size: clamp(18px, 2.2vmin + 8px, 26px);
  --radius: clamp(14px, 2.6vw, 28px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--room-lo);
  color: var(--phosphor);
  font-family: "VT323", "Courier New", Courier, monospace;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* The room: a dark desk that the monitor lights up. */
.room {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 36px;
  position: relative;
  background: radial-gradient(ellipse 75% 65% at 50% 42%, var(--room-hi), var(--room-lo) 100%);
}

.room::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 55% 48% at 50% 42%, rgba(51, 255, 51, 0.13), transparent 70%);
  opacity: 0;
  transition: opacity 1.4s ease 0.6s;
}

body.on .room::before { opacity: 1; }

/* Monitor housing: putty-beige plastic. */
.monitor {
  width: min(92vw, 900px, calc((100svh - 170px) * 1.22));
  position: relative;
  padding: 3.8% 3.8% 0;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--beige-hi) 0%, var(--beige) 38%, var(--beige-mid) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    inset 3px 0 0 rgba(255, 255, 255, 0.22),
    inset -3px 0 0 rgba(0, 0, 0, 0.12),
    0 40px 70px -24px rgba(0, 0, 0, 0.85),
    0 12px 28px rgba(0, 0, 0, 0.5);
}

.bezel {
  padding: 2.3%;
  border-radius: calc(var(--radius) * 0.7);
  background: linear-gradient(180deg, var(--beige-lo), var(--beige-mid));
  box-shadow:
    inset 0 4px 8px rgba(0, 0, 0, 0.38),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}

.tube {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: calc(var(--radius) * 0.55);
  background: var(--tube-off);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.7);
  transition: box-shadow 0.9s ease 0.5s;
}

body.on .tube {
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.7),
    0 0 34px rgba(51, 255, 51, 0.22);
}

/* The phosphor surface. */
.screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 82% 72% at 50% 50%, var(--tube-hi) 0%, var(--tube) 55%, #020a05 100%);
  opacity: 0;
  transition: opacity 0.35s ease;
}

body.on .screen,
body.no-js .screen {
  opacity: 1;
  transition-delay: 0.78s;
}

/* scanlines */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0 2px,
    rgba(0, 0, 0, 0.26) 2px 3px
  );
}

/* vignette */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse 92% 88% at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.55) 100%);
  box-shadow: inset 0 0 48px rgba(0, 0, 0, 0.55);
}

.rollbar {
  position: absolute;
  left: 0; right: 0;
  height: 16%;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.035) 50%, transparent);
  animation: roll 8s linear infinite;
}

@keyframes roll {
  from { top: -20%; }
  to   { top: 100%; }
}

.term {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 4.5% 5%;
  font-size: var(--font-size);
  line-height: 1.25;
  overflow-y: auto;
  scrollbar-width: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow:
    0 0 2px rgba(51, 255, 51, 0.9),
    0 0 10px var(--glow);
  animation: flicker 5s infinite;
}

.term::-webkit-scrollbar { display: none; }

@keyframes flicker {
  0%, 100% { opacity: 1; }
  41%  { opacity: 0.985; }
  42%  { opacity: 0.94; }
  43%  { opacity: 1; }
  78%  { opacity: 0.98; }
  79%  { opacity: 1; }
}

.line { min-height: 1.25em; }

.prompt { color: var(--phosphor-dim); }

.term a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.term button.copy {
  all: unset;
  cursor: pointer;
  text-decoration: underline dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.term .copied { color: var(--phosphor-dim); }

.term a:hover,
.term a:focus-visible,
.term button.copy:hover,
.term button.copy:focus-visible {
  background: var(--phosphor);
  color: var(--tube);
  text-shadow: none;
  text-decoration: none;
  outline: none;
}

.cursor {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: var(--phosphor);
  box-shadow: 0 0 8px var(--glow);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Glass: a soft reflection sitting on top of everything. */
.glass {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 48% 34% at 22% 12%, rgba(255, 255, 255, 0.10), transparent 70%),
    linear-gradient(115deg, rgba(255, 255, 255, 0.045) 0%, transparent 38%, transparent 62%, rgba(255, 255, 255, 0.025) 100%);
}

/* Power-on: a bright line that opens up into the full picture. */
.flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transform: scale(0, 0.004);
  background: radial-gradient(ellipse at center, #f0fff0 0%, #9dff9d 55%, #33ff33 100%);
}

body.on .flash {
  animation: poweron 0.95s cubic-bezier(0.2, 0.7, 0.2, 1) 0.3s forwards;
}

@keyframes poweron {
  0%   { opacity: 1; transform: scale(0, 0.004); }
  28%  { opacity: 1; transform: scale(1, 0.004); }
  58%  { opacity: 0.95; transform: scale(1, 1); }
  100% { opacity: 0; transform: scale(1, 1); }
}

/* Power-off: the picture collapses to a line, then a dot. */
body.off .screen {
  animation: poweroff 0.55s ease-in forwards;
}

@keyframes poweroff {
  0%   { opacity: 1; transform: scale(1, 1); filter: brightness(1); }
  55%  { opacity: 1; transform: scale(1, 0.004); filter: brightness(3); }
  100% { opacity: 0; transform: scale(0, 0.004); filter: brightness(3); }
}

/* Chin: badge, grille, power light. */
.chin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 2.6% 1.6% 2.8%;
}

.badge {
  font-family: system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(10px, 1.1vmin + 5px, 14px);
  letter-spacing: 0.03em;
  color: var(--beige-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.vents {
  flex: 1;
  max-width: 28%;
  height: 11px;
  margin: 0 auto;
  border-radius: 2px;
  opacity: 0.75;
  background: repeating-linear-gradient(to right, var(--beige-lo) 0 2px, transparent 2px 7px);
}

.led {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5a3d2c;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: background 0.2s, box-shadow 0.2s;
}

body.on .led,
body.no-js .led {
  background: var(--led);
  box-shadow:
    0 0 6px var(--led),
    0 0 14px rgba(255, 179, 71, 0.6),
    inset 0 0 2px #fff;
}

/* Stand. */
.neck {
  width: 24%;
  max-width: 220px;
  height: clamp(14px, 2.4vmin, 26px);
  background: linear-gradient(180deg, var(--beige-lo), var(--beige-deep));
  box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.3);
}

.base {
  width: 44%;
  max-width: 420px;
  height: clamp(10px, 1.9vmin, 20px);
  border-radius: 6px 6px 50% 50% / 6px 6px 100% 100%;
  background: linear-gradient(180deg, var(--beige-mid), var(--beige-lo));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 16px 40px rgba(0, 0, 0, 0.7);
}

.hint {
  margin: 26px 0 0;
  min-height: 1.3em;
  font-size: clamp(16px, 1.4vmin + 9px, 20px);
  color: rgba(216, 205, 180, 0.42);
  transition: opacity 0.7s ease;
}

.hint.hidden { opacity: 0; }

/* Invisible input that catches typing, so the keyboard works on phones too. */
.ghost {
  position: fixed;
  top: 0; left: 0;
  width: 1px; height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  caret-color: transparent;
  color: transparent;
  background: transparent;
}

@media (max-width: 520px) {
  :root { --font-size: 18px; }
  .monitor { padding: 4.6% 4.6% 0; }
  .vents { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .room::before { transition: none; }
  .tube, .screen, .led, .hint { transition: none; }
  .flash, .rollbar { display: none; }
  .term, .cursor { animation: none; }
  body.on .screen { transition-delay: 0s; }
  body.off .screen { animation: none; opacity: 0; }
}
