/*
 * Copyright (C) 2025-2026 Marco Iannacone
 * SPDX-License-Identifier: AGPL-3.0-only
 */

:root {
  --bg: #020503;
  --panel: #06120a;
  --ink: #bfffd0;
  --dim: #6dae7a;
  --green: #6cff8d;
  --amber: #ffd166;
  --red: #ff4f4f;
  --cyan: #7dd3fc;
  --white: #f1fff4;
  --line: rgba(108,255,141,.22);
  --mono: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: var(--ink);
  font-family: var(--mono);
  text-transform: uppercase;
}

body {
  overflow-x: hidden;
}

.joshua-body {
  background: radial-gradient(circle at 50% 20%,rgba(108,255,141,.08),transparent 35%),#020503;
}

.crt {
  min-height: 100vh;
  position: relative;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: linear-gradient(rgba(255,255,255,.025) 50%,rgba(0,0,0,.06) 50%);
  background-size: 100% 4px;
  mix-blend-mode: screen;
  opacity: .35;
}

.app {
  width: min(1280px,calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.terminal-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg,rgba(5,18,9,.97),rgba(0,5,2,.97));
  min-height: calc(100vh - 40px);
  box-shadow: 0 30px 90px rgba(0,0,0,.45),inset 0 0 40px rgba(108,255,141,.035);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  color: var(--dim);
  font-size: 13px;
}

.topbar a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dotted rgba(125,211,252,.55);
}

