/* ============================================================================
   PACK CHALLENGES — challenges + leaderboards (member page)
   Theme: navy #0a1628 / #0f1a2e / #16223c + gold #c8a03c. No emoji icons.
   ============================================================================ */
.challenges-page {
    width: 100%;
    padding: 1.5rem 1rem 4rem;
    color: #fff;
}

.challenges-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.challenges-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.challenges-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: #c8a03c;
    background: #16223c;
    border: 1px solid rgba(200, 160, 60, 0.35);
    flex-shrink: 0;
}
.challenges-title h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: #fff;
}
.challenges-title p {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.btn-challenge-create {
    flex-shrink: 0;
    background: linear-gradient(135deg, #c8a03c, #b8972e);
    color: #0a1628;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1.1rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
}
.btn-challenge-create:hover { filter: brightness(1.08); }
.btn-challenge-create:active { transform: translateY(1px); }

/* ---- Scope tabs (My / Organisation / Squad / Global / HYROX) ---- */
.challenge-tabbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.6rem;
}
.challenge-tabbar:empty { display: none; }
.challenge-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #16223c;
    color: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.42rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.challenge-tab:hover {
    color: #fff;
    border-color: rgba(200, 160, 60, 0.4);
}
.challenge-tab.active {
    background: linear-gradient(135deg, #c8a03c, #b8972e);
    color: #0a1628;
    border-color: #c8a03c;
}
.challenge-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 0.3rem;
    border-radius: 9px;
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(10, 22, 40, 0.18);
    color: inherit;
}
.challenge-tab:not(.active) .challenge-tab-count {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
}
.challenge-hyrox-pane[hidden],
.challenges-list[hidden] { display: none; }
.challenge-hyrox-pane > .hyrox-standings:first-child,
.challenge-hyrox-pane > .hyrox-standings { margin-top: 0; }
.challenge-hyrox-pane > .hyrox-standards { margin-top: 1.25rem; }
/* Compact the standings: lay division+category groups in a responsive grid
   instead of one long stacked column, and tighten the per-group spacing. */
.challenge-hyrox-pane #hyrox-standings-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.85rem 1rem;
    align-items: start;
}
.challenge-hyrox-pane .hyrox-standings-group,
.challenge-hyrox-pane .hyrox-standings-group:first-of-type { margin-top: 0; }
.challenge-hyrox-pane .hyrox-standings-empty,
.challenge-hyrox-pane .hyrox-standings-loading { grid-column: 1 / -1; }
.challenge-hyrox-pane .hyrox-standings-table { min-width: 0; font-size: 0.8rem; }
.challenge-hyrox-pane .hyrox-standings-table thead th,
.challenge-hyrox-pane .hyrox-standings-table tbody td { padding: 0.4rem 0.6rem; }

.challenges-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1rem;
    align-items: start;
}
@media (max-width: 560px) {
    .challenges-list { grid-template-columns: 1fr; }
}
.challenges-loading,
.challenges-empty,
.challenge-lb-empty {
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.9rem;
}
.challenges-loading-sm { padding: 0.6rem; font-size: 0.8rem; }
.challenges-empty {
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    background: #0f1a2e;
}

