/* HaxBall Player Ratings — Custom Styles */

/* Force light theme */
:root {
    color-scheme: light;
}

/* Navigation */
nav .nav-brand {
    text-decoration: none;
}

nav a.active {
    font-weight: bold;
    text-decoration: underline;
}

/* Highlighted nav item (UHL 2.0) */
nav a.nav-highlight {
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
    padding: 0.3rem 0.75rem;
    border-radius: 1rem;
    text-decoration: none;
    white-space: nowrap;
}

nav a.nav-highlight:hover,
nav a.nav-highlight.active {
    background: var(--pico-primary-hover);
    color: var(--pico-primary-inverse);
    text-decoration: none;
}

nav .nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    vertical-align: middle;
}

/* Rating page */
.rating-card {
    max-width: 600px;
    margin: 0 auto;
}

.rating-card .player-name {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.rating-card .player-team {
    color: var(--pico-muted-color);
    margin-bottom: 1.5rem;
}

.player-aka {
    color: var(--pico-muted-color);
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 0.25rem;
}

.rating-row {
    margin-bottom: 1rem;
}

.rating-row label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.rating-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.rating-buttons button {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid var(--pico-primary);
    background: transparent;
    color: var(--pico-primary);
    border-radius: var(--pico-border-radius);
    transition: background-color 0.15s, color 0.15s;
}

.rating-buttons button.selected {
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
}

.rating-buttons button:hover {
    background: var(--pico-primary-focus);
    color: var(--pico-primary);
}

.rating-buttons button.selected:hover {
    background: var(--pico-primary-hover);
    color: var(--pico-primary-inverse);
}

.rating-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.rating-actions button {
    flex: 1;
}

.rating-actions .btn-skip {
    --pico-background-color: #c62828;
    --pico-border-color: #c62828;
    --pico-color: #fff;
}

.rating-actions .btn-skip:hover,
.rating-actions .btn-skip:active,
.rating-actions .btn-skip:focus {
    --pico-background-color: #a01c1c;
    --pico-border-color: #a01c1c;
    --pico-color: #fff;
}

.progress-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

.done-message {
    text-align: center;
    padding: 3rem 1rem;
}

.done-message h2 {
    color: var(--pico-primary);
}

/* Category tooltip */
.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 50%;
    background: var(--pico-muted-border-color);
    color: var(--pico-muted-color);
    cursor: help;
    position: relative;
    vertical-align: middle;
    margin-left: 0.3rem;
    user-select: none;
}

.tooltip-trigger::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--pico-contrast);
    color: var(--pico-contrast-inverse);
    font-size: 0.8rem;
    font-weight: 400;
    padding: 0.4rem 0.6rem;
    border-radius: var(--pico-border-radius);
    white-space: normal;
    width: max-content;
    max-width: 260px;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}

.tooltip-trigger.active::after {
    opacity: 1;
}

/* Country flag (flag-icons library) */
.country-flag {
    vertical-align: middle;
    margin-right: 0.15em;
}

/* Leaderboard */
.leaderboard-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: end;
}

.leaderboard-controls > div {
    flex: 1;
    min-width: 200px;
}

/* Rating bars */
.rating-bar-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.rating-bar-label {
    min-width: 140px;
    font-weight: 500;
}

.rating-bar {
    flex: 1;
    height: 24px;
    background: var(--pico-secondary-background);
    border-radius: var(--pico-border-radius);
    overflow: hidden;
}

.rating-bar-fill {
    height: 100%;
    background: var(--pico-primary);
    border-radius: var(--pico-border-radius);
    transition: width 0.3s ease;
}

.rating-bar-value {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
}

/* Player votes table */
.votes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.vote-chip {
    text-align: center;
    padding: 0.25rem;
    border-radius: var(--pico-border-radius);
    font-size: 0.85rem;
    font-weight: 600;
}

