/* ============================================================================
   BVV Beach-Volleyball Turnier-Tool – zentrales Stylesheet
   ============================================================================
   Diese Datei ist die EINZIGE Quelle für das Theme. Sie wird von index.html
   UND von turnier_template.html (also allen generierten Turnierseiten)
   geladen. Farben, Abstände und Schriftgrößen nur hier ändern.

   TOKEN-SYSTEM (alles in :root):

   Flächen      --bg            Seitenhintergrund
                --bg-panel      Karten, Tabellen-Container
                --bg-raised     Topbar, Tabellenkopf, Badges-Hintergrund
                --bg-hover      Hover-Zustand
                --bg-active     Aktiv/gedrückt

   Linien       --border        Standard-Rahmen (1px)
                --border-strong Betonte Trennlinien

   Text         --text-dim      Sekundär (Labels, Meta)
                --text          Fließtext
                --text-bright   Überschriften, wichtige Werte

   Semantik     --ok            grün   = zugelassen, aktiv, alles gut
   (feste       --warn          gelb   = Warteliste, Warnung, überbucht
   Bedeutung!)  --danger        rot    = Fehler
                --bvv           cyan   = BVV-Punkte / BVV-Kontingent
                --dvv           violett= DVV-Punkte / DVV-Kontingent
                --link          blau   = Links
                --wc            orange = Wildcard

   Kategorien   --kat-bm/-k1p/-k1/-k2/-k3 – nur für die Outline-Pills,
                bewusst getrennt von der Semantik oben.

   Typo         --fs-xs … --fs-xl  Schriftgrößen-Skala (11–18px)
   Spacing      --sp-1 … --sp-6    4 / 8 / 12 / 16 / 24 / 32 px
   ========================================================================= */

:root {
    /* Flächen */
    --bg:        #0a0e14;
    --bg-panel:  #0d1117;
    --bg-raised: #161b22;
    --bg-hover:  #1c2333;
    --bg-active: #222e3a;

    /* Linien */
    --border:        #30363d;
    --border-strong: #444c56;

    /* Text */
    --text-dim:    #8b949e;   /* heller als vorher (#6e7681) → besserer Kontrast */
    --text:        #c9d1d9;
    --text-bright: #e6edf3;

    /* Semantik – jede Farbe hat genau EINE Bedeutung */
    --ok:       #3fb950;
    --ok-dim:   #238636;
    --ok-bg:    #12261b;
    --warn:     #d29922;
    --warn-bg:  #1a1500;
    --danger:   #f85149;
    --bvv:      #39d2c0;
    --dvv:      #bc8cff;
    --dvv-bg:   #1a1033;
    --link:     #58a6ff;
    --wc:       #f0883e;

    /* Kategorie-Pills (Wiedererkennung, nicht Semantik) */
    --kat-bm:  #d29922;
    --kat-k1p: #f778ba;
    --kat-k1:  #f0883e;
    --kat-k2:  #58a6ff;
    --kat-k3:  #3fb950;

    /* Typografie */
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
    --fs-xs:   11px;
    --fs-sm:   12px;
    --fs-base: 13px;
    --fs-md:   14px;
    --fs-lg:   16px;
    --fs-xl:   18px;

    /* Spacing-Skala */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;

    --radius: 6px;
    --topbar-h: 37px;   /* für sticky-Berechnungen */
}

/* ── Basis ──────────────────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--fs-base);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Punktespalten & Zahlen: Ziffern gleich breit → saubere Spalten */
.num, .cell-points, .stat-value { font-variant-numeric: tabular-nums; }

