/* Mainframe terminal layer: the first-visit boot sequence, CRT glass over the whole site,
   and terminal type for the interface chrome. Loads after styles.css. */

:root {
  --crt: "VT323", "IBM Plex Mono", ui-monospace, monospace;
  --phosphor: #ff8a2a;
}

/* ---------- CRT glass: scanlines and a dark vignette over everything ---------- */

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgb(255 140 60 / 0.035) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 70%, rgb(0 0 0 / 0.42) 100%);
}

/* The open file sits in the top layer, so it gets its own glass. */
.file::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgb(255 140 60 / 0.035) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 70%, rgb(0 0 0 / 0.42) 100%);
}

/* Directory path above the grid, ending in a blinking block cursor. */
.path { color: var(--accent); }
.path::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 1em;
  margin-left: 4px;
  vertical-align: -0.12em;
  background: var(--accent);
}

/* Search reads as a command prompt. */
.search { position: relative; display: block; }
.search::before {
  content: ">";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font: 500 var(--text-body)/1 var(--mono);
  color: var(--accent);
}
.search input { padding-left: 18px; font-family: var(--mono); font-size: var(--text-ui); caret-color: var(--accent); }

/* "Decrypting" line shown for a moment as a file opens. */
.file-decrypt {
  flex: none;
  margin: 0;
  font: 500 var(--text-label)/1.4 var(--mono);
  letter-spacing: var(--tracking);
  color: var(--accent);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- First-visit boot sequence ---------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(20px, 5vw, 64px);
  background: radial-gradient(ellipse at center, #140904 0%, #000 75%);
  color: var(--phosphor);
  font: 400 clamp(17px, 2.2vw, 26px)/1.25 var(--crt);
  text-shadow: 0 0 6px rgb(255 120 30 / 0.65), 0 0 18px rgb(255 100 20 / 0.25);
  overflow: hidden;
  cursor: default;
  animation: flicker 3s steps(1) infinite;
}

.booting .boot, .boot.is-off { display: flex; }

/* Keep the site out of sight (and its opening animations unplayed) until the boot sequence finishes. */
.booting .app { visibility: hidden; }

/* Warm-up: the tube brightens from a single bright line. */
.boot.is-warming { animation: crt-on 1.1s steps(11) both, flicker 3s steps(1) 1.1s infinite; }

@keyframes crt-on {
  0% { clip-path: inset(50% 0 50% 0); filter: brightness(4); }
  35% { clip-path: inset(49.5% 0 49.5% 0); filter: brightness(4); }
  70% { clip-path: inset(8% 0 8% 0); filter: brightness(1.8); }
  100% { clip-path: inset(0); filter: brightness(1); }
}

.boot-output { display: flex; flex-direction: column; gap: 2px; max-width: 70ch; transition: opacity 0.3s steps(3), filter 0.3s steps(3); }
.boot-line { min-height: 1.25em; white-space: pre-wrap; overflow-wrap: anywhere; }
.boot-line:last-child::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.1em;
  background: var(--phosphor);
  box-shadow: 0 0 8px var(--phosphor);
  animation: blink 1s steps(2, jump-none) infinite;
}
.boot-head { font-size: 1.3em; }
.boot-dim { opacity: 0.6; }
.boot-ok { color: #ffd2a8; }

/* Recovered files scroll past while the index decrypts. */
.boot-files {
  height: 9em;
  margin-top: 10px;
  overflow: hidden;
  font-size: 0.82em;
  opacity: 0.85;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 45%);
  mask-image: linear-gradient(to bottom, transparent, #000 45%);
}
.boot-file { white-space: pre; overflow: hidden; }

.boot-skip {
  position: absolute;
  right: clamp(20px, 5vw, 64px);
  bottom: clamp(16px, 4vw, 40px);
  margin: 0;
  font-size: 0.72em;
  opacity: 0.55;
}

/* Power-off: the terminal collapses to a bright line, then a dot, and the site cuts in behind it. */
.boot.is-off { animation: crt-off 700ms steps(9) forwards; }

@keyframes crt-off {
  0% { transform: scaleY(1); filter: brightness(1); opacity: 1; }
  40% { transform: scaleY(0.006); filter: brightness(3); opacity: 1; }
  75% { transform: scale(0.25, 0.006); filter: brightness(5); opacity: 1; }
  100% { transform: scale(0, 0.006); opacity: 0; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 0.93; }
  48% { opacity: 1; }
  83% { opacity: 0.97; }
}

/* ---------- Motion ---------- */

.motion .path::after { animation: blink 1s steps(2, jump-none) infinite; }
