/* live.scorix.app: Designtoken und Grundstil.
   Die Werte stammen aus dem SMC (static/css/smc.css im Media-Center), damit
   beide Seiten als ein Produkt erkennbar sind. Dunkel ist der einzige Modus. */

@font-face {
  font-family: "General Sans";
  src: url("/static/fonts/GeneralSans-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* Marke */
  --blue-950: #06182d;
  --blue-900: #08294d;
  --blue-700: #153b6e;
  --cyan: #33d4ff;
  --cyan-deep: #12b4e6;
  --teal: #71d2d6;
  --teal-ink: #021229;

  /* Flächen und Schrift */
  --bg: var(--blue-950);
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.68);
  --dim: rgba(255, 255, 255, 0.48);
  --danger: #ff6b6b;
  --ok: #4ade80;
  --live-tint: rgba(51, 212, 255, 0.12);

  /* Scoreboard wie im SMC-Overlay (templates/overlay.html im Media-Center).
     Wer hier einen Wert ändert, gleicht ihn dort ab. */
  --sb-table-bg: #ffa500;
  --sb-table-ink: #0d4775;
  --sb-name-top: #1a5f97;
  --sb-name-bottom: #15507f;
  --sb-sets: rgba(18, 50, 74, 0.92);
  --sb-points: rgba(14, 40, 61, 0.98);
  --sb-divider: rgba(255, 255, 255, 0.1);
  --sb-serve: #ffffff;
  --sb-card-timeout: #ffffff;
  --sb-card-yellow: #ffc107;
  --sb-card-red: #f32424;
  --sb-card-ink: #000000;

  --radius-card: 20px;
  --radius-pill: 50px;
  --radius-sm: 10px;
  --radius-sb: 6px;

  --font-sans: "General Sans", ui-sans-serif, system-ui, -apple-system,
    "Helvetica Neue", Arial, sans-serif;

  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* Die Wurzel trägt das Blau mit, sonst blitzt beim Überscrollen Weiß auf. */
html {
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(6, 24, 45, 0.94), rgba(8, 41, 77, 0.88)),
    url("/static/brand/scorix-numbers-bg-blue.webp") center / cover fixed,
    var(--blue-950);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--cyan);
}