/* Sichtbarer Tastatur-Fokus (Maus-Klicks bleiben ohne Ring) */
:focus-visible {
    outline: 2px solid var(--ok);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Nur für Screenreader sichtbar */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Topbar (bewusst unverändert zum Original) ──────────────────────────── */

.topbar {
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    padding: var(--sp-2) 20px;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
}

.topbar-title {
    color: var(--text-dim);
    font-size: var(--fs-sm);
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title span { color: var(--ok); }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ── Welcome-Block & ASCII-Header ───────────────────────────────────────── */

.welcome-block {
    margin-bottom: var(--sp-5);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
}

.ascii-header {
    color: var(--ok);
    font-size: var(--fs-xs);
    line-height: 1.2;
    margin-bottom: var(--sp-2);
    white-space: pre;
    overflow-x: auto;   /* mobil scrollen statt unleserlich schrumpfen */
}

.output { color: var(--text-dim); margin-top: var(--sp-1); }
.output a { text-decoration: none; }
.output a:hover { text-decoration: underline; }

/* Der EINZIGE blinkende Cursor lebt im ASCII-Header / Footer */
.cursor-blink { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.last-update { color: var(--text-dim); font-size: var(--fs-xs); margin-bottom: 20px; }
.last-update .dot { color: var(--ok); }
.last-update .time { color: var(--warn); }

/* ── Abschnitts-Label ───────────────────────────────────────────────────── */

.section-label {
    color: var(--bvv);
    font-size: var(--fs-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.section-label .count { color: var(--text-dim); letter-spacing: 0; text-transform: none; font-weight: 400; }

/* ── Toolbar: Suche, Filter, Sortierung ─────────────────────────────────── */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.search-wrap { flex: 1; min-width: 220px; position: relative; }

.search-input {
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: var(--fs-base);
    padding: 7px 36px 7px 12px;
}

.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { border-color: var(--ok-dim); outline: none; }

/* "/"-Hinweis rechts im Suchfeld */
.search-key {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 6px;
    font-size: var(--fs-xs);
    color: var(--text-dim);
    pointer-events: none;
}

.toolbar select {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    padding: 7px 10px;
    cursor: pointer;
}

.toolbar select:hover { border-color: var(--border-strong); }
.toolbar select:focus { border-color: var(--ok-dim); outline: none; }

/* Ergebniszeile im Terminal-Stil: "$ filter … → 12 Turniere" */
.result-line {
    color: var(--text-dim);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-4);
}
.result-line .cmd { color: var(--ok); }
.result-line .val { color: var(--text-bright); }

/* ── Geschlecht-Tabs ────────────────────────────────────────────────────── */

.gender-tabs { display: flex; margin-bottom: var(--sp-3); }

.gender-tab {
    padding: var(--sp-2) 20px;
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--fs-base);
    font-weight: 500;
    background: var(--bg-panel);
    border: 1px solid var(--border);
}

.gender-tab:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.gender-tab:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.gender-tab + .gender-tab { border-left: none; }
.gender-tab:hover { color: var(--text); background: var(--bg-hover); }
.gender-tab[aria-pressed="true"] {
    color: var(--ok);
    background: var(--bg-active);
    border-color: var(--ok-dim);
}

/* ── Turnier-Grid & Karten ──────────────────────────────────────────────── */

.turnier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-6);
}

.turnier-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.turnier-card:hover  { background: var(--bg-hover); border-color: var(--ok-dim); }
.turnier-card:active { background: var(--bg-active); }

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
}

.card-title {
    color: var(--text-bright);
    font-weight: 500;
    font-size: var(--fs-md);
    line-height: 1.4;
}

.card-badges { display: flex; gap: var(--sp-1); flex-shrink: 0; }

.card-meta {
    color: var(--text-dim);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-3);
}
.card-meta .sep { color: var(--border-strong); }

/* ── Badges ─────────────────────────────────────────────────────────────
   Farbregel pro Karte: NUR die Kategorie-Pille trägt Farbe (wichtigste
   Info zum Wiedererkennen), Status-Badges sind bewusst monochrom.      */

.kat {
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 0 var(--sp-2);
    font-size: var(--fs-xs);
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.7;
    /* dezenter Farbton-Hintergrund in der Kategoriefarbe */
    background: color-mix(in srgb, currentColor 14%, transparent);
}

.kat-bm  { color: var(--kat-bm); }
.kat-k1p { color: var(--kat-k1p); }
.kat-k1  { color: var(--kat-k1); }
.kat-k2  { color: var(--kat-k2); }
.kat-k3  { color: var(--kat-k3); }

