/* Drifting Apart: the green CRT terminal. Look and timing from mockup-time.html (approved). */

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

:root {
  --g: #45e28c;        /* phosphor colour: dims and yellows with age (set from app.js) */
  --glow: .5;          /* glow strength */
  --bright: 1;
}
* { box-sizing: border-box }
html, body { margin: 0; height: 100% }
body {
  background: #000;
  font-family: "VT323", ui-monospace, Menlo, monospace;
  overflow: hidden;
  transition: opacity 8s ease;           /* the ending fade */
}
body.gone { opacity: 0 }
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 50% at 50% 45%, rgba(40,120,70,.10), transparent 70%);
}

/* ---------- CRT ---------- */
.bezel { position: fixed; left: 0; right: 0; top: 0; height: 100%; height: 100dvh }
.screen {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  background: radial-gradient(ellipse 50% 50% at 50% 48%, #10281a 0%, #0a1c12 45%, #050e08 75%, #000 100%);
  transition: opacity 1.2s ease, filter 1.2s ease;
}
.screen.off { opacity: 0; filter: blur(6px) brightness(1.6) }
.screen::after { /* scanlines + vignette */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.34) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 48%, #000 62%, transparent 100%);
          mask-image: radial-gradient(ellipse 50% 50% at 50% 48%, #000 62%, transparent 100%);
}
.screen::before { /* slow rolling refresh band */
  content: ""; position: absolute; left: 0; right: 0; height: 18%; top: -20%; pointer-events: none; z-index: 6;
  background: linear-gradient(to bottom, transparent, rgba(120,255,170,.035) 50%, transparent);
  animation: roll 9s linear infinite;
}
@keyframes roll { to { top: 110% } }
.noise {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; opacity: .04;
  will-change: transform; image-rendering: pixelated;
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 48%, #000 55%, transparent 100%);
          mask-image: radial-gradient(ellipse 50% 50% at 50% 48%, #000 55%, transparent 100%);
  animation: noise .25s steps(3) infinite;
}
@keyframes noise {
  0%  { transform: scale(1.15) translate(0,0) }
  33% { transform: scale(1.15) translate(-4%,3%) }
  66% { transform: scale(1.15) translate(3%,-4%) }
}

.term {
  position: absolute; inset: 0; overflow: hidden;
  padding: clamp(28px,8vh,90px) clamp(18px,6vw,80px) clamp(56px,12vh,120px);
  padding-bottom: max(clamp(56px,12vh,120px), env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: .55em;
  color: color-mix(in srgb, var(--g) calc(var(--bright)*88%), #0a1c12);
  font-size: clamp(20px,1.9vw,26px); line-height: 1.3;   /* VT323 runs small: sized up */
  text-shadow: 0 0 2px color-mix(in srgb, var(--g) calc(var(--glow)*100%), transparent),
               0 0 6px color-mix(in srgb, var(--g) calc(var(--glow)*80%), transparent),
               0 0 18px color-mix(in srgb, var(--g) calc(var(--glow)*40%), transparent),
               1px 0 1px rgba(255,80,80,.10), -1px 0 1px rgba(80,160,255,.10);
  opacity: .82; will-change: opacity;
  transition: color 1.5s ease;
}

.log, .inputrow { width: 100%; max-width: 72ch }
.log { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding-right: .3em; overscroll-behavior: contain }
.log::-webkit-scrollbar { display: none }
.line { margin: 0 0 .65em; white-space: pre-wrap; overflow-wrap: break-word }
.who { opacity: .7 }
.sys { opacity: .68 }
.you { opacity: .9 }
.st  { opacity: .5 }   /* [...] words lost to static */
.row { display: block; animation: rowin .7s ease-out both }
@keyframes rowin { from { opacity: 0 } to { opacity: 1 } }
.try { cursor: pointer }
.try:hover { text-decoration: underline }

/* ---------- input: a textarea with a block cursor drawn after the text ---------- */
.inputrow { display: flex; gap: .6em; align-items: flex-start }
.inputrow.hide { visibility: hidden }
.field { position: relative; flex: 1; min-width: 0 }
.field textarea, .mirror {
  font: inherit; line-height: inherit; letter-spacing: inherit;
  margin: 0; padding: 0; border: 0; width: 100%;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.field textarea {
  display: block; resize: none; overflow: hidden; outline: none;
  background: transparent; color: var(--g); text-shadow: inherit;
  caret-color: transparent;
  max-height: 7.3em; overflow-y: auto; scrollbar-width: none;
  -webkit-appearance: none; appearance: none; border-radius: 0;
}
.field textarea::-webkit-scrollbar { display: none }
.field textarea.native-caret { caret-color: var(--g) }
.mirror { position: absolute; left: 0; top: 0; color: transparent; text-shadow: none; pointer-events: none; max-height: 7.3em; overflow: hidden }
.cursor {
  display: inline-block; width: .6em; height: 1.1em; background: var(--g); vertical-align: -.15em;
  animation: blink 1s steps(1) infinite; box-shadow: 0 0 8px var(--g);
}
.cursor.off { visibility: hidden }
@keyframes blink { 50% { opacity: 0 } }

/* ---------- the note outside the story (distress) ---------- */
.care {
  position: fixed; z-index: 20; left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%); width: min(30rem, calc(100% - 32px));
  background: #121714; color: #e9f0eb; border: 1px solid #3c4d42; border-radius: 12px;
  padding: 18px 20px 16px; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
  animation: carein .6s ease-out both;
}
.care[hidden] { display: none }
.care p { margin: 0 0 .7em }
.care .care-title { font-weight: 600; color: #fff }
.care strong { color: #fff }
.care button {
  font: inherit; background: #e9f0eb; color: #0b120e; border: 0; border-radius: 8px;
  padding: 8px 18px; cursor: pointer; margin-top: .2em;
}
.care button:focus-visible { outline: 2px solid #8fe8b5; outline-offset: 2px }
@keyframes carein { from { opacity: 0; transform: translate(-50%, 12px) } to { opacity: 1; transform: translate(-50%, 0) } }

@media (prefers-reduced-motion: reduce) {
  .screen::before, .noise { animation: none }
}
