/* 0fps-control-panel — Basis-Styles. Später durch Tailwind v4 + Basecoat-Theme ersetzt/ergänzt;
   die Custom Properties hier sind bereits als Theme-Variablen gedacht. */

:root {
  --bg: oklch(0.16 0.005 260);
  --bg-elev: oklch(0.20 0.006 260);
  --card: oklch(0.21 0.006 260 / 0.75);
  --border: oklch(0.35 0.008 260 / 0.5);
  --text: oklch(0.93 0.004 260);
  --text-dim: oklch(0.68 0.006 260);
  --text-faint: oklch(0.52 0.006 260);
  --accent: oklch(0.65 0.16 250);
  --accent-dim: oklch(0.65 0.16 250 / 0.15);
  --ok: oklch(0.72 0.17 150);
  --warn: oklch(0.78 0.15 85);
  --err: oklch(0.63 0.21 25);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Layout ---- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0;
  width: 220px; height: 100vh; flex-shrink: 0;
  padding: 20px 12px;
  background: oklch(0.18 0.005 260 / 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}

.sidebar .brand {
  font-size: 15px; font-weight: 700; letter-spacing: -0.02em;
  padding: 0 10px 16px;
}
.sidebar .brand .dot { color: var(--accent); }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-dim); text-decoration: none;
  font-weight: 500; cursor: pointer;
}
.nav-link:hover { background: oklch(0.26 0.006 260 / 0.6); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }
.nav-link .icon { width: 18px; text-align: center; }

main#content {
  flex: 1; padding: 28px 32px; max-width: 1200px;
}

/* ---- Typografie ---- */

h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
.subtitle { color: var(--text-dim); margin: 0 0 24px; }

.num, .metric-value, td.num, .price {
  font-variant-numeric: tabular-nums; /* Pflicht laut CLAUDE.md — kein Layout-Zappeln beim Poll */
}

/* ---- Karten & Grids ---- */

.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; } /* Zellen dürfen unter Content-Breite schrumpfen */
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1000px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1200px) { .grid.cols-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .grid.cols-5 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card.pad-0 { padding: 0; }
.card-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.card-header .hint { text-align: right; }
.card-note { margin-top: 10px; font-size: 11px; color: var(--text-faint); line-height: 1.45; }
.card-header h2 { margin: 0; }
.card-header .hint { color: var(--text-faint); font-size: 12px; }

.metric-label { color: var(--text-dim); font-size: 12px; font-weight: 500; }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.metric-sub { color: var(--text-faint); font-size: 12px; }

/* ---- Status-Punkte (nicht Text-Badges) ---- */

.dot-status {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  vertical-align: middle; margin-right: 8px;
}
.dot-status.ok { background: var(--ok); box-shadow: 0 0 6px oklch(0.72 0.17 150 / 0.5); }
.dot-status.warn { background: var(--warn); }
.dot-status.err { background: var(--err); }
.dot-status.off { background: var(--text-faint); }

/* ---- Tabellen ---- */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-faint);
  padding: 10px 18px; border-bottom: 0.5px solid var(--border);
}
td { padding: 10px 18px; border-bottom: 0.5px solid var(--border); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }

.pos { color: var(--ok); }
.neg { color: var(--err); }

/* ---- Sonstiges ---- */

.tag {
  display: inline-block; font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 999px;
  background: oklch(0.28 0.006 260 / 0.7); color: var(--text-dim);
}

.bar {
  height: 6px; border-radius: 3px; background: oklch(0.30 0.006 260 / 0.6);
  overflow: hidden;
}
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.seg {
  display: inline-flex; flex-wrap: wrap; border: 0.5px solid var(--border); border-radius: 8px; overflow: hidden;
}
.seg button {
  background: none; border: none; color: var(--text-dim);
  font: inherit; font-size: 12px; padding: 4px 12px; cursor: pointer;
}
.seg button.active { background: var(--accent-dim); color: var(--accent); }

.chart { width: 100%; max-width: 100%; }
.uplot { font-family: var(--font) !important; }
.u-legend { color: var(--text-dim) !important; font-size: 11px !important; }
/* Legende umbrechen lassen — als einzeilige Tabelle erzwingt sie sonst
   eine Mindestbreite und die Seite scrollt auf dem iPhone horizontal */
.chart .u-legend { display: block; max-width: 100%; }
.chart .u-legend tr { display: inline-block; margin: 0 6px 2px 0; }

/* ---- Mobile (iPhone/iPad Hochformat): Sidebar wird zur Top-Nav ---- */

@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: 10;
    width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 0.5px solid var(--border);
  }
  .sidebar .brand { padding: 0 10px 0 0; flex-shrink: 0; }
  .nav-link { flex-shrink: 0; padding: 10px 12px; } /* >= 44px Touch-Target */
  main#content { padding: 16px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .metric-value { font-size: 22px; }
}

@media (max-width: 480px) {
  .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 12px 14px; }
  main#content { padding: 12px; }
}