.status {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 var(--sp-2);
    font-size: var(--fs-xs);
    white-space: nowrap;
    line-height: 1.7;
    color: var(--text-dim);
}

/* Alle Status grau – nur "läuft" hebt sich per Helligkeit + grünem
   Symbol ab, weil das die einzige zeitkritische Info ist */
.status--meldung,
.status--gelost        { color: var(--text-dim); }
.status--laeuft        { color: var(--text-bright); border-color: var(--border-strong); }
.status--vorbei,
.status--abgeschlossen,
.status--abgesagt      { color: var(--text-dim); background: var(--bg-raised); }

/* Status-Symbol (sdot) – neutral, Ausnahme: läuft */
.sdot { color: var(--text-dim); }
.sdot--laeuft { color: var(--ok); }

/* ── Mini-Visualisierungen (pure CSS-Balken) ────────────────────────────── */

.bar-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    margin-bottom: 5px;
}

.bar-label { color: var(--text-dim); letter-spacing: 1px; }
.bar-value { color: var(--text-dim); }
.bar-value strong { color: var(--text-bright); font-weight: 500; }
.bar-value .warn { color: var(--warn); }

.bar {
    display: flex;
    gap: 2px;
    height: 8px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: var(--sp-3);
}

.bar:last-child { margin-bottom: 0; }
.bar-row:last-child { margin-bottom: 0; }

/* schmalerer Plätze-Balken auf der Detailseite */
.bar--thin { height: 5px; }

/* Segmente: flex-Wert kommt inline aus JS bzw. Template (= Anteil) */
.seg--ok   { background: var(--ok); }
.seg--warn { background: var(--warn); opacity: 0.55; }
.seg--dvv  { background: var(--dvv); }
.seg--bvv  { background: var(--bvv); }
.seg--rest { background: var(--border); }   /* freie Plätze */

/* Legende unter den Balken (Index) */
.bar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    font-size: var(--fs-xs);
    color: var(--text-dim);
    margin: calc(-1 * var(--sp-4)) 0 var(--sp-5);
}
.bar-legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* ── Skeleton-Loader im Terminal-Stil ───────────────────────────────────── */

.skeleton-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4);
}

.sk-line {
    height: 12px;
    border-radius: 3px;
    background: var(--bg-raised);
    margin-bottom: var(--sp-3);
    animation: sk-pulse 1.4s ease-in-out infinite;
}

.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }
.sk-line.w90 { width: 90%; height: 8px; }

@keyframes sk-pulse { 50% { opacity: 0.45; } }

.empty-state, .error-state {
    grid-column: 1 / -1;
    color: var(--text-dim);
    padding: var(--sp-5);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.error-state { color: var(--danger); border-color: var(--danger); }

/* ── Detailseite: Kopf & Info-Grid ──────────────────────────────────────── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--link);
    text-decoration: none;
    font-size: var(--fs-md);
    margin-bottom: var(--sp-4);
}
.back-link:hover { text-decoration: underline; }

.turnier-header {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.turnier-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

.turnier-title {
    color: var(--text-bright);
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: 1.3;
}

.turnier-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-3) var(--sp-5);
    margin-bottom: var(--sp-4);
}

.info-item  { display: flex; gap: var(--sp-2); }
.info-label { color: var(--text-dim); white-space: nowrap; }
.info-value { color: var(--text-bright); }

/* Balken im Turnier-Kopf (von app.js befüllt) */
.header-bars { max-width: 520px; }

/* ── Tabs (Detailseite, ARIA-konform) ───────────────────────────────────── */

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    color: var(--text-dim);
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font-mono);
    font-size: var(--fs-base);
    font-weight: 500;
    background: none;
    white-space: nowrap;
}

.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab[aria-selected="true"] { color: var(--ok); border-bottom-color: var(--ok); }
.tab .key { color: var(--border-strong); margin-right: 6px; }

