/* Terraforming Mars Live-Dashboard — Mars-Thema (Oberflächen/Akzent/Typografie),
   Spieler-Kategorialfarben bleiben die CVD-geprüfte dataviz-Referenzpalette (unverändert).
   Alle Text-/UI-Kontraste sind rechnerisch gegen WCAG AA geprüft (siehe docs/). */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

.viz-root {
  color-scheme: light;
  /* Neutrale, helle Fläche — Wärme kommt allein vom Akzent, nicht vom Text/Hintergrund
     (bewusst kein Braun-auf-Braun, das war zu schwach lesbar). */
  --page-plane:      #f5f1ea;
  --surface-1:        #fffdfa;
  --text-primary:     #17130f;
  --text-secondary:   #4a423a;
  --text-muted:       #5f574d;   /* 6.99:1 auf --surface-1, AA auch bei kleiner Schrift */
  --gridline:         #e5e0d6;
  --baseline:         #cabca9;
  --border:           rgba(23,19,15,0.14);
  --success-text:     #006300;

  --status-good:      #0ca30c;
  --status-warning:   #fab219;
  --status-serious:   #ec835a;
  --status-critical:  #d03b3b;

  /* Eigens für Fließtext auf --page-plane/--surface-1 kalibriert (>=4.5:1 AA),
     statt der fixen Status-Badge-Farben, die dafür nicht garantiert reichen */
  --ink-up:           #0a6b0a;  /* 5.98:1 auf --page-plane */
  --ink-down:          #a8322e;  /* 5.90:1 auf --page-plane */
  --ink-sample:        #8a5a00;  /* 5.26:1 auf --page-plane */

  /* Mars-Akzent (Chrome: Meter, Buttons, Header-Linie) — getrennt von den
     Spieler-Kategorialfarben, damit deren CVD-Prüfung unberührt bleibt */
  --accent:            #b9461f;
  --accent-strong:     #a8390f;  /* 6.45:1 mit weißem Text, 5.73:1 auf --page-plane */
  --link:              #a8390f;  /* 6.35:1 auf --surface-1 */

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */

  min-height: 100vh;
  padding-bottom: 3rem;
  background-image: radial-gradient(ellipse 900px 420px at 50% -120px, color-mix(in srgb, var(--accent) 10%, transparent), transparent);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    /* Neutrale, dunkle Fläche statt gesättigtem Schwarzbraun — gleiche Logik wie hell. */
    --page-plane:      #131110;
    --surface-1:        #1d1a17;
    --text-primary:     #f7f3ee;
    --text-secondary:   #cec7bc;
    --text-muted:       #a89f92;  /* 6.63:1 auf --surface-1 */
    --gridline:         #322c26;
    --baseline:         #4a4038;
    --border:           rgba(247,243,238,0.12);
    --success-text:     #0ca30c;

    --ink-up:           #3fcf5a;  /* 9.22:1 auf --page-plane */
    --ink-down:          #f0716f;  /* 6.54:1 auf --page-plane */
    --ink-sample:        #ffce6b;  /* 12.81:1 auf --page-plane */

    --accent:            #e2712f;
    --accent-strong:     #c14a15; /* 4.93:1 mit weißem Text, 3.82:1 auf --page-plane (groß/fett) */
    --link:              #e2712f; /* 5.47:1 auf --surface-1 - accent-strong waere hier zu dunkel */

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page-plane:      #131110;
  --surface-1:        #1d1a17;
  --text-primary:     #f7f3ee;
  --text-secondary:   #cec7bc;
  --text-muted:       #a89f92;
  --gridline:         #322c26;
  --baseline:         #4a4038;
  --border:           rgba(247,243,238,0.12);
  --success-text:     #0ca30c;

  --ink-up:           #3fcf5a;
  --ink-down:          #f0716f;
  --ink-sample:        #ffce6b;

  --accent:            #e2712f;
  --accent-strong:     #c14a15;
  --link:              #e2712f;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header */

.app-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0.9rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--accent);
}

.app-header__title h1 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0;
  display: inline;
  color: var(--accent-strong);
}

.app-header__subtitle {
  color: var(--text-secondary);
  margin-left: 0.6rem;
  font-size: 0.95rem;
}

.app-header__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent-strong); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.status-pill {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.status-pill[data-state="live"] { color: var(--ink-up); border-color: var(--ink-up); }
.status-pill[data-state="sample"] { color: var(--ink-sample); border-color: var(--ink-sample); }
.status-pill[data-state="disconnected"] { color: var(--ink-down); border-color: var(--ink-down); }

.sample-banner {
  max-width: 1080px;
  margin: 0 auto 1rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--status-warning) 18%, var(--surface-1));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  text-align: center;
}

/* Stat tiles */

.meta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 8rem;
}

.stat-tile__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-tile__value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-tile--hero .stat-tile__value { font-size: 2.25rem; color: var(--accent-strong); }
.stat-tile__value--small { font-size: 1.1rem; }

.stat-tile__delta {
  font-size: 0.75rem;
  font-weight: 600;
}
.stat-tile__delta--up { color: var(--ink-up); }
.stat-tile__delta--down { color: var(--ink-down); }
.stat-tile__delta--flat { color: var(--text-muted); }

/* Global parameters (meters) */

.global-params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.meter-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.meter-tile__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.meter-tile__value {
  font-size: 1.375rem;
  font-weight: 600;
  margin: 0.15rem 0 0.5rem;
}

.meter-track {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, var(--surface-1));
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* Players */

.players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: 1rem;
}

.player-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  border-top: 4px solid var(--player-color, var(--series-1));
}

.player-card__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.player-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--player-color, var(--series-1));
  flex: none;
}

.player-card__name {
  font-weight: 600;
  font-size: 1rem;
}

.player-card__corp {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.player-card__tr {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.player-card__tr .stat-tile__value { font-size: 1.5rem; }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.resource-cell {
  background: var(--page-plane);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}

.resource-cell__label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
}

.resource-cell__value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Milestones / Awards */

.board-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.panel__title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gridline);
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.track-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--gridline);
}
.track-list li:last-child { border-bottom: none; }

.track-owner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.track-owner--open {
  color: var(--text-muted);
  font-weight: 400;
}

/* Setup / Download panel */

.setup-panel__text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0 0 0.85rem;
}

.setup-panel__text strong { color: var(--text-primary); }

.setup-panel__note {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  margin: 0.85rem 0 0;
}

.setup-panel__note a {
  color: var(--link);
  font-weight: 600;
}

.setup-panel__text code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: var(--text-primary);
}

.download-button {
  display: inline-block;
  background: var(--accent-strong);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
}
.download-button:hover { filter: brightness(1.08); }
.download-button:active { filter: brightness(0.96); }

/* Footer */

.app-footer {
  max-width: 1080px;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

@media (max-width: 480px) {
  .resource-grid { grid-template-columns: repeat(2, 1fr); }
}
