/*
 * /challenges (challenges/index.php): the title beside the solved ring and a bar per level, the topic chips and
 * filters, the challenges as a table (LeetCode-like), and the side column. lpMark() sets the states (is-solved,
 * is-tried, --p) before the first paint. On learn-shell.css's tokens.
 */
.chs {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 28px;
}

/* ---------- The top: title and lead, and what this browser solved ---------- */
.chs-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 40px;
    align-items: center;
    padding: 48px 0 24px;
}

.chs-hero h1 {
    margin: 0 0 14px;
    font-size: clamp(40px, 5vw, 54px);
}

.chs-lead {
    max-width: 36em;
    margin: 0;
    color: var(--ink-2);
    font-size: 18px;
}

.chs-progress {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 20px 22px;
}

.chs-progress .ring {
    width: 92px;
    height: 92px;
}

.chs-progress .ring b {
    display: block;
    font-size: 26px;
    line-height: 1;
}

.chs-progress .ring small {
    display: block;
    margin-top: 2px;
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 500;
}

.chs-levels {
    display: grid;
    flex: 1;
    gap: 9px;
    min-width: 0;
}

.chs-level {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3px 10px;
    font-size: 13px;
}

.chs-level > span:first-child {
    color: var(--badge);
    font-weight: 650;
}

.chs-level > span:nth-child(2) {
    color: var(--ink-3);
}

.chs-level b {
    color: var(--ink);
    font-weight: 650;
}

.chs-level .bar {
    --part: var(--badge);
    grid-column: 1 / -1;
    height: 5px;
}

/* ---------- The list and the side column ---------- */
.chs-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 32px;
    align-items: start;
}

.chs-main {
    grid-row: 1;
    grid-column: 1;
    min-width: 0;
}

.chs-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.chs-filters .ls {
    flex: 1 1 260px;
    max-width: none;
}

.chs-filters .ls-hero .ls-input {
    height: 42px;
    border-radius: var(--r-md);
    font-size: 15px;
    box-shadow: none;
}

.chs-select {
    height: 42px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%238590A6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 10px center / 14px no-repeat;
    color: var(--ink);
    font-size: 14.5px;
    appearance: none;
    cursor: pointer;
}

.chs-select:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.chs-pick {
    height: 42px;
}

.program-none {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: var(--r-lg);
    color: var(--ink-2);
    text-align: center;
}

/* The table: status, the challenge, its topics, level and XP. Its columns have set widths (table-layout: fixed, from the
   head's cells), so rows read after the first paint never widen one and move the others */
.chs-table {
    width: 100%;
    table-layout: fixed;
    overflow: hidden;
    border: 1px solid var(--line);
    border-spacing: 0;
    border-collapse: separate;
    border-radius: var(--r-lg);
    background: var(--surface);
    font-size: 14.5px;
}

.chs-table th {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 650;
    text-align: left;
}

.chs-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.chs-table tr:last-child td {
    border-bottom: 0;
}

.ch-row {
    position: relative;
}

.ch-row:hover {
    background: var(--surface-2);
}

/* Solved: a soft green wash from the left, gone by the middle */
.ch-row.is-solved {
    background: linear-gradient(90deg, color-mix(in srgb, var(--done) 12%, transparent), transparent 50%);
}

.ch-row.is-solved:hover {
    background: linear-gradient(90deg, color-mix(in srgb, var(--done) 16%, transparent), var(--surface-2) 50%);
}

.ch-st {
    width: 44px;
    padding-right: 0 !important;
    text-align: center;
}

.ch-name .learn-row-title {
    color: var(--ink);
    font-size: 15.5px;
    font-weight: 650;
}

.ch-name .learn-row-title:hover {
    color: var(--brand);
    text-decoration: none;
}

/* The whole row is the link */
.ch-name .learn-row-title::after {
    content: "";
    position: absolute;
    inset: 0;
}

.ch-name .ch-stars {
    margin-left: 6px;
}

.ch-about {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--ink-3);
    font-size: 13.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 52ch;
}

.ch-tp {
    width: 176px;
    color: var(--ink-2);
    font-size: 13.5px;
}

.ch-lv {
    width: 132px;
}

.ch-xp {
    width: 60px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* The side column: Pick up, and how a challenge works. First in the page, on the right above 1180px */
.chs-side {
    grid-row: 1;
    grid-column: 2;
    position: sticky;
    top: calc(var(--nav-h) + 20px);
    display: grid;
    gap: 16px;
}

.chs-last {
    display: grid;
    gap: 6px;
    justify-items: start;
    color: var(--ink);
    border-color: color-mix(in srgb, var(--hi) 60%, var(--line));
    background: linear-gradient(180deg, var(--hi-soft), var(--surface) 70%);
}

.chs-last:hover {
    text-decoration: none;
}

.chs-last small {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.chs-last b {
    display: block;
    overflow: hidden;
    max-width: 100%;
    min-height: 1.2em;
    font-size: 18px;
    font-weight: 720;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Its name until the list's row is read (lpMark()): a bar the size of the name */
.chs-last b:empty::before {
    content: "";
    display: block;
    width: 60%;
    height: 1em;
    margin-top: .1em;
    border-radius: 6px;
    background: var(--line);
}

.chs-last .btn {
    margin-top: 6px;
    pointer-events: none;
}

/* Today's challenge (learn-progress.js fills it after the page, the same for everyone on a date): its size is fixed from
   the start, one line of name, two of about, one of level and XP, with a bar in each until then, so filling it moves
   nothing, the list under it on narrower screens least of all */
.chs-side .daily-title,
.chs-side .daily-about {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
}

.chs-side .daily-title {
    min-height: 1.2em;
    -webkit-line-clamp: 1;
    line-clamp: 1;
}

.chs-side .daily-about {
    min-height: 2.9em;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.chs-side .daily-meta {
    min-height: 22px;
}

.chs-side .daily-title:empty::before,
.chs-side .daily-about:empty::before {
    content: "";
    display: block;
    width: 70%;
    height: 1em;
    margin-top: .1em;
    border-radius: 6px;
    background: rgba(255, 255, 255, .16);
}

.chs-how h2 {
    margin: 0 0 10px;
    font-size: 15px;
}

.chs-how ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 18px;
    color: var(--ink-2);
    font-size: 14px;
}

/* ---------- Narrower ---------- */
@media (max-width: 1180px) {
    .chs-body {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The side cards above the list, side by side */
    .chs-side,
    .chs-main {
        grid-row: auto;
        grid-column: 1;
    }

    .chs-side {
        position: static;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}

@media (max-width: 860px) {
    .chs {
        padding: 0 18px;
    }

    .chs-hero {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
        padding-top: 32px;
    }

    .ch-tp {
        display: none;
    }

    /* Phones get to the list sooner: How a challenge works stays on wider screens */
    .chs-how {
        display: none;
    }

    .ch-about {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
}

@media (max-width: 480px) {
    .chs {
        padding: 0 12px;
    }

    .chs-table td,
    .chs-table th {
        padding-left: 10px;
        padding-right: 10px;
    }

    .ch-xp {
        display: none;
    }

    .chs-filters .chs-select,
    .chs-pick {
        flex: 1 1 40%;
    }
}
