/*
 * /dashboard (learn/dashboard.php, dashboard.js; M4): the level ring, XP and streak in one band, the next step and the
 * day's challenge, the last 15 weeks, the counts and the badges. On learn-shell.css's tokens.
 */
.dash {
    max-width: 1080px;
    margin: 0 auto;
    padding: 30px 24px 0;
}

.dash-head h1 {
    margin: 0;
    font-size: clamp(32px, 4.4vw, 42px);
}

.dash-where {
    margin: 6px 0 22px;
    color: var(--ink-2);
}

.dash-note {
    margin: 6px 0 0;
    color: var(--ink-3);
    font-size: 13.5px;
}

.dash-ic .ic {
    width: 20px;
    height: 20px;
}

/* Nothing yet */
.dash-empty {
    margin-bottom: 20px;
    padding: 22px 24px;
    border: 1px dashed color-mix(in srgb, var(--brand) 40%, var(--line));
    border-radius: 16px;
    background: var(--brand-soft);
}

.dash-empty h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.dash-empty p {
    margin: 0 0 14px;
    color: var(--ink-2);
}

/* ---------- Level, XP and streak ---------- */
/* Two halves: on the left the level and XP over the streak card (its last 7 days inside), on the right the counts,
   two by two; one column on phones */
.dash-hero {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "progress counts" "streak counts";
    gap: 16px 24px;
    align-items: stretch;
    padding: 22px 26px 20px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
        radial-gradient(55% 140% at 0% 0%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 70%),
        radial-gradient(40% 120% at 70% 100%, color-mix(in srgb, var(--p4) 6%, transparent), transparent 70%),
        var(--surface);
    box-shadow: var(--shadow);
}

.dash-progress {
    display: flex;
    grid-area: progress;
    align-items: center;
    gap: 22px;
}

.dash-progress .dash-xp {
    flex: 1;
    min-width: 0;
}

.dash-level {
    position: relative;
    flex: none;
    width: 108px;
    height: 108px;
}

.dash-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.dash-ring circle {
    fill: none;
    stroke-width: 10;
}

.dash-ring-track {
    stroke: var(--line);
}

.dash-ring-fill {
    stroke: url(#dash-ring-grad);
    stroke-dasharray: 0 400;
    stroke-linecap: round;
    transition: stroke-dasharray .6s ease;
}

.dash-level-num {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
}

.dash-level-num small {
    color: var(--ink-3);
    font-size: 12.5px;
    font-weight: 600;
}

.dash-level-num b {
    color: var(--ink);
    font-size: 38px;
    line-height: 1;
}

.dash-xp-total {
    margin: 0 0 10px;
    color: var(--ink-2);
    font-size: 18px;
}

.dash-xp-total b {
    color: var(--ink);
    font-size: 34px;
    font-weight: 750;
}

.dash-bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--line);
}

.dash-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--p4));
    transition: width .6s ease;
}

.dash-streak {
    display: grid;
    grid-area: streak;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-2);
}

.dash-streak.is-on {
    background: color-mix(in srgb, var(--lv3) 10%, var(--surface));
}

/* The fire (its own colours), grey until a streak runs */
.dash-flame .ic {
    width: 40px;
    height: 40px;
    opacity: .45;
    filter: grayscale(1);
}

.dash-streak.is-on .dash-flame .ic {
    opacity: 1;
    filter: none;
}

.dash-streak-text p {
    margin: 0;
    color: var(--ink-2);
}

.dash-streak-text b {
    color: var(--ink);
    font-size: 30px;
    font-weight: 750;
}

/* The last 7 days (dashboard.js), in the streak card: a dot per day, its weekday under it */
.dash-week {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin: 10px 0 4px;
    padding: 0;
    list-style: none;
}

.dash-wk {
    display: grid;
    justify-items: center;
    gap: 4px;
}

.dash-wk-dot {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: #FFFFFF;
}

.dash-wk-dot .ic {
    width: 15px;
    height: 15px;
}

.dash-wk.is-on .dash-wk-dot {
    border-color: color-mix(in srgb, var(--lv3) 45%, var(--surface));
    background: color-mix(in srgb, var(--lv3) 14%, var(--surface));
}