.vote-chip.low { background: #fee2e2; color: #991b1b; }
.vote-chip.mid { background: #fef9c3; color: #854d0e; }
.vote-chip.high { background: #dcfce7; color: #166534; }

/* Rating badges */
.rating-badge {
    display: inline-block;
    min-width: 2em;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9em;
    line-height: 1.4;
    color: #fff;
}

.rb-1  { background-color: #d32f2f; }
.rb-30 { background-color: #e64a19; }
.rb-40 { background-color: #f57c00; }
.rb-50 { background-color: #fbc02d; color: #333; }
.rb-60 { background-color: #c0ca33; color: #333; }
.rb-70 { background-color: #7cb342; }
.rb-80 {
	background: linear-gradient(135deg, #2e7d32, #43a047, #2e7d32);
    box-shadow: 0 0 6px rgba(67, 160, 71, 0.5);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.rb-90 {
    background: linear-gradient(135deg, #b8860b, #ffd700, #b8860b);
    color: #1a1a1a;
	box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}
.rb-95 {
    background: linear-gradient(135deg, #b8860b, #ffd700, #b8860b);
    color: #1a1a1a;
	box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* Provisional rating badge */
.rating-provisional {
    background-color: #e0e0e0;
    color: #9e9e9e;
}

.provisional-row {
    opacity: 0.7;
}

/* Rating badge sizes */
.rating-badge-lg {
    font-size: 2.5rem;
    padding: 0.3em 0.5em;
    min-width: 2em;
    border-radius: 8px;
}

.rating-badge-md {
    font-size: 1.4rem;
    padding: 0.25em 0.45em;
    min-width: 2em;
    border-radius: 6px;
}

/* Player profile rating layout */
.player-rating-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.player-rating-hero-label {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--pico-muted-color);
}

.player-rating-cats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.player-rating-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.player-rating-cat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--pico-muted-color);
    text-align: center;
}

/* Received ratings section */
.received-ratings {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--pico-muted-border-color);
}

/* Season history section */
.season-history-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--pico-muted-border-color);
}

/* Team page */
.team-header {
    margin-bottom: 2rem;
}

/* Admin */
.admin-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.admin-nav a {
    padding: 0.5rem 1rem;
    border-radius: var(--pico-border-radius);
    text-decoration: none;
    border: 1px solid var(--pico-primary);
}

.admin-nav a.active {
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
}

/* Collapsible action cards (admin players) */
.admin-action {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color, var(--pico-muted-border-color));
    border-radius: var(--pico-border-radius);
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.admin-action > summary {
    font-weight: 600;
    padding: 1rem 0;
    cursor: pointer;
}

.admin-action[open] {
    padding-bottom: 1rem;
}

.admin-action[open] > summary {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--pico-primary);
}

.stat-card .stat-label {
    color: var(--pico-muted-color);
}

/* Alert messages */
.alert {
    padding: 1rem;
    border-radius: var(--pico-border-radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde68a;
}

/* Season history table */
.season-history td,
.season-history th {
    text-align: center;
}

.season-history td:first-child,
.season-history th:first-child {
    text-align: left;
}

/* Emoji buttons (aura) */
.emoji-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.emoji-buttons button {
    width: 50px;
    height: 50px;
    padding: 0;
    margin: 0;
    font-size: 1.5rem;
    cursor: pointer;
    border: 1px solid var(--pico-primary);
    background: transparent;
    color: var(--pico-primary);
    border-radius: var(--pico-border-radius);
    transition: background-color 0.15s, color 0.15s;
}

.emoji-buttons button.selected {
    background: var(--pico-primary);
}

.emoji-buttons button:hover {
    background: var(--pico-primary-focus);
}

.emoji-buttons button.selected:hover {
    background: var(--pico-primary-hover);
}

/* Player aura display */
.player-aura {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.player-aura-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--pico-muted-color);
}

.player-aura-emoji {
    font-size: 2rem;
    line-height: 1;
}

/* Leaderboard aura column */
.leaderboard-aura {
    font-size: 1.2rem;
}

/* Language switcher */
.lang-switcher a {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--pico-primary);
    border-radius: var(--pico-border-radius);
    text-decoration: none;
}

/* Wrapped button */
.btn-wrapped {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff !important;
    border: none;
    padding: 0.6rem 1.4rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-wrapped:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.55);
    color: #fff !important;
}

.btn-wrapped:active {
    transform: translateY(0);
}

.leaderboard-controls > .leaderboard-wrapped {
    display: flex;
    align-items: center;
    margin-left: auto;
    flex: 0 0 auto;
    min-width: 0;
    align-self: center;
}

/* Home page players grid */
.home-players-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.home-player-card {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 10px;
    padding: 0.4rem 0.75rem;
    font-size: 0.92rem;
    white-space: nowrap;
    text-decoration: none;
    color: var(--pico-color);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.home-player-card:hover {
    transform: translateY(-2px);
    border-color: var(--pico-primary);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    color: var(--pico-color);
}

.home-player-name {
    font-weight: 500;
}

/* Sticky table headers */
figure:has(table) {
    overflow-x: clip;
}

/* On narrow screens allow horizontal scrolling of wide tables.
   overflow-x: auto is needed for the scroll, but it breaks the page-level
   sticky headers above, so it's only applied where the table can't fit. */
@media (max-width: 768px) {
    figure:has(table) {
        overflow-x: auto;
    }
}

figure:has(table) thead th {
    position: sticky;
    top: 0;
    background: var(--pico-background-color, #fff);
    z-index: 1;
    box-shadow: 0 1px 0 var(--pico-muted-border-color);
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.2em;
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.3em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75em;
    opacity: 0.4;
}

th.sortable.sort-asc::after {
    content: '↑';
    opacity: 1;
}

th.sortable.sort-desc::after {
    content: '↓';
    opacity: 1;
}

th.sortable.sort-asc,
th.sortable.sort-desc {
    font-weight: 900;
}

th.sortable:hover {
    text-decoration: underline;
}

/* Leaderboard category columns — uniform width */
.col-category {
    width: 90px;
    min-width: 90px;
    text-align: center;
}

/* Responsive tweaks */
@media (max-width: 768px) {
    nav ul {
        flex-wrap: wrap;
    }

    .leaderboard-controls {
        flex-direction: column;
    }

    .rating-buttons button {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }

    .emoji-buttons button {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
}
