/* Zorkinator CRT theme. Kenna 2026-11-12 per Marta's spec via Eli.
   Target aesthetic: 1980s amber/green monochrome terminal. */

@import url("https://fonts.googleapis.com/css2?family=VT323&display=swap");

:root {
  --bg:        #000000;
  --fg:        #33ff33;
  --fg-dim:    #1aaa1a;
  --accent:    #39ff14;
  --warn:      #ffb000;
  --err:       #ff3333;
  --score:     #ffb000;
  --rule:      #1aaa1a;
  --panel:     #000000;
  --panel-sel: #002200;
  --glow:      0 0 5px var(--fg), 0 0 10px rgba(51, 255, 51, 0.4);
  --glow-soft: 0 0 2px rgba(51, 255, 51, 0.6);
  --glow-am:   0 0 5px var(--warn), 0 0 10px rgba(255, 176, 0, 0.4);
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 0;
  font-family: "VT323", "Courier New", Menlo, Consolas, monospace;
  font-size: 18px;
  line-height: 1.35;
  min-height: 100vh;
  text-shadow: var(--glow-soft);
  position: relative;
}

/* CRT scanline overlay. Subtle, no flicker, non-interactive. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
  z-index: 9998;
}

#desk {
  max-width: 1360px;
  margin: 24px auto;
  background: var(--bg);
  border: 1px solid var(--fg-dim);
  overflow: hidden;
}

#desk-chrome {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 6px 14px;
  border-bottom: 1px solid var(--fg-dim);
  color: var(--fg-dim);
  font-size: 16px;
}
.desk-dots { display: flex; gap: 6px; }
.desk-dots .dot { width: 10px; height: 10px; background: #111; border: 1px solid var(--fg-dim); }
.desk-dots .dot.red    { background: var(--err); border-color: var(--err); box-shadow: 0 0 4px var(--err); }
.desk-dots .dot.yellow { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 4px var(--warn); }
.desk-dots .dot.green  { background: var(--fg); border-color: var(--fg); box-shadow: 0 0 4px var(--fg); }
.desk-title {
  flex: 1;
  text-align: center;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: var(--glow);
}
.desk-session {
  color: var(--fg-dim);
  font-size: 15px;
  min-width: 14ch;
  text-align: right;
}

/* top-right nav links (logout, back) */
#logout-link,
#back-courses-link {
  color: var(--warn);
  text-decoration: none;
  font-size: 15px;
  margin-right: 1em;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: var(--glow-am);
}
#logout-link:hover,
#back-courses-link:hover {
  color: var(--fg);
  text-shadow: var(--glow);
}

/* -------- 3-column grid: scenarios | terminal | mission image -------- */

#desk-grid {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 0;
  height: 78vh;
  min-height: 0;
}

#side-scenarios,
#side-mission {
  background: var(--bg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#side-scenarios { border-right: 1px solid var(--fg-dim); }
#side-mission   { border-left: 1px solid var(--fg-dim); }

.side-head {
  color: var(--accent);
  font-size: 15px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--fg-dim);
  text-transform: uppercase;
  text-shadow: var(--glow);
}

.scenario-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-right: 2px;
  min-height: 0;
}

.difficulty-header {
  color: var(--warn);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 0 2px 0;
  border-bottom: 1px dotted var(--fg-dim);
  margin-top: 4px;
  text-shadow: var(--glow-am);
}
.difficulty-header:first-child { margin-top: 0; }

.scenario-card {
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  border-left: 2px solid var(--fg-dim);
  padding: 4px 8px;
  text-align: left;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.scenario-card:hover,
.scenario-card:focus {
  border-left-color: var(--accent);
  color: var(--accent);
  outline: none;
}
.scenario-card.selected,
.scenario-card.active {
  background: var(--panel-sel);
  border-color: var(--fg);
  border-left: 2px solid var(--fg);
  color: var(--accent);
}
.scenario-card .scenario-title {
  color: var(--fg);
  font-size: 16px;
  line-height: 1.2;
}
.scenario-card.selected .scenario-title,
.scenario-card.active .scenario-title {
  color: var(--accent);
}
.scenario-card .scenario-meta {
  color: var(--fg-dim);
  font-size: 14px;
  letter-spacing: 0.3px;
  text-transform: lowercase;
}

.side-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--fg-dim);
  display: flex;
  gap: 6px;
}
.start-btn,
.end-btn {
  flex: 1;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 6px 0;
  font: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  text-shadow: var(--glow);
}
.start-btn:disabled,
.end-btn:disabled {
  color: var(--fg-dim);
  border-color: var(--fg-dim);
  cursor: not-allowed;
  text-shadow: none;
}
.start-btn:not(:disabled):hover {
  background: var(--fg);
  color: var(--bg);
  text-shadow: none;
}
.end-btn { color: var(--warn); border-color: var(--warn); text-shadow: var(--glow-am); }
.end-btn:not(:disabled):hover { background: var(--warn); color: var(--bg); text-shadow: none; }

