/* vim: set tabstop=2 shiftwidth=2 expandtab smarttab: */

/* Bourbon Night XII: a terminal in the war room at 11:53 pm. */

:root {
  --bg: #0b0706;
  --screen: #100b09;
  --ink: #e6edd8;
  --dim: #8f9786;
  --red: #ff3b2f;
  --red-deep: #7a120c;
  --amber: #ffb000;
  --line: rgba(230, 237, 216, 0.22);
  --glow: 0 0 6px rgba(230, 237, 216, 0.35);
  --red-glow: 0 0 8px rgba(255, 59, 47, 0.6);
  --mono: "VT323", ui-monospace, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 24px 16px 40px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1.25;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 45% at 50% -5%, rgba(255, 59, 47, 0.16), transparent 70%),
    linear-gradient(rgba(255, 59, 47, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 59, 47, 0.045) 1px, transparent 1px);
  background-size: auto, 48px 48px, 48px 48px;
  background-attachment: fixed;
  text-shadow: var(--glow);
  -webkit-font-smoothing: antialiased;
}

/* scanlines + vignette over everything */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  animation: flicker 6s infinite steps(1);
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 0.92; }
  48% { opacity: 1; }
  82% { opacity: 0.96; }
}

a {
  color: inherit;
}

a:hover {
  color: var(--red);
}

p {
  margin: 0 0 10px;
}

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

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

.console {
  max-width: 640px;
  margin: 0 auto;
  animation: power-on 0.7s ease-out backwards;
}

.masthead {
  text-align: left;
  margin-bottom: 18px;
}

.ascii {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(22px, 6.4vw, 34px);
  line-height: 0.95;
  color: var(--red);
  text-shadow: var(--red-glow);
}

.masthead h1 {
  /* the ASCII art is the visible title */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.screen {
  position: relative;
  padding: 18px 22px 22px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(230, 237, 216, 0.05), transparent 70%),
    var(--screen);
  border: 1px solid #2a1f1b;
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 6px #070504,
    inset 0 0 60px rgba(0, 0, 0, 0.8),
    0 0 0 1px #000,
    0 20px 60px rgba(0, 0, 0, 0.6);
}

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

.status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  color: var(--dim);
  font-size: 19px;
  letter-spacing: 0.04em;
}

.status b {
  font-weight: normal;
  color: var(--ink);
}

/* ---------- transcript ---------- */

.transcript {
  margin-bottom: 24px;
}

.transcript p {
  margin-bottom: 4px;
}

.transcript .dim {
  margin-top: 10px;
  font-size: 20px;
}

.on-file b {
  color: var(--red);
  font-weight: normal;
  text-shadow: var(--red-glow);
}

.coords {
  margin-top: 14px;
}

.transcript .coords-label {
  margin-bottom: 2px;
  color: var(--dim);
  font-size: 19px;
  letter-spacing: 0.04em;
}

.crack {
  letter-spacing: 0.06em;
}

.transcript .coords-place {
  font-size: 30px;
  line-height: 1.1;
  color: var(--red);
  text-shadow: var(--red-glow);
}

.crack .cracking {
  color: var(--dim);
  text-shadow: none;
}

.crack .locked {
  animation: lock-in 0.6s ease-out;
}

