/* ================= ATLAS — main.css ================= */
:root {
  --nms-black: #070A0F;
  --nms-deep-red: #1A0505;
  --nms-red: #CC1A1A;
  --nms-red-bright: #FF3322;
  --nms-orange: #FF8C00;
  --nms-teal: #00E5CC;
  --nms-cyan: #00FFEE;
  --nms-white: #E8F4F8;
  --nms-panel-bg: rgba(0, 20, 25, 0.75);
  --font-head: 'GeoNMS', 'Orbitron', monospace;
  --font-body: 'Share Tech Mono', monospace;
}

/* NMS alphabet — used for glyph subtitles beneath ATLAS replies */
@font-face {
  font-family: 'NMSGlyphs';
  src: url('../assets/fonts/nms-alphabet.ttf') format('truetype');
  font-display: swap;
}

/* Drop GeoNMS.woff2 into assets/fonts/ and this activates automatically */
@font-face {
  font-family: 'GeoNMS';
  src: url('../assets/fonts/GeoNMS.woff2') format('woff2'),
       url('../assets/fonts/GeoNMS.otf') format('opentype');
  font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--nms-black);
  color: var(--nms-white);
  font-family: var(--font-body);
  overflow: hidden;
}

/* ====== BACKGROUND LAYERS ====== */
#bg-base {
  position: fixed; inset: 0; z-index: 0;
  background: url('../assets/bg-spaceport.jpg') center/cover no-repeat;
  filter: blur(2px) brightness(0.55);
  opacity: 0.6;
}
#bg-scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    rgba(0, 229, 204, 0.03) 3px 4px
  );
  animation: scan-scroll 12s linear infinite;
}
@keyframes scan-scroll {
  from { background-position-y: 0; }
  to   { background-position-y: 200px; }
}
#bg-grid {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.15;
}
#bg-vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%,
    transparent 30%, rgba(7, 10, 15, 0.85) 100%);
}

/* ====== APP GRID ====== */
#app {
  position: relative; z-index: 3;
  display: grid;
  height: 100vh;
  height: 100dvh;
  grid-template-rows: 52px 1fr 96px;
  grid-template-columns: 250px 1fr 250px;
  grid-template-areas:
    "header header header"
    "left   centre right"
    "left   hist   right";
  gap: 12px;
  padding: 12px;
}

/* prevent any wide child (ticker text etc.) from blowing the grid out */
#app > * { min-width: 0; }

/* ====== HEADER ====== */
#header-bar {
  grid-area: header;
  overflow: hidden;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--nms-panel-bg);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 140, 0, 0.35);
  border-bottom: 2px solid var(--nms-orange);
  box-shadow: 0 0 18px rgba(255, 140, 0, 0.15);
}
.brand {
  font-family: var(--font-head);
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--nms-orange);
  text-shadow: 0 0 12px rgba(255, 140, 0, 0.6);
  text-transform: uppercase;
}
.brand-sub { font-size: 0.65rem; color: var(--nms-teal); letter-spacing: 0.15em; }
.header-clocks {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.8rem; color: var(--nms-teal);
  flex: 0 0 auto;
}

/* ====== EXPEDITION TICKER ====== */
#ticker {
  flex: 1 1 auto;
  overflow: hidden;
  margin: 0 18px;
  min-width: 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}
#ticker-track {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--nms-orange);
  text-shadow: 0 0 8px rgba(255, 140, 0, 0.4);
  text-transform: uppercase;
  animation: ticker-scroll 38s linear infinite;
  will-change: transform;
}
#ticker:hover #ticker-track,
#ticker.paused #ticker-track { animation-play-state: paused; }
#ticker { cursor: pointer; }
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}
.clock-sep { color: var(--nms-orange); }
#mute-btn {
  background: none; border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-teal); cursor: pointer;
  width: 28px; height: 28px; border-radius: 4px; font-size: 0.9rem;
}
#mute-btn:hover { box-shadow: 0 0 8px var(--nms-teal); }
#mute-btn.muted { color: #555; border-color: #444; }

#settings-btn {
  background: none; border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-teal); cursor: pointer;
  width: 28px; height: 28px; border-radius: 4px; font-size: 0.9rem;
}
#settings-btn:hover { box-shadow: 0 0 8px var(--nms-teal); }

