/* =============================================================================
   SOKKOPINGIS-CUP — shared page components (dark theme)
   Load after css/cup_theme.css, which holds the tokens, base, header and nav.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   LAYOUT CONTAINERS
   (the page frame comes from .tournament-container / .tournament-content)
   ----------------------------------------------------------------------------- */

.container,
.athlete-stats-container {
    max-width: 1100px;
    margin: 0 auto;
}

.stats-page-container {
    width: 100%;
    margin: 0 auto;
}

/* -----------------------------------------------------------------------------
   PAGE HEADER BLOCK (title + controls)
   ----------------------------------------------------------------------------- */

.standings-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text);
    padding: 18px 22px;
    margin-bottom: 20px;
    text-align: center;
}

.standings-header h1,
.standings-header h2 {
    font-size: clamp(1.4rem, 4.5vw, 1.9rem);
    line-height: 1.25;
    color: #fff;
    margin-bottom: 12px;
}

.standings-header p {
    color: var(--text2);
    font-size: 1em;
    margin-top: 5px;
}

.archive-nav-link { margin: 0 0 12px; }
.archive-nav-link a {
    color: var(--accent);
    text-decoration: underline;
    font-weight: bold;
    font-size: 0.95em;
}
.archive-nav-link a:hover { color: var(--accent-h); }

/* -----------------------------------------------------------------------------
   CONTROLS
   ----------------------------------------------------------------------------- */

.controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}

.view-toggle {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.view-toggle button,
.quick-filter-btn {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--accent);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.2s ease;
    min-width: 140px;
    min-height: 40px;
    text-align: center;
    border-radius: var(--radius);
}
.view-toggle button:hover,
.quick-filter-btn:hover { background: var(--accent-bg); }
.view-toggle button.active,
.quick-filter-btn.active {
    background: var(--accent);
    color: var(--on-accent);
}

/* Season selector */
.season-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 8px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.season-selector label {
    font-weight: bold;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text3);
}
.season-selector select,
.filter-group input,
.filter-group select {
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border2);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1em;
    min-width: 120px;
    min-height: 40px;
    border-radius: var(--radius);
}
.season-selector select:focus,
.filter-group input:focus,
.filter-group select:focus { border-color: var(--accent); }

.drop-lowest-toggle { border: none; }
.drop-lowest-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1em;
    color: var(--text);
}
.drop-lowest-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* -----------------------------------------------------------------------------
   INDEX PAGE NAVIGATION CARDS
   ----------------------------------------------------------------------------- */

.index-section { margin: 0 0 32px; }

.index-navigation {
    list-style: none;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    margin: 0;
    padding: 0;
}

.index-link-container {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--card-accent, var(--accent));
    border-radius: var(--radius);
    transition: background 0.15s;
}
.index-link-container:hover { background: var(--hover); }

.index-link {
    display: block;
    color: var(--text);
    text-decoration: none;
    padding: 16px 40px 14px 18px;
    height: 100%;
}
.index-link:focus-visible { outline-offset: 2px; }

.index-link h2,
.index-link h3 {
    color: #fff;
    font-size: 1.15em;
    font-weight: bold;
    margin: 0 0 4px 0;
    line-height: 1.25;
}
.index-link p {
    color: var(--text2);
    font-size: 0.92em;
    margin: 0;
    line-height: 1.4;
}
.index-link:hover h2,
.index-link:hover h3,
.index-link:focus h2,
.index-link:focus h3 { color: var(--card-accent, var(--accent)); }

.index-link::after {
    content: '→';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    color: var(--card-accent, var(--accent));
    opacity: 0.7;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.index-link:hover::after,
.index-link:focus::after {
    transform: translateY(-50%) translateX(3px);
    opacity: 1;
}

.accent-cyan  { --card-accent: var(--accent); }
.accent-amber { --card-accent: var(--gold); }
.accent-green { --card-accent: var(--green); }
.accent-muted { --card-accent: var(--text3); }

/* Coming soon */
.index-link-container.coming-soon { opacity: 0.6; }
.index-link-container.coming-soon:hover { background: var(--surface); }
.index-link-container.coming-soon .index-link {
    cursor: not-allowed;
    pointer-events: none;
}
.index-link-container.coming-soon .index-link::after { content: none; }
.soon-tag {
    display: inline-block;
    font-size: 0.65em;
    font-weight: bold;
    color: var(--gold);
    border: 1px solid rgba(251,191,36,0.5);
    background: var(--gold-bg);
    border-radius: var(--radius);
    padding: 0 6px;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Back link to cup front page (sub pages) */
.back-to-cup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text2);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.92em;
    margin-bottom: 12px;
}
.back-to-cup:hover { color: var(--accent); }

