/* Flarelight - css/game.css
 * Visual identity: a survey vessel's instrument suite. Machine readouts are set
 * in a monospaced utility face; the ship's log is set in a serif, because a
 * person writes it. Amber phosphor for state, signal cyan for anything you can
 * act on, and nothing else competes.
 */

:root {
  --hull: #080d14;
  --panel: #121b25;
  --panel-2: #18242f;
  --rule: #2b3b4a;
  --amber: #ffb547;
  --amber-dim: #a2703a;
  --cyan: #6fd8de;
  --cyan-dim: #3d7f84;
  --alert: #e05353;
  --bone: #d7dde3;
  --muted: #7d8b98;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --notch: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

/* An author rule that sets display beats the browser's own [hidden] rule, so
   the attribute is made authoritative here. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--hull);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
}

body {
  background-image:
    radial-gradient(circle at 18% 8%, rgba(111, 216, 222, 0.06), transparent 45%),
    radial-gradient(circle at 82% 92%, rgba(255, 181, 71, 0.05), transparent 40%);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 10px;
  gap: 10px;
}

/* ------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--rule);
  clip-path: var(--notch);
  padding: 8px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 16px; height: 16px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 181, 71, 0.55), inset 0 0 6px rgba(255, 181, 71, 0.4);
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.42em;
  color: var(--amber);
  font-size: 15px;
}

.gauges {
  display: flex;
  flex: 1 1 auto;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.gauge { min-width: 74px; }
.gauge .k {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}
.gauge .v { display: block; font-size: 15px; color: var(--bone); }
.gauge .v.warn { color: var(--amber); }
.gauge .v.bad { color: var(--alert); }

/* the flare index: the one piece of ornament in the interface, and it is a
   readout, not decoration */
.flare-arc { display: flex; align-items: center; gap: 8px; }
.flare-arc svg { display: block; }

.topbtns { display: flex; gap: 6px; }

button {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--cyan);
  background: #10202a;
  border: 1px solid var(--cyan-dim);
  padding: 6px 10px;
  cursor: pointer;
  transition: background 120ms linear, color 120ms linear;
}
button:hover:not(:disabled) { background: #17323d; color: #b8f3f6; }
button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
button:disabled { color: #4b5a66; border-color: #2b3b4a; cursor: not-allowed; }
button.mini { padding: 4px 8px; font-size: 11px; }
button.primary { color: var(--amber); border-color: var(--amber-dim); background: #241a0e; }
button.primary:hover:not(:disabled) { background: #382713; color: #ffd28f; }
button.danger { color: var(--alert); border-color: #7a2f2f; background: #2a1212; }


.version-tag {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  border-left: 1px solid var(--rule);
  padding-left: 9px;
}

.mission-summary {
  display: grid;
  gap: 7px;
  font-size: 11.5px;
}
.mission-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
}
.mission-stat span:first-child { color: var(--muted); }
.mission-stat strong { color: var(--bone); font-weight: 500; }
.mission-objective {
  margin-top: 3px;
  padding: 7px 8px;
  border-left: 2px solid var(--amber-dim);
  background: rgba(255,181,71,0.045);
  color: #c7d0d8;
  font-family: var(--serif);
  line-height: 1.4;
}
.keycap {
  float: right;
  min-width: 19px;
  text-align: center;
  padding: 0 4px;
  margin-left: 8px;
  border: 1px solid var(--rule);
  color: var(--muted);
  background: rgba(0,0,0,0.18);
  font-size: 9px;
  line-height: 17px;
}
button.autosave-off { color: var(--muted); border-color: var(--rule); background: #0d1720; }

.mission-clues { display: flex; gap: 5px; flex-wrap: wrap; margin: -1px 0 2px; }
.mission-clues span {
  padding: 2px 5px; border: 1px solid var(--rule); color: var(--muted);
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
}
.mission-clues span.done { color: var(--cyan); border-color: var(--cyan-dim); background: rgba(111,216,222,0.05); }

/* -------------------------------------------------------------- frame */

.frame {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 280px;
  gap: 10px;
  align-items: start;
}

.col {
  background: var(--panel);
  border: 1px solid var(--rule);
  clip-path: var(--notch);
  padding: 10px 12px 14px;
  min-height: 200px;
}

.col-mid { padding-bottom: 10px; }

.panel-title {
  margin: 4px 0 8px;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber-dim);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 5px;
  font-weight: 600;
}

/* --------------------------------------------------------------- crew */

.crew-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 6px;
  padding: 5px 0;
  border-bottom: 1px dotted #22303c;
}
.crew-post {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  grid-column: 1 / -1;
}
.crew-name { color: var(--bone); }
.crew-skill { color: var(--amber); }
.crew-name.hurt { color: var(--alert); }

.hold-list { font-size: 12.5px; }
.hold-row { display: flex; justify-content: space-between; padding: 2px 0; color: var(--muted); }
.hold-row b { color: var(--bone); font-weight: 400; }
.hold-empty { color: #56636e; font-style: italic; }

/* ----------------------------------------------------------- viewport */

.viewport-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.view-name {
  font-size: 13px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--amber);
}
.view-sub { font-size: 11.5px; color: var(--muted); }

.canvas-wrap {
  position: relative;
  background: #050a10;
  border: 1px solid var(--rule);
  overflow: hidden;
}
.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px);
}
#screen { display: block; width: 100%; height: auto; cursor: crosshair; }

.canvas-hint {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  color: var(--cyan);
  background: rgba(5, 10, 16, 0.82);
  border: 1px solid var(--cyan-dim);
  padding: 3px 7px;
  pointer-events: none;
  max-width: 70%;
}

.message {
  margin-top: 8px;
  min-height: 20px;
  color: var(--amber);
  font-size: 13px;
}
.message.bad { color: var(--alert); }

.log {
  margin-top: 6px;
  max-height: 132px;
  overflow-y: auto;
  border-top: 1px solid var(--rule);
  padding-top: 6px;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
  color: #b9c4ce;
}
.log p { margin: 0 0 5px; }
.log .stamp {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--amber-dim);
  margin-right: 7px;
}

