/* ==========================================================================
   TV Lebach – gemeinsames Design-Fundament (Dashboard + Spielerverwaltung)
   Orientiert an Apples Human Interface Guidelines:
   - Systemschrift, skaliert mit der Textgröße des Geräts (Dynamic Type)
   - semantische Farben für Hell/Dunkel, keine eigene Umschaltung
   - Glas-Material nur für Navigationsleisten, Inhalte bleiben opak
   - Tippflächen mindestens 44 × 44 px
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Flächen */
  --bg: #f2f2f7;               /* systemGroupedBackground */
  --card: #ffffff;             /* secondarySystemGroupedBackground */
  --card-raised: #ffffff;
  --inset: #f2f2f7;            /* tertiarySystemGroupedBackground */
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);

  /* Text (Kontrast auf --card: 21:1 / 5,1:1 / dekorativ) */
  --label: #000000;
  --label-2: #6c6c70;
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.22);

  /* Vereinsfarbe TV Lebach – nur für Auswahl, Hauptaktion und Live-Status
     #c32c21 auf Weiß 5,7:1 */
  --tint: #c32c21;
  --tint-soft: rgba(195, 44, 33, 0.1);
  --on-tint: #ffffff;

  /* Status */
  --win: #1f7a35;              /* 5,4:1 auf Weiß */
  --win-soft: rgba(52, 199, 89, 0.16);
  --loss: #6c6c70;
  --loss-soft: rgba(120, 120, 128, 0.16);
  --up: #1f7a35;
  --down: #b25000;             /* systemOrange, dunkel – 4,9:1 */

  /* Glas für Leisten */
  --glass: rgba(249, 249, 249, 0.82);
  --glass-line: rgba(0, 0, 0, 0.12);

  /* Form */
  --radius: 12px;
  --radius-lg: 18px;
  --pad: 16px;
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.16);

  /* Schrift */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-score: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-raised: #2c2c2e;
    --inset: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --label: #ffffff;
    --label-2: #aeaeb2;          /* 7,6:1 auf #1c1c1e */
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.65);
    --tint: #ff6b5e;             /* 6,1:1 auf #1c1c1e */
    --tint-soft: rgba(255, 107, 94, 0.16);
    --on-tint: #1c0402;
    --win: #30d158;
    --win-soft: rgba(48, 209, 88, 0.2);
    --loss: #aeaeb2;
    --loss-soft: rgba(118, 118, 128, 0.3);
    --up: #30d158;
    --down: #ff9f0a;
    --glass: rgba(28, 28, 30, 0.8);
    --glass-line: rgba(255, 255, 255, 0.1);
    --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.6);
  }
}

@media (prefers-contrast: more) {
  :root { --label-2: #3a3a3c; --sep: rgba(60, 60, 67, 0.5); --glass: var(--card); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --label-2: #d1d1d6; --sep: rgba(235, 235, 245, 0.45); }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--card); }
}

/* Textgröße: 17 px Standard, folgt auf Apple-Geräten der Systemeinstellung */
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--tint); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }

/* Schriftstufen (Apple-Typografie, in rem → skaliert mit) */
.t-large  { font-family: var(--font-display); font-size: 2rem;    line-height: 1.2;  font-weight: 700; letter-spacing: 0.01em; }
.t-title2 { font-family: var(--font-display); font-size: 1.3rem;  line-height: 1.25; font-weight: 700; }
.t-title3 { font-family: var(--font-display); font-size: 1.18rem; line-height: 1.25; font-weight: 600; }
.t-head   { font-size: 1rem;    font-weight: 600; }
.t-body   { font-size: 1rem; }
.t-sub    { font-size: 0.88rem; }
.t-foot   { font-size: 0.765rem; }
.t-cap    { font-size: 0.7rem; }
.muted    { color: var(--label-2); }
.num      { font-variant-numeric: tabular-nums; }
.score    { font-family: var(--font-score); font-variant-numeric: tabular-nums; }

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

/* Fokus für Tastatur */
:focus { outline: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 70%, transparent); outline-offset: 2px; border-radius: 8px; }

/* Symbole */
.ico { width: 1.25em; height: 1.25em; flex: none; fill: currentColor; }
.ico-stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Glas-Leiste oben (Navigationsleiste) ─────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 52px; padding: 4px 8px; padding-top: max(4px, env(safe-area-inset-top));
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(1.5); backdrop-filter: blur(30px) saturate(1.5);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s;
}
.navbar.scrolled { border-bottom-color: var(--glass-line); }
.navbar .nav-title { font-weight: 600; opacity: 0; transition: opacity 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; text-align: center; }
.navbar.scrolled .nav-title { opacity: 1; }
.navbar .nav-lead { justify-self: start; display: flex; gap: 4px; }
.navbar .nav-trail { justify-self: end; display: flex; gap: 4px; align-items: center; }