.dash-wk.is-on .dash-wk-dot .ic {
    width: 26px;
    height: 26px;
}

.dash-wk.is-frozen .dash-wk-dot {
    border-color: var(--p5);
    background: var(--p5);
}

.dash-wk.is-today .dash-wk-dot {
    border-style: dashed;
    border-color: var(--lv3);
}

.dash-wk-day {
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 600;
}

.dash-wk.is-today .dash-wk-day {
    color: var(--ink);
}

.dash-freezes,
.dash-today {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    color: var(--ink-2);
    font-size: 13px;
    line-height: 1.4;
}

.dash-freezes .dash-ic .ic {
    width: 15px;
    height: 15px;
    color: var(--p5);
    vertical-align: -2px;
}

.dash-streak.is-today .dash-today {
    color: var(--done);
    font-weight: 650;
}

/* ---------- Cards ---------- */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.dash-card {
    display: flex;
    flex-direction: column;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(13, 27, 51, .04);
}

.dash-card .btn {
    align-self: flex-start;
}

/* The lessons after the next one */
.dash-then {
    margin: 14px 0 4px;
    color: var(--ink-3);
    font-size: 12.5px;
    font-weight: 650;
}

.dash-upcoming {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-upcoming a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 9px;
    color: var(--ink-2);
    font-size: 14.5px;
}

.dash-upcoming a:hover {
    background: var(--surface-2);
    color: var(--ink);
    text-decoration: none;
}

.dash-upcoming span {
    display: grid;
    flex: none;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 700;
}

/* The course under the next step: how far, as a meter */
.dash-course {
    margin-top: auto;
    padding-top: 16px;
}

.dash-course p {
    display: flex;
    justify-content: space-between;
    margin: 0 0 8px;
    color: var(--ink-2);
    font-size: 13.5px;
}

.dash-course p span:first-child {
    color: var(--ink);
    font-weight: 650;
}

/* A meter: done of all, in its tile's colour (the counts) or the brand's */
.dash-meter {
    display: block;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
}

.dash-meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--tile, linear-gradient(90deg, var(--brand), var(--p4)));
    transition: width .6s ease;
}

/* The leaderboard's rank, big; the certificate's lessons */
.dash-rank {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 14px;
    color: var(--ink-2);
}

.dash-rank b {
    color: var(--ink);
    font-size: 34px;
    font-weight: 780;
    line-height: 1;
    letter-spacing: -.02em;
}

.dash-board h2 .ic {
    color: #D99A00;
}

.dash-cert p {
    margin: 0 0 12px;
    color: var(--ink-2);
}

.dash-cert .dash-meter {
    margin-bottom: 14px;
}

.dash-card h2,
.dash-badges-box h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 17px;
}

.dash-card h2 .ic {
    width: 17px;
    height: 17px;
    color: var(--p5);
}

.dash-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    text-decoration: none;
}

.dash-step:hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
    background: var(--brand-soft);
    text-decoration: none;
}

.dash-step .dash-ic {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
}

.dash-step-text {
    display: grid;
    flex: 1;
    min-width: 0;
}

.dash-step-text small {
    color: var(--ink-3);
    font-size: 13px;
}

.dash-step-text b {
    overflow: hidden;
    font-size: 16.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- The day's challenge (the card is learn-shell.css's .daily-card): the whole card is its link ---------- */
.dash-daily-link {
    display: grid;
    gap: 12px;
    color: inherit;
}

.dash-daily-link:hover {
    text-decoration: none;
}

.dash-daily-link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.dash-daily-link:focus-visible {
    outline: none;
}

.dash-daily-link:focus-visible::after {
    box-shadow: inset 0 0 0 3px #FFFFFF;
}

.dash-daily .daily-note {
    margin-top: auto;
}

/* ---------- Activity: a calendar as wide as the card, Monday to Sunday down each column (dashboard.js sets --weeks) ---------- */
.dash-activity {
    margin-top: 18px;
}

.dash-activity-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 16px;
    margin-bottom: 14px;
}

.dash-activity-head h2 {
    margin: 0;
}

.dash-activity-head .dash-note {
    margin: 0;
}

.dash-cal {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-areas: ". months" "days heat";
    gap: 6px;
}