/* ====== CENTRE ====== */
#panel-centre {
  grid-area: centre;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}
#orb-zone {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center;
}
#status-line {
  margin-top: 6px;
  font-size: 0.78rem; letter-spacing: 0.3em;
  color: var(--nms-teal); text-transform: uppercase;
}
.cursor { animation: blink 1s steps(1) infinite; color: var(--nms-red-bright); }

#silence-btn {
  margin-top: 8px;
  background: rgba(20, 8, 0, 0.8);
  border: 1px solid var(--nms-orange);
  color: var(--nms-orange);
  font-family: var(--font-body); font-size: 0.72rem;
  letter-spacing: 0.2em; padding: 7px 18px;
  cursor: pointer; border-radius: 4px;
  animation: blink-soft 1.4s ease-in-out infinite;
}
#silence-btn.hidden { display: none; }
@keyframes blink-soft { 50% { opacity: 0.55; } }

#wake-btn {
  flex: 0 0 44px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--nms-panel-bg);
  border: 1px solid rgba(255, 140, 0, 0.35);
  color: rgba(255, 140, 0, 0.45);
  font-size: 0.85rem; cursor: pointer; border-radius: 6px;
  transition: box-shadow 0.2s, color 0.2s;
  letter-spacing: -0.05em;
}
#wake-btn.active {
  color: var(--nms-orange);
  border-color: var(--nms-orange);
  box-shadow: 0 0 12px rgba(255, 140, 0, 0.5);
  animation: wake-breathe 2.4s ease-in-out infinite;
}
@keyframes wake-breathe { 50% { box-shadow: 0 0 22px rgba(255, 140, 0, 0.7); } }

#auto-btn {
  flex: 0 0 40px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--nms-panel-bg);
  border: 1px solid rgba(0, 229, 204, 0.35);
  color: rgba(0, 229, 204, 0.45);
  font-size: 1.3rem; cursor: pointer; border-radius: 6px;
  transition: box-shadow 0.2s, color 0.2s;
}
#auto-btn.active {
  color: var(--nms-teal);
  border-color: var(--nms-teal);
  box-shadow: 0 0 12px rgba(0, 229, 204, 0.5);
}
#mic-btn.disabled { opacity: 0.3; cursor: not-allowed; }
@keyframes blink { 50% { opacity: 0; } }

/* ====== SPEECH DECODE (live dual captions while ATLAS speaks) ====== */
#speech-decode {
  width: min(680px, 100%);
  margin: 8px auto 0;
  padding: 14px 16px;
  background: rgba(10, 2, 2, 0.78);
  border: 1px solid rgba(255, 51, 34, 0.4);
  box-shadow: 0 0 14px rgba(204, 26, 26, 0.25);
}
#speech-decode.hidden { display: none; }
.sd-line { min-height: 1.5em; }
.sd-glyphs {
  font-family: 'NMSGlyphs', monospace;
  font-size: 1rem;
  color: var(--nms-teal);
  opacity: 0.85;
  line-height: 1.95;       /* tall glyphs need headroom — no clipping */
  text-align: center;
  padding: 2px 4px 8px;
  word-break: break-all;
  max-height: 6.2em;       /* ~3 glyph lines, scrolls within its own window */
  overflow-y: auto;
}
#sd-english {
  font-size: 0.95rem;
  color: var(--nms-white);
  line-height: 1.55;
  text-align: center;
  margin-top: 8px;
  padding: 10px 4px 2px;
  border-top: 1px dashed rgba(0, 229, 204, 0.3);
  max-height: 4.7em;       /* ~3 lines, scrolls within its own window */
  overflow-y: auto;
}