/* Schlichte Leisten-Knöpfe (monochrom, Tint nur für Hauptaktion) */
.bar-btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; min-width: 44px; padding: 0 10px;
  border: 0; border-radius: 22px; background: transparent; color: var(--tint);
  cursor: pointer; font-size: 1rem; text-decoration: none;
}
.bar-btn:hover { background: var(--fill); text-decoration: none; }
.bar-btn.icon-only { padding: 0; justify-content: center; }
.bar-btn.prominent { background: var(--tint); color: var(--on-tint); font-weight: 600; padding: 0 16px; }
.bar-btn.prominent:hover { filter: brightness(1.06); }

/* ── Gruppierte Listen (inset grouped) ───────────────────────────────── */
.section { margin: 0 0 28px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 4px 8px; padding: 0 var(--pad);
}
.section-head h2 { margin: 0; }
.section-foot { margin: 8px 4px 0; padding: 0 var(--pad); color: var(--label-2); font-size: 0.765rem; }

.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.group > .row + .row, .group > li + li > .row { border-top: 0.5px solid var(--sep); margin-left: var(--pad); padding-left: 0; width: calc(100% - var(--pad)); }
ul.group { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 11px var(--pad);
  color: inherit; text-decoration: none; background: transparent; border: 0; width: 100%; text-align: left;
}
a.row:hover, button.row:hover { background: var(--fill); text-decoration: none; }
a.row:active, button.row:active { background: var(--fill-strong); }
.row-main { flex: 1; min-width: 0; display: block; }
.row-title { display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.row-title.t-head { font-weight: 600; }
.row-sub { display: block; color: var(--label-2); font-size: 0.88rem; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.row-trail { color: var(--label-2); display: flex; align-items: center; gap: 8px; flex: none; }
.chev { width: 0.75rem; height: 0.75rem; color: var(--label-3); flex: none; }

/* ── Segmentierte Steuerung ──────────────────────────────────────────── */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 2px; border-radius: 10px; background: var(--fill); gap: 2px;
}
.segmented button {
  min-height: 36px; border: 0; border-radius: 8px; background: transparent;
  font-size: 0.88rem; font-weight: 500; cursor: pointer; padding: 0 8px; white-space: nowrap;
}
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] {
  background: var(--card-raised); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 0.5px rgba(0,0,0,.04);
}
@media (pointer: coarse) { .segmented button { min-height: 40px; } }

/* Aufklapp-Auswahl (pop-up button) */
.popup {
  appearance: none; -webkit-appearance: none;
  min-height: 44px; padding: 0 36px 0 14px; border-radius: 10px; border: 0;
  background-color: var(--fill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 16'%3E%3Cpath d='M2 6l4-4 4 4M2 10l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 10px 14px;
  font-size: 0.94rem; cursor: pointer; max-width: 100%;
}

/* Schalter */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.switch input { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: #34c759; }
.switch input:checked::after { transform: translateX(20px); }

/* Knöpfe im Inhalt */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--fill); color: var(--tint); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--fill-strong); text-decoration: none; }
.btn.primary { background: var(--tint); color: var(--on-tint); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.destructive { color: #d70015; }
@media (prefers-color-scheme: dark) { .btn.destructive { color: #ff6961; } }
.btn[disabled] { opacity: .5; cursor: default; }

/* Ergebnis-Marken (Sieg/Niederlage – Farbe + Buchstabe, nie Farbe allein) */
.res { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 2.6em; height: 1.6em; padding: 0 .45em; border-radius: .8em; font-family: var(--font-score); font-weight: 600; font-size: .82rem; font-variant-numeric: tabular-nums; }
.res.S { background: var(--win-soft); color: var(--win); }
.res.N { background: var(--loss-soft); color: var(--loss); }
.res.L { background: var(--tint); color: var(--on-tint); }
.dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; flex: none; }
.dot.S { background: var(--win); }
.dot.N { background: transparent; box-shadow: inset 0 0 0 1.5px var(--loss); }

.live-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--tint); display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
}

/* Leere Zustände, Laden */
.empty { padding: 28px var(--pad); text-align: center; color: var(--label-2); }
.skeleton { background: linear-gradient(90deg, var(--fill) 0%, var(--fill-strong) 50%, var(--fill) 100%); background-size: 200% 100%; border-radius: 8px; color: transparent; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s linear infinite; } @keyframes shimmer { to { background-position: -200% 0; } } }

/* Hinweis-Banner (Fehler, Offline) */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px var(--pad); border-radius: var(--radius); background: var(--card); font-size: .88rem; }
.notice .ico { color: var(--down); margin-top: 1px; }

/* Toast */
.toast-root { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--card-raised); color: var(--label); padding: 12px 18px; border-radius: 22px; box-shadow: var(--shadow-pop); font-size: .94rem; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
