/* /module/portal/cups.css
   Öffentlicher Cup-Bereich (Übersicht + Einzelcup-Auflistung).
   Design analog /portal/aktuell (Karten-Grid), nur CSS-Variablen —
   keine hartcodierten Farben, damit Dark/Light Theme funktioniert. */

/* ------------------------------------------------------------------ */
/* Abschnitte + Überschriften                                          */
/* ------------------------------------------------------------------ */
.cups-intro {
    color: var(--seccol);
    font-size: 0.95rem;
    margin: 0 0 1.5rem 0;
}

.cups-section {
    margin-bottom: 2rem;
}

.cups-section-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--bgcolmid);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--textcol);
}

.cups-status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.cups-status-indicator.running {
    background-color: var(--primcol);
    animation: cups-pulse 2s infinite;
}

.cups-status-indicator.upcoming {
    background-color: var(--accent);
}

.cups-status-indicator.past {
    background-color: var(--seccol);
}

@keyframes cups-pulse {
    0%   { opacity: 1; }
    50%  { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ------------------------------------------------------------------ */
/* 1. Ebene: Karten der Cupgruppen                                     */
/* ------------------------------------------------------------------ */
.cups-container {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.cup-card {
    background: var(--bgcolmid);
    border: 1px solid var(--bgcoldark);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 8px var(--blacktrans);
    transition: all 0.3s ease;
    position: relative;
    color: var(--textcol);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.cup-card:hover {
    box-shadow: 0 5px 15px var(--blacktrans);
    transform: translateY(-2px);
    background: var(--bgcol);
}

.cup-card.laufend {
    border-left: 4px solid var(--primcol);
}

.cup-card.kommend {
    border-left: 4px solid var(--accent);
}

.cup-card.vergangen {
    border-left: 4px solid var(--seccol);
    opacity: 0.8;
}

.cup-card .status-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--bgcoldark);
}

.cup-card.laufend .status-badge   { background-color: var(--primcol); }
.cup-card.kommend .status-badge   { background-color: var(--accent); }
.cup-card.vergangen .status-badge { background-color: var(--seccol); }

.cup-card-body {
    flex: 1;
}

.cup-header {
    margin-bottom: 1rem;
}

.cup-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--textcol);
    margin: 0 0 0.5rem 0;
    padding-right: 5rem; /* Platz für das Status-Badge */
}

.cup-type {
    color: var(--seccol);
    font-size: 0.9rem;
    margin: 0;
    font-weight: 500;
}

.cup-details {
    display: grid;
    gap: 0.5rem;
}

.cup-info {
    margin-top: 1rem;
    padding: 0.75rem;
    border-top: 1px solid var(--bgcoldark);
    border-radius: 4px;
    background: var(--blacktrans);
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--seccol);
    white-space: pre-line;
}

.cup-links {
    padding: 0.5rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

/* Detailzeilen (Datum, Sparte, Bundesland …) — auch im Kopf der 2. Ebene.
   Beschriftung und Wert stehen direkt nebeneinander in einer Zeile
   ("Sparte: Springen") — keine Spaltenausrichtung, kompakte Schrift. */
.detail-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem;
    font-size: 0.85rem;
}

.detail-label {
    font-weight: bold;
    color: var(--accent);
}

.detail-value {
    color: var(--textcol);
}

/* ------------------------------------------------------------------ */
/* 2. Ebene: Kopfbereich + Einzelcups                                  */
/* ------------------------------------------------------------------ */
.cups-back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
}

.cups-back-link:hover {
    text-decoration: underline;
}

.cup-head {
    background: var(--bgcolmid);
    border: 1px solid var(--bgcoldark);
    border-left: 4px solid var(--primcol);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--textcol);
}

.cup-head-name {
    font-size: 1.4rem;
    font-weight: bold;
    margin: 0 0 1rem 0;
    color: var(--textcol);
}

.cup-head-details {
    display: grid;
    gap: 0.5rem;
}

