/* GRID//BLOCK shell.
   The palette comes straight off the concept art: navy and brick foundations,
   warm amber interiors, teal network signals, restrained coral for danger. */

@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

:root {
  --navy: #060e1b;
  --navy-2: #0c1727;
  --line: #1e3450;
  --teal: #4de2d5;
  --teal-dim: #2b8f92;
  --amber: #ffb14d;
  --coral: #ff6b7a;
  --green: #7dff9b;
  --text: #cfe0f0;
  --muted: #7e93ad;
  --mono: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Chakra Petch", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* `hidden` has to beat the layout rules below, which all set `display`. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

#shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

/* ------------------------------------------------------------------ header -- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #0d1a2c, #081221);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 14px;
}

.brand small {
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0.12em;
  font-size: 10px;
  text-transform: uppercase;
}

.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.headline {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

#clock { color: var(--teal); }

/* -------------------------------------------------------------------- main -- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 322px;
  min-height: 0;
}

#viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #050b16;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(6, 12, 22, 0.20) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 45%, transparent 58%, rgba(3, 7, 14, 0.5) 100%);
}

#flags {
  position: absolute;
  top: 10px; left: 10px;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

.flag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(7, 15, 28, 0.72);
  color: var(--muted);
}

.flag.on { color: var(--teal); border-color: var(--teal-dim); }
.flag.alarm {
  color: var(--coral);
  border-color: var(--coral);
  animation: blink 0.9s steps(2, end) infinite;
}

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

#toast {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 12px);
  padding: 7px 14px;
  background: rgba(7, 16, 28, 0.92);
  border: 1px solid var(--teal-dim);
  border-left: 3px solid var(--teal);
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.24s ease, transform 0.24s ease;
  pointer-events: none;
  max-width: 78%;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- overlays -- */

#intro, #pause, #debrief {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(90% 80% at 50% 40%, rgba(8, 18, 32, 0.7), rgba(3, 7, 14, 0.94));
  z-index: 5;
}

#intro { background-image: linear-gradient(90deg, rgba(4,12,22,0.95) 0 42%, rgba(4,12,22,0.55)); }
#intro.hide { display: none; }

.intro-card {
  max-width: 540px;
  padding: 22px 24px;
  background: linear-gradient(180deg, rgba(14, 28, 46, 0.96), rgba(8, 17, 30, 0.96));
  border: 1px solid var(--line);
  border-top: 2px solid var(--teal);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--teal);
  margin-bottom: 10px;
}

.intro-card h1 {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.04;
  text-shadow: 3px 3px 0 #14293d;
}

.intro-card h2 { margin: 0 0 12px; font-size: 20px; }

.intro-card p {
  margin: 0 0 14px;
  color: #a9c0d6;
  font-size: 13px;
  line-height: 1.55;
}

.intro-card p.fine { color: var(--muted); font-size: 12px; }

.keys {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.keys li { display: flex; align-items: center; gap: 4px; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #0e1b2c;
  color: var(--text);
}

button {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  padding: 10px 20px;
  color: #04121a;
  background: var(--teal);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

button:hover { filter: brightness(1.12); transform: translateY(-1px); }

/* Discarding a run is a deliberate, quieter choice than continuing one. */
button.secondary {
  margin-left: 8px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

button.secondary:hover { color: var(--text); }

.intro-card p.saved {
  font-family: var(--mono);
  color: var(--teal);
  border-left: 2px solid var(--teal);
  padding-left: 8px;
}

#debriefBody {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-family: var(--mono);
  font-size: 11px;
}

#debriefBody div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(8, 18, 32, 0.8);
  border-left: 2px solid var(--teal-dim);
}

#debriefBody dt { color: var(--muted); margin: 0; }
#debriefBody dd { margin: 0; }

/* ------------------------------------------------------------------ aside -- */

aside {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  min-height: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, #091425, #060d18);
  border-left: 1px solid var(--line);
  scrollbar-width: thin;
}

.panel {
  padding: 10px 11px;
  background: rgba(14, 27, 44, 0.72);
  border: 1px solid var(--line);
  border-radius: 2px;
}

.label, .panel-head {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.24em;
  color: var(--muted);
  margin-bottom: 7px;
}

.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.panel-head b { color: var(--muted); letter-spacing: 0.14em; }
.panel-head b.live { color: var(--green); }
.panel-head b.partial { color: var(--amber); }

.mission { border-left: 2px solid var(--amber); }
.mission h2 { margin: 0 0 6px; font-size: 16px; }

.mission p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #a9c0d6;
}

