/* ==========================================================================
   Player stats table – responsive, sortable, searchable
   Scoped under .st-* so it never clashes with common.css.
   ========================================================================== */

.st-page {
    --st-font: clamp(0.75rem, 0.62rem + 0.65vw, 0.875rem);
    --st-font-head: clamp(0.6rem, 0.54rem + 0.3vw, 0.7rem);
    --st-cell-x: clamp(0.25rem, 0.05rem + 0.6vw, 0.5rem);
    --st-cell-y: clamp(0.4rem, 0.3rem + 0.4vw, 0.65rem);
    --st-player-col: clamp(7.5rem, 4rem + 13vw, 15rem);
    --st-logo: clamp(1.1rem, 0.9rem + 0.9vw, 1.5rem);

    --st-line: #e4e8ec;
    --st-line-strong: #c9d2d8;
    --st-text: #1f2a30;
    --st-muted: #6b7a83;
    --st-accent: #15607a;
    --st-row: #ffffff;
    --st-row-alt: #f7f9fa;
    --st-row-hover: #e8f1f5;

    max-width: 1300px;
    margin: 0 auto;
    padding: clamp(0.75rem, 0.5rem + 1.5vw, 1.5rem);
    color: var(--st-text);
}

.st-page h1 {
    font-size: clamp(1.25rem, 1rem + 1.8vw, 1.75rem);
    text-align: center;
    margin-bottom: 0.4rem;
}

.st-intro {
    text-align: center;
    color: var(--st-muted);
    font-size: clamp(0.8rem, 0.74rem + 0.3vw, 0.95rem);
    line-height: 1.5;
    max-width: 40rem;
    margin: 0 auto 1.25rem;
}

.st-intro a { color: var(--st-accent); }

/* --- toolbar ------------------------------------------------------------ */

.st-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    margin-bottom: 0.75rem;
}

.st-search {
    flex: 1 1 14rem;
    position: relative;
}

.st-search input {
    width: 100%;
    padding: 0.55rem 2.2rem 0.55rem 0.8rem;
    border: 1px solid var(--st-line-strong);
    border-radius: 999px;
    font: inherit;
    font-size: clamp(0.85rem, 0.8rem + 0.25vw, 1rem);
    background: #fff;
    color: inherit;
}

.st-search input:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 1px;
}

.st-search-clear {
    all: unset;
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--st-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.st-search-clear:hover { background: var(--st-row-alt); color: var(--st-text); }
.st-search-clear[hidden] { display: none; }

.st-toggle,
.st-select {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.85rem);
    color: var(--st-text);
    background: #fff;
    border: 1px solid var(--st-line-strong);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    white-space: nowrap;
}

.st-toggle:focus-within,
.st-select:focus-within {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
}

.st-toggle input { accent-color: var(--st-accent); margin: 0; }

.st-select select {
    border: none;
    background: transparent;
    font: inherit;
    color: inherit;
    cursor: pointer;
    padding: 0;
}

.st-select select:focus { outline: none; }

.st-count {
    font-size: 0.75rem;
    color: var(--st-muted);
    margin-left: auto;
}

/* --- table shell -------------------------------------------------------- */

.st-card {
    background: #fff;
    border: 1px solid var(--st-line);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(16, 32, 40, 0.08);
    overflow: hidden;
}

.st-scroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.st-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--st-font);
    font-variant-numeric: tabular-nums;
}

/* --- header ------------------------------------------------------------- */

.st-table th {
    background: #fff;
    font-weight: 600;
    color: var(--st-muted);
    font-size: var(--st-font-head);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.5rem var(--st-cell-x) 0.4rem;
    text-align: center;
    white-space: nowrap;
    border-bottom: 2px solid var(--st-line-strong);
    vertical-align: bottom;
}

.st-sort {
    all: unset;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    cursor: pointer;
    font: inherit;
    color: inherit;
    padding: 0.15rem 0.1rem;
    border-radius: 0.25rem;
    width: 100%;
    line-height: 1.15;
}

.st-sort:hover { color: var(--st-accent); }

.st-sort:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 1px;
}

.st-th-sub {
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    opacity: 0.8;
}

.st-th-arrow { font-size: 0.85em; opacity: 0.35; }
.st-th-arrow::before { content: "↕"; }
th[aria-sort="ascending"] .st-th-arrow::before { content: "↑"; }
th[aria-sort="descending"] .st-th-arrow::before { content: "↓"; }
th[aria-sort] .st-th-arrow { opacity: 1; }
th[aria-sort] .st-sort { color: var(--st-accent); }

.st-table .st-c-player .st-sort { align-items: flex-start; }

/* On phones the idle arrows go; only the sorted column keeps its arrow. */
@media (max-width: 559.98px) {
    .st-th-arrow { display: none; }
    th[aria-sort] .st-th-arrow { display: inline; }
}

/* --- body --------------------------------------------------------------- */

.st-table td,
.st-table tbody th {
    padding: var(--st-cell-y) var(--st-cell-x);
    text-align: center;
    border-bottom: 1px solid var(--st-line);
    background: var(--st-row);
    white-space: nowrap;
}

.st-table tbody th {
    color: var(--st-text);
    font-size: var(--st-font);
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    border-bottom: 1px solid var(--st-line);
}