/* -----------------------------------------------------------------------------
   SIMPLE (LIST) VIEW
   ----------------------------------------------------------------------------- */

.simple-list {
    max-width: 900px;
    margin: 0 auto;
}

.simple-sarja {
    margin-bottom: 25px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    border-radius: var(--radius);
}

.simple-sarja h3,
#standings-tables h3 {
    background: var(--surface2);
    color: #fff;
    padding: 12px 20px;
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
    border-bottom: 2px solid var(--accent);
    text-align: left;
}

.simple-sarja ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.simple-athlete {
    padding: 10px 18px;
    margin: 0;
    background: transparent;
    border-left: 4px solid transparent;
    border-bottom: 1px solid var(--border);
    font-size: 1em;
    line-height: 1.4;
    color: var(--text);
    transition: background-color 0.2s ease;
}
.simple-athlete:hover { background: var(--hover); }
.simple-athlete.top-3 {
    font-weight: bold;
    background: var(--top-row);
    border-left-color: var(--gold);
}
.simple-athlete:last-child { border-bottom: none; }

/* -----------------------------------------------------------------------------
   STANDINGS TABLES (kokonaiscup + archives)
   ----------------------------------------------------------------------------- */

#standings-tables,
#standings-simple {
    margin: 0 auto;
    max-width: 1000px;
}

#standings-tables section {
    margin-bottom: 25px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    border-radius: var(--radius);
}
#standings-tables section:last-child { margin-bottom: 0; }

#standings-tables table,
.stats-table-container table,
.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

#standings-tables th,
.stats-table-container th,
.stats-table th {
    background: var(--surface2);
    color: #fff;
    padding: 11px 10px;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid var(--accent);
    font-size: 0.92em;
}

#standings-tables th:first-child { width: 50px; text-align: center; }
#standings-tables th:nth-child(2) { width: 45%; }
#standings-tables th:nth-child(3),
#standings-tables th:nth-child(4),
#standings-tables th:nth-child(5) { width: 15%; text-align: center; }
#standings-tables th:nth-child(6) { width: 10%; text-align: center; }

#standings-tables td,
.stats-table-container td,
.stats-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

#standings-tables tbody tr:last-child td,
.stats-table tbody tr:last-child td { border-bottom: none; }

#standings-tables tbody tr:hover,
.stats-table-container tbody tr:hover,
.stats-table tbody tr:hover { background: var(--hover); }

#standings-tables .position {
    text-align: center;
    font-weight: bold;
    color: var(--text);
}
#standings-tables .name { font-weight: 600; color: #fff; }
#standings-tables .club { color: var(--text3); font-size: 0.9em; font-weight: normal; }
#standings-tables .points { text-align: center; font-weight: bold; color: var(--accent); }
#standings-tables .first-places,
#standings-tables .best-placement,
#standings-tables .tournaments-count,
#standings-tables .lowest-points { text-align: center; color: var(--text2); font-weight: normal; }

/* Top 3 */
#standings-tables tbody tr:nth-child(-n+3) { background: var(--top-row); }
#standings-tables tbody tr:nth-child(-n+3):hover { background: #24477a; }
#standings-tables tbody tr:nth-child(-n+3) .name { font-weight: bold; }
#standings-tables tbody tr:nth-child(1) .position { color: var(--gold); }
#standings-tables tbody tr:nth-child(2) .position { color: var(--silver); }
#standings-tables tbody tr:nth-child(3) .position { color: var(--bronze); }

/* -----------------------------------------------------------------------------
   FILTERS
   ----------------------------------------------------------------------------- */

.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    border: none;
}
.filter-group-tickbox {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
    border: none;
}
.filter-group label {
    font-weight: bold;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 1em;
}
.filter-group input[type="checkbox"] { min-height: 0; min-width: 0; width: 18px; height: 18px; }

.quick-filters { grid-column: 1/-1; margin-top: 10px; }
.quick-filters-label {
    font-weight: bold;
    color: var(--text3);
    margin-bottom: 10px;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.quick-filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.clear-filters {
    background: transparent;
    color: var(--warn);
    border: 2px solid var(--warn);
    padding: 8px 16px;
    min-height: 40px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    border-radius: var(--radius);
    transition: background-color 0.2s ease;
}
.clear-filters:hover { background: var(--warn-bg); }

/* -----------------------------------------------------------------------------
   STATISTICS TABLES
   ----------------------------------------------------------------------------- */

.stats-table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    max-width: 1000px;
    margin: 0 auto 20px;
    border-radius: var(--radius);
}