.cup-head-info {
    margin-top: 1rem;
    padding: 0.75rem;
    border-top: 1px solid var(--bgcoldark);
    border-radius: 4px;
    background: var(--blacktrans);
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--seccol);
    white-space: pre-line;
}

.cup-head-links {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

/* PDF-/Link-Buttons (Ausschreibung, Ergebnis-PDF) */
.cup-pdf-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: bold;
}

.cup-pdf-link:hover {
    opacity: 0.75;
    text-decoration: underline;
}

/* Blatt-Symbol in den PDF-Links: Inline-SVG statt Emoji, damit es der
   Textfarbe folgt und in beiden Themes gleich aussieht. */
.cup-pdf-icon-svg {
    width: 1.05em;
    height: 1.05em;
    flex-shrink: 0;
}

/* PDF-Symbol neben der Cup-Ueberschrift (Gesamtwertung als PDF) */
.cup-pdf-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    padding: 0.25rem;
    border-radius: 4px;
    color: var(--accent);
    vertical-align: middle;
}

.cup-pdf-icon .cup-pdf-icon-svg {
    width: 1.3rem;
    height: 1.3rem;
}

.cup-pdf-icon:hover {
    background: var(--whitetrans);
    opacity: 0.85;
}

/* Einzelcup-Zeilen: kompakte Karten, Name links, PDF rechts */
.cup-einzel-card {
    background: var(--bgcolmid);
    border: 1px solid var(--bgcoldark);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--textcol);
    transition: all 0.2s ease;
}

.cup-einzel-card:hover {
    background: var(--bgcol);
}

.cup-einzel-card.abgesagt {
    opacity: 0.6;
}

.cup-einzel-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.cup-einzel-nr {
    background: var(--bgcoldark);
    color: var(--accent);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.cup-einzel-name {
    font-weight: bold;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.cup-einzel-badge {
    background: var(--seccol);
    color: var(--bgcoldark);
    border-radius: 12px;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    flex-shrink: 0;
}

.cup-einzel-hinweis {
    color: var(--seccol);
    font-size: 0.85rem;
}

/* ------------------------------------------------------------------ */
/* PDF-Viewer im Popup (nur Desktop)                                   */
/* ------------------------------------------------------------------ */
.cup-pdf-viewer {
    display: flex;
    flex-direction: column;
    height: 80vh;
}

.cup-pdf-viewer-head {
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--bgcolmid);
}

.cup-pdf-viewer-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--textcol);
}

.cup-pdf-viewer-title .close {
    background: none;
    border: none;
    color: var(--textcol);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.cup-pdf-viewer-links {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.cup-pdf-viewer-links a {
    color: var(--accent);
    font-size: 0.85rem;
}

.cup-pdf-viewer iframe {
    flex: 1;
    border: none;
    width: 100%;
    border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/* Lade-/Leerzustände (analog aktuell)                                 */
/* ------------------------------------------------------------------ */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--textcol);
}

.spinner {
    border: 4px solid var(--bgcolmid);
    border-top: 4px solid var(--primcol);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: cups-spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes cups-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--textcol);
    background: var(--bgcolmid);
    border-radius: 8px;
    border: 1px solid var(--bgcoldark);
}

.no-data h3 {
    margin: 0 0 1rem 0;
    color: var(--accent);
}

.error-message {
    background-color: var(--blacktrans);
    color: var(--textcol);
    padding: 1rem;
    border: 1px solid var(--thirdcol);
    border-radius: 4px;
    margin: 1rem 0;
    text-align: center;
}

/* ------------------------------------------------------------------ */
/* Mobile                                                              */
/* ------------------------------------------------------------------ */

/* =====================================================================
   Gesamtwertung eines Wertungs-Cups (cupwertung.php)

   Eine Zeile je Wertungstraeger, eine Spalte je AUFGABE (nicht je
   Station) — genau der Aufbau, den die Reiter vom haendisch gefuehrten
   Zwischenstand kennen. Die Tabelle wird schnell breit, deshalb
   scrollt sie in ihrem eigenen Container statt die Seite zu sprengen.
   ===================================================================== */

