/* =========================================================================
   Drachenboot – Mobile-First Stylesheet
   ========================================================================= */

* { box-sizing: border-box; }

:root {
    --c-primary: #007bff;
    --c-primary-dark: #0056b3;
    --c-accent: #28a745;
    --c-bg: #f4f4f4;
    --c-surface: #ffffff;
    --c-text: #222;
    --c-muted: #666;
    --c-border: #ddd;
    --c-error-bg: #ffebee;
    --c-error: #c62828;
    --radius: 8px;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

html { scroll-behavior: smooth; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--c-bg);
    color: var(--c-text);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

/* --- Header & Navigation (Mobile-First) ---------------------------------- */
header {
    background-color: var(--c-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
}

.header-bar h1 {
    font-size: 1.25rem;
    margin: 0;
}

#nav-toggle {
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}
#nav-toggle span {
    display: block;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

#main-nav {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
}
#main-nav.open {
    max-height: 600px;
}

#main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.year-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--c-primary-dark);
    border-top: 1px solid rgba(255,255,255,0.15);
}
.year-nav button {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.45rem 0.9rem;
    font-size: 1rem;
    border-radius: 999px;
    cursor: pointer;
    min-width: 64px;
    transition: background 0.15s;
}
.year-nav button:hover { background: rgba(255,255,255,0.3); }
.year-nav button.active {
    background: #fff;
    color: var(--c-primary-dark);
    font-weight: 600;
    border-color: #fff;
}

.section-nav {
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(255,255,255,0.15);
}
.section-nav li { border-top: 1px solid rgba(255,255,255,0.1); }
.section-nav li:first-child { border-top: 0; }
.section-nav a {
    display: block;
    color: #fff;
    text-decoration: none;
    padding: 0.85rem 1rem;
    font-size: 1rem;
}
.section-nav a:active { background: rgba(0,0,0,0.15); }

/* --- Main / Sections ----------------------------------------------------- */
main {
    padding: 1rem;
    max-width: 1100px;
    margin: 0 auto;
}

section {
    margin-bottom: 1.25rem;
    background-color: var(--c-surface);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

section h2 {
    margin-top: 0;
    font-size: 1.25rem;
    color: var(--c-primary-dark);
    border-bottom: 2px solid var(--c-bg);
    padding-bottom: 0.4rem;
}

#hero {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}
.hero-content h2 {
    border: 0;
    margin-bottom: 0.5rem;
}
.cta-button {
    background-color: var(--c-accent);
    color: #fff;
    padding: 0.7rem 1.2rem;
    text-decoration: none;
    border-radius: var(--radius);
    display: inline-block;
    margin-top: 0.5rem;
    font-weight: 600;
}
.cta-button:active { transform: translateY(1px); }

footer {
    text-align: center;
    padding: 1rem;
    background-color: #333;
    color: #fff;
    font-size: 0.9rem;
}

/* --- Status bar ---------------------------------------------------------- */
.status-bar {
    background: #e3f2fd;
    color: #0d47a1;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.status-bar.error {
    background: var(--c-error-bg);
    color: var(--c-error);
}

/* --- Buttons ------------------------------------------------------------- */
.actions {
    text-align: center;
    margin: 1rem 0;
}
#reload-button {
    background: var(--c-primary);
    color: #fff;
    border: 0;
    padding: 0.7rem 1.4rem;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
}
#reload-button:hover { background: var(--c-primary-dark); }

/* --- Tabellen: Mobile (Card-Layout via data-label) ----------------------- */
#results-container, #schedule-container, #team-container, #info-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
}

th, td {
    border: 1px solid var(--c-border);
    padding: 0.6rem 0.5rem;
    text-align: left;
    font-size: 0.95rem;
}
th { background-color: #f2f2f2; font-weight: 600; }

/* Card-Layout für Tabellen auf Mobile */
@media (max-width: 640px) {
    table thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr {
        margin-bottom: 0.75rem;
        border: 1px solid var(--c-border);
        border-radius: var(--radius);
        overflow: hidden;
        background: #fafafa;
    }
    td {
        border: 0;
        border-bottom: 1px solid var(--c-border);
        padding: 0.5rem 0.75rem;
        display: flex;
        justify-content: space-between;
        gap: 0.75rem;
    }
    td:last-child { border-bottom: 0; }
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--c-muted);
        flex: 0 0 45%;
    }
}

#team-container ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}
#team-container li {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--c-border);
}
#team-container li:last-child { border-bottom: 0; }
#team-container h3 {
    margin: 1rem 0 0.25rem 0;
    color: var(--c-primary-dark);
}

/* --- SVG Animation ------------------------------------------------------- */
.scene { width: 100%; max-width: 800px; margin: 0 auto; }
#dragon-boat-svg { width: 100%; height: auto; }

@keyframes move-boat {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
#boat-container { animation: move-boat 10s linear infinite; }

@keyframes move-water {
    from { transform: translateX(0); }
    to   { transform: translateX(-400px); }
}
.wave { animation: move-water 4s linear infinite; }

@keyframes paddle-row {
    0%, 100% { transform: rotate(20deg); }
    50%      { transform: rotate(-20deg); }
}
.paddle-instance {
    transform-origin: center -5px;
    animation: paddle-row 1.2s infinite ease-in-out;
    animation-delay: var(--delay);
}

/* --- Desktop ------------------------------------------------------------- */
@media (min-width: 768px) {
    .header-bar { padding: 1rem 1.5rem; }
    .header-bar h1 { font-size: 1.6rem; }

    #nav-toggle { display: none; }

    #main-nav {
        max-height: none !important;
        overflow: visible;
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
    }
    .year-nav {
        background: transparent;
        border-top: 0;
        padding: 0.5rem 0;
    }
    .section-nav {
        flex-direction: row;
        border-top: 0;
    }
    .section-nav li { border: 0; }
    .section-nav a {
        padding: 0.75rem 0.9rem;
        border-radius: var(--radius);
    }
    .section-nav a:hover { background: rgba(255,255,255,0.15); }

    #hero {
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        text-align: left;
    }
    .hero-content { flex: 1; }
    .hero-image { flex: 1; }

    section h2 { font-size: 1.5rem; }
}