/* Game-Updates */
.game-card {
  cursor: pointer; user-select: none;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0; /* Grid-Item darf schrumpfen, sonst sprengen lange Titel die Spalte */
}
.game-card:hover { border-color: oklch(0.45 0.01 260 / 0.6); }
.game-card.active { border-color: var(--accent); background: var(--accent-dim); }
.game-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.game-card-title { min-width: 0; }
.game-card-title .name {
  font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.game-card-meta {
  margin-top: auto; /* pinnt die Zeile unten — alle Karten wirken gleich hoch */
  display: flex; justify-content: space-between; gap: 8px; min-width: 0;
}
.game-card-meta .when { flex-shrink: 0; }
.truncate {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.game-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; font-size: 19px;
  flex-shrink: 0;
}
.update-card h2 { font-size: 14px; }
.game-name { font-weight: 700; }

/* Tagesverlauf-Karte: Höhe fixieren, damit der Erstaufbau nicht springt.
   Der Tageswechsel selbst swappt nicht mehr — app.js updatet das Chart in place. */
#day-chart .chart { min-height: 248px; } /* 220px Chart + Legende */

/* Label/Wert-Liste: Werte in eigener Spalte, rechtsbündig — mit tabular-nums
   stehen die Kommas exakt untereinander */
.kv-list {
  display: grid;
  grid-template-columns: max-content max-content;
  column-gap: 12px;
  justify-content: start;
}
.kv-list span:nth-child(even) { text-align: right; }

/* Sonnencreme-Hinweis */
.sunscreen {
  margin-top: 8px; font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 8px; display: inline-block;
}
.sunscreen.warn { background: oklch(0.78 0.15 85 / 0.12); color: var(--warn); }
.sunscreen.ok { background: oklch(0.72 0.17 150 / 0.10); color: var(--ok); }

/* DWD-Warnbanner — vier Stufen: gelb / orange / rot / rot pulsierend */
.alert-banner { margin-bottom: 14px; display: block; }
.alert-banner.alert-minor { border-color: oklch(0.78 0.15 85 / 0.6); background: oklch(0.78 0.15 85 / 0.08); }
.alert-banner.alert-moderate { border-color: oklch(0.72 0.15 55 / 0.65); background: oklch(0.72 0.15 55 / 0.09); }
.alert-banner.alert-severe { border-color: oklch(0.63 0.21 25 / 0.7); background: oklch(0.63 0.21 25 / 0.10); }
.alert-banner.alert-extreme {
  border-color: oklch(0.63 0.21 25 / 0.9); background: oklch(0.63 0.21 25 / 0.14);
  animation: alert-pulse 1.6s ease-in-out infinite;
}
@keyframes alert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.63 0.21 25 / 0.35); }
  50% { box-shadow: 0 0 0 5px oklch(0.63 0.21 25 / 0); }
}
/* Vorabinformation: gilt erst später — optisch gedämpft, keine Puls-Animation */
.alert-banner.alert-upcoming { opacity: 0.75; animation: none; }
.day-alert { font-size: 11px; margin-left: 2px; }
.alert-link { text-decoration: none; color: var(--text); position: relative; }
.alert-link:hover { filter: brightness(1.15); }
.alert-link .alert-arrow { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }

/* Warn-Punkt am Wetter-Menüpunkt */
.nav-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.nav-dot.on.alert-minor { background: oklch(0.78 0.15 85); }
.nav-dot.on.alert-moderate { background: oklch(0.72 0.15 55); }
.nav-dot.on.alert-severe, .nav-dot.on.alert-extreme {
  background: oklch(0.63 0.21 25);
  box-shadow: 0 0 6px oklch(0.63 0.21 25 / 0.6);
}
.nav-dot.on.alert-extreme { animation: alert-pulse 1.6s ease-in-out infinite; }

/* Wetter-Forecast-Reihe — scrollt auf schmalen Screens horizontal in der Karte,
   statt die Seite zu sprengen */
.forecast {
  display: grid; grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 6px; text-align: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.forecast .day { padding: 10px 4px; border-radius: 10px; cursor: pointer; user-select: none; }
.forecast .day:hover { background: oklch(0.26 0.006 260 / 0.5); }
.forecast .day.sel { background: var(--accent-dim); box-shadow: inset 0 0 0 0.5px var(--accent); }
.forecast .icon { font-size: 22px; margin: 6px 0; }

/* Seiten ohne Anmeldung (join.0fps.de, 401) */
.public {
  max-width: 34rem;
  margin: 3rem auto;
  padding: 0 16px;
}

/* Eingebetteter Screenshare-Viewer (view.0fps.de) */
.viewer-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 180px);
  min-height: 320px;
  border: 0;
  border-radius: 14px;
  background: #000;
}

/* Formulare (Einladungen, Verwaltung) */
.form-card { margin-bottom: 16px; }
.form-card h2 { margin: 0 0 8px; font-size: 15px; }
.form-card label { display: block; margin-top: 12px; color: var(--text-dim); font-size: 12px; }
.form-card input, .form-card select {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  font: inherit;
}
.form-card button, .public form > button {
  min-height: 44px;
  margin-top: 16px;
  padding: 0 18px;
  background: var(--accent);
  color: var(--bg);
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.form-card ol { padding-left: 20px; }
.form-error { color: var(--err); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Einladungs-Verwaltung */
.table-scroll { overflow-x: auto; }
table.invites { width: 100%; border-collapse: collapse; font-size: 13px; }
table.invites th, table.invites td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 0.5px solid var(--border);
}
table.invites th { color: var(--text-faint); font-weight: 500; }
.link-button {
  min-height: 44px;
  padding: 0;
  background: none;
  color: var(--accent);
  border: 0;
  font: inherit;
  cursor: pointer;
}