.cupw-portal-wrap {
    overflow-x: auto;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.cupw-portal-tabelle {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bgcolmid);
    font-size: 0.9rem;
}

.cupw-portal-tabelle th,
.cupw-portal-tabelle td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--blacktrans);
    white-space: nowrap;
}

.cupw-portal-tabelle thead th {
    background-color: var(--bgcoldark);
    color: var(--textcol);
    font-weight: bold;
    text-align: center;
    position: sticky;
    top: 0;
}

.cupw-p-station {
    border-left: 2px solid var(--blacktrans);
    font-size: 0.8rem;
}

/* Name der Station. Auf breiten Bildschirmen einzeilig wie der Rest der
   Kopfzeile; die Umbruchregel steht in der Media Query weiter unten. */
.cupw-p-stationname {
    display: block;
}

/* Datum unter dem Stationsnamen, damit der Kopf schmal bleibt */
.cupw-p-datum {
    display: block;
    font-weight: normal;
    font-size: 0.7rem;
    opacity: 0.7;
}

.cupw-p-aufgabe {
    font-size: 0.8rem;
    font-weight: normal;
}

.cupw-p-spaltenlink {
    color: var(--accent);
    text-decoration: none;
}

.cupw-p-spaltenlink:hover {
    text-decoration: underline;
}

/* Abgesagte Aufgabe: sichtbar, zaehlt aber nicht */
.cupw-p-abgesagt {
    text-decoration: line-through;
    opacity: 0.5;
}

.cupw-p-rang {
    width: 3rem;
    text-align: center;
    font-weight: bold;
}

.cupw-p-name {
    text-align: left;
    min-width: 14rem;
    white-space: normal;
}

.cupw-pferde {
    opacity: 0.7;
    font-size: 0.85em;
}

.cupw-p-wert {
    text-align: right;
}

.cupw-p-zaehlt {
    font-weight: bold;
}

/* Wert liegt nicht unter den besten N und zaehlt deshalb nicht mit */
.cupw-p-gestrichen {
    opacity: 0.45;
}

.cupw-p-leerzelle {
    background-color: var(--blacktrans);
}

/* Station des Cups, die noch aussteht: Sie hat noch keinen Teilbewerb und
   bleibt trotzdem als Spalte sichtbar — sonst saehe der Zwischenstand aus
   wie ein Endstand. Blass, weil dort (noch) nichts steht. */
.cupw-p-station-offen,
.cupw-p-aufgabe-offen {
    opacity: 0.55;
    font-style: italic;
}

.cupw-p-zelle-offen {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        var(--blacktrans) 4px,
        var(--blacktrans) 5px
    );
}

/* Block der zaehlenden Ergebnisse, absteigend sortiert. Er macht die Summe
   nachvollziehbar und ist im Portal genauso aufgebaut wie in der
   Verwaltung — die Reiter kennen diese Darstellung vom haendisch
   gefuehrten Zwischenstand. */
.cupw-p-bestenkopf {
    border-left: 3px solid var(--primcol);
    font-size: 0.8rem;
}

.cupw-p-bestenspalte {
    width: 2.8rem;
    font-size: 0.75rem;
    font-weight: normal;
    border-left: 1px solid var(--blacktrans);
}

.cupw-p-beste {
    text-align: right;
    background-color: rgba(var(--warncol-rgb), 0.15);
}

.cupw-p-beste-leer {
    background-color: var(--blacktrans);
    opacity: 0.4;
}

.cupw-p-summe {
    text-align: right;
    font-weight: bold;
    border-left: 3px solid var(--primcol);
    background-color: var(--blacktrans);
}

/* Mindestteilnahmen nicht erreicht — steht ohne Rang hinten */
.cupw-p-ohne {
    opacity: 0.6;
}

.cupw-p-platziert .cupw-p-rang {
    color: var(--primcol);
}

.cupw-p-leer {
    opacity: 0.5;
}

.cupw-portal-hinweis {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--accent);
    background-color: var(--bgcolmid);
    font-size: 0.85rem;
}

