/* ============================================
   CHALLENGES (custom requests) — video-first browse
   Replaces the form-and-filters layout with a wall of
   challenge videos, in the spirit of a YouTube/TikTok
   browse page. Brand accent: #cb0c9f / #830866
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

.ch-page {
    --ch-brand: #830866;
    --ch-brand-neon: #cb0c9f;
    --ch-accent-grad: linear-gradient(135deg, #cb0c9f 0%, #830866 100%);
    --ch-success: #22c55e;
    --ch-warn: #f59e0b;
    --ch-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ch-font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --ch-radius-sm: 10px;
    --ch-radius-md: 14px;
    --ch-radius-lg: 20px;
    min-height: calc(100vh - 64px);
    padding: 20px 16px 56px;
    box-sizing: border-box;
    background: var(--ch-page-bg);
    color: var(--ch-text);
    font-family: var(--ch-font);
}

.ch-page--dark {
    --ch-page-bg: #09090b;
    --ch-surface: #18181e;
    --ch-surface-2: #1c1c24;
    --ch-surface-hover: #20202a;
    --ch-input-bg: #111114;
    --ch-border: rgba(255, 255, 255, 0.08);
    --ch-border-strong: rgba(255, 255, 255, 0.14);
    --ch-text: #f4f4f5;
    --ch-text-2: #a1a1aa;
    --ch-text-muted: #71717a;
    --ch-skeleton: #26262f;
}

.ch-page--light {
    --ch-page-bg: #f4f4f6;
    --ch-surface: #ffffff;
    --ch-surface-2: #f8f8fa;
    --ch-surface-hover: #f1f1f4;
    --ch-input-bg: #ffffff;
    --ch-border: rgba(9, 9, 11, 0.08);
    --ch-border-strong: rgba(9, 9, 11, 0.14);
    --ch-text: #18181b;
    --ch-text-2: #52525b;
    --ch-text-muted: #71717a;
    --ch-skeleton: #e4e4e8;
}

.ch-container {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

/* --- Header -------------------------------------------------------------- */
.ch-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ch-header__title {
    margin: 0;
    font-family: var(--ch-font-display);
    font-size: clamp(23px, 5.5vw, 32px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.12;
}

.ch-header__sub {
    margin: 5px 0 0;
    font-size: 14.5px;
    color: var(--ch-text-2);
}

.ch-header__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Buttons ------------------------------------------------------------- */
.ch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: var(--ch-font);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: filter .15s ease, background .15s ease;
}

.ch-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-btn--primary { background: var(--ch-accent-grad); color: #fff; }
.ch-btn--primary:hover { filter: brightness(1.08); color: #fff; text-decoration: none; }
.ch-btn--ghost { background: var(--ch-surface); border-color: var(--ch-border); color: var(--ch-text); }
.ch-btn--ghost:hover { background: var(--ch-surface-hover); color: var(--ch-text); text-decoration: none; }
.ch-btn--sm { padding: 8px 14px; font-size: 13px; }
.ch-btn--block { width: 100%; }

/* --- Stats strip --------------------------------------------------------- */
.ch-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 640px) { .ch-stats { grid-template-columns: repeat(2, 1fr); } }

.ch-stat {
    padding: 13px 15px;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-md);
    background: var(--ch-surface);
}

.ch-stat__value {
    display: block;
    font-family: var(--ch-font-display);
    font-size: 19px;
    font-weight: 800;
}

.ch-stat__label {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ch-text-muted);
}

/* --- Toolbar ------------------------------------------------------------- */
.ch-toolbar { display: flex; gap: 10px; flex-wrap: wrap; }

.ch-search {
    display: flex;
    align-items: center;
    flex: 1 1 260px;
    min-width: 0;
    border: 1px solid var(--ch-border);
    border-radius: 999px;
    background: var(--ch-input-bg);
    overflow: hidden;
}

.ch-search__icon { display: flex; padding-left: 14px; color: var(--ch-text-muted); }
.ch-search__icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; }

.ch-search__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 14px;
    border: 0;
    background: transparent;
    color: var(--ch-text);
    font-family: var(--ch-font);
    font-size: 14px;
}