/* ------------------------------------------------------------ actions */

.actions { display: flex; flex-direction: column; gap: 6px; }
.actions button { text-align: left; width: 100%; }
.actions .group {
  margin-top: 8px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 3px;
}

.detail { margin-top: 12px; font-size: 12.5px; }
.detail h4 {
  margin: 10px 0 5px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber-dim);
}
.detail .kv { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.detail .kv span:first-child { color: var(--muted); }
.detail p { margin: 6px 0; font-family: var(--serif); font-size: 13.5px; color: #b9c4ce; }
.bar {
  height: 6px;
  background: #0d1720;
  border: 1px solid var(--rule);
  margin: 3px 0 7px;
}
.bar > i { display: block; height: 100%; background: var(--cyan); }
.bar > i.amber { background: var(--amber); }
.bar > i.alert { background: var(--alert); }

.transcript {
  max-height: 190px;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: 13.5px;
}
.transcript .who {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber-dim);
  display: block;
}
.transcript p { margin: 0 0 8px; }

/* -------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 12, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--amber-dim);
  clip-path: var(--notch);
  padding: 20px 24px;
  max-width: 620px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
}
.modal-box h3 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber);
}
.modal-body { font-family: var(--serif); font-size: 14.5px; color: #c3ccd5; }
.modal-body h4 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin: 14px 0 4px;
}
.modal-body ul { margin: 4px 0 4px 18px; padding: 0; }
.modal-body table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
.modal-body td, .modal-body th { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--rule); }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.boot-error {
  margin: 40px auto;
  max-width: 640px;
  border: 1px solid var(--alert);
  padding: 18px;
  color: var(--alert);
  font-family: var(--mono);
}

/* --------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .frame { grid-template-columns: 1fr; }
  .col-left { order: 2; }
  .col-mid { order: 1; }
  .col-right { order: 3; }
  .log { max-height: 110px; }
}

@media (max-width: 640px) {
  html, body { font-size: 13px; }
  .brand-name { letter-spacing: 0.26em; font-size: 13px; }
  .app { padding: 6px; }
  .col { padding: 8px 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
  .canvas-wrap::after { display: none; }
}


/* ------------------------------------------------ mission intelligence */
.intel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 12px;
}
.intel-card {
  border: 1px solid var(--rule);
  background: #08111a;
  padding: 9px 10px;
  display: grid;
  gap: 3px;
}
.intel-card span {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.intel-card strong { color: var(--bone); font-family: var(--mono); font-size: 14px; }
.intel-card em { color: var(--cyan); font-family: var(--mono); font-size: 10.5px; font-style: normal; }
.intel-note { border-left: 2px solid var(--amber-dim); padding-left: 9px; color: #aeb9c3 !important; }
.intel-ok { color: var(--cyan) !important; }
.intel-warn { color: var(--amber) !important; }
.intel-bad { color: var(--alert) !important; }
@media (max-width: 640px) { .intel-grid { grid-template-columns: 1fr; } }


/* --------------------------------------------------------- v2.2 logbook */
.waypoint-list { display:flex; flex-wrap:wrap; gap:6px; margin:6px 0 12px; }
.waypoint-chip { border:1px solid var(--amber-dim); color:var(--amber); padding:3px 7px; font-family:var(--mono); font-size:10px; letter-spacing:.08em; }
.muted-inline { color:var(--muted); font-family:var(--mono); font-size:11px; }
.logbook-archive { max-height:46vh; overflow:auto; border:1px solid var(--rule); background:#071019; }
.logbook-archive table { margin:0; }
.logbook-archive td { vertical-align:top; padding:5px 7px; }
.logbook-day { width:68px; white-space:nowrap; color:var(--amber-dim); font-family:var(--mono); }

/* ------------------------------------------------------ v2.3 catalog */
.catalog-table-wrap { max-height: 48vh; overflow: auto; border: 1px solid var(--rule); background: #061019; }
.catalog-table { margin: 0; min-width: 680px; }
.catalog-table th { position: sticky; top: 0; z-index: 2; background: #0a141e; color: var(--amber-dim); }
.catalog-table td { vertical-align: middle; }
.catalog-table td:first-child { min-width: 170px; }
.catalog-table small { display: block; margin-top: 2px; color: var(--muted); font-size: 9.5px; letter-spacing: .04em; }
.catalog-state { font-size: 9px; letter-spacing: .08em; white-space: nowrap; }
.catalog-state.known { color: var(--cyan); }
.catalog-state.open { color: var(--amber); }
.catalog-best { background: rgba(111,216,222,.065); box-shadow: inset 2px 0 0 var(--cyan); }
.catalog-course, .catalog-waypoint { padding: 4px 7px; min-height: 28px; font-size: 9.5px; white-space: nowrap; }
.catalog-recommend { border: 1px solid var(--cyan-dim); background: rgba(111,216,222,.045); padding: 7px 9px; color: #c8edf0 !important; }
.catalog-recommend b { color: var(--cyan); font-family: var(--mono); font-size: 10px; letter-spacing: .1em; }

/* v2.4.0 accessibility and fullscreen polish */
:fullscreen .app { min-height: 100vh; }
:fullscreen .frame { min-height: calc(100vh - 58px); }
canvas:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
@media (forced-colors: active) {
  button, .catalog-state, .waypoint-chip { border: 1px solid ButtonText; }
  canvas:focus-visible { outline: 3px solid Highlight; }
}


/* v2.6.0 expedition turnaround */
.readiness-note { margin: 2px 0 4px; padding: 6px 8px; border-left: 2px solid var(--cyan); background: rgba(111,216,222,.045); color: var(--cyan); font-size: 11px; }
.readiness-note.caution { border-left-color: var(--amber); color: var(--amber); background: rgba(255,181,71,.045); }
.readiness-note.danger { border-left-color: var(--alert); color: var(--alert); background: rgba(224,83,83,.05); }
.readiness-issues { font-size: 12px !important; color: var(--muted) !important; }

/* v2.8.0 surface map panning */
#screen { touch-action: none; }
#screen.is-panning { cursor: grabbing; }

/* v2.9 tactical combat computer */
.combat-advice{border-left:3px solid #6fd8de;padding:8px 10px;background:rgba(111,216,222,.06);color:#cfe9ec}

/* v2.9.1 sidebar visibility and scrolling */
@media (min-width: 1101px) {
  .col-left,
  .col-right {
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 92px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-bottom: 28px;
  }
  .col-left::-webkit-scrollbar,
  .col-right::-webkit-scrollbar { width: 10px; }
  .col-left::-webkit-scrollbar-track,
  .col-right::-webkit-scrollbar-track { background: #0a1118; }
  .col-left::-webkit-scrollbar-thumb,
  .col-right::-webkit-scrollbar-thumb {
    background: var(--cyan-dim);
    border: 2px solid #0a1118;
  }
  .col-left, .col-right { scrollbar-color: var(--cyan-dim) #0a1118; scrollbar-width: thin; }
  .col-left::after,
  .col-right::after {
    content: "END OF PANEL";
    display: block;
    margin-top: 18px;
    padding-top: 8px;
    border-top: 1px solid var(--rule);
    color: #5d6d79;
    font-size: 8.5px;
    letter-spacing: .18em;
    text-align: center;
  }
}

@media (max-height: 760px) and (min-width: 1101px) {
  .col-left, .col-right { max-height: calc(100vh - 70px); }
}
