/*
 * Public Judges Scores — themed via .portal-page-themed + portal-components.css tokens.
 */

.ji-scores-main {
    --ji-scores-footer-gap: 1.5rem;
    --ji-scores-footer-offset: calc(var(--portal-chrome-offset-top) + var(--portal-chrome-offset-bottom) + var(--ji-scores-footer-gap));

    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--portal-chrome-offset-top));
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.ji-scores-toolbar {
    flex: 0 0 auto;
}

.ji-scores-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
}

.ji-scores-panel > .card-header {
    flex-shrink: 0;
}

.ji-scores-panel > .card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ji-scores-picker {
    flex-shrink: 0;
}

.ji-scores-loading {
    flex-shrink: 0;
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--portal-c-text-muted);
}

#view-scores-table {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ji-scores-results {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ji-scores-results-toolbar {
    flex-shrink: 0;
}

.ji-scores-table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.ji-scores-table-scroll .table-responsive {
    overflow: visible;
}

.ji-scores-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}

.ji-scores-card-header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.ji-scores-total-badge {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background-color: var(--portal-c-badge-muted-bg) !important;
    color: var(--portal-c-badge-muted-color) !important;
    border: 1px solid var(--portal-c-border);
}

/* Data table */
.portal-page-themed .ji-public-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--portal-c-text);
    --bs-table-border-color: var(--portal-c-border-subtle);
    --bs-table-hover-bg: var(--portal-c-tab-hover);
    margin-bottom: 0;
    font-size: 0.8125rem;
}

.portal-page-themed .ji-public-table thead th {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--portal-c-text-muted);
    border-bottom-color: var(--portal-c-border);
    padding-top: 0.5rem;
    padding-bottom: 0.625rem;
    white-space: nowrap;
    background-color: var(--portal-c-tab-track);
}

.portal-page-themed .ji-public-table tbody td {
    vertical-align: middle;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom-color: var(--portal-c-border-subtle);
    white-space: nowrap;
}

.portal-page-themed .ji-public-table tbody tr:last-child td {
    border-bottom: none;
}

.ji-scores-table-scroll .ji-public-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Winner highlight */
.portal-page-themed .judge-score-td-bg-pink {
    --bs-table-bg: rgba(207, 35, 202, 0.22);
    --bs-table-color: var(--portal-c-text);
    font-weight: 600;
}

.portal-page-themed .judge-score-td-bg-blue {
    --bs-table-bg: rgba(0, 218, 216, 0.18);
    --bs-table-color: var(--portal-c-text);
    font-weight: 600;
}

.portal-page-themed[data-bs-theme="light"] .judge-score-td-bg-pink {
    --bs-table-bg: rgba(207, 35, 202, 0.12);
}

.portal-page-themed[data-bs-theme="light"] .judge-score-td-bg-blue {
    --bs-table-bg: rgba(0, 168, 166, 0.12);
}

/* Sortable columns */
.portal-page-themed .ji-public-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 1.5rem;
    user-select: none;
}

.portal-page-themed .ji-public-table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 0.4rem;
    color: var(--portal-c-text-muted);
    font-size: 0.75rem;
}

.portal-page-themed .ji-public-table th.sortable.sort-asc::after {
    content: '↑';
    color: var(--portal-c-accent);
}

.portal-page-themed .ji-public-table th.sortable.sort-desc::after {
    content: '↓';
    color: var(--portal-c-accent);
}

/* Icon and message sit together on one centered row. Explicit centering rather than
   relying on inherited text-align: this block is a flex item of #view-scores-table. */
.ji-scores-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--portal-c-text-muted);
}

.ji-scores-empty i {
    font-size: 1.75rem;
    opacity: 0.45;
}

@media (max-width: 991.98px) {
    .ji-scores-main {
        height: auto;
        min-height: calc(100dvh - var(--portal-chrome-offset-top));
        overflow: visible;
    }

    .ji-scores-panel,
    .ji-scores-panel > .card-body,
    #view-scores-table,
    .ji-scores-results {
        flex: none;
        overflow: visible;
    }

    .ji-scores-table-scroll {
        flex: none;
        height: 55dvh;
        max-height: calc(100dvh - var(--ji-scores-footer-offset) - 13rem);
        min-height: 14rem;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
    }

    .ji-scores-table-scroll .ji-public-table thead th {
        position: static;
    }
}

@media (min-width: 992px) {
    .ji-scores-main {
        --ji-scores-chrome: 12rem;
    }

    .ji-scores-table-scroll {
        max-height: calc(100dvh - var(--ji-scores-footer-offset) - var(--ji-scores-chrome));
    }
}
