/* nightshift -- die Bedienoberflaeche fuer den Nachtbetrieb.
 *
 * Der Grund ist Schiefer, nicht Schwarz: das hier laeuft nachts neben einem Spielfenster,
 * und ein schwarzer Block daneben ist ein Loch. Der einzige Akzent ist Gold -- die Waehrung,
 * an der im Werkzeug das Tor haengt (Tagesbudget, Transferkosten, Cash-Schwelle).
 *
 * Die Ressourcenfarben erscheinen in den Kategorie-Chips -- dem einen lauten Element der
 * Seite, weil sie das Einzige sind, was man hier entscheidet --, leise im Wachstum je Basis
 * und in den Rasterzellen eines Berichts, wo sie zeigen, WO eine Ressource liegt.
 *
 * Alles, was eine Maschine erzeugt hat -- Ids, Koordinaten, Protokoll --, steht in
 * Festbreite. Alles, was ein Mensch geschrieben hat, nicht. */

:root {
  --bg: #131c26;
  --surface: #1b2733;
  --raised: #22303e;
  --line: #2c3d4e;
  --text: #e2eaf2;
  --muted: #8ba0b5;
  --gold: #e8b13c;
  --warn: #e2705a;
  --ok: #6fbf8b;

  --tiberium: #7cc47f;
  --crystal: #6aa9d8;
  --power: #e0c76a;
  --off: #d98a6a;
  --defense: #93a7bd;
  --auto: #cddbe8;

  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  /* Zahlen stehen hier in Spalten -- Level, Wachstum, Ids. */
  font-variant-numeric: tabular-nums;
}

h1, h2 { font-weight: 600; margin: 0; }

/* --- Kopf ---------------------------------------------------------------- */

.head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px max(16px, 50% - 31rem);
}

.head-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: baseline;
  justify-content: space-between;
}
.head-row + .head-row { margin-top: 12px; }

.head h1 {
  font-size: 20px;
  letter-spacing: -0.01em;
}
.head h1::after {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-left: 9px;
  border-radius: 50%;
  background: var(--line);
  vertical-align: middle;
}
body.running .head h1::after { background: var(--ok); }
body.stopping .head h1::after { background: var(--warn); }

.account {
  margin: 0;
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
}
.account .gold {
  font: 600 17px/1 var(--mono);
  color: var(--gold);
}
.account .unit { font-size: 12px; }

.stages { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); }
.stages label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.stages input { accent-color: var(--gold); }

.buttons { display: flex; gap: 8px; }

.button {
  font: 600 14px/1 var(--sans);
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--raised);
  color: var(--text);
  cursor: pointer;
}
.button:hover:not(:disabled) { border-color: var(--muted); }
.button:disabled { opacity: 0.45; cursor: default; }
.button-go { border-color: var(--gold); color: var(--gold); }
.button-stop { border-color: var(--warn); color: var(--warn); }