/* transcript */
#transcript {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 10px auto 8px;
  width: min(680px, 100%);
  padding: 10px 14px;
  background: rgba(0, 10, 14, 0.55);
  border: 1px solid rgba(0, 229, 204, 0.2);
  font-size: 0.92rem;
  line-height: 1.5;
}
.t-user  { color: var(--nms-cyan); margin-bottom: 6px; }
.t-atlas { color: var(--nms-white); margin-bottom: 10px; }
.t-user::before  { content: "TRAVELLER ► "; color: var(--nms-teal); font-size: 0.75em; letter-spacing: 0.1em; }
.t-atlas::before { content: "ATLAS ◆ "; color: var(--nms-red-bright); font-size: 0.75em; letter-spacing: 0.1em; }
.t-interim { opacity: 0.55; font-style: italic; }
.t-restored {
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--nms-orange);
  opacity: 0.55;
  margin: 8px 0;
}
.t-glyphs {
  font-family: 'NMSGlyphs', monospace;
  font-size: 0.8rem;
  color: var(--nms-teal);
  opacity: 0.4;
  margin-top: 2px;
  letter-spacing: 0.08em;
  line-height: 1.5;
  word-break: break-all;
  user-select: none;
}
.t-error { color: var(--nms-orange); }

/* input bar */
#input-bar {
  flex: 0 0 auto;
  display: flex; gap: 8px;
  width: min(680px, 100%);
  margin: 0 auto;
}
#mic-btn, #send-btn {
  flex: 0 0 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--nms-panel-bg);
  border: 1px solid var(--nms-red);
  color: var(--nms-red-bright);
  cursor: pointer; border-radius: 6px;
  transition: box-shadow 0.2s, background 0.2s;
}
#mic-btn:hover, #send-btn:hover { box-shadow: 0 0 14px rgba(255, 51, 34, 0.6); }
#mic-btn.active {
  background: var(--nms-red);
  color: #fff;
  box-shadow: 0 0 22px var(--nms-red-bright);
  animation: mic-pulse 0.8s ease-in-out infinite;
}
@keyframes mic-pulse {
  50% { box-shadow: 0 0 34px var(--nms-red-bright); }
}
#send-btn { border-color: var(--nms-teal); color: var(--nms-teal); }
#send-btn:hover { box-shadow: 0 0 14px rgba(0, 229, 204, 0.6); }
#text-input {
  flex: 1 1 auto; height: 48px;
  background: rgba(0, 10, 14, 0.7);
  border: 1px solid rgba(0, 229, 204, 0.35);
  color: var(--nms-cyan);
  font-family: var(--font-body); font-size: 1rem;
  padding: 0 14px; border-radius: 6px;
  min-width: 0;
}
#text-input:focus {
  outline: none;
  border-color: var(--nms-teal);
  box-shadow: 0 0 12px rgba(0, 229, 204, 0.35);
}
#text-input::placeholder { color: rgba(0, 229, 204, 0.35); }

/* ====== HISTORY ====== */
#history {
  grid-area: hist;
  background: var(--nms-panel-bg);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 140, 0, 0.3);
  padding: 8px 14px;
  display: flex; flex-direction: column;
  min-height: 0;
}
.history-label { margin-bottom: 4px; }
#history-list { overflow-y: auto; flex: 1; font-size: 0.8rem; line-height: 1.45; }
.h-msg { margin-bottom: 4px; }
#log-placeholder {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: var(--nms-teal);
  opacity: 0.45;
  text-align: center;
  padding: 14px 0;
}
.h-msg .h-who { letter-spacing: 0.1em; font-size: 0.72em; margin-right: 6px; }
.h-msg.user .h-who  { color: var(--nms-teal); }
.h-msg.atlas .h-who { color: var(--nms-red-bright); }
.h-msg.user  { color: var(--nms-cyan); }
.h-msg.atlas { color: var(--nms-white); }

/* scrollbars */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 20, 25, 0.4); }
::-webkit-scrollbar-thumb { background: var(--nms-orange); border-radius: 3px; }

/* ====== BOOT SEQUENCE ====== */
@keyframes boot-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
#header-bar   { animation: boot-in 0.5s ease-out 0.05s backwards; }
#panel-centre { animation: boot-in 0.5s ease-out 0.25s backwards; }
#panel-left   { animation: boot-in 0.5s ease-out 0.45s backwards; }
#panel-right  { animation: boot-in 0.5s ease-out 0.6s backwards; }
#history      { animation: boot-in 0.5s ease-out 0.75s backwards; }