/* -------- center: terminal -------- */

#main-terminal {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  min-height: 0;
  overflow: hidden;
}

#terminal-head {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--fg-dim);
  font-size: 16px;
  padding: 0 2px 8px 2px;
  border-bottom: 1px solid var(--fg-dim);
  margin-bottom: 10px;
}
#terminal-head .ind {
  width: 10px;
  height: 10px;
  background: var(--fg-dim);
  flex-shrink: 0;
}
#terminal-head .ind.live {
  background: var(--fg);
  box-shadow: 0 0 6px var(--fg), 0 0 12px var(--fg);
}
#terminal-head .t-title { color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
#terminal-head .t-note {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 15px;
  font-style: normal;
}

#output {
  flex: 1;
  min-height: 0;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 2px 2px 10px 2px;
  overflow-y: auto;
  font-size: 18px;
}
#output .user      { color: var(--accent); }
#output .user::before { content: "$ "; color: var(--accent); }
#output .assistant { color: var(--fg); }
#output .system    { color: var(--fg-dim); font-style: normal; }
#output .err       { color: var(--err); text-shadow: 0 0 5px var(--err); }
#output .turn      { margin-bottom: 10px; }
#output .pending   {
  color: var(--accent);
  animation: pending-blink 1.6s ease-in-out infinite;
  letter-spacing: 1.5px;
  white-space: nowrap;
}
#output .pending::after {
  content: "...";
  display: inline-block;
  margin-left: 4px;
  animation: pending-dots 1.6s steps(4, end) infinite;
  width: 2.4ch;
  overflow: hidden;
  vertical-align: baseline;
  letter-spacing: 0;
  white-space: nowrap;
}
@keyframes pending-blink {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1.0; }
}
@keyframes pending-dots {
  0%   { width: 0; }
  25%  { width: 0.6ch; }
  50%  { width: 1.2ch; }
  75%  { width: 1.8ch; }
  100% { width: 2.4ch; }
}

#input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--fg-dim);
  padding: 6px 2px 2px 2px;
  margin-top: 6px;
  flex-shrink: 0;
}
.prompt { color: var(--accent); font-weight: bold; text-shadow: var(--glow); }
#input {
  flex: 1;
  background: transparent;
  color: var(--fg);
  border: none;
  outline: none;
  font: inherit;
  font-size: 18px;
  text-shadow: var(--glow-soft);
  caret-color: var(--fg);
}
#input:disabled { opacity: 0.4; }

/* -------- right: mission image panel -------- */

.mission-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border: 1px solid var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
  position: relative;
}
.mission-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.9) sepia(0.2) hue-rotate(80deg) saturate(1.5);
}
.mission-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  text-align: center;
  padding: 20px;
  gap: 12px;
}
.placeholder-glyph {
  font-size: 56px;
  color: var(--fg-dim);
  text-shadow: var(--glow);
}
.placeholder-label {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mission-meta {
  color: var(--fg-dim);
  font-size: 15px;
  padding: 8px 2px 0 2px;
  border-top: 1px solid var(--fg-dim);
}
.mission-meta .meta-title {
  color: var(--accent);
  font-size: 17px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.mission-desc {
  color: var(--fg-dim);
  font-size: 15px;
  line-height: 1.4;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--fg-dim);
}

@media (max-width: 1024px) {
  #desk-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  #side-scenarios,
  #side-mission { border: none; border-bottom: 1px solid var(--fg-dim); }
  #main-terminal { min-height: 60vh; overflow: visible; }
}

/* Score panel at end-of-session */
.turn.score-panel {
  border: 1px solid var(--score);
  background: transparent;
  padding: 10px 14px;
  margin: 14px 0;
  text-shadow: var(--glow-am);
}
.score-head {
  color: var(--score);
  font-weight: bold;
  font-size: 1.1em;
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.score-detail {
  color: var(--fg);
  font-family: inherit;
  font-size: 1em;
  margin: 0;
  white-space: pre;
  text-shadow: var(--glow);
}