.run-line { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
/* Ohne Meldung keine leere Zeile -- sonst klafft im Kopf eine Luecke, die aussieht wie ein
   Fehler. */
.run-line:empty { display: none; }
.run-line.error { color: var(--warn); }
/* Der Kontohinweis unter den Kopfzeilen (#account-note); .note allein haette keinen Abstand. */
.head > .note { margin: 8px 0 0; }

/* Die Gruendungskasse (#335): eine eigene Kopfzeile. Je Balken ist die Fuellung der Bestand und
   der weisse Strich der Soll-Stand heute -- liegt die Fuellung links davon, haengt die Kasse
   hinter dem Ziel. */
.head-row.fund { display: block; font-size: 13px; color: var(--muted); }
.fund-grid {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 6px 14px;
  align-items: center;
}
.fund-label { color: var(--text); font-weight: 600; }
.fund-label[title] { cursor: help; }
.fund-bar {
  position: relative;
  height: 8px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.fund-bar > span {
  position: absolute; left: 0; top: 0; bottom: 0;
  max-width: 100%;
  background: var(--gold);
  border-radius: 3px 0 0 3px;
}
.fund-bar > i {
  position: absolute; top: -4px; bottom: -4px;
  width: 2px; margin-left: -1px;
  background: var(--text);
}
.fund-bar.faint { opacity: 0.4; }
.fund-text { font: 12px/1.4 var(--mono); white-space: nowrap; }
.fund-status { margin: 8px 0 0; }
.fund-status.warn { color: var(--warn); }
.fund-status.ok { color: var(--ok); }
.fund-status.muted { color: var(--muted); }
@media (max-width: 600px) {
  .fund-grid { grid-template-columns: auto 1fr; }
  .fund-text { grid-column: 1 / -1; white-space: normal; }
}

/* --- Inhalt -------------------------------------------------------------- */

main { padding: 0 max(16px, 50% - 31rem) 64px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 32px 0 4px;
}

.notices { margin-top: 20px; }
.notice {
  border-left: 2px solid var(--warn);
  padding: 8px 0 8px 12px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}

.snapshot-age { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.snapshot-age.stale { color: var(--warn); }

/* --- Basen --------------------------------------------------------------- */

.base-list { list-style: none; margin: 0; padding: 0; }
.base-list .empty { color: var(--muted); padding: 20px 0; }

.base {
  border-top: 1px solid var(--line);
  padding: 18px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 24px;
}

.base-name { font-weight: 600; }
.base-place {
  font: 400 13px/1.5 var(--mono);
  color: var(--muted);
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}
.base-id { margin-left: 14px; color: #4d6376; }
.base-data {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 8px;
}
.base-data b { color: var(--text); font-weight: 400; }
.base-data .warn { color: var(--warn); }

/* Das Wachstum traegt seine Bedeutung in der Farbe. Eine Beschriftung ueber drei Zahlen
   waere hier nur eine Zeile mehr -- die Toene sind dieselben wie in den Chips darunter. */
.growth {
  grid-column: 1 / -1;
  margin: 0 0 12px;
  font: 400 13px/1.5 var(--mono);
  display: flex;
  gap: 14px;
  align-items: baseline;
}
.value-tiberium { color: var(--tiberium); }
.value-crystal { color: var(--crystal); }
.value-power { color: var(--power); }
.growth .unit { font-family: var(--sans); color: var(--muted); font-size: 12px; }

.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }

.auto-note {
  grid-column: 1 / -1;
  margin: 9px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.chip {
  font: 500 13px/1 var(--sans);
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chip:hover:not(:disabled) { border-color: var(--ton, var(--muted)); color: var(--text); }
.chip[aria-pressed="true"] {
  border-color: var(--ton, var(--gold));
  color: var(--bg);
  background: var(--ton, var(--gold));
}
.chip:disabled { opacity: 0.4; cursor: default; }

.chip-auto { --ton: var(--auto); }
.chip-power { --ton: var(--power); }
.chip-tiberium { --ton: var(--tiberium); }
.chip-crystal { --ton: var(--crystal); }
.chip-off { --ton: var(--off); }
.chip-defense { --ton: var(--defense); }
/* Cash ist Gold, die Waehrung, die der Akzent der Seite schon traegt (#335). */
.chip-cash { --ton: var(--gold); }

.overridden {
  grid-column: 1 / -1;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--warn);
}

/* --- Durchgaenge (Issue #337) ---------------------------------------------
 *
 * Die Stelle zum Lesen: je Durchgang eine Kopfzeile, darunter nur die Basen, an denen etwas
 * geschah. Ruhige Durchgaenge treten zurueck, Auffaelligkeiten tragen das Warnrot. Die Uhrzeit
 * steht in Festbreite, damit die Spalte steht -- sie ist auch eine Maschinenangabe. */

/* Vier Tage Durchgaenge sind lang. Eine eigene Scrollflaeche haelt die Basen darunter in
   Reichweite -- dort stehen die Kategorie-Chips, die man hier bedient. Die Tagesueberschrift bleibt
   beim Scrollen stehen. */
.passes { max-height: 65vh; overflow-y: auto; overscroll-behavior: contain; }
.passes .list-note { color: var(--muted); font-size: 14px; }
.pass-day-label {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  padding: 12px 0 6px;
}
.pass-list { list-style: none; margin: 0; padding: 0; }
.pass {
  border-top: 1px solid var(--line);
  padding: 8px 0;
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 2px 12px;
  font-size: 14px;
}
.pass-time { font: 400 13px/1.6 var(--mono); color: var(--muted); }
.pass-head { color: var(--text); }
.pass.tone-quiet .pass-head { color: var(--muted); }
.pass.tone-note .pass-head { color: var(--muted); font-style: italic; }
.pass.tone-warn .pass-head { color: var(--warn); }
.pass-lines {
  grid-column: 2;
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}
.pass-lines li { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 10px; padding: 1px 0; }
.pass-base { color: var(--text); overflow-wrap: anywhere; }
.pass-text { overflow-wrap: anywhere; }
.pass-lines .tone-warn .pass-text { color: var(--warn); }

/* Auf dem Telefon untereinander: die Zeit ueber dem Kopf, der Basisname ueber seinem Satz. */
@media (max-width: 34rem) {
  .pass { grid-template-columns: minmax(0, 1fr); }
  .pass-lines { grid-column: 1; }
  .pass-lines li { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 3px 0; }
}

/* --- Laufausgabe (bis #337: Protokoll) ----------------------------------- */

.log-section summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-section summary:hover { color: var(--text); }

.log {
  font: 400 12.5px/1.6 var(--mono);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
  margin: 0;
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}
.log .aus { color: var(--text); }
.log .err { color: var(--gold); }

/* --- Grundausstattung ---------------------------------------------------- */

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .button, .chip { transition: border-color 120ms, background-color 120ms, color 120ms; }
}

@media (max-width: 34rem) {
  .head-row { flex-direction: column; align-items: stretch; }
  .base { grid-template-columns: 1fr; }
  .base-place { grid-column: 1; grid-row: auto; text-align: left; }
}

/* --- Zeitplan ------------------------------------------------------------- */

.schedule-section { margin-bottom: 22px; }
.schedule-section summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}
.schedule-section summary:hover { color: var(--text); }

.form { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.field { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.field input, .field select {
  font: 14px/1 var(--sans);
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--raised);
  color: var(--text);
}
.field input:focus, .field select:focus { outline: 1px solid var(--gold); }
.note { font-size: 12px; color: var(--muted); margin: 0; }

/* [hidden] setzt display:none -- aber jede Regel mit eigenem display gewinnt dagegen, und
   .form-row hat eines. Ohne diese Zeile stehen Zeitfenster und Uhrzeiten nebeneinander,
   obwohl immer nur eines von beiden gilt. */
[hidden] { display: none !important; }

/* Eine zerstoerte Basis ist das Einzige in dieser Oberflaeche, was nightshift nicht beheben
   kann -- sie muss im Spiel von Hand neu platziert werden. Also faellt sie auf, auch wenn
   die Liste lang ist. */
.notice.urgent {
  border-left-width: 3px;
  color: var(--warn);
  font-weight: 600;
}
.base.ghost {
  border-left: 3px solid var(--warn);
  padding-left: 12px;
}
.base.ghost .base-name { color: var(--warn); }

/* --- Ranglisten (Issue #37) ------------------------------------------------
 *
 * Die Tabelle ist der Inhalt, nicht der Rahmen: keine Gitterlinien, nur Luft und eine
 * leise Kopfzeile. Alles, was eine Maschine erzeugt hat -- Zahlen, Orte, Stufen --, steht
 * in Festbreite, wie ueberall auf dieser Seite. */

.rankings { grid-column: 1 / -1; margin-top: 12px; }
.rankings summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  list-style-position: outside;
}
.rankings summary:hover { color: var(--text); }

.list-name {
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.list-note { margin: 0 0 6px; font-size: 12px; color: var(--muted); }

/* Neun Spalten passen auf kein Telefon. Scrollen darf die Tabelle, nie die Seite. */
.table-scroll { overflow-x: auto; }

.ranking {
  border-collapse: collapse;
  width: 100%;
  font: 400 13px/1.6 var(--mono);
  white-space: nowrap;
}
.ranking th {
  text-align: left;
  font: 400 11px/1.6 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 4px 12px 4px 0;
}
.ranking td { padding: 3px 12px 3px 0; color: var(--muted); }
.ranking td:first-child { color: var(--text); }
.ranking tr:hover td { background: var(--raised); }

/* Der Rueckstand fett, wo die Nachziehpflicht greift -- wie im Bericht. */
.ranking .behind { color: var(--text); font-weight: 700; }

/* Die Spalte bezahlbar ist das Tor. Sie traegt die einzige Farbe dieser Tabellen, weil sie
   die Auskunft ist, die man hier sucht -- und ihr Grund steht daneben, nicht in einem
   Tooltip: was man aufklappen muss, liest niemand. */
.gate-yes { color: var(--ok); }
.gate-transfer { color: var(--gold); }
.gate-no { color: var(--muted); }

.overview { margin-top: 26px; }
.overview .note { margin: 0 0 10px; max-width: 62ch; }
.overview .stages { margin-bottom: 6px; }

/* Ein Spaltenkopf, der sich anklicken laesst, muss danach aussehen -- und der aktive muss
   sich vom Rest unterscheiden, sonst weiss man nach dem Klick nicht, was gilt. */
.ranking th.sortable { cursor: pointer; }
.ranking th.sortable:hover { color: var(--text); }
.ranking th.sortable.active { color: var(--gold); }
.ranking th.sortable.active::after { content: " ↓"; }

/* --- Marken (Issue #37 Teil 2) ---------------------------------------------
 *
 * Nur zeigen, was eine Handlung verlangt: jede Marke ist Auskunft, keine Bedienung -- anders
 * als der Chip darunter tragen sie keinen Rahmen, keinen Cursor, keinen Hover. Kein
 * Trennzeichen zwischen ihnen: ein Punkt stuende IN der ersten der beiden Marken und
 * wanderte beim Umbruch mit an den Zeilenanfang -- eine verwaiste Marke am Zeilenanfang.
 * Das Haus trennt hier wie .chips und .growth: allein ueber gap, ohne Satzzeichen. Die
 * Marken sind Fliesstext ohne Rahmen und brauchen mehr Luft als ein Chip mit Rand und
 * Fuellung -- deshalb ein groesserer Wert als die 6px von .chips.
 * Zwei Marken melden einen Schaden (Gebaeude- und Verteidigungsprozent) und tragen deshalb
 * den Warnton -- dieselbe Farbe, die die Seite schon fuer "die Verteidigung liegt zurueck"
 * und fuer den Ruinenhinweis verwendet. Die uebrigen sagen nur, was ansteht, nicht dass
 * etwas beschaedigt ist, und bleiben darum leise. */
.badges {
  grid-column: 1 / -1;
  margin: 9px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--muted);
}
.badge-damage { color: var(--warn); }

/* Der Vollzug (Issue #25). Bewusst im Ton der Not-Aus-Taste: dass ein Lauf Ressourcen
   ausgibt, ist die eine Eigenschaft, die man nicht uebersehen darf. */
.mandate { margin-bottom: 22px; }
.mandate summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}
.mandate summary:hover { color: var(--text); }
.mandate-badge {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--warn);
  border-left: 2px solid var(--warn);
  padding-left: 8px;
}
.mandate-warning { color: var(--warn); }