/* ====== REDUCED MOTION ====== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #ticker-track { animation: none !important; padding-left: 0; }
  #bg-scanlines { display: none; }
}

/* ====== WELCOME POPUP ====== */
.welcome-box { position: relative; text-align: left; }
.welcome-box h2 { text-align: center; }
.welcome-box p { font-size: 0.88rem; }
.welcome-box strong { color: var(--nms-teal); font-weight: normal; }
.modal-x {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px;
  background: none; border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-teal); cursor: pointer; font-size: 1rem;
  border-radius: 4px;
}
.modal-x:hover { box-shadow: 0 0 10px var(--nms-teal); }

/* ====== MOBILE DISPLAY HINT ====== */
#mobile-hint {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: rgba(20, 8, 0, 0.95);
  border-bottom: 2px solid var(--nms-orange);
  color: var(--nms-orange);
  font-size: 0.95rem; line-height: 1.5;
  letter-spacing: 0.06em;
  padding: 14px 52px 14px 16px;
  text-transform: uppercase;
}
#mobile-hint.hidden { display: none; }
#mobile-hint-close {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  background: none; border: 1px solid var(--nms-orange);
  color: var(--nms-orange); cursor: pointer; font-size: 1rem;
}

/* ====== MODAL ====== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(7, 10, 15, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-box {
  width: min(440px, 92vw);
  background: var(--nms-panel-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--nms-red);
  box-shadow: 0 0 40px rgba(204, 26, 26, 0.4);
  padding: 28px; text-align: center;
}
.modal-box h2 {
  font-family: var(--font-head);
  color: var(--nms-red-bright);
  letter-spacing: 0.3em; margin-bottom: 14px;
  text-shadow: 0 0 14px rgba(255, 51, 34, 0.7);
}
.modal-box p { font-size: 0.85rem; line-height: 1.5; margin-bottom: 16px; color: var(--nms-white); }
.modal-box a { color: var(--nms-teal); }
.modal-box a:hover { color: var(--nms-cyan); }
.key-row { display: flex; gap: 6px; margin-bottom: 14px; }
.key-row input {
  flex: 1; height: 44px;
  background: rgba(0, 10, 14, 0.8);
  border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-cyan); font-family: var(--font-body);
  padding: 0 12px;
}
.key-row button {
  flex: 0 0 44px; width: 44px; background: none;
  border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-teal); cursor: pointer;
}
.voice-row {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 14px;
}
.voice-label {
  font-size: 0.62rem; letter-spacing: 0.2em;
  color: var(--nms-orange); flex: 0 0 auto;
}
.voice-row select {
  flex: 1 1 auto; min-width: 0; height: 38px;
  background: rgba(0, 10, 14, 0.8);
  border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-cyan); font-family: var(--font-body);
  font-size: 0.72rem; padding: 0 6px;
}
#voice-test {
  flex: 0 0 auto; height: 38px; padding: 0 10px;
  background: none;
  border: 1px solid rgba(0, 229, 204, 0.4);
  color: var(--nms-teal); cursor: pointer;
  font-family: var(--font-body); font-size: 0.7rem;
  letter-spacing: 0.1em;
}
#voice-test:hover { box-shadow: 0 0 10px rgba(0, 229, 204, 0.5); }

.btn-primary {
  width: 100%; height: 46px;
  background: var(--nms-red);
  border: none; color: #fff;
  font-family: var(--font-head); font-size: 1rem;
  letter-spacing: 0.25em; cursor: pointer;
  transition: box-shadow 0.2s;
}
.btn-primary:hover { box-shadow: 0 0 24px var(--nms-red-bright); }
.btn-demo {
  width: 100%; height: 40px; margin-top: 8px;
  background: none;
  border: 1px solid rgba(0, 229, 204, 0.5);
  color: var(--nms-teal);
  font-family: var(--font-head); font-size: 0.78rem;
  letter-spacing: 0.2em; cursor: pointer;
  transition: box-shadow 0.2s;
}
.btn-demo:hover { box-shadow: 0 0 16px rgba(0, 229, 204, 0.5); }

.key-note { font-size: 0.7rem !important; opacity: 0.6; margin-top: 12px !important; margin-bottom: 0 !important; }
.key-warn {
  color: var(--nms-orange) !important;
  opacity: 0.85;
  margin-top: 8px !important;
  border-top: 1px solid rgba(255, 140, 0, 0.25);
  padding-top: 8px;
}