.dash-cal-months,
.dash-heat {
    display: grid;
    grid-template-columns: repeat(var(--weeks, 15), minmax(0, 1fr));
    gap: 4px;
}

.dash-cal-months {
    grid-area: months;
    height: 16px;
    color: var(--ink-3);
    font-size: 12px;
    white-space: nowrap;
}

.dash-cal-days {
    display: grid;
    grid-area: days;
    grid-template-rows: repeat(7, minmax(0, 1fr));
    gap: 4px;
    color: var(--ink-3);
    font-size: 11.5px;
}

.dash-cal-days span {
    display: flex;
    align-items: center;
}

.dash-heat {
    grid-area: heat;
    grid-template-rows: repeat(7, auto);
    grid-auto-flow: column;
}

.dash-day,
.dash-legend i {
    border-radius: 4px;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
}

.dash-day {
    aspect-ratio: 1;
}

.dash-activity [data-l="1"] { background: color-mix(in srgb, var(--done) 28%, var(--surface)); }
.dash-activity [data-l="2"] { background: color-mix(in srgb, var(--done) 52%, var(--surface)); }
.dash-activity [data-l="3"] { background: color-mix(in srgb, var(--done) 76%, var(--surface)); }
.dash-activity [data-l="4"] { background: var(--done); }

.dash-day[data-l],
.dash-legend i[data-l] {
    box-shadow: none;
}

.dash-day.is-today {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.dash-day.is-later {
    visibility: hidden;
}

.dash-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin: 12px 0 0;
    color: var(--ink-3);
    font-size: 12px;
}

.dash-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ---------- Counts ---------- */
.dash-counts {
    display: grid;
    grid-area: counts;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-count {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: center;
    gap: 0 12px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.dash-count .dash-meter {
    grid-column: 1 / -1;
    height: 6px;
    margin-top: 12px;
}

.dash-count-icon {
    display: grid;
    grid-row: span 3;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--tile) 14%, var(--surface));
    color: var(--tile);
}

.dash-count-icon .ic {
    width: 20px;
    height: 20px;
}

.dash-count b {
    font-size: 24px;
    line-height: 1.1;
}

.dash-count span:not(.dash-count-icon) {
    color: var(--ink-2);
    font-size: 14px;
}

.dash-count small {
    color: var(--ink-3);
    font-size: 12.5px;
}

/* ---------- The learner's fastest solves ---------- */
.dash-times,
.dash-join {
    margin-top: 18px;
}

/* A guest's Sign in and See the leaderboard, side by side */
.dash-join-acts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.dash-times-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-times-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
}

.dash-times-list a:hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
    background: var(--brand-soft);
    text-decoration: none;
}

.dash-time-name {
    overflow: hidden;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-time {
    flex: none;
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--done-soft);
    color: var(--done);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dash-times .dash-note {
    margin: 0;
}

/* ---------- Badges ---------- */
.dash-badges-box {
    margin-top: 26px;
}

.dash-badges-box h2 small {
    color: var(--ink-3);
    font-size: 14px;
    font-weight: 500;
}

/* Earned, then Still to earn (dashboard.js shows a part once it has a badge) */
.dash-badges-part + .dash-badges-part {
    margin-top: 22px;
}

.dash-badges-part h3 {
    margin: 0 0 10px;
    color: var(--ink-2);
    font-size: 14.5px;
    font-weight: 600;
}

.dash-badges {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-badge {
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 4px;
    padding: 16px 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    text-align: center;
}

/* A badge's medal (dashboard.js medal()): text in its chip in the page's font */
.dash-medal {
    flex: none;
    width: 68px;
    height: 68px;
    margin-bottom: 6px;
    filter: drop-shadow(0 3px 3px rgba(13, 27, 51, .22));
}

body.dark .dash-medal {
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5));
}

.dash-medal text {
    fill: #0D1B33;
    font-family: var(--font);
    font-weight: 800;
}

/* The medals' gradients: out of sight, never display: none, which would leave the medals without them */
.dash-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.dash-badge b {
    font-size: 14.5px;
}

.dash-badge small {
    color: var(--ink-3);
    font-size: 12.5px;
    line-height: 1.35;
}

.dash-badge:not(.is-earned) b {
    color: var(--ink-2);
}