.terminal-output {
  padding: 22px;
  min-height: calc(100vh - 142px);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal-line {
  min-height: 1.5em;
}

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

.terminal-line.amber {
  color: var(--amber);
}

.terminal-line.red {
  color: var(--red);
}

.terminal-line.cyan {
  color: var(--cyan);
}

.terminal-line.white {
  color: var(--white);
  font-weight: 800;
}

.command-form {
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.prompt {
  color: var(--green);
  white-space: nowrap;
}

.command-form input {
  flex: 1;
  min-width: 0;
  background: transparent;
  color: var(--ink);
  border: 0;
  font: inherit;
  text-transform: uppercase;
  font-size: 16px;
}

/* Keyboard focus must be clearly visible against the dark terminal, but a
   mouse click should not leave a distracting outline on non-text controls. */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.command-form button,
.ghost-button,
.return-button,
.launch-button {
  font: inherit;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(108,255,141,.09);
  color: var(--ink);
  padding: 8px 13px;
  cursor: pointer;
  text-decoration: none;
}

.command-form button:hover,
.ghost-button:hover,
.return-button:hover,
.launch-button:hover {
  border-color: var(--green);
  background: rgba(108,255,141,.16);
}

.hidden {
  display: none!important;
}

/* Visually hidden but announced by screen readers (the live status region). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.choice-button {
  font: inherit;
  color: var(--ink);
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-transform: uppercase;
}

.choice-button:hover {
  border-color: var(--green);
  color: var(--white);
}

.board {
  font-size: 18px;
  line-height: 1.55;
  margin: 12px 0;
  color: var(--white);
}

.tic-screen {
  min-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #010402;
  box-shadow: 0 30px 90px rgba(0,0,0,.55),inset 0 0 40px rgba(108,255,141,.03);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.tic-shell {
  width: min(700px,100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
  z-index: 2;
}

.tic-title {
  font-size: clamp(28px,4vw,52px);
  color: var(--white);
  font-weight: 900;
  letter-spacing: .1em;
}

.tic-board {
  width: min(78vw,480px);
  height: min(78vw,480px);
  display: grid;
  grid-template-columns: repeat(3,1fr);
  grid-template-rows: repeat(3,1fr);
  border: 3px solid rgba(220,245,255,.92);
  box-shadow: 0 0 12px rgba(180,255,220,.18);
}

.tic-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 3px solid rgba(220,245,255,.92);
  border-bottom: 3px solid rgba(220,245,255,.92);
  color: #e8f3ff;
  font-size: clamp(42px,11vw,110px);
  font-weight: 900;
  text-shadow: 0 0 18px rgba(220,245,255,.16);
}

.tic-cell:nth-child(3n) {
  border-right: 0;
}

.tic-cell:nth-last-child(-n+3) {
  border-bottom: 0;
}

.tic-cell.empty {
  color: transparent;
}

.tic-instruction {
  color: var(--dim);
  text-align: center;
  font-size: 13px;
  letter-spacing: .08em;
}

.tic-status {
  min-height: 2.5em;
  color: var(--amber);
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.tic-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.82);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: pre-wrap;
  text-align: center;
  padding: 30px;
  font-size: clamp(26px,4vw,56px);
  color: var(--white);
  font-weight: 900;
  letter-spacing: .08em;
  text-shadow: 0 0 14px rgba(255,255,255,.15);
}

.tic-screen.tic-overheat {
  animation: ticFlicker .18s steps(2) infinite;
}

.tic-screen.tic-overheat .tic-title,
.tic-screen.tic-overheat .tic-status {
  color: var(--red);
}

.tic-screen.tic-overheat .tic-board {
  box-shadow: 0 0 25px rgba(255,79,79,.45);
}

@keyframes ticFlicker {
  0% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.4);
  }
  100% {
    filter: brightness(.85);
  }
}

.war-room {
  position: relative;
  min-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #010402;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0,0,0,.55),inset 0 0 40px rgba(108,255,141,.03);
}

.war-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.war-title {
  font-weight: 900;
  color: var(--white);
  letter-spacing: .08em;
}

.war-subtitle {
  color: var(--dim);
  font-size: 13px;
  margin-top: 4px;
}

/* .war-grid's explicit height + grid-template-rows:minmax(0,1fr), together with min-height:0 on its three children below, are the fix for a regression where the growing event log inflated the row's auto-computed height and dragged .map-stage's geometry along with it, sliding the map out of view. Do not remove these without re-testing that a long-running event log cannot resize the map. */

.war-grid {
  display: grid;
  grid-template-columns: 260px minmax(0,1fr) 320px;
  grid-template-rows: minmax(0,1fr);
  gap: 0;
  height: calc(100vh - 120px);
  min-height: 620px;
}

.status-panel,
.event-panel,
.map-stage {
  min-height: 0;
}

.status-panel,
.event-panel {
  border-right: 1px solid var(--line);
  padding: 14px;
  background: rgba(5,18,9,.65);
  display: flex;
  flex-direction: column;
}

.status-panel {
  overflow: auto;
}

.event-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
  overflow: hidden;
}

.status-panel h2,
.event-panel h2 {
  margin: 0 0 12px;
  color: var(--amber);
  font-size: 15px;
  flex: none;
}

.status-panel dl {
  margin: 0;
}

.status-panel dt {
  color: var(--dim);
  font-size: 12px;
  margin-top: 10px;
}

.status-panel dd {
  margin: 2px 0 0;
  color: var(--white);
  font-weight: 800;
}

.event-log {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.event-log div {
  border-bottom: 1px solid rgba(108,255,141,.08);
  padding: 5px 0;
}

.map-stage {
  position: relative;
  background: radial-gradient(circle at 50% 50%,rgba(108,255,141,.06),transparent 38%),#000704;
  overflow: hidden;
}

.map-viewport {
  position: absolute;
  inset: 0;
  transition: transform 2.7s ease-in-out;
  transform-origin: center center;
}

.world-map,
.war-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.world-map {
  opacity: .78;
  filter: drop-shadow(0 0 7px rgba(108,255,141,.12));
}

.war-overlay {
  z-index: 2;
}

.node {
  fill: rgba(108,255,141,.8);
  stroke: #eaffef;
  stroke-width: 1.2;
  filter: drop-shadow(0 0 4px rgba(108,255,141,.65));
}

.node.target {
  fill: rgba(255,209,102,.85);
}

.node.impact {
  fill: var(--red);
  stroke: #fff;
}

.node-label {
  fill: #d7ffe0;
  font-size: 13px;
  letter-spacing: .08em;
  text-shadow: 0 0 5px #000;
}

.trajectory {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2.4;
  stroke-dasharray: 6 5;
  filter: drop-shadow(0 0 5px rgba(255,209,102,.55));
  animation: dash 1.2s linear infinite;
}

.trajectory.red {
  stroke: var(--red);
  filter: drop-shadow(0 0 5px rgba(255,79,79,.65));
}

.trajectory.blue {
  stroke: #8fd7ff;
  filter: drop-shadow(0 0 5px rgba(143,215,255,.7));
}

@keyframes dash {
  to {
    stroke-dashoffset: -22;
  }
}

.impact-ring {
  fill: none;
  stroke: var(--red);
  stroke-width: 2;
  opacity: .85;
  animation: impact 1.25s ease-out forwards;
}

.impact-ring.big {
  stroke-width: 2.8;
  animation: impactBig 1.45s ease-out forwards;
}

.flash {
  fill: rgba(255,255,255,.88);
  animation: flash 1s ease-out forwards;
}

.flash.big {
  fill: rgba(255,240,180,.95);
  animation: flash 1.15s ease-out forwards;
}

@keyframes impact {
  from {
    r: 4;
    opacity: .9;
  }
  to {
    r: 42;
    opacity: 0;
  }
}

@keyframes impactBig {
  from {
    r: 7;
    opacity: 1;
  }
  to {
    r: 88;
    opacity: 0;
  }
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.report-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: min(760px,calc(100% - 38px));
  max-height: min(82vh,760px);
  overflow: auto;
  background: rgba(0,8,3,.98);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  z-index: 10;
  box-shadow: 0 30px 90px rgba(0,0,0,.65);
}

.report-panel h2 {
  margin: 0 0 16px;
  color: var(--white);
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 22px;
}

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

.report-val {
  color: var(--white);
  font-weight: 900;
}

.report-panel .choice-grid {
  margin-top: 22px;
}

.final-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px;
}

.final-text {
  font-size: clamp(28px,5vw,70px);
  line-height: 1.25;
  color: var(--white);
  font-weight: 900;
  letter-spacing: .08em;
  white-space: pre-wrap;
  text-shadow: 0 0 16px rgba(108,255,141,.25);
}

.return-button {
  margin-top: 42px;
  color: var(--ink);
}

.joshua-launch {
  width: min(1180px,calc(100% - 32px));
  margin: 0 auto;
  padding: 8vh 0;
}

.joshua-launch-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg,rgba(7,17,11,.96),rgba(3,8,5,.96));
  padding: clamp(24px,5vw,54px) clamp(24px,5vw,54px) clamp(34px,5vw,54px) clamp(24px,5vw,54px);
  box-shadow: 0 35px 90px rgba(0,0,0,.45);
}