.mission p.status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--teal);
  margin: 6px 0 0;
}

.progress, .track {
  height: 4px;
  background: #0a1524;
  border: 1px solid var(--line);
  overflow: hidden;
}

.fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal-dim), var(--teal));
  transition: width 0.25s ease;
}

.fill.botnet { background: linear-gradient(90deg, #2b6f92, #6fd0ff); }
.fill.hot { background: linear-gradient(90deg, #b8642f, var(--amber)); }
.fill.critical { background: linear-gradient(90deg, #8f2f3f, var(--coral)); }

.stages {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: #4f6480;
}

.stages li {
  padding: 3px 6px 3px 16px;
  position: relative;
  border-left: 1px solid var(--line);
}

.stages li::before { content: "○"; position: absolute; left: 4px; }
.stages li.done { color: var(--teal-dim); }
.stages li.done::before { content: "●"; }
.stages li.active {
  color: var(--teal);
  background: rgba(77, 226, 213, 0.07);
  border-left-color: var(--teal);
}
.stages li.active::before { content: "▸"; }

/* ---------------------------------------------------------------- profiler -- */

.profiler { border-left: 2px solid var(--teal-dim); }

.who {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 9px;
}

#portrait {
  width: 54px;
  height: 72px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  background: #0d1521;
}

.identity h3 { margin: 0 0 2px; font-size: 15px; }

.identity p {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--teal);
}

.identity p.employer { color: var(--muted); letter-spacing: 0.04em; }

#profileEmpty { font-size: 12px; color: var(--muted); line-height: 1.5; }

.profiler dl {
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.profiler dl div {
  padding: 5px 7px;
  background: rgba(8, 18, 32, 0.72);
  border-left: 2px solid var(--teal-dim);
}

.profiler dt {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.profiler dd { margin: 1px 0 0; font-size: 13px; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 5px;
  font-size: 11px;
  line-height: 1.45;
}

.row span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: var(--muted);
  flex: 0 0 62px;
  padding-top: 2px;
}

.row b { font-weight: 500; text-align: right; color: #bcd2e6; }

.relations {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: #9fb6cc;
}

.relations li {
  padding: 3px 6px;
  background: rgba(8, 18, 32, 0.6);
  border-left: 2px solid #24384f;
}

.relations li b { color: #bcd2e6; font-weight: 500; }

/* An edge that exists only because of something the player did. */
.relations li.changed {
  color: #ffd4a0;
  border-left-color: var(--amber);
  background: rgba(48, 32, 12, 0.45);
}

.relations li.muted { color: var(--muted); font-style: italic; }

.secret {
  margin: 8px 0 0;
  padding: 7px 8px;
  font-size: 11px;
  line-height: 1.45;
  color: #9fb6cc;
  background: rgba(8, 18, 32, 0.8);
  border-left: 2px solid #3b4f68;
}

.secret.actionable {
  color: #ffd9a0;
  border-left-color: var(--amber);
  background: rgba(48, 32, 12, 0.5);
}

/* ----------------------------------------------------------------- network -- */

.network { display: grid; gap: 8px; }

.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.stat b { color: var(--teal); font-size: 12px; }
.stat b.ok { color: var(--green); }
.stat b.bad { color: var(--coral); }
.stat b.warn { color: var(--amber); }

/* The target's own state, read from the mission panel. */
.row b.ok { color: var(--green); }
.row b.warn { color: var(--amber); }
.row b.bad { color: var(--coral); }

.meter-head {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 4px;
}

.meter-head b { color: var(--text); }

/* -------------------------------------------------------------------- feed -- */

.feed { flex: 1 1 auto; min-height: 92px; }

#log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.4;
}

#log li {
  padding: 3px 6px;
  color: #8aa2bd;
  background: rgba(8, 18, 32, 0.6);
  border-left: 2px solid #24384f;
}

#log li.ok { color: #a9e8bd; border-left-color: var(--green); }
#log li.warn { color: #ffd4a0; border-left-color: var(--amber); }
#log li.bad { color: #ffb0b8; border-left-color: var(--coral); }

/* ------------------------------------------------------------------ footer -- */

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: #081221;
  border-top: 1px solid var(--line);
}

.foot-right b { color: var(--teal); }

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

@media (max-width: 940px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  aside {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 44vh;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    align-content: start;
  }
  .feed { min-height: 70px; }
}

@media (max-width: 560px) {
  .brand small { display: none; }
  .intro-card h1 { font-size: 24px; }
}