a:hover {
  color: var(--teal);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p {
  margin: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

.nums {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Spaltenbreite des SMC: 48 px Rand bei 1440 px, 16 px auf dem Smartphone. */
.shell {
  width: min(1460px, calc(100% - clamp(40px, 7vw, 96px)));
  margin-inline: auto;
}

/* ---------------- Kopfzeile ---------------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 88px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: block;
  width: auto;
  height: 26px;
}

/* „Live“ steht so im Quelltext, damit ein Vorleseprogramm es ausspricht statt zu
   buchstabieren. */
.live-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--dim);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background-color 0.3s, color 0.3s;
}

body.has-live .live-badge {
  background: var(--live-tint);
  color: var(--cyan);
}

.live-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

body.has-live:not(.is-offline) .live-badge .live-dot,
body:not(.is-offline) .meeting-card.is-live .live-dot {
  animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(51, 212, 255, 0.55);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(51, 212, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(51, 212, 255, 0);
  }
}

.clock {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.clock:empty {
  display: none;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.search label {
  color: var(--muted);
  font-size: 13px;
}

.search-input {
  width: 280px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: var(--dim);
}

.search-input:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.search-input:focus-visible {
  border-color: var(--cyan);
  outline-offset: 2px;
  border-radius: var(--radius-pill);
}

/* ---------------- Seitenkopf und Filter ---------------- */

.overview {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 28px;
  padding-block: 28px 56px;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 24px;
}

.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  min-width: 0;
}

.page-heading h1 {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
}

.page-summary {
  color: var(--muted);
  font-size: 15px;
}

.filter {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
}

/* Beide Zustände tragen dieselbe Stärke, sonst verschiebt ein Klick die Nachbarn. */
.filter button {
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.filter button:hover {
  background: var(--surface-2);
}

.filter button[aria-pressed="true"] {
  background: var(--teal);
  color: var(--teal-ink);
}

.filter button:focus-visible {
  outline-offset: 2px;
  border-radius: var(--radius-pill);
}

.connection {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 107, 107, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 107, 0.1);
  font-size: 14px;
  font-weight: 550;
}

.connection::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

/* Veraltete Stände treten zurück, solange keine Verbindung besteht. */
body.is-offline .meeting-grid {
  opacity: 0.6;
}

.empty-state {
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  color: var(--muted);
  font-size: 17px;
  text-align: center;
  text-wrap: pretty;
}

/* ---------------- Raster und Abschnitte ---------------- */

.meeting-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  transition: opacity 0.3s;
}

@media (min-width: 820px) {
  .meeting-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .meeting-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.recent-sections {
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.recent-sections:empty {
  display: none;
}

#live-section:not([hidden]) + .recent-sections {
  margin-top: 16px;
}

.recent-heading {
  margin-bottom: 18px;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
}

/* ---------------- Begegnung ---------------- */

.meeting-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.meeting-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.meeting-group {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sandbox-badge {
  display: none;
  flex: none;
  padding: 2px 9px;
  border: 1px solid var(--teal);
  border-radius: var(--radius-pill);
  color: var(--teal);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meeting-card.is-sandbox .sandbox-badge {
  display: inline-block;
}

.meeting-status {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
}

.meeting-status .live-dot {
  display: none;
  width: 7px;
  height: 7px;
}

.meeting-card.is-live .meeting-status {
  color: var(--cyan);
}

.meeting-card.is-live .meeting-status .live-dot {
  display: block;
}

.meeting-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.team {
  overflow-wrap: break-word;
  hyphens: auto;
}

.team-guest {
  text-align: right;
}

.meeting-result {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(6, 24, 45, 0.7);
  font-size: 36px;
  line-height: 1;
}

.result-sep {
  padding: 0 6px;
  color: rgba(255, 255, 255, 0.45);
}

.match-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.match-list:empty {
  display: none;
}

.meeting-last {
  padding-top: 12px;
  border-top: 1px solid var(--sb-divider);
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  line-height: 1.45;
}

.meeting-last:empty {
  display: none;
}

/* ---------------- Spiel am Tisch ----------------
   Die Fläche ragt 8 px über den Inhalt, damit Hover und Fokus Luft haben. */

.match {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: -8px;
  padding: 8px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.15s;
}

.match:hover {
  background: var(--surface-2);
  color: var(--text);
}

.match:focus-visible {
  outline-offset: 0;
  border-radius: 12px;
}

.match-board {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.match-table {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  border-radius: var(--radius-sb);
  background: var(--sb-table-bg);
  color: var(--sb-table-ink);
  font-weight: 700;
}

.match-table-label {
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.match-table-no {
  font-size: 22px;
  line-height: 1.1;
}

.match.no-table .match-table {
  display: none;
}

.match-rows {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.match-row {
  display: flex;
  height: 34px;
  overflow: hidden;
  border-radius: var(--radius-sb);
}

.row-name {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0 10px;
  background: linear-gradient(var(--sb-name-top), var(--sb-name-bottom));
}

.row-name-text {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ind {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 18px;
  border-radius: 3px;
}

.ind-timeout {
  background: var(--sb-card-timeout);
  color: var(--sb-card-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.ind-yellow {
  background: var(--sb-card-yellow);
}

.ind-red {
  background: var(--sb-card-red);
}

.match-row.has-timeout .ind-timeout,
.match-row.has-yellow .ind-yellow,
.match-row.has-red .ind-red {
  display: flex;
}

/* Der Punkt behält seinen Platz, damit beim Aufschlagwechsel nichts springt. */
.ind-serve {
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--sb-serve);
  opacity: 0;
}

.match-row.is-serving .ind-serve {
  opacity: 1;
}

.row-sets,
.row-points {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.row-sets {
  width: 30px;
  background: var(--sb-sets);
  font-size: 18px;
}

.row-points {
  width: 42px;
  background: var(--sb-points);
  font-size: 20px;
}

.match-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.match-name {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.match-sets-text:empty,
.match-alert:empty {
  display: none;
}

.match-kind + .match-phase::before {
  content: "·";
  margin-inline: 0.35em;
}

.match-alert {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--cyan);
  color: var(--teal-ink);
  font-weight: 700;
  white-space: nowrap;
}

.match-sets-text {
  margin-left: auto;
  white-space: nowrap;
}

/* Unterbrochen: die Tafel tritt zurück, die Fußzeile bleibt lesbar. */
.match.is-paused .match-board {
  opacity: 0.55;
}

.match.is-finished .row-points,
.match.is-finished .ind-serve {
  display: none;
}

.match-row.is-winner .row-sets {
  background: var(--teal);
  color: var(--teal-ink);
}

.match.is-finished:has(.is-winner) .match-row:not(.is-winner) .row-name-text,
.match.is-finished:has(.is-winner) .match-row:not(.is-winner) .row-sets {
  color: rgba(255, 255, 255, 0.75);
}

/* ---------------- Bewegung ---------------- */

@media (prefers-reduced-motion: reduce) {
  body.has-live:not(.is-offline) .live-badge .live-dot,
  body:not(.is-offline) .meeting-card.is-live .live-dot {
    animation: none;
  }

  .live-badge,
  .filter button,
  .match,
  .meeting-grid {
    transition: none;
  }
}

/* ---------------- Smartphone ----------------
   Nichts scrollt waagrecht, jedes Bedienelement ist mindestens 44 px hoch. */

@media (max-width: 767px) {
  .shell {
    width: calc(100% - 32px);
  }

  .site-header {
    flex-wrap: wrap;
    gap: 10px 14px;
    min-height: 0;
    padding-block: 14px;
  }

  .brand-logo {
    height: 22px;
  }

  .clock {
    order: 1;
    flex-basis: 100%;
    font-size: 13px;
    white-space: normal;
  }

  .search {
    order: 2;
    flex-basis: 100%;
    margin-left: 0;
  }

  .search-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: 44px;
    font-size: 16px;
  }

  .overview {
    gap: 22px;
    padding-block: 22px 40px;
  }

  .page-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-heading h1 {
    font-size: 28px;
  }

  .page-summary {
    font-size: 14px;
  }

  .filter button {
    flex: 1 1 0;
    height: 44px;
    padding: 0 10px;
  }

  .meeting-grid {
    gap: 16px;
  }

  .meeting-card {
    gap: 16px;
    padding: 16px;
  }

  .meeting-teams {
    gap: 10px;
    font-size: 16px;
  }

  .meeting-result {
    padding: 7px 11px;
    font-size: 30px;
  }

  .recent-heading {
    font-size: 18px;
  }
}