@keyframes lock-in {
  0% { color: #fff; text-shadow: 0 0 10px #fff, 0 0 18px var(--red); }
}

/* ---------- form ---------- */

form {
  margin: 0;
}

.field {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field > label,
.field > legend {
  display: block;
  padding: 0;
  margin-bottom: 4px;
  color: var(--dim);
  font-size: 19px;
  letter-spacing: 0.03em;
}

input,
textarea,
button {
  font: inherit;
  color: inherit;
  text-shadow: inherit;
}

input:not([type=radio]),
textarea {
  display: block;
  width: 100%;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 26px;
  caret-color: var(--red);
  outline: none;
}

textarea {
  resize: vertical;
  border: 1px solid var(--line);
  padding: 6px 8px;
  line-height: 1.15;
}

input:focus,
textarea:focus {
  border-color: var(--ink);
  background: rgba(230, 237, 216, 0.04);
}

input.short {
  width: 4.5em;
  display: inline-block;
}

.inline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 24px;
}

input[type=number] {
  -moz-appearance: textfield;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* YES / no as bracketed toggles */
.choices {
  display: flex;
  gap: 14px;
}

.choices input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choices label {
  cursor: pointer;
  padding: 2px 14px;
  font-size: 26px;
  border: 1px solid var(--line);
}

.choices label::before { content: "[ "; color: var(--dim); }
.choices label::after { content: " ]"; color: var(--dim); }

.choices label:hover {
  border-color: var(--ink);
}

.choices input:focus-visible + label {
  outline: 1px dashed var(--ink);
  outline-offset: 3px;
}

.choices input:checked + label {
  background: var(--ink);
  color: var(--screen);
  text-shadow: none;
  box-shadow: var(--glow);
}

.choices input:checked + label::before,
.choices input:checked + label::after {
  color: var(--screen);
}

/* ---------- buttons ---------- */

.submit-row {
  margin: 22px 0 0;
}

.launch {
  display: block;
  width: 100%;
  padding: 12px 18px;
  border: 2px solid var(--red);
  border-radius: 4px;
  background: transparent;
  color: var(--red);
  font-size: 30px;
  letter-spacing: 0.12em;
  text-shadow: var(--red-glow);
  box-shadow: inset 0 0 18px rgba(255, 59, 47, 0.15), 0 0 14px rgba(255, 59, 47, 0.15);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.launch:hover,
.launch:focus-visible {
  background: var(--red);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

.launch.busy {
  background: var(--red);
  color: var(--bg);
  text-shadow: none;
  cursor: progress;
}

.launch.busy::after {
  content: "_";
  animation: blink 0.5s steps(1) infinite;
}

.key {
  padding: 6px 14px;
  margin-top: 6px;
  border: 1px solid var(--ink);
  background: transparent;
  font-size: 24px;
  cursor: pointer;
}

.key:hover,
.key:focus-visible {
  background: var(--ink);
  color: var(--screen);
  text-shadow: none;
  outline: none;
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.linkish:hover {
  color: var(--red);
}

.aside {
  max-width: 640px;
  margin: 14px auto 0;
  color: var(--dim);
  font-size: 20px;
  text-align: center;
}

.error {
  margin: 4px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--red);
  color: var(--red);
  text-shadow: var(--red-glow);
  background: rgba(255, 59, 47, 0.07);
}

.error p:last-child {
  margin: 0;
}

.fine {
  font-size: 75%;
}

/* ---------- ticker: amber LED message board ---------- */

.ticker {
  display: flex;
  align-items: stretch;
  max-width: 640px;
  margin: 26px auto 0;
  background: #050302;
  border: 1px solid #2a1f1b;
  border-radius: 6px;
  box-shadow: inset 0 0 0 4px #000, inset 0 2px 12px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.ticker-label {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--red-deep);
  color: #ffd9d4;
  font-size: 18px;
  letter-spacing: 0.1em;
  text-shadow: none;
  border-right: 1px solid #000;
}

.ticker-window {
  position: relative;
  flex: 1;
  overflow: hidden;
  padding: 10px 0 8px;
}

/* the dot-matrix grille */
.ticker-window::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 0 1.1px, #050302 1.5px) 0 0 / 3px 3px;
  opacity: 0.85;
}

.ticker-track {
  display: flex;
  width: max-content;
  animation: ticker 60s linear infinite;
}

.ticker-window:hover .ticker-track {
  animation-play-state: paused;
}

.ticker-run {
  display: flex;
  flex: none;
}

.ticker-run span {
  flex: none;
  padding-right: 3em;
  font-family: "DotGothic16", var(--mono);
  font-size: 22px;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--amber);
  text-shadow: 0 0 4px rgba(255, 176, 0, 0.9), 0 0 12px rgba(255, 120, 0, 0.5);
}

.ticker-run span b {
  font-weight: normal;
  color: #ffe08a;
}

.ticker-run span b::after {
  content: ":";
}

.ticker-run a {
  color: inherit;
}

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- the transmission (video) ---------- */

.tv {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 2, 2, 0.96);
}

.tv-frame {
  width: min(100%, 1100px, calc((100vh - 190px) * 16 / 9));
  max-height: 100%;
  overflow-y: auto;
  animation: tv-on 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.tv-bar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--red);
  text-shadow: var(--red-glow);
  font-size: 20px;
  letter-spacing: 0.06em;
}

.tv-close {
  margin-left: auto;
  padding: 2px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}