/* How far a badge still to earn is: a meter in its colour, and "7 of 10" */
.dash-badge .dash-meter {
    width: min(120px, 80%);
    height: 5px;
    margin-top: 6px;
}

.dash-badge .dash-badge-way {
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dash-badge:not(.is-earned) {
    border-style: dashed;
    background: none;
}

/* Not earned yet: an unpainted blank of the same medal */
.dash-badge:not(.is-earned) .dash-medal {
    opacity: .42;
    filter: grayscale(1) contrast(.8) brightness(1.08);
}

body.dark .dash-badge:not(.is-earned) .dash-medal {
    opacity: .38;
    filter: grayscale(1) contrast(.8) brightness(.9);
}

.dash-badge.is-earned {
    border-color: color-mix(in srgb, var(--tile) 35%, var(--line));
    background: linear-gradient(180deg, color-mix(in srgb, var(--tile) 7%, var(--surface)), var(--surface) 70%);
}

/* A badge celebrated on this visit (below) */
.dash-badge.is-new {
    position: relative;
}

.dash-badge.is-new::before {
    content: "New";
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--tile);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

/* ---------- New badges, celebrated once (dashboard.js): the dialog, each badge popping in after the one before, a ring
   bursting from it and a shine across it as it lands, then confetti (confetti.js) ---------- */
.dash-cele {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
}

.dash-cele::backdrop {
    background: rgba(13, 27, 51, .5);
    backdrop-filter: blur(2px);
}

.dash-cele-in {
    display: grid;
    justify-items: center;
    gap: 20px;
    padding: 30px 24px 26px;
    text-align: center;
    animation: cele-in .35s ease-out both;
}

.dash-cele h2 {
    margin: 0;
    font-size: 24px;
}

.dash-cele-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-cele-badge {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 3px;
    width: 120px;
    animation: cele-pop .65s cubic-bezier(.2, 1.5, .4, 1) both;
    animation-delay: calc(var(--i) * var(--step) + 250ms);
}

.dash-cele-badge::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 96px;
    height: 96px;
    margin-left: -48px;
    border: 3px solid var(--tile);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    animation: cele-ring .7s ease-out both;
    animation-delay: calc(var(--i) * var(--step) + 420ms);
}

.dash-cele-badge .dash-medal {
    width: 96px;
    height: 96px;
}

/* The band of light, in the medal's own units, inside its frame */
.dash-medal-shine {
    fill: rgba(255, 255, 255, .6);
    animation: cele-shine .8s ease-out both;
    animation-delay: calc(var(--i) * var(--step) + 650ms);
}

.dash-cele-badge b {
    font-size: 15px;
}

.dash-cele-badge small {
    color: var(--ink-3);
    font-size: 12.5px;
    line-height: 1.35;
}

.dash-cele-next {
    margin: 0;
    color: var(--ink-2);
    font-size: 14px;
}

.dash-cele-next b {
    color: var(--ink);
}

@keyframes cele-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }
}

@keyframes cele-pop {
    0% {
        opacity: 0;
        transform: scale(.3) rotate(-14deg);
    }

    60% {
        opacity: 1;
        transform: scale(1.12) rotate(4deg);
    }

    100% {
        opacity: 1;
        transform: none;
    }
}

@keyframes cele-ring {
    0% {
        opacity: .9;
        transform: scale(.7);
    }

    100% {
        opacity: 0;
        transform: scale(1.9);
    }
}

@keyframes cele-shine {
    to {
        transform: translateX(150px);
    }
}

/* Reduced motion: the badges are simply there, without the ring, the shine or confetti */
@media (prefers-reduced-motion: reduce) {
    .dash-cele-in,
    .dash-cele-badge {
        animation: none;
    }

    .dash-cele-badge::before,
    .dash-medal-shine {
        display: none;
    }
}

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

    .dash-hero {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "progress" "streak" "counts";
        padding: 18px;
    }

    .dash-grid {
        grid-template-columns: minmax(0, 1fr);
    }

}

@media (max-width: 480px) {
    .dash-level {
        width: 92px;
        height: 92px;
    }

    .dash-level-num b {
        font-size: 30px;
    }

    .dash-xp-total b {
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dash-ring-fill,
    .dash-bar span,
    .dash-meter i {
        transition: none;
    }
}