.sarja-badge {
    padding: 3px 8px;
    font-size: 0.85em;
    font-weight: bold;
    text-align: center;
    border-radius: 3px;
}

.era-voitot { text-align: center; font-weight: bold; color: var(--green); }
.era-prosentti { text-align: center; font-weight: bold; color: #c4b5fd; }

.percentage { font-weight: 600; text-align: center; }
.percentage.high,
.percentage-high {
    color: #86efac;
    background: var(--green-bg);
    padding: 2px 6px;
    border-radius: 3px;
}
.percentage.low,
.percentage-low {
    color: #fca5a5;
    background: var(--red-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

.ottelut-tot { text-align: center; color: var(--text2); }

.current-result,
.current-result-table { font-weight: bold; }
.previous-result,
.previous-result-table { font-style: italic; font-weight: normal; color: var(--text2); }

/* -----------------------------------------------------------------------------
   TEXT CARDS
   ----------------------------------------------------------------------------- */

.text-card {
    background: var(--surface);
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    transition: background-color 0.2s ease;
}
.text-card:hover { background: var(--hover); }

.player-name-text {
    font-size: 1.2em;
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
}
.player-details {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.detail-item { font-size: 0.9em; color: var(--text2); }
.detail-value { font-weight: 600; color: var(--text); }

/* -----------------------------------------------------------------------------
   UTILITY
   ----------------------------------------------------------------------------- */

.last-updated {
    text-align: center;
    color: var(--text3);
    font-size: 0.9em;
    margin: 25px auto 0;
    padding: 15px;
    border-top: 1px solid var(--border);
    max-width: 1000px;
}

/* -----------------------------------------------------------------------------
   RESPONSIVE
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .standings-header { padding: 14px 12px; }

    .season-selector {
        flex-direction: column;
        gap: 5px;
        text-align: center;
        padding: 6px 10px;
    }

    .view-toggle button,
    .quick-filter-btn {
        min-width: 120px;
        padding: 8px 12px;
        font-size: 0.95em;
    }

    .filters {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px 12px;
    }
    .quick-filter-buttons { justify-content: center; }

    .simple-sarja { margin-bottom: 15px; }
    .simple-sarja h3,
    #standings-tables h3 { padding: 10px 14px; font-size: 1.1em; }
    .simple-athlete { padding: 8px 12px; font-size: 0.95em; }
    #standings-tables section { margin-bottom: 15px; }

    #standings-tables th,
    #standings-tables td,
    .stats-table-container th,
    .stats-table-container td,
    .stats-table th,
    .stats-table td {
        padding: 6px 4px;
        font-size: 0.85em;
    }

    /* Hide some columns on mobile for better readability */
    #standings-tables th:nth-child(3),
    #standings-tables td:nth-child(3),
    .stats-table-container th:nth-child(3),
    .stats-table-container td:nth-child(3),
    .stats-table th:nth-child(3),
    .stats-table td:nth-child(3) {
        display: none;
    }

    .player-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .text-card { padding: 10px; margin-bottom: 8px; }

    .index-navigation { grid-template-columns: 1fr; gap: 8px; }
    .index-link { padding: 12px 36px 11px 14px; }
    .index-link h2,
    .index-link h3 { font-size: 1.05em; }
    .index-link p { font-size: 0.85em; }
    .index-section { margin-bottom: 24px; }
}

@media (max-width: 480px) {
    .view-toggle button,
    .quick-filter-btn {
        min-width: 100px;
        padding: 6px 10px;
        font-size: 0.9em;
    }

    .simple-athlete { padding: 6px 10px; font-size: 0.9em; }

    /* Hide additional columns on very small screens */
    #standings-tables th:nth-child(6),
    #standings-tables td:nth-child(6),
    #standings-tables th:nth-child(7),
    #standings-tables td:nth-child(7),
    .stats-table-container th:nth-child(6),
    .stats-table-container td:nth-child(6),
    .stats-table-container th:nth-child(7),
    .stats-table-container td:nth-child(7),
    .stats-table th:nth-child(6),
    .stats-table td:nth-child(6),
    .stats-table th:nth-child(7),
    .stats-table td:nth-child(7) {
        display: none;
    }

    #standings-tables th,
    #standings-tables td,
    .stats-table-container th,
    .stats-table-container td,
    .stats-table th,
    .stats-table td {
        padding: 5px 3px;
        font-size: 0.8em;
    }

    .player-name-text { font-size: 1.1em; }
}