.tab-content {
    display: none;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.tab-content.active { display: block; }

/* ── Tabellen ───────────────────────────────────────────────────────────── */

/* Wrapper für horizontales Scrollen auf schmalen Screens */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

.data-table th {
    background: var(--bg-raised);
    color: var(--text-dim);
    font-weight: 700;
    text-align: left;
    padding: 10px var(--sp-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }

/* Erste Spalte (#/Setz/Platz) mobil festpinnen – siehe Media Query unten */

.cell-rank   { color: var(--text-dim); font-weight: 700; width: 50px; }
.cell-team   { color: var(--text-bright); font-weight: 700; }
.cell-player { color: var(--text); }
.cell-points { text-align: right; font-weight: 500; min-width: 55px; }
.cell-bvv    { color: var(--bvv); }
.cell-dvv    { color: var(--dvv); }
.cell-via    { font-weight: 700; font-size: var(--fs-xs); }

.via-dvv { color: var(--dvv); }
.via-bvv { color: var(--bvv); }
.via-wc  { color: var(--wc); }

.warteliste-header {
    background: var(--bg-raised);
    padding: var(--sp-2) var(--sp-3);
    color: var(--warn);
    font-weight: 700;
    font-size: var(--fs-sm);
    border-top: 2px solid var(--border);
}

.warteliste-row td { opacity: 0.6; }
.warteliste-row:hover td { opacity: 1; }

.separator-row td { padding: 0; height: 2px; background: var(--border); border: none; }

/* ── Hinweis-Boxen (ersetzen die Inline-Styles aus generate.py) ─────────── */

.notice {
    border-radius: var(--radius);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    font-size: var(--fs-sm);
    line-height: 1.5;
    border: 1px solid var(--border);
}

.notice-icon { font-weight: 700; margin-right: 6px; }

.notice--warn { background: var(--warn-bg); border-color: var(--warn); }
.notice--warn .notice-icon, .notice--warn strong { color: var(--warn); }

.notice--info { background: var(--dvv-bg); border-color: var(--dvv); }
.notice--info .notice-icon, .notice--info strong { color: var(--dvv); }

.notice-detail { margin-top: var(--sp-1); color: var(--text-dim); }

/* ── Help-Overlay (Taste "?") ───────────────────────────────────────────── */

.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1, 4, 9, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: var(--sp-4);
}

.help-overlay[hidden] { display: none; }

.help-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-5);
    max-width: 420px;
    width: 100%;
}

.help-box h2 {
    color: var(--text-bright);
    font-size: var(--fs-md);
    margin-bottom: var(--sp-4);
}

.help-row {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-1) 0;
    font-size: var(--fs-sm);
}

.help-row span:first-child { color: var(--text-dim); }

kbd {
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 6px;
    font-size: var(--fs-xs);
    color: var(--text-bright);
    background: var(--bg-raised);
}

.help-close { margin-top: var(--sp-4); color: var(--text-dim); font-size: var(--fs-xs); }

/* ── Footer ─────────────────────────────────────────────────────────────── */

.footer {
    margin-top: 40px;
    padding: var(--sp-4);
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: var(--fs-xs);
    text-align: center;
}

.footer span { color: var(--ok); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .container { padding: var(--sp-3); }

    .turnier-grid { grid-template-columns: 1fr; }

    .ascii-header { font-size: 10px; }   /* nie unter 10px – lieber scrollen */

    /* Geschlecht-Tabs kleben mobil unter der Topbar */
    .gender-tabs {
        position: sticky;
        top: var(--topbar-h);
        z-index: 90;
        background: var(--bg);
        padding: var(--sp-2) 0;
        margin: 0 0 var(--sp-2);
    }

    .gender-tab { flex: 1; text-align: center; padding: var(--sp-2) 0; }

    .turnier-info-grid { grid-template-columns: 1fr; gap: var(--sp-2); }

    .tab { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }

    .data-table { font-size: var(--fs-xs); }
    .data-table th, .data-table td { padding: 6px var(--sp-2); }

    /* Erste Spalte sticky beim horizontalen Scrollen */
    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        background: var(--bg-panel);
        z-index: 1;
        box-shadow: 1px 0 0 var(--border);
    }
    .data-table th:first-child { background: var(--bg-raised); }
    .data-table tbody tr:hover td:first-child { background: var(--bg-hover); }
}