.launch-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.launch-kicker {
  color: var(--amber);
  font-size: 13px;
  letter-spacing: .16em;
  min-width: 0;
}

.launch-version {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: .08em;
}

.joshua-launch-card h1 {
  font-size: clamp(36px,7vw,86px);
  line-height: 1.05;
  margin: 14px 0 20px;
  color: var(--white);
  letter-spacing: .06em;
  display: flex;
  flex-wrap: wrap;
  gap: .05em clamp(8px,1.5vw,20px);
}

.joshua-launch-card h1 span {
  display: block;
}

.launch-lang {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px dotted rgba(125,211,252,.55);
  white-space: nowrap;
  flex: none;
}

.launch-lang:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 2px;
}

.leadline {
  font-size: clamp(18px,2.3vw,25px);
  color: var(--ink);
}

.launch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  align-items: center;
}

.launch-actions-split {
  justify-content: space-between;
}

.launch-actions a {
  color: var(--cyan);
  text-decoration: none;
}

.launch-button {
  color: var(--ink)!important;
  background: rgba(108,255,141,.12);
}

.launch-return-button {
  background: rgba(125,211,252,.08)!important;
  border-color: rgba(125,211,252,.28)!important;
}

.launch-credit {
  margin: 42px 14px 0;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: .08em;
}

@media (max-width: 900px) {
  .app {
    width: 100%;
    padding: 0;
  }
  .terminal-panel,
  .war-room,
  .tic-screen {
    border-radius: 0;
    min-height: 100vh;
  }
  .war-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
    min-height: 0;
  }
  .status-panel,
  .event-panel {
    border: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }
  .event-log {
    flex: none;
    max-height: 40vh;
  }
  .map-stage {
    min-height: 52vh;
    height: 52vh;
    order: -1;
  }
  .command-form {
    flex-wrap: wrap;
  }
  .command-form button {
    width: 100%;
  }
  .report-grid {
    grid-template-columns: 1fr;
  }
  .terminal-output {
    min-height: calc(100vh - 156px);
    padding: 16px;
  }
  .topbar {
    font-size: 12px;
  }
  .joshua-launch {
    padding: 0;
    width: 100%;
  }
  .joshua-launch-card {
    border-radius: 0;
    min-height: calc(100vh - 52px);
  }
  .launch-meta {
    gap: 10px;
  }
  .joshua-launch-card h1 {
    gap: 0;
    flex-direction: column;
  }
  .launch-actions-split {
    align-items: flex-start;
  }
  .launch-button,
  .launch-return-button {
    width: 100%;
    text-align: center;
  }
  .launch-credit {
    padding: 0 16px 24px;
  }
}

.trajectory.russia {
  stroke: #ff4f4f;
  filter: drop-shadow(0 0 6px rgba(255,79,79,.75));
}

.trajectory.china {
  stroke: #ffd84d;
  filter: drop-shadow(0 0 6px rgba(255,216,77,.72));
}

.trajectory.usa {
  stroke: #66b7ff;
  filter: drop-shadow(0 0 6px rgba(102,183,255,.72));
}

.trajectory.europe {
  stroke: #6cff8d;
  filter: drop-shadow(0 0 6px rgba(108,255,141,.70));
}

.trajectory.pacific {
  stroke: #ff9f43;
  filter: drop-shadow(0 0 6px rgba(255,159,67,.70));
}

.trajectory.grey {
  stroke: #cbd5e1;
  filter: drop-shadow(0 0 6px rgba(203,213,225,.62));
}

.trajectory.global {
  stroke: #ffffff;
  stroke-width: 2.8;
  filter: drop-shadow(0 0 7px rgba(255,255,255,.78));
}

/* Reduced motion: keep the WarGames aesthetic but drop the repetitive,
   flashing, and long-running purely decorative motion. Logical game/simulation
   timing is untouched (that lives in JS, not these animations). The brief
   one-shot impact/flash pulses are left in place because they convey an event
   rather than looping decoratively. */
@media (prefers-reduced-motion: reduce) {
  .tic-screen.tic-overheat {
    animation: none;
  }
  .trajectory {
    animation: none;
  }
  .map-viewport {
    transition: none;
  }
}