/* Eine vollzogene Aktion ist eine gute Nachricht, kein Schaden -- deshalb der Gold-Ton der
   erledigten Dinge und nicht der Warnton des Vollzugsschalters. */
.badge-done { color: var(--gold); }

/* --- Berichte (Issue #37) ---------------------------------------------------
 *
 * Der Bericht ist ein Dokument und bleibt eines: dieselben leisen Tabellen wie die
 * Ranglisten, der Fliesstext in einer lesbaren Breite. Tabellen und Raster scrollen fuer
 * sich -- ein Raster, das umbricht, zeigt die Ressourcen an der falschen Stelle. */

.reports { margin-top: 26px; }
.reports summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}
.reports summary:hover { color: var(--text); }
.report-pick { margin: 4px 0 16px; }
/* Die Berichtsnamen sind lang; auf einem Telefon wird die Auswahl schmaler statt der Seite
   breiter. */
.report-pick .field { max-width: 100%; min-width: 0; }
.report-pick select { min-width: 0; max-width: 100%; }
.field select:disabled { opacity: 0.45; }

.report { font-size: 14px; color: var(--muted); }
.report p, .report ul, .report ol { margin: 0 0 10px; max-width: 72ch; }
.report ul, .report ol { padding-left: 1.4em; }
.report strong { color: var(--text); font-weight: 600; }
.report code { font: 400 12.5px/1 var(--mono); color: var(--text); }
.report hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* Die Seite fuehrt h1 und h2 schon; die Klasse traegt die Stufe im Bericht. */
.report .md-h1, .report .md-h2, .report .md-h3 { color: var(--text); font-weight: 600; }
.report .md-h1 { font-size: 17px; margin: 6px 0 12px; }
.report .md-h2 {
  font-size: 15px;
  margin: 30px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.report .md-h3 { font: 600 13.5px/1.5 var(--mono); margin: 22px 0 6px; }

/* Ein Zitat im Bericht ist der Abbruchvermerk oder ein Nachtrag -- beides muss man sehen. */
.report blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--warn);
}
.report blockquote p:last-child { margin-bottom: 0; }

.report .table-scroll { margin: 0 0 14px; }
.md-table {
  border-collapse: collapse;
  font: 400 13px/1.6 var(--mono);
  white-space: nowrap;
}
.md-table th {
  text-align: left;
  font: 400 11px/1.6 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 4px 16px 4px 0;
}
.md-table td { padding: 3px 16px 3px 0; }
.md-table td:first-child { color: var(--text); }
.md-table .num { text-align: right; }
.md-table .mid { text-align: center; }
.md-table tr:hover td { background: var(--raised); }

.md-code {
  font: 400 13px/1.45 var(--mono);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 14px;
  margin: 0 0 14px;
  overflow-x: auto;
  white-space: pre;
  color: var(--muted);
}
/* Nur die Ressourcenfelder tragen Farbe; der Untergrund bleibt Punkt und leise. */
.cell-tiberium { color: var(--tiberium); font-weight: 700; }
.cell-crystal { color: var(--crystal); font-weight: 700; }
