/* ===== Challenges Page — Webrace ===== */

.challenges-page {
    width: 100%;
    max-width: none;
    padding: 4px 32px 0;
    box-sizing: border-box;
}

/* Neutralize the global `svg { width:100%; height:100% }` rule in style.css
   so our inline SVGs render at their authored size. */
.challenges-page svg {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    flex-shrink: 0;
}

/* ===== Page header ===== */
.challenges-header {
    margin-bottom: 20px;
}

.challenges-header__title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.challenges-header__icon {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #a326ff;
    flex-shrink: 0;
}

.challenges-header__icon svg {
    width: 26px;
    height: 26px;
}

.challenges-header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.challenges-header__sub {
    font-weight: 600;
    color: #9ca3af;
    margin-left: 4px;
}

/* ===== Active / Completed tabs ===== */
.challenges-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: #161616;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.challenges-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.challenges-tab:hover {
    color: #fff;
}

.challenges-tab.active {
    background: linear-gradient(180deg, #4f8cff 0%, #2f6ce5 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(47, 108, 229, 0.35);
}

.challenges-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 6px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.challenges-tab:not(.active) .challenges-tab__count {
    background: rgba(255, 255, 255, 0.05);
}

/* ===== Panels ===== */
.challenges-panel[hidden] {
    display: none;
}

.challenges-empty {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* ===== Grid ===== */
.challenges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding-bottom: 24px;
}

/* ===== Card ===== */
.challenge-card {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 14px;
    background: linear-gradient(180deg, #181126 0%, #14101e 100%);
    border: 1px solid rgba(163, 38, 255, 0.35);
    border-radius: 14px;
    box-shadow:
        0 0 0 1px rgba(163, 38, 255, 0.05) inset,
        0 8px 24px -12px rgba(0, 0, 0, 0.6);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}

.challenge-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    pointer-events: none;
    background: radial-gradient(ellipse 70% 50% at 0% 0%, rgba(163, 38, 255, 0.12), transparent 60%);
}

.challenge-card:hover {
    transform: translateY(-3px);
    border-color: rgba(163, 38, 255, 0.7);
    box-shadow:
        0 0 0 1px rgba(163, 38, 255, 0.1) inset,
        0 12px 32px -8px rgba(163, 38, 255, 0.35);
}

.challenge-card--completed {
    border-color: rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, #161616 0%, #121212 100%);
}

.challenge-card--completed::before {
    background: none;
}

.challenge-card--completed:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}

/* Thumbnail */
.challenge-card__thumb {
    position: relative;
    flex: 0 0 118px;
    width: 118px;
    height: 158px;
    border-radius: 10px;
    overflow: hidden;
    background: #0f0f12;
    border: 1px solid rgba(255, 255, 255, 0.06);
    align-self: stretch;
}

.challenge-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.challenge-card:hover .challenge-card__img {
    transform: scale(1.04);
}

.challenge-card--completed .challenge-card__img {
    filter: grayscale(0.5) brightness(0.7);
}

/* Chips (badges) */
.challenge-chip {
    position: absolute;
    top: 8px;
    left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 6px;
    color: #1a1a1a;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    line-height: 1;
    z-index: 2;
}

.challenge-chip--exclusive {
    background: linear-gradient(180deg, #fff 0%, #f3e8ff 100%);
    color: #1a0a35;
}

.challenge-chip--countdown {
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    border: 1px solid rgba(163, 38, 255, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
    font-size: 11px;
}

.challenge-chip--countdown svg {
    color: #c89bff;
    flex-shrink: 0;
}

.challenge-chip--ended {
    background: rgba(0, 0, 0, 0.78);
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
    font-size: 11px;
}

/* Body */
.challenge-card__body {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    z-index: 1;
}

.challenge-card__head {
    margin: 2px 0 10px;
}

.challenge-card__title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.challenge-card__desc {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #9ca3af;
}

.challenge-card__desc strong {
    color: #fff;
    font-weight: 700;
}

/* Meta rows */
.challenge-card__meta {
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.challenge-card__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
}

.challenge-card__row dt {
    color: #6b7280;
    font-weight: 600;
}

.challenge-card__row dd {
    margin: 0;
    color: #d4d4d8;
    font-weight: 700;
    text-align: right;
}

.challenge-card__prize {
    color: #fbbf24 !important;
    font-weight: 800 !important;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.challenge-card__creator,
.challenge-card__winner {
    color: #fff !important;
}

/* Button */
.challenge-card__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
    padding: 10px 14px;
    background: linear-gradient(180deg, #4f8cff 0%, #2f6ce5 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
    box-shadow: 0 4px 12px rgba(47, 108, 229, 0.3);
}

.challenge-card__btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 6px 16px rgba(47, 108, 229, 0.45);
}

.challenge-card__btn svg {
    flex-shrink: 0;
}

.challenge-card__btn--ghost {
    background: rgba(255, 255, 255, 0.04);
    color: #6b7280;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    cursor: not-allowed;
    font-weight: 700;
}

.challenge-card__btn--ghost:hover {
    transform: none;
    filter: none;
    box-shadow: none;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .challenges-page {
        padding: 4px 16px 0;
    }

    .challenges-header__title {
        align-items: flex-start;
    }

    .challenges-header h1 {
        font-size: 16px;
    }

    .challenges-header__sub {
        display: block;
        margin-left: 0;
        margin-top: 2px;
    }

    .challenges-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .challenge-card {
        padding: 12px;
        gap: 12px;
    }

    .challenge-card__thumb {
        flex: 0 0 104px;
        width: 104px;
        height: 140px;
    }

    .challenge-card__title {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .challenge-card {
        flex-direction: column;
    }

    .challenge-card__thumb {
        width: 100%;
        height: 160px;
    }

    .challenge-card__row dt,
    .challenge-card__row dd {
        font-size: 13px;
    }
}
