/* ── Stats Page ─────────────────────────────────────────── */

.stats-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 24px 80px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Centered top-of-page caption. Slight dark pill so it reads cleanly against
   the page bg without over-shouting. */
.stats-tagline {
    color: rgba(240, 236, 230, 0.78);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-align: center;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 6px 14px;
    align-self: center;
    max-width: 100%;
}

.stats-stats-start {
    color: rgba(240, 236, 230, 0.65);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    text-align: center;
    margin-top: -8px;
    min-height: 1em;
}

/* Admin-only manual recompute control. Sits above the tabs, only revealed by
   stats.js when the signed-in user has admin=true; the endpoint also enforces
   admin server-side, so the CSS hide is purely UX. */
.stats-admin-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 191, 0, 0.18);
    border-radius: 8px;
    padding: 8px 14px;
    align-self: center;
    max-width: 100%;
}

.stats-admin-info {
    color: rgba(240, 236, 230, 0.78);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
}

.stats-admin-btn {
    background: rgba(255, 191, 0, 0.18);
    border: 1px solid rgba(255, 191, 0, 0.45);
    color: #ffbf00;
    padding: 6px 14px;
    border-radius: 6px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.2s;
}

.stats-admin-btn:hover { background: rgba(255, 191, 0, 0.3); }
.stats-admin-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Tabs ─────────────────────────────────────────────────── */
.stats-tabs {
    display: flex;
    gap: 0;
    background: rgba(8, 8, 8, 0.7);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 10px;
    padding: 4px;
    flex-wrap: wrap;
}

.stats-tab {
    flex: 1 1 auto;
    min-width: 110px;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    color: rgba(240, 236, 230, 0.45);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.75rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    position: relative;
}

.stats-tab:hover {
    color: rgba(240, 236, 230, 0.8);
    background: rgba(255, 255, 255, 0.04);
}

.stats-tab.active {
    background: rgba(255, 191, 0, 0.15);
    color: #ffbf00;
}

.stats-lock-icon {
    font-size: 0.7rem;
    margin-left: 6px;
    opacity: 0.55;
}

.stats-tab-premium.stats-unlocked .stats-lock-icon {
    display: none;
}

/* ── Panels ──────────────────────────────────────────────── */
.stats-panel {
    display: none;
    position: relative;
}

.stats-panel.active {
    display: block;
}

.stats-content {
    transition: filter 0.2s;
}

.stats-content-locked {
    filter: blur(4px) saturate(0.5);
    pointer-events: none;
    user-select: none;
}

/* ── Lock Overlay ────────────────────────────────────────── */
/* Popup is anchored to the top of the panel (just under the tabs) instead of
   centered. Centering looked fine on average-height panels, but tall ones (Decks)
   pushed the popup hundreds of pixels off-screen and short ones (Matchup) made
   the larger popup card overflow above the panel into the tab row. */
.stats-locked-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: rgba(14, 14, 14, 0.55);
    backdrop-filter: blur(2px);
    border-radius: 14px;
    padding: 24px 16px;
    box-sizing: border-box;
}

.stats-locked-overlay[hidden] {
    display: none;
}

/* Locked panels get a comfortable min-height so the popup card never overflows
   above the panel's top edge into the tabs (which happens when the panel's
   actual content is shorter than the popup itself). :has() lets us target only
   the panels currently showing an unhidden lock overlay. */
.stats-panel.active:has(.stats-locked-overlay:not([hidden])) {
    min-height: 340px;
}