/* ---- Challenge card ---- */
.challenge-card {
    background: #0f1a2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.1rem 1.15rem;
}
.challenge-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}
.challenge-name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.challenge-global-tag {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #c8a03c;
    border: 1px solid rgba(200, 160, 60, 0.5);
    border-radius: 6px;
    padding: 0.1rem 0.4rem;
}
.challenge-desc {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.4;
}
.btn-challenge-submit {
    flex-shrink: 0;
    background: transparent;
    color: #c8a03c;
    border: 1px solid rgba(200, 160, 60, 0.6);
    border-radius: 9px;
    padding: 0.5rem 0.9rem;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-challenge-submit:hover { background: #c8a03c; color: #0a1628; }

.challenge-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.85rem 0 0.25rem;
}
.challenge-chip {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.7);
    background: #16223c;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    padding: 0.22rem 0.6rem;
}
.challenge-mybest {
    margin-left: auto;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.8);
}
.challenge-mybest strong { color: #c8a03c; }
.challenge-mybest-empty { color: rgba(255, 255, 255, 0.4); }

/* ---- Leaderboard ---- */
.challenge-leaderboard {
    margin-top: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.challenge-lb-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
}
.challenge-lb-row.is-me {
    background: rgba(200, 160, 60, 0.12);
    border: 1px solid rgba(200, 160, 60, 0.3);
}
.challenge-lb-rank {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    background: #16223c;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.challenge-lb-rank.rank-1 { background: #c8a03c; color: #0a1628; border-color: #c8a03c; }
.challenge-lb-rank.rank-2 { background: #c7ccd6; color: #0a1628; border-color: #c7ccd6; }
.challenge-lb-rank.rank-3 { background: #c08a4a; color: #0a1628; border-color: #c08a4a; }
.challenge-lb-name {
    flex: 1;
    font-size: 0.88rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.challenge-lb-you {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #c8a03c;
    border: 1px solid rgba(200, 160, 60, 0.5);
    border-radius: 5px;
    padding: 0.05rem 0.35rem;
}
.challenge-lb-value {
    flex-shrink: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #c8a03c;
}

/* Modal sub-title reused by submit/create modals */
.challenge-modal-sub {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}
.challenge-global-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0.25rem 0 1rem;
    cursor: pointer;
}
.challenge-global-toggle input { accent-color: #c8a03c; }

@media (max-width: 560px) {
    .challenges-header { flex-direction: column; align-items: stretch; }
    .btn-challenge-create { width: 100%; }
    .challenge-mybest { margin-left: 0; width: 100%; }
}

/* ============================================================================
   CHALLENGE TILES — each challenge (and HYROX) is a tile showing its podium
   (1st/2nd/3rd). Tapping a tile opens the full detail (leaderboard + submit,
   or the HYROX standings + standards). Responsive grid: 1-up on phones, 2+ on
   wider screens.
   ============================================================================ */
.challenge-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.challenge-tile {
    background: var(--card-bg, #142238);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.05s ease;
    -webkit-tap-highlight-color: transparent;
}
.challenge-tile:hover { border-color: var(--gold, #c8a03c); }
.challenge-tile:active { transform: scale(0.99); }
.challenge-tile-hyrox { border-color: rgba(200, 160, 60, 0.4); }
.challenge-tile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}
.challenge-tile-name { font-size: 1.05rem; font-weight: 700; color: #fff; }
.ct-tag {
    flex: 0 0 auto;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gold, #c8a03c);
    border: 1px solid rgba(200, 160, 60, 0.4);
    border-radius: 999px;
    padding: 2px 8px;
}
.challenge-tile-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 12px;
}
.challenge-tile-podium { display: flex; flex-direction: column; gap: 7px; }
.ct-podium-row { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.ct-rank {
    flex: 0 0 auto;
    min-width: 30px;
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
}
.ct-rank-1 { color: #f0d77c; }
.ct-rank-2 { color: #cfd4dc; }
.ct-rank-3 { color: #d8a07a; }
.ct-name {
    flex: 1;
    min-width: 0;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ct-value { flex: 0 0 auto; font-weight: 600; color: rgba(255, 255, 255, 0.85); }
.ct-podium-empty, .ct-podium-loading {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    padding: 4px 0;
}

/* In the detail modal the modal header already shows the name, so hide the
   card's own duplicate title (keep its description, submit + leaderboard). */
/* On the detail PAGE the back-title already shows the name, so hide the card's
   own title and strip its card chrome (it's the page now, not a tile). */
.challenge-detail-page .challenge-name { display: none !important; }
.challenge-detail-page .challenge-card {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}
/* The challenge's description + meta + submit sit in a tight guide card, the
   leaderboard table is the majority below. */
.challenge-detail-page .challenge-card-head { margin-bottom: 8px !important; }
.challenge-detail-page .challenge-leaderboard { margin-top: 4px !important; }

/* ============================================================================
   DETAIL AS A PAGE (HYROX / any challenge) — replaces the modal. Thin back-title
   header, a tight guide strip, and the results table as the majority.
   ============================================================================ */
.challenge-detail-page { display: flex; flex-direction: column; gap: 12px; }
.cdp-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
}
.cdp-back svg { color: rgba(255, 255, 255, 0.55); flex: 0 0 auto; }
.cdp-back:hover svg { color: var(--gold, #c8a03c); }
.cdp-body { display: flex; flex-direction: column; gap: 12px; }

/* Tight guide + standings cards (were oversized modal cards). */
.challenge-detail-page .hyrox-standards,
.challenge-detail-page .hyrox-standings {
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    padding: 12px 14px !important;
    margin: 0 !important;
}
.challenge-detail-page .hyrox-standards-head h2,
.challenge-detail-page .hyrox-standings-head h2 {
    font-size: 0.95rem !important;
    margin: 0 0 3px 0 !important;
}
.challenge-detail-page .hyrox-standards-head p,
.challenge-detail-page .hyrox-standings-head p {
    font-size: 0.78rem !important;
    line-height: 1.35 !important;
    margin: 0 0 10px 0 !important;
    color: rgba(255, 255, 255, 0.55) !important;
}
.challenge-detail-page .hyrox-standings-head { margin-bottom: 6px; }
/* The table is the majority — let it grow; the page scrolls. */
.challenge-detail-page .results-table-wrap { max-height: none !important; }

/* (legacy modal width kept harmless in case any modal still uses the class) */
@media (min-width: 769px) {
    .challenge-detail-modal {
        max-width: 1100px !important;
        width: min(1100px, 92vw) !important;
        max-height: 90vh !important;
    }
}

/* HYROX standards — thin, selectable bands instead of a wide cropping table. */
.hyrox-std-selectors { display: flex; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.hyrox-std-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 140px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.55);
}
.hyrox-std-field select {
    background: var(--input-bg, #142238);
    color: #fff;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    text-transform: none;
    letter-spacing: 0;
    min-height: 44px;
}
/* Horizontal band cells (4 across) — a thin guide strip, not 4 tall rows, so
   the standings table gets the room (matters at hundreds of submissions). */
.hyrox-band-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
    gap: 6px;
}
.hyrox-band-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--gold, #c8a03c);
    border-radius: 8px;
}
.hyrox-band-row.band-0 { border-left-color: #f0d77c; }
.hyrox-band-row.band-1 { border-left-color: #cfd4dc; }
.hyrox-band-row.band-2 { border-left-color: #d8a07a; }
.hyrox-band-row.band-3 { border-left-color: rgba(255, 255, 255, 0.3); }
.hyrox-band-label {
    font-size: 0.56rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 700;
    white-space: nowrap;
}
.hyrox-band-val { font-size: 0.8rem; font-weight: 700; color: #fff; white-space: nowrap; }
.hyrox-band-empty { color: rgba(255, 255, 255, 0.4); padding: 8px 0; font-size: 0.85rem; }

/* Submit-your-result button (opens the HYROX publish flow). */
.btn-hyrox-publish {
    margin-top: 10px;
    background: var(--gold, #c8a03c);
    color: #0a1628;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 44px;
}
.btn-hyrox-publish:active { transform: scale(0.98); }

/* Scalable results table (challenge leaderboards + HYROX standings). Scrolls
   with a sticky header so hundreds of entries stay usable. */
.results-table-wrap {
    max-height: 50vh;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
}
.results-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.results-table thead th {
    position: sticky;
    top: 0;
    background: #0f1a2e;
    color: var(--gold, #c8a03c);
    text-align: left;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
}
.results-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    white-space: nowrap;
}
.results-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.results-table tr.is-me { background: rgba(200, 160, 60, 0.1); }
.results-table .rt-rank { color: var(--gold, #c8a03c); font-weight: 700; width: 34px; }
.results-table .rt-name { font-weight: 600; white-space: normal; }
.results-table .rt-org { display: block; font-size: 0.68rem; color: rgba(255, 255, 255, 0.4); }
.results-table .rt-val { font-weight: 700; text-align: right; }
.results-table .rt-you {
    margin-left: 6px;
    font-size: 0.6rem;
    background: var(--gold, #c8a03c);
    color: #0a1628;
    padding: 1px 6px;
    border-radius: 999px;
    vertical-align: middle;
}