.cupw-portal-legende {
    font-size: 0.8rem;
    opacity: 0.75;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .cups-container {
        grid-template-columns: 1fr;
    }

    .cup-card {
        padding: 1rem;
    }

    .cup-name {
        font-size: 1.1rem;
        padding-right: 4.5rem;
    }

    .cups-section-title {
        font-size: 1.25rem;
    }

    /* Detailzeilen bleiben auch mobil einzeilig ("Sparte: Springen");
       nur bei sehr langen Werten bricht flex-wrap um */

    .cup-head {
        padding: 1rem;
    }

    .cup-head-name {
        font-size: 1.2rem;
    }

    /* Einzelcups untereinander statt nebeneinander */
    .cup-einzel-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    /* Auf dem Handy zaehlt jede Spalte — Schrift und Innenabstand kleiner,
       gescrollt wird ohnehin waagrecht im eigenen Container */
    .cupw-portal-tabelle {
        font-size: 0.8rem;
    }

    .cupw-portal-tabelle th,
    .cupw-portal-tabelle td {
        padding: 0.3rem 0.35rem;
    }

    .cupw-p-name {
        min-width: 10rem;
    }

    /* Stationsnamen duerfen mehrzeilig werden. Ein Name wie "RSZ Reifnitz,
       Maria Woerth" schiebt sonst die halbe Tabelle nach rechts aus dem
       Bild — und gerade auf dem Handy ist waagrechtes Scrollen der teuerste
       Weg zur Information. Die max-width erzwingt den Umbruch: Ohne sie
       wuerde die Spalte im scrollenden Container einfach breiter statt
       umzubrechen. */
    .cupw-p-stationname {
        max-width: 8rem;
        margin: 0 auto;
        white-space: normal;
        overflow-wrap: break-word;
        line-height: 1.2;
    }
}

/* Spalte, deren Bewerb im Portal noch nicht freigegeben ist: Der Kopf
   bleibt stehen, damit die Tabelle vollstaendig aussieht, die Werte
   fehlen aber. Ohne Markierung wuerde der Stand fertig wirken. */
.cupw-p-offen {
    opacity: 0.6;
}

.cupw-p-offen-marker {
    color: var(--accent);
    font-size: 0.7rem;
}

/* ==========================================================================
   Blaettern zwischen den Cups einer Serie (cupwertung.php)

   Zwei Pfeile links und rechts der Ueberschrift, damit man fuer den
   naechsten Cup nicht ueber die Uebersicht zurueck muss.

   Die Pfeile sind Inline-SVG und keine Zeichen wie ➡: das kommt auf vielen
   Geraeten als farbiges Emoji und folgt dann weder der Textfarbe noch dem
   Theme - dieselbe Ueberlegung wie beim PDF-Symbol weiter oben.
   ========================================================================== */

.cup-head-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Nimmt den ganzen freien Platz, damit die Pfeile aussen sitzen */
.cup-head-nav .cup-head-inhalt {
    flex: 1;
    min-width: 0;
}

.cup-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--bgcoldark);
    border-radius: 4px;
    background: var(--bgcoldark);
    color: var(--textcol);
    text-decoration: none;
    transition: all 0.3s ease;
}

.cup-nav-btn:hover {
    background: var(--accent);
    color: var(--bgcoldark);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.cup-nav-btn svg {
    width: 1.4rem;
    height: 1.4rem;
}

/* Kein Nachbar in dieser Richtung: der Platz bleibt bestehen, sonst
   verrutscht die Ueberschrift beim Durchblaettern. */
.cup-nav-btn-aus {
    opacity: 0.3;
    cursor: default;
}

.cup-nav-btn-aus:hover {
    background: var(--bgcoldark);
    color: var(--textcol);
    transform: none;
    box-shadow: none;
}

@media (max-width: 768px) {
    /* Auf dem Handy zaehlt die Breite fuer den Cupnamen */
    .cup-head-nav {
        gap: 0.5rem;
    }

    .cup-nav-btn {
        width: 2rem;
        height: 2rem;
    }

    .cup-nav-btn svg {
        width: 1.1rem;
        height: 1.1rem;
    }
}
