/* issue 1: the depot terminal.
   One green-phosphor CRT, lovingly maintained since 2017. */

:root {
  --phos: #98ff98;
  --phos-dim: rgba(152, 255, 152, 0.55);
  --phos-glow: rgba(152, 255, 152, 0.35);
  --ink: #041504;
  --alert: #ff4b3e;
}

* {
  box-sizing: border-box;
}

html {
  background: #000;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'VT323', monospace;
  font-size: 18px;
  line-height: 1.25;
  color: var(--phos);
  background: radial-gradient(ellipse at 50% 38%, #0b1d0b 0%, #041004 55%, #000 100%) fixed;
  perspective: 25em; /* the story pane tilts in 3D; perspective lives on the parent */
  text-shadow: 0 0 1px rgba(152, 255, 152, 0.6), 0 0 7px var(--phos-glow);
}

::selection {
  background: var(--phos);
  color: var(--ink);
  text-shadow: none;
}

/* ---- CRT physics ------------------------------------------------- */

.crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.crt::before {
  /* scanlines */
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.22) 0 1px,
    transparent 1px 3px
  );
}

.crt::after {
  /* tube vignette */
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

body::after {
  /* slow phosphor roll bar */
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  top: -30vh;
  height: 30vh;
  pointer-events: none;
  z-index: 11;
  background: linear-gradient(180deg, transparent, rgba(152, 255, 152, 0.05), transparent);
  animation: roll 11s linear infinite;
}

@keyframes roll {
  to {
    transform: translateY(160vh);
  }
}

.screen {
  max-width: 40em;
  margin: 0 auto;
  padding: 2.5em 1.5em 5em;
  animation: poweron 0.45s cubic-bezier(0.23, 1, 0.32, 1), flicker 4s steps(1) infinite 0.45s;
}

@keyframes poweron {
  0% {
    transform: scaleY(0.004);
    filter: brightness(8);
  }
  60% {
    transform: scaleY(1);
    filter: brightness(1.6);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  53% { opacity: 0.96; }
  54% { opacity: 1; }
  81% { opacity: 0.97; }
  82% { opacity: 1; }
}

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

header {
  text-align: center;
  padding: 1.25em 1em 1em;
  border: 3px solid var(--phos);
  box-shadow: 0 0 14px var(--phos-glow), inset 0 0 14px rgba(152, 255, 152, 0.15);
}

h1 {
  margin: 0 0 0.35em;
  font-weight: normal;
  font-size: 3em;
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

header p {
  margin: 0.35em 0;
}

header small {
  font-size: 0.95em;
  color: var(--phos-dim);
}

.red {
  color: var(--alert);
  text-shadow: 0 0 1px rgba(255, 75, 62, 0.6), 0 0 7px rgba(255, 75, 62, 0.4);
}

a {
  color: var(--phos);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:focus-visible {
  outline: 2px solid var(--phos);
  outline-offset: 2px;
}

/* ---- session log ------------------------------------------------- */

#log {
  height: 8.75em;
  margin: 1.75em 0 0;
  overflow: hidden;
  font-family: inherit;
  font-size: 1.1em;
  white-space: pre-wrap;
  color: var(--phos-dim);
}

/* ---- the story --------------------------------------------------- */

#story {
  min-height: 7em;
  margin: 0.5em 0 1.5em;
  font-size: 1.5em;
  transition: transform 0.6s ease, opacity 0.3s ease;
}

#story.receiving {
  opacity: 0.2;
}

#story.fresh {
  animation: materialize 0.35s ease-out;
}

@keyframes materialize {
  0% {
    opacity: 0;
    filter: brightness(6) blur(1px);
  }
  100% {
    opacity: 1;
    filter: brightness(1) blur(0);
  }
}

/* ---- the prompt -------------------------------------------------- */

.center {
  text-align: center;
}

#download {
  display: inline-block;
  padding: 1em 2.5em;
  border: 3px solid var(--phos);
  box-shadow: 0 0 14px var(--phos-glow), inset 0 0 14px rgba(152, 255, 152, 0.15);
  font-size: 1.25em;
}

#download p {
  margin: 0 0 0.75em;
}

#download p::after {
  content: '█';
  margin-left: 0.2em;
  animation: blink 1.1s steps(1) infinite;
}

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

#download input[type='submit'] {
  appearance: none;
  background: transparent;
  color: var(--phos);
  font: inherit;
  text-shadow: inherit;
  border: 2px solid var(--phos);
  padding: 0.3em 1.2em;
  cursor: pointer;
}

#download input[type='submit']:hover,
#download input[type='submit']:focus-visible {
  background: var(--phos);
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 0 18px var(--phos-glow);
  outline: none;
}

#download input[type='submit']:active {
  filter: brightness(1.3);
}

/* ---- status line ------------------------------------------------- */

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  gap: 1em;
  padding: 0.1em 0.75em;
  background: var(--phos);
  color: var(--ink);
  text-shadow: none;
  font-size: 1.05em;
}

footer a {
  color: var(--ink);
}

/* ---- small screens ----------------------------------------------- */

@media only screen and (max-width: 480px) {
  .screen {
    padding: 1.25em 0.9em 5em;
  }

  h1 {
    font-size: 2.2em;
  }

  #story {
    font-size: 1.3em;
  }

  #download {
    padding: 0.75em 1.25em;
    width: 100%;
  }

  footer span:first-child {
    display: none;
  }
}

/* ---- decency ----------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  body::after,
  .screen,
  #download p::after,
  #story.fresh {
    animation: none;
  }

  #story {
    transition: none;
  }
}