/* Zebra on the cells so the sticky player column stays opaque. */
.st-table tbody tr:nth-child(even) > * { background: var(--st-row-alt); }
.st-table tbody tr:hover > * { background: var(--st-row-hover); }
.st-table tbody tr:last-child > * { border-bottom: none; }

/* Colour-scaled cells paint over the zebra; hover still gets a tint. */
.st-table tbody tr td.st-scaled { background: var(--st-scale); }
.st-table tbody tr:hover td.st-scaled {
    background: color-mix(in srgb, var(--st-scale) 70%, var(--st-row-hover));
}

.st-table .st-c-player {
    position: sticky;
    left: 0;
    z-index: 2;
    text-align: left;
    box-shadow: 4px 0 6px -4px rgba(16, 32, 40, 0.25), 1px 0 0 var(--st-line);
}

.st-table thead .st-c-player { z-index: 3; }

/* The player column gets its token width; the stat columns share the rest
   evenly instead of the player column swallowing all the slack. */
.st-table thead .st-c-player { width: var(--st-player-col); }

.st-label-short { display: none; }

@media (max-width: 559.98px) {
    .st-label-full { display: none; }
    .st-label-short { display: inline; }
}

/* The player block has an explicit width, which is what lets long names
   truncate instead of stretching the sticky column. */
.st-player {
    display: flex;
    align-items: center;
    gap: clamp(0.4rem, 0.3rem + 0.5vw, 0.6rem);
    width: var(--st-player-col);
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.st-player:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.st-logo {
    width: var(--st-logo);
    height: var(--st-logo);
    object-fit: contain;
    flex: none;
}

.st-player-text { min-width: 0; line-height: 1.2; }

.st-player-name {
    display: block;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-player-team {
    display: block;
    font-size: 0.8em;
    color: var(--st-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.st-player:hover .st-player-name { color: var(--st-accent); text-decoration: underline; }

.st-strong { font-weight: 700; }

/* --- states ------------------------------------------------------------- */

.st-status {
    padding: 1.5rem;
    text-align: center;
    color: var(--st-muted);
    font-size: 0.9rem;
}

.st-status--error { color: #c62828; }

.st-skeleton td span {
    display: block;
    height: 0.7rem;
    border-radius: 0.35rem;
    background: linear-gradient(90deg, #eef1f3 25%, #e2e7ea 37%, #eef1f3 63%);
    background-size: 400% 100%;
    animation: st-shimmer 1.2s ease-in-out infinite;
}

@keyframes st-shimmer {
    from { background-position: 100% 50%; }
    to { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .st-skeleton td span { animation: none; }
}

/* --- pagination --------------------------------------------------------- */

.st-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem;
    border-top: 1px solid var(--st-line);
    background: #fff;
}

.st-pager button {
    all: unset;
    min-width: 2.1rem;
    padding: 0.35rem 0.55rem;
    text-align: center;
    border: 1px solid var(--st-line-strong);
    border-radius: 0.4rem;
    font-size: 0.8rem;
    color: var(--st-text);
    cursor: pointer;
    box-sizing: border-box;
}

.st-pager button:hover:not(:disabled) { background: var(--st-row-hover); }

.st-pager button:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 1px;
}

.st-pager button[aria-current="page"] {
    background: var(--st-accent);
    border-color: var(--st-accent);
    color: #fff;
    font-weight: 600;
}

.st-pager button:disabled { opacity: 0.45; cursor: not-allowed; }

.st-pager-gap { color: var(--st-muted); padding: 0 0.2rem; }

.st-pager-info {
    flex-basis: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: var(--st-muted);
    margin-top: 0.25rem;
}

.st-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- column priorities --------------------------------------------------
   Narrow screens show the headline numbers; wider screens add detail.
   "All columns" overrides this and falls back to horizontal scrolling with
   the player column pinned.
   ----------------------------------------------------------------------- */

.st-p1, .st-p2, .st-p3 { display: none; }

@media (min-width: 680px) { .st-p1 { display: table-cell; } }
@media (min-width: 980px) { .st-p2 { display: table-cell; } }
@media (min-width: 1180px) { .st-p3 { display: table-cell; } }

.st-card.is-full .st-p1,
.st-card.is-full .st-p2,
.st-card.is-full .st-p3 { display: table-cell; }

.st-card.is-full .st-table { min-width: 64rem; }

/* The toggle only matters while columns are actually hidden. */
@media (min-width: 1180px) { .st-toggle--columns { display: none; } }

/* data-max-prio is the highest priority among the loaded columns. */
.st-page[data-max-prio="0"] .st-toggle--columns { display: none; }
@media (min-width: 680px) { .st-page[data-max-prio="1"] .st-toggle--columns { display: none; } }
@media (min-width: 980px) { .st-page[data-max-prio="2"] .st-toggle--columns { display: none; } }

/* --- league / season selects (the "all" pages) --------------------------- */

.st-selects {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.st-selects select {
    padding: 0.45rem 0.8rem;
    font: inherit;
    font-size: clamp(0.85rem, 0.8rem + 0.25vw, 1rem);
    border: 1px solid var(--st-line-strong);
    border-radius: 0.5rem;
    background: #fff;
    color: inherit;
}