.ch-search__input:focus { outline: none; }

.ch-search__btn {
    padding: 12px 20px;
    border: 0;
    background: var(--ch-accent-grad);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.ch-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.ch-tabs::-webkit-scrollbar { display: none; }

.ch-tab {
    flex: 0 0 auto;
    padding: 10px 16px;
    border: 1px solid var(--ch-border);
    border-radius: 999px;
    background: var(--ch-surface);
    color: var(--ch-text-2);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.ch-tab:hover { background: var(--ch-surface-hover); color: var(--ch-text); text-decoration: none; }
.ch-tab.is-active { background: var(--ch-accent-grad); border-color: transparent; color: #fff; }

/* --- Section headings ---------------------------------------------------- */
.ch-section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.ch-section__title {
    margin: 0;
    font-family: var(--ch-font-display);
    font-size: 18px;
    font-weight: 700;
}

.ch-section__count { font-size: 12.5px; color: var(--ch-text-muted); }

/* --- Video grid ---------------------------------------------------------- */
.ch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}

@media (max-width: 520px) {
    .ch-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

.ch-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
    text-decoration: none;
}

.ch-card__media {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: var(--ch-radius-md);
    background: var(--ch-skeleton);
    overflow: hidden;
}

/* Portrait tiles for delivered challenge clips; landscape for funding cards. */
.ch-card--wide .ch-card__media { aspect-ratio: 16 / 9; }

.ch-card__media video,
.ch-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ch-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--ch-text-muted);
}

.ch-card__placeholder svg { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.ch-card__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(0,0,0,.06), rgba(0,0,0,.42));
    opacity: 1;
    transition: opacity .18s ease;
}

.ch-card:hover .ch-card__play { opacity: 0; }

.ch-card__play span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(9, 9, 11, .62);
    backdrop-filter: blur(4px);
}

.ch-card__play svg { width: 18px; height: 18px; fill: #fff; margin-left: 2px; }

.ch-badge {
    position: absolute;
    top: 9px;
    left: 9px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(9, 9, 11, .74);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
}

.ch-badge--paid { background: rgba(34, 197, 94, .92); }
.ch-badge--open { background: rgba(203, 12, 159, .92); }

.ch-amount {
    position: absolute;
    right: 9px;
    bottom: 9px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(9, 9, 11, .78);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    backdrop-filter: blur(4px);
}

.ch-card__body { display: flex; gap: 9px; }

.ch-card__avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.ch-card__meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.ch-card__title {
    font-family: var(--ch-font-display);
    font-size: 14.5px;
    font-weight: 700;
    color: var(--ch-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ch-card:hover .ch-card__title { color: var(--ch-brand-neon); }

.ch-card__sub {
    font-size: 12.5px;
    color: var(--ch-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Funding progress ---------------------------------------------------- */
.ch-fund { margin-top: 2px; }

.ch-fund__track {
    height: 5px;
    border-radius: 999px;
    background: var(--ch-skeleton);
    overflow: hidden;
}

.ch-fund__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--ch-accent-grad);
}

.ch-fund__label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ch-text-muted);
}

.ch-fund__label strong { color: var(--ch-text); }

/* --- Rail (horizontal scroller) ------------------------------------------ */
.ch-rail {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(250px, 1fr);
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.ch-rail::-webkit-scrollbar { display: none; }
.ch-rail > * { scroll-snap-align: start; }

/* --- Empty state --------------------------------------------------------- */
.ch-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 52px 24px;
    border: 1px dashed var(--ch-border-strong);
    border-radius: var(--ch-radius-lg);
    background: var(--ch-surface);
    text-align: center;
}

.ch-empty__icon { color: var(--ch-text-muted); }
.ch-empty__icon svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.ch-empty h3 { margin: 6px 0 0; font-family: var(--ch-font-display); font-size: 18px; font-weight: 700; }
.ch-empty p { margin: 0 0 10px; font-size: 14px; color: var(--ch-text-2); max-width: 460px; }

.ch-pagination { display: flex; justify-content: center; }
.ch-pagination .pagination { margin: 0; }

@media (prefers-reduced-motion: reduce) {
    .ch-card__play, .ch-btn { transition: none; }
}