.stats-lock-content {
    background: rgba(8, 8, 8, 0.92);
    border: 1px solid rgba(255, 191, 0, 0.35);
    border-radius: 14px;
    padding: 28px 36px;
    text-align: center;
    max-width: 380px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.stats-lock-content i.fas.fa-lock {
    font-size: 1.8rem;
    color: #ffbf00;
    margin-bottom: 10px;
}

.stats-lock-content h3 {
    font-family: 'Dragon Slayer', serif;
    color: #ffbf00;
    margin: 6px 0 10px;
    letter-spacing: 1px;
}

.stats-lock-content p {
    font-family: 'HwyGothic', Arial, sans-serif;
    color: rgba(240, 236, 230, 0.7);
    margin: 0 0 16px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.stats-subscribe-btn {
    display: inline-block;
    background: rgba(255, 191, 0, 0.15);
    border: 1px solid rgba(255, 191, 0, 0.5);
    color: #ffbf00;
    padding: 10px 28px;
    border-radius: 10px;
    font-family: 'HwyGothic', Arial, sans-serif;
    letter-spacing: 2px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.stats-subscribe-btn:hover {
    background: rgba(255, 191, 0, 0.28);
}

/* Inline column blur (premium-only columns when locked) */
.stats-blurred {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* ── Action Bar (search, buttons) ────────────────────────── */
.stats-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.stats-search {
    flex: 1;
    min-width: 200px;
    background: rgba(8, 8, 8, 0.7);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 10px;
    padding: 10px 16px;
    color: #f0ece6;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    outline: none;
    transition: border-color 0.2s;
}

.stats-search:focus {
    border-color: rgba(255, 191, 0, 0.35);
}

.stats-search::placeholder {
    color: rgba(240, 236, 230, 0.3);
}

.stats-btn-primary,
.stats-btn-secondary {
    background: rgba(255, 191, 0, 0.15);
    border: 1px solid rgba(255, 191, 0, 0.3);
    border-radius: 10px;
    padding: 10px 18px;
    color: #ffbf00;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.8rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.2s;
}

.stats-btn-primary:hover,
.stats-btn-secondary:hover {
    background: rgba(255, 191, 0, 0.28);
}

.stats-btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(240, 236, 230, 0.85);
    border-color: rgba(255, 255, 255, 0.12);
}

.stats-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ── Tables ──────────────────────────────────────────────── */
.stats-table-wrap {
    background: rgba(8, 8, 8, 0.84);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 14px;
    overflow: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table th,
.stats-table td {
    padding: 3px 14px;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.82rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 191, 0, 0.06);
    text-align: center;
    white-space: nowrap;
    line-height: 1.2;
}

.stats-table th {
    padding-top: 6px;
    padding-bottom: 6px;
}

.stats-table th {
    background: rgba(255, 191, 0, 0.08);
    color: #ffbf00;
    font-size: 0.7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 1;
}

.stats-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.stats-table th.sortable:hover {
    background: rgba(255, 191, 0, 0.14);
}

.stats-table td {
    color: rgba(240, 236, 230, 0.82);
}

.stats-table tr:hover td {
    background: rgba(255, 191, 0, 0.03);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-num {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.stats-loading {
    text-align: center;
    color: rgba(240, 236, 230, 0.6);
    font-style: italic;
    padding: 24px 16px;
}

.stats-card-link {
    color: rgba(240, 236, 230, 0.92);
    text-decoration: none;
    border-bottom: 1px dotted rgba(255, 191, 0, 0.3);
}

.stats-card-link:hover {
    color: #ffbf00;
}

.stats-delta-pos { color: #6dd47e; }
.stats-delta-neg { color: #f47670; }

/* ── Section Titles & Notes ──────────────────────────────── */
.stats-section-title {
    font-family: 'Dragon Slayer', serif;
    color: #ffbf00;
    font-size: 1.1rem;
    letter-spacing: 1.5px;
    margin: 16px 0 8px;
}

/* Captions/notes that sit underneath section titles. Slight dark pill keeps
   them legible against the dark page bg, matching the .admin-result-count look. */
.stats-section-note {
    color: rgba(240, 236, 230, 0.78);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.8rem;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 6px 12px;
    display: inline-block;
    max-width: 100%;
}

/* ── Matchup ─────────────────────────────────────────────── */
.stats-matchup-pickers {
    display: flex;
    align-items: end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stats-matchup-pick {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 180px;
}

.stats-matchup-pick label {
    color: rgba(240, 236, 230, 0.55);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.stats-matchup-pick select {
    background: rgba(8, 8, 8, 0.7);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 10px;
    padding: 10px 14px;
    color: #f0ece6;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.85rem;
    outline: none;
}

.stats-matchup-vs {
    color: #ffbf00;
    font-family: 'Dragon Slayer', serif;
    font-size: 1.1rem;
    padding-bottom: 8px;
}

.stats-matchup-card {
    background: rgba(8, 8, 8, 0.84);
    border: 1px solid rgba(255, 191, 0, 0.18);
    border-radius: 14px;
    padding: 22px 24px;
}

.stats-matchup-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-family: 'Dragon Slayer', serif;
    font-size: 1.4rem;
    color: #ffbf00;
    letter-spacing: 1.5px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.stats-matchup-amp {
    color: rgba(240, 236, 230, 0.45);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.95rem;
}

.stats-matchup-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    text-align: center;
}

.stats-matchup-stats > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stats-stat-label {
    font-family: 'HwyGothic', Arial, sans-serif;
    color: rgba(240, 236, 230, 0.5);
    font-size: 0.75rem;
    letter-spacing: 2px;
}

.stats-stat-value {
    font-family: 'HwyGothic', Arial, sans-serif;
    color: #ffbf00;
    font-size: 1.4rem;
    letter-spacing: 1px;
}

/* ── Trend Chart ─────────────────────────────────────────── */
.stats-chart-wrap {
    background: rgba(8, 8, 8, 0.84);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 14px;
    padding: 16px;
    height: 360px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media only screen and ((max-width: 767px) or (hover: none)) {
    .stats-page {
        padding: 16px 12px 60px;
    }

    .stats-tab {
        padding: 8px 10px;
        font-size: 0.7rem;
        letter-spacing: 1px;
        min-width: 90px;
    }

    .stats-table th,
    .stats-table td {
        padding: 2px 9px;
        font-size: 0.76rem;
    }
    .stats-table th {
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .stats-matchup-stats {
        grid-template-columns: 1fr;
    }

    .stats-chart-wrap {
        height: 280px;
    }
}
