/*
 * RESTRICTED AREA - amber CRT terminal.
 * (A joke placeholder page. See the comment in index.html.)
 */

:root {
  /* Phosphor color. Everything derives from it.
     amber: #ffb000   green: #33ff66   red: #ff3b30   white: #e8e8e8 */
  --phosphor: #ffb000;

  --dim: color-mix(in srgb, var(--phosphor) 45%, transparent);
  --halo: color-mix(in srgb, var(--phosphor) 55%, transparent);
  --haze: color-mix(in srgb, var(--phosphor) 22%, transparent);
  --glow: 0 0 1px var(--phosphor), 0 0 0.25em var(--halo), 0 0 0.9em var(--haze);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: #000;
  background: radial-gradient(ellipse at center,
      color-mix(in srgb, var(--phosphor) 5%, #000) 0%,
      #000 75%);
  color: var(--phosphor);
  font-family: "Courier New", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--phosphor);
  color: #000;
}

/* ---------------------------------------------------------------- layout */

.screen {
  width: 100%;
  padding: 2rem 1rem;
  text-align: center;
  text-shadow: var(--glow);
  user-select: none;
  -webkit-user-select: none;
  animation:
    power-on 0.9s ease-out both,
    flicker 7s linear 0.9s infinite;
}

.sign {
  display: inline-block;
  width: min(52rem, 92vw);
}

.hazard {
  height: clamp(0.5rem, 1.6vw, 0.8rem);
  background: repeating-linear-gradient(-45deg,
      var(--phosphor) 0 0.7rem,
      transparent 0.7rem 1.4rem);
  opacity: 0.85;
  filter: drop-shadow(0 0 4px var(--halo));
}

.title {
  margin: 0.45em 0 0.15em;
  font-size: clamp(1.5rem, 6vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.14em;
  text-indent: 0.14em; /* balances trailing letter-spacing */
}

.subtitle {
  margin: 0 0 1.1em;
  font-size: clamp(0.7rem, 2.3vw, 1.05rem);
  letter-spacing: 0.38em;
  text-indent: 0.38em;
  color: var(--dim);
}

.prompt {
  margin: clamp(2rem, 7vh, 3.5rem) 0 0;
  font-size: clamp(0.85rem, 2.8vw, 1.25rem);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

/* ---------------------------------------------------------- code slots */

.code {
  display: flex;
  justify-content: center;
  gap: 0.3em;
  margin: 0.2em 0 0.35em;
  font-size: clamp(2.75rem, 13vw, 6.5rem);
  font-weight: 700;
  line-height: 1;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 0.9em;
  height: 1.25em;
  border-bottom: 0.07em solid var(--dim);
}

/* The big blinking block cursor. */
.slot.active::after {
  content: "";
  position: absolute;
  inset: 0.12em 0.08em;
  background: var(--phosphor);
  box-shadow: var(--glow);
  animation: blink 1.06s step-end infinite;
}

.rejected .slot {
  animation: blink 0.8s step-end infinite;
}

/* ------------------------------------------------------ status lines */

.status {
  min-height: 2.6em;
  margin: 0.6em 0 0;
  font-size: clamp(1rem, 4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  white-space: pre-line;
}

.footnote {
  min-height: 1.4em;
  margin: 0.4em 0 0;
  font-size: clamp(0.65rem, 2vw, 0.9rem);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--dim);
}

.blink {
  animation: blink 0.8s step-end infinite;
}

.locked .prompt,
.locked .code {
  display: none;
}

.locked .status {
  margin-top: clamp(2rem, 7vh, 3.5rem);
  font-size: clamp(1.6rem, 7vw, 3.5rem);
}

/* --------------------------------------------------------- hidden input */

/* Kept focusable so phones open their keyboard; never visible. */
.entry {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  color: transparent;
  background: transparent;
  caret-color: transparent;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------ CRT glass */

.crt {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0 2px,
      rgba(0, 0, 0, 0.28) 2px 3px),
    radial-gradient(ellipse at center,
      transparent 55%,
      rgba(0, 0, 0, 0.8) 100%);
}

/* Slow rolling refresh band. */
.crt::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 25vh;
  background: linear-gradient(to bottom,
      transparent,
      color-mix(in srgb, var(--phosphor) 5%, transparent),
      transparent);
  animation: roll 9s linear infinite;
}

/* ----------------------------------------------------------- keyframes */

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

@keyframes roll {
  from { transform: translateY(-25vh); }
  to   { transform: translateY(100vh); }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  3%       { opacity: 0.9; }
  4%       { opacity: 1; }
  41%      { opacity: 1; }
  42%      { opacity: 0.84; }
  43%      { opacity: 1; }
  77%      { opacity: 1; }
  78%      { opacity: 0.94; }
  80%      { opacity: 1; }
}

@keyframes power-on {
  0%   { opacity: 0; transform: scale(1, 0.004); filter: brightness(4); }
  35%  { opacity: 1; transform: scale(1, 0.004); filter: brightness(4); }
  70%  { transform: scale(1, 1); filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}

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

  .crt::before {
    display: none;
  }

  .slot.active::after,
  .rejected .slot,
  .blink {
    animation-duration: 2s;
  }
}