.tv-close:hover,
.tv-close:focus-visible {
  background: var(--ink);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

.tv-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 1px #2a1f1b, 0 0 80px rgba(255, 59, 47, 0.12);
}

.tv-screen video {
  display: block;
  cursor: pointer;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.tv-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  border: 2px solid var(--red);
  background: rgba(0, 0, 0, 0.75);
  color: var(--red);
  font-size: 30px;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.tv-play:hover {
  background: var(--red);
  color: var(--bg);
}

.tv-full {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border: 1px solid rgba(230, 237, 216, 0.35);
  background: rgba(0, 0, 0, 0.6);
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 0.06em;
  cursor: pointer;
  opacity: 0.75;
}

.tv-full:hover,
.tv-full:focus-visible {
  opacity: 1;
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

/* a phone turned sideways: give the video the whole height */
@media (orientation: landscape) and (max-height: 520px) {
  .tv {
    padding: 6px 12px;
  }
  .tv-frame {
    width: min(100%, calc((100vh - 48px) * 16 / 9));
  }
  .tv-bar {
    margin-bottom: 4px;
    font-size: 16px;
  }
  .tv-screen {
    border-radius: 4px;
  }
}

.tv-message {
  margin-top: 12px;
  color: var(--ink);
  font-size: 20px;
}

.tv-message:empty {
  display: none;
}

.inline-video {
  display: block;
  width: 100%;
  margin-top: 14px;
  aspect-ratio: 16 / 9;
  background: #000;
}

body.tv-on .console {
  filter: blur(2px) brightness(0.5);
  transition: filter 0.4s;
}

body.tv-off .tv-frame {
  animation: tv-off 0.45s ease-in both;
}

body.tv-off .tv {
  transition: opacity 0.45s;
  opacity: 0;
}

/* ---------- the launch sequence ---------- */

body.launching .screen {
  animation: alarm 0.5s steps(1) infinite;
}

body.midnight .console,
body.midnight .aside,
body.midnight .ticker {
  animation: tv-off 0.55s ease-in both;
}

.flash {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: #fff6ea;
  opacity: 0;
}

body.midnight .flash {
  animation: flash 1.4s ease-out both;
}

@keyframes alarm {
  0% { box-shadow: inset 0 0 0 6px #070504, inset 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--red), 0 0 40px rgba(255, 59, 47, 0.35); }
  50% { box-shadow: inset 0 0 0 6px #070504, inset 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 1px #000, 0 20px 60px rgba(0, 0, 0, 0.6); }
}

@keyframes flash {
  0% { opacity: 0; }
  35% { opacity: 0; }
  42% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* a CRT collapsing to a line, then a dot */
@keyframes tv-off {
  0% { transform: scale(1, 1); filter: brightness(1); opacity: 1; }
  55% { transform: scale(1, 0.004); filter: brightness(3); opacity: 1; }
  100% { transform: scale(0, 0.004); filter: brightness(5); opacity: 0; }
}

/* and opening back up */
@keyframes tv-on {
  0% { transform: scale(0, 0.004); filter: brightness(5); opacity: 0; }
  40% { transform: scale(1, 0.004); filter: brightness(3); opacity: 1; }
  100% { transform: scale(1, 1); filter: brightness(1); opacity: 1; }
}

@keyframes power-on {
  0% { opacity: 0; filter: brightness(3); }
  100% { opacity: 1; filter: brightness(1); }
}

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

.blink {
  animation: blink 1s steps(1) infinite;
}

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

@media (max-width: 520px) {
  body {
    font-size: 20px;
    padding-top: 16px;
  }
  .screen {
    padding: 14px 14px 18px;
  }
  .status {
    font-size: 17px;
  }
  .tv-bar {
    font-size: 17px;
  }
  .tv-bar {
    white-space: nowrap;
  }
  .tv-close {
    font-size: 16px;
  }
  .tv-close .esc {
    display: none;
  }
  .tv-full {
    right: 6px;
    bottom: 6px;
    padding: 0 6px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crt-overlay,
  .console,
  .tv-frame,
  body.launching .screen,
  body.midnight .console,
  body.midnight .aside,
  body.midnight .ticker,
  body.midnight .flash,
  body.tv-off .tv-frame {
    animation: none !important;
  }
  .ticker-track {
    animation-duration: 240s !important;
  }
}
