/*
 * A lesson (learn/lesson.php) and the reading pages that share its parts (the quiz, a program, an error page): the
 * three columns (the course, the lesson, On this page), the lesson's prose, the runnable blocks (LessonMarkdown::runner,
 * LearnRunner.markup), hints, the exercises' checks, Going deeper, callouts, the end of a lesson and the share
 * buttons. On learn-shell.css's tokens; the older --lr-* names it still uses are aliases there.
 */

/* ========== The three columns ========== */
.lesson {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 220px;
    gap: 40px;
    align-items: start;
    max-width: 1340px;
    margin: 0 auto;
    padding: 28px 28px 0;
}

.lesson-main {
    width: 100%;
    max-width: 760px;
    min-width: 0;
    margin: 0 auto;
}

/* The course: a sticky column (its own scroll); a drawer under 860px (learn-nav.js) */
.lesson-course {
    position: sticky;
    top: calc(var(--nav-h) + 20px);
    max-height: calc(100vh - var(--nav-h) - 40px);
    overflow-y: auto;
    padding-right: 4px;
}

@media (min-width: 861px) {
    .lesson-course[hidden] {
        display: block !important;
    }
}

.course-head {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.course-head a {
    color: var(--ink);
    font-size: 15px;
    font-weight: 720;
}

.course-head > span:not(.bar) {
    color: var(--ink-3);
    font-size: 13px;
}

.course-head .bar {
    --part: var(--done);
    margin-top: 4px;
}

.course-part {
    margin-bottom: 2px;
}

.course-part summary {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px 8px 16px;
    border-radius: 8px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 650;
    list-style: none;
    cursor: pointer;
}

.course-part summary::-webkit-details-marker {
    display: none;
}

/* The part's colour, as a bar beside its name */
.course-part summary::before {
    content: "";
    position: absolute;
    top: 9px;
    bottom: 9px;
    left: 4px;
    width: 3px;
    border-radius: 3px;
    background: var(--part);
}

.course-part summary:hover {
    background: var(--surface-2);
}

.course-part-count {
    color: var(--ink-3);
    font-size: 12.5px;
    font-weight: 500;
}

.course-part.is-folded .course-part-count {
    color: var(--done);
}

.course-part ol {
    margin: 2px 0 10px;
    padding: 0;
    list-style: none;
}

.course-part a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 14px;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.35;
}

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

.course-part a[aria-current="page"] {
    background: var(--hi-soft);
    color: var(--ink);
    font-weight: 650;
}

.course-dot {
    display: grid;
    flex: none;
    place-items: center;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--line);
    border-radius: 50%;
}

.course-dot .ic {
    display: none;
    width: 11px;
    height: 11px;
    stroke-width: 2.6;
}

.course-part a.is-done .course-dot {
    border-color: var(--done);
    background: var(--done);
    color: #FFFFFF;
}

body.dark .course-part a.is-done .course-dot {
    color: #0B1222;
}

.course-part a.is-done .course-dot .ic {
    display: block;
}

/* The lesson open, not done yet: a yellow ring (done, its green tick says enough beside the highlight) */
.course-part a[aria-current="page"]:not(.is-done) .course-dot {
    border-color: var(--hi);
}

/* ========== The lesson's head ========== */
.lesson-course-btn {
    display: none;
    margin-bottom: 14px;
}

.lesson-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    color: var(--ink-3);
    font-size: 14px;
}

.lesson-crumbs a {
    color: var(--ink-2);
}

.lesson-crumbs .ic {
    width: 12px;
    height: 12px;
}

.lesson-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.lesson-head h1 {
    flex: 1;
    margin: 0;
    font-size: clamp(36px, 5vw, 46px);
}

.lesson-save {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink-2);
}

.lesson-save:hover {
    border-color: var(--ink-3);
    color: var(--ink);
}

.lesson-save[aria-pressed="true"],
.lesson-save-wide[aria-pressed="true"] {
    color: var(--brand);
}

.lesson-save[aria-pressed="true"] .ic,
.lesson-save-wide[aria-pressed="true"] .ic {
    fill: currentColor;
}

.lesson-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 28px;
}

.lesson-chips .ic {
    width: 13px;
    height: 13px;
}

/* ========== On this page ========== */
.lesson-aside {
    position: sticky;
    top: calc(var(--nav-h) + 20px);
    display: grid;
    gap: 20px;
    max-height: calc(100vh - var(--nav-h) - 40px);
    overflow-y: auto;
}

.lesson-toc {
    display: grid;
    gap: 2px;
    padding-left: 2px;
}

.lesson-toc p {
    margin: 0 0 6px;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 700;
}

.lesson-toc a {
    padding: 4px 0 4px 12px;
    border-left: 2px solid var(--line);
    color: var(--ink-2);
    font-size: 13.5px;
    line-height: 1.4;
}

.lesson-toc a:hover {
    color: var(--ink);
    text-decoration: none;
}

.lesson-toc a[aria-current] {
    border-left-color: var(--brand);
    color: var(--brand);
    font-weight: 600;
}

.lesson-aside-actions {
    display: grid;
    gap: 6px;
}

.lesson-aside-actions .btn {
    justify-content: flex-start;
    width: 100%;
    min-height: 36px;
    font-size: 14px;
}

/* Mark as complete, pressed: done, in green */
.lp-done-btn[aria-pressed="true"] {
    border-color: var(--done);
    background: var(--done-soft);
    color: var(--done);
}

/* ========== The end of a lesson ========== */
.lesson-finish {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 48px 0 20px;
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
}

.lesson-finish h2 {
    margin: 0 0 4px;
    font-size: 21px;
}

.lp-done-note {
    margin: 0;
    color: var(--ink-3);
    font-size: 14px;
}

.lesson-finish .lp-done-btn {
    min-height: 44px;
}

.lesson-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 36px;
}

.lesson-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    color: var(--ink);
    transition: border-color .15s, transform .15s;
}

.lesson-card:hover {
    border-color: var(--brand);
    text-decoration: none;
}

.lesson-card.is-next {
    border-color: transparent;
    background: var(--brand);
    color: var(--brand-ink);
}

.lesson-card.is-next:hover {
    background: color-mix(in srgb, var(--brand) 88%, var(--ink));
}

.lesson-card-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--tile) 14%, transparent);
    color: var(--tile);
}

.lesson-card-icon .ic {
    width: 20px;
    height: 20px;
}

.lesson-card-body {
    display: grid;
    flex: 1;
    gap: 2px;
    min-width: 0;
}

.lesson-card-body small {
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 600;
}

.lesson-card-body b {
    font-size: 18px;
    font-weight: 720;
}

.lesson-card-body > span {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ink-2);
    font-size: 14px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.lesson-card.is-next small,
.lesson-card.is-next .lesson-card-body > span {
    color: color-mix(in srgb, var(--brand-ink) 78%, transparent);
}

.lesson-card-go {
    flex: none;
}

.lesson-card .chip.is-pass,
.lesson-card .chip:not([hidden]) {
    margin-left: 6px;
}

/* This lesson's challenges */
.ch-practice {
    margin: 0 0 36px;
}

.ch-practice h2 {
    margin: 0 0 4px;
    font-size: 21px;
}

.ch-practice > p {
    margin: 0 0 14px;
    color: var(--ink-2);
    font-size: 15px;
}

.learn-row.is-solved .learn-row-num {
    background: var(--done-soft);
    color: var(--done);
}

/* Previous and next */
.lesson-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 32px 0 0;
}

.lesson-pager a {
    display: grid;
    gap: 2px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
}

.lesson-pager a:hover {
    border-color: var(--brand);
    text-decoration: none;
}

.lesson-pager small {
    color: var(--ink-3);
    font-size: 13px;
}

.lesson-pager small .ic {
    width: 12px;
    height: 12px;
}

.lesson-pager b {
    font-weight: 650;
}

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

    .lesson-aside {
        display: none;
    }
}

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

    .lesson-course-btn {
        display: inline-flex;
    }

    /* The button above says it already */
    .lesson-chips .chip:first-child {
        display: none;
    }

    .lesson-course {
        position: fixed;
        z-index: 40;
        top: var(--nav-h);
        bottom: 0;
        left: 0;
        width: min(340px, 88vw);
        max-height: none;
        padding: 14px 12px 24px;
        border-right: 1px solid var(--line);
        background: var(--page);
        box-shadow: var(--shadow-pop);
        animation: course-in .16s ease-out;
    }

    @keyframes course-in {
        from { transform: translateX(-16px); opacity: 0; }
    }
}

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

    .lesson-finish {
        padding: 18px;
    }

    .lesson-pager {
        grid-template-columns: 1fr;
    }
}

/* ========== The lesson's prose ========== */
.learn-content {
    color: var(--ink);
    font-size: 17px;
    line-height: 1.7;
}

.learn-content > :first-child {
    margin-top: 0;
}

.learn-content p,
.learn-content ul,
.learn-content ol {
    margin: 0 0 16px;
}

.learn-content ul,
.learn-content ol {
    padding-left: 1.4em;
}

.learn-content li + li {
    margin-top: 4px;
}

.learn-content h2 {
    margin: 40px 0 12px;
    padding-top: 8px;
    font-size: 28px;
    line-height: 1.2;
    scroll-margin-top: calc(var(--nav-h) + 20px);
}

.learn-content h3 {
    margin: 28px 0 10px;
    font-size: 20px;
    scroll-margin-top: calc(var(--nav-h) + 20px);
}

.learn-content a {
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent);
    text-underline-offset: 2px;
}

.learn-content a:hover {
    text-decoration-color: var(--brand);
}

.learn-content code {
    padding: .1em .35em;
    border-radius: 5px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
    font-size: .86em;
}

.learn-content pre {
    margin: 0 0 16px;
    padding: 14px 16px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--code-bg);
    color: var(--code-ink);
    font-size: 14px;
    line-height: 1.55;
}

.learn-content pre code {
    padding: 0;
    border-radius: 0;
    background: none;
    color: inherit;
    font-size: inherit;
}

.learn-content pre.lr-static .ace_static_highlight {
    background: transparent;
    font-family: var(--mono);
    font-size: 14px;
}

/* A table: a card of its own (LessonMarkdown's .lr-table box), the header tinted, the rows plain. A table wider than
   the screen scrolls sideways inside its card, never the page */
.learn-content .lr-table {
    margin: 0 0 20px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.learn-content table {
    width: 100%;
    border-spacing: 0;
    border-collapse: separate;
    font-size: 15.5px;
}

.learn-content th,
.learn-content td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.learn-content tr:last-child td {
    border-bottom: 0;
}

.learn-content th {
    background: var(--code-head);
    color: var(--ink);
    font-weight: 700;
}


/* A plain > quote is a tip: the brand's blue, as before (callouts, > [!info] and the rest, have their own) */
.learn-content blockquote {
    margin: 0 0 16px;
    padding: 10px 16px;
    border-left: 4px solid var(--brand);
    border-radius: 0 8px 8px 0;
    background: var(--brand-soft);
    color: var(--ink);
    font-size: 16.5px;
}

.learn-content blockquote p:last-child {
    margin-bottom: 0;
}

/* ========== Runnable blocks ==========
   One card: a slim head (the actions on the left, Run first, then Visualize, Copy and Reset after an edit; on the right
   the caption, if any, and an exercise's Your code / Answer, Show answer and Hint), the code (3 to 20 lines, then it
   scrolls), and the output under it once the code has run. */
.lr-runner {
    margin: 20px 0 28px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--code-bg);
    box-shadow: var(--shadow);
    font-size: 15px;
    line-height: 1.5;
}

.lr-head {
    container: lr-head / inline-size;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    min-height: 46px;
    padding: 6px 12px 6px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--code-head);
}

/* The caption: what the block is for, clearly readable, a small brand square before it */
.lr-caption {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: var(--ink);
    font-size: 14px;
    font-weight: 620;
    line-height: 1.35;
}

.lr-caption::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--brand);
}

.lr-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 4px;
}

/* The caption and an exercise's switch, Show answer and Hint: on the right of the actions' line */
.lr-actions-end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px 8px;
    min-width: 0;
    margin-left: auto;
}

/* An exercise's Your code / Answer, once the answer shows: a small segmented switch */
.lr-files {
    display: inline-flex;
    gap: 2px;
    margin-right: 4px;
    padding: 2px;
    border-radius: 8px;
    background: var(--line);
}

.lr-tab {
    height: 26px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.lr-tab.active {
    background: var(--code-bg);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(13, 27, 51, .12);
}

/* Quiet icon buttons: Visualize, Reset, Copy, and in the output's head Copy and Clear */
.lr-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink-2);
}

.lr-icon:hover,
.lr-icon:focus-visible {
    background: var(--surface-2);
    color: var(--ink);
}

.lr-icon .ic {
    width: 16px;
    height: 16px;
}

.lr-viz {
    color: var(--brand);
}

.lr-viz.is-loading .ic {
    animation: spin 1s linear infinite;
}

.lr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 620;
    line-height: 1;
    white-space: nowrap;
}

.lr-btn:hover:not(:disabled) {
    border-color: var(--ink-3);
}

.lr-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.lr-btn .ic {
    width: 15px;
    height: 15px;
}

.lr-hint-btn .ic {
    color: var(--lv2);
}

/* Run: first, the one coloured button; Stop while it runs */
.lr-run {
    min-width: 76px;
    margin-right: 4px;
    border-color: var(--go);
    background: var(--go);
    color: #FFFFFF;
}

.lr-run:hover:not(:disabled) {
    border-color: var(--go);
    background: color-mix(in srgb, var(--go) 86%, #000000);
}

.lr-run .ic {
    width: 15px;
    height: 15px;
    margin-left: -2px;
}

.lr-runner.is-running .lr-run {
    border-color: var(--bad);
    background: var(--bad);
}

/* A narrow block (a phone): the right-hand part gets a line of its own under the actions, starting at the left */
@container lr-head (max-width: 560px) {
    .lr-actions-end {
        flex-basis: 100%;
        justify-content: flex-start;
        margin-left: 0;
    }
}


/* Copied: a green check */
.lr-copy.lr-copy-ok,
.lr-snippet-copy.lr-copy-ok {
    color: var(--lr-co-success, #1a7f45);
}

.lr-snippet-copy.lr-copy-ok {
    border-color: currentColor;
}

/* Plain code blocks: copy button floating top right, shown on hover/focus (always on touch) */
.lr-snippet {
    position: relative;
}

.lr-snippet-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--lr-border);
    border-radius: 6px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.lr-snippet-copy .ic {
    width: 15px;
    height: 15px;
}

.lr-snippet:hover .lr-snippet-copy,
.lr-snippet-copy:focus-visible,
.lr-snippet-copy.lr-copied {
    opacity: 1;
}

.lr-snippet-copy:hover,
.lr-snippet-copy.lr-copied {
    color: var(--lr-text);
}

@media (hover: none) {
    .lr-snippet-copy {
        opacity: 1;
    }
}

/* The code: as many lines as it has (6 for an exercise, to write in), a little room above and below */
.learn-content .lr-code,
.learn-content .lr-output {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--lr-code-bg);
}

.learn-content .lr-code {
    margin: 10px 0;
    padding: 0;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
}

.learn-content .lr-code.ace_editor {
    overflow: hidden;
    padding: 0;
    border: 0;
    white-space: normal;
    word-break: normal;
}

/* Match the Ace theme background to the block in both themes */
.lr-runner .ace_editor,
.lr-runner .ace_editor .ace_gutter {
    background: var(--lr-code-bg);
}

.lr-runner .ace_editor .ace_gutter {
    color: var(--lr-info);
}

/* Fixed line height: Ace measures its rows from the container's font, so pinning it here lets the plain <pre> below
   reserve exactly the editor's height (no layout shift) */
.learn-content .lr-code,
.learn-content .lr-code.ace_editor {
    font-size: 14px;
    line-height: 18px;
}

/* Before Ace takes over: the same rows x line height as the editor will have (--lr-rows on the block) */
.learn-content pre.lr-code:not(.ace_editor) {
    height: calc(var(--lr-rows, 6) * 18px);
    padding: 0 16px 0 48px;
    white-space: pre;
    overflow: hidden;
}

/* The output: opens under the code on Run, with a small label row (status, Copy, Clear); long output scrolls */
.lr-out {
    border-top: 1px solid var(--lr-border);
    background: var(--lr-surface);
}

.lr-out[hidden] {
    display: none;
}

/* An example's saved output (LessonMarkdown::outPanel()): shown from the start; a sample says it is one run; dimmed
   with a note once the code is edited (learn-runner.js), until a Run replaces it */
.lr-saved-note,
.lr-stale-note {
    color: var(--ink-3);
    font-size: 12px;
    white-space: nowrap;
}

.lr-stale-note,
.lr-out.is-stale .lr-saved-note {
    display: none;
}

.lr-out.is-stale .lr-stale-note {
    display: inline;
    color: var(--lr-warn, var(--lv2));
    font-weight: 600;
}

.lr-out.is-stale .lr-output {
    opacity: .45;
}

.lr-out-head {
    container: lr-out-head / inline-size;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 6px 0 14px;
}

/* The head's messages in two lengths (longShort in learn-runner.js): the short ones when it's narrow, so they stay on
   one line: "No change · 41 ms" */
.lr-short {
    display: none;
}

@container lr-out-head (max-width: 480px) {
    .lr-long {
        display: none;
    }

    .lr-short {
        display: inline;
    }
}

.lr-out-label {
    color: var(--lr-muted);
    font-size: 13px;
    font-weight: 700;
}

.lr-out-head .lr-icon {
    width: 28px;
    height: 28px;
}

.lr-out-head .lr-icon .ic {
    width: 14px;
    height: 14px;
}

.lr-status {
    margin-left: auto;
    color: var(--lr-muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.lr-status.ok {
    color: var(--lr-run);
}

/* An exercise's check says whether it's right; its "Done" stays neutral */
.lr-runner[data-kind="exercise"] .lr-status.ok {
    color: var(--lr-muted);
}

.lr-status.err {
    color: var(--lr-err);
}

.lr-status.warn {
    color: #c27c0e;
}

/* What changed since this block's last run (markChanges in learn-runner.js): how many lines, in the head, before the
   status ("2 lines changed · Done in 31 ms"), and those lines tinted, the hint box's amber */
.lr-diff {
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
    color: var(--lr-muted);
    font-size: 12.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lr-diff[hidden] {
    display: none;
}

.lr-diff.is-changed {
    color: #b8860b;
}

body.learn-page.dark .lr-diff.is-changed {
    color: #e0b84a;
}

.lr-diff:not([hidden]) + .lr-status {
    margin-left: 0;
}

.lr-diff:not([hidden]) + .lr-status:not(:empty)::before {
    content: '· ';
}

.lr-output .lr-changed {
    display: inline-block;
    box-sizing: border-box;
    min-width: calc(100% + 14px);
    min-height: 1.5em;
    margin: 0 -7px;
    padding: 0 7px;
    border-radius: 3px;
    background: rgba(234, 179, 8, 0.14);
    vertical-align: top;
}

/* 15 lines (of 1.5em), then it scrolls */
.learn-content .lr-output {
    box-sizing: border-box;
    max-height: calc(15 * 1.5em + 12px);
    line-height: 1.5;
    padding: 0 14px 12px;
    overflow: auto;
    background: transparent;
    color: var(--lr-text);
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.lr-output .lr-err {
    color: var(--lr-err);
}

.lr-output .lr-info {
    color: var(--lr-info);
    font-style: italic;
}

/* A failed run's "How to fix this NameError" (learn-runner.js): the way out of the traceback, so a real link */
.lr-output .lr-errhelp {
    color: var(--lr-accent);
    font-style: normal;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.lr-output .lr-in {
    color: var(--lr-in);
}

.lr-output .lr-input {
    min-width: 120px;
    width: 50%;
    padding: 0 4px;
    border: 0;
    border-bottom: 1px solid var(--lr-accent);
    outline: none;
    background: transparent;
    color: var(--lr-in);
    font: inherit;
}

/* Phones: Visualize keeps its icon only and the buttons are tighter, so an exercise's actions fit on one line */
@keyframes lr-spin {
    to {
        transform: rotate(360deg);
    }
}


/* Light text on dark reads heavier; give it a little more room */
body.learn-page.dark .learn-content {
    line-height: 1.75;
}

/* Show code characters literally: fallback fonts such as JetBrains Mono would otherwise
   draw ligatures such as == as one long bar and >= as a single symbol */
.learn-page code,
.learn-page pre,
.learn-page kbd,
.lr-runner,
.lr-runner .ace_editor,
.lr-runner .ace_editor * {
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
}

/* ide.css sets a global "pre { min-height: 95% }" for the IDE; on lesson pages it
   made the output (and editor) taller than their pane, hiding the last output line */
.learn-content .lr-code,
.learn-content .lr-output {
    min-height: 0;
}

/* ========== Exercise hints ========== */
.lr-hint {
    padding: 10px 14px;
    background: var(--lr-hint-bg);
    border-top: 1px solid var(--lr-hint-border);
    font-size: 15px;
    line-height: 1.55;
}

.lr-hint p {
    margin: 4px 0 0;
}

.lr-hint p:first-of-type {
    display: inline;
}

.lr-hint-label {
    display: inline-block;
    margin-right: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #b8860b;
}

body.learn-page.dark .lr-hint-label {
    color: #e0b84a;
}

/* ========== Auto-check feedback ========== */
.lr-feedback {
    padding: 10px 14px;
    border-top: 1px solid var(--lr-border);
    font-size: 15px;
}

.lr-feedback.is-correct {
    background: var(--lr-ok-bg);
    border-top-color: var(--lr-ok-border);
    color: var(--lr-run);
    font-weight: 600;
}

.lr-feedback.is-wrong {
    background: var(--lr-bad-bg);
    border-top-color: var(--lr-bad-border);
}

.lr-feedback.is-wrong .lr-feedback-title {
    color: var(--lr-err);
    font-weight: 600;
}

.lr-feedback-title i {
    margin-right: 4px;
}

.lr-compare {
    margin-top: 6px;
}

.lr-compare summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--lr-muted);
    list-style: none;
    user-select: none;
}

.lr-compare summary::-webkit-details-marker {
    display: none;
}

.lr-compare summary:hover {
    color: var(--lr-heading);
}

/* Chevron: points right when collapsed, down when open */
.lr-compare summary::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.lr-compare[open] summary::before {
    transform: rotate(45deg) translate(-2px, -2px);
}

/* The input() form only wraps the input for mobile keyboards; keep the layout inline */
.lr-input-form {
    display: contents;
}

.lr-compare-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.lr-compare-label {
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--lr-muted);
}

.learn-content .lr-compare pre {
    min-height: 0;
    max-height: 220px;
    margin: 0;
    padding: 8px 10px;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    background: var(--lr-code-bg);
}

@media (max-width: 639px) {
    .lr-compare-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ========== "Going deeper" boxes (optional extras) ========== */
.learn-deeper {
    margin: 20px 0 24px;
    border: 1px dashed var(--lr-border);
    border-radius: 8px;
    background: var(--lr-panel);
}

.learn-deeper>summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--lr-heading);
    list-style: none;
    cursor: pointer;
}

.learn-deeper>summary::-webkit-details-marker {
    display: none;
}

.learn-deeper>summary:focus-visible {
    outline: 2px solid var(--lr-accent);
    outline-offset: 2px;
}

.learn-deeper>summary>.ic {
    color: var(--lr-accent);
}

.learn-deeper-title {
    flex: 1;
    min-width: 0;
}

/* Opens and closes it: a round chevron, pointing down, up once open, filled with the brand colour on hover (as
   /learn's rows' arrows) */
.learn-deeper-chev {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink-3);
    transition: background-color .15s, border-color .15s, color .15s;
}

.learn-deeper-chev .ic {
    width: 14px;
    height: 14px;
    vertical-align: 0;
    stroke-width: 2.2;
    transition: transform .2s ease;
}

.learn-deeper[open] .learn-deeper-chev .ic {
    transform: rotate(180deg);
}

.learn-deeper>summary:hover .learn-deeper-chev {
    border-color: var(--lr-accent);
    background: var(--lr-accent);
    color: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
    .learn-deeper-chev,
    .learn-deeper-chev .ic {
        transition: none;
    }
}

.learn-deeper-tag {
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--lr-surface-2);
    color: var(--lr-muted);
    font-size: 12px;
    font-weight: 600;
    vertical-align: 2px;
}

.learn-deeper-body {
    padding: 0 16px 6px;
    font-size: 17px;
}

.learn-deeper[open]>summary {
    border-bottom: 1px dashed var(--lr-border);
    margin-bottom: 12px;
}


/* ========== Callouts: > [!info|success|warning|danger] Title ========== */
.learn-content .learn-callout {
    --co: var(--lr-co-info);
    --co-bg: var(--lr-co-info-bg);
    margin: 0 0 18px;
    padding: 12px 16px;
    border-left: 4px solid var(--co);
    border-radius: 0 8px 8px 0;
    background: var(--co-bg);
    font-size: 17px;
}

.learn-content .learn-callout-success {
    --co: var(--lr-co-success);
    --co-bg: var(--lr-co-success-bg);
}

.learn-content .learn-callout-warning {
    --co: var(--lr-co-warning);
    --co-bg: var(--lr-co-warning-bg);
}

.learn-content .learn-callout-danger {
    --co: var(--lr-co-danger);
    --co-bg: var(--lr-co-danger-bg);
}

.learn-content .learn-callout-title {
    margin: 0 0 4px;
    color: var(--co);
    font-weight: 700;
}

.learn-content .learn-callout-title::before {
    display: inline-block;
    width: 1.3em;
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    content: "\f05a";
    /* info-circle */
}

.learn-content .learn-callout-success .learn-callout-title::before {
    content: "\f058";
    /* check-circle */
}

.learn-content .learn-callout-warning .learn-callout-title::before {
    content: "\f071";
    /* exclamation-triangle */
}

.learn-content .learn-callout-danger .learn-callout-title::before {
    content: "\f06a";
    /* exclamation-circle */
}

.learn-content .learn-callout-body> :last-child {
    margin-bottom: 0;
}

.learn-content .learn-callout-body:empty {
    display: none;
}

.learn-content .learn-callout:has(.learn-callout-body:empty) .learn-callout-title {
    margin-bottom: 0;
}


/* ========== Share buttons (the end of a lesson) ========== */
.learn-share {
    margin: 40px 0 0;
    text-align: center;
}

.learn-share-title {
    margin: 0 0 12px;
    color: var(--ink-2);
    font-size: 15px;
    font-weight: 650;
}

.learn-share-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.learn-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink-2);
    transition: transform .15s, background-color .15s, color .15s;
}

.learn-share-btn .ic {
    width: 18px;
    height: 18px;
}

.learn-share-btn:hover,
.learn-share-btn:focus-visible {
    border-color: transparent;
    color: #FFFFFF;
    text-decoration: none;
    transform: translateY(-2px);
}

.learn-share-btn.is-linkedin:hover { background: #0A66C2; }
.learn-share-btn.is-x:hover { background: #0F1419; }
.learn-share-btn.is-facebook:hover { background: #1877F2; }
.learn-share-btn.is-whatsapp:hover { background: #25D366; }

.learn-share-btn.is-copy:hover,
.learn-share-btn.is-copy:focus-visible {
    border-color: var(--line);
    background: var(--surface-2);
    color: var(--ink);
}

.learn-share-btn.is-copy.copied {
    border-color: var(--done);
    background: var(--done);
    color: #FFFFFF;
}

.learn-share-copied {
    display: block;
    min-height: 20px;
    margin-top: 8px;
    color: var(--done);
    font-size: 14px;
}

/* Python is loading (the first run): a spinner and what's happening, in the output */
.lr-loading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 4px 14px 14px;
    color: var(--lr-text);
}

.lr-loading[hidden] {
    display: none;
}

.lr-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--lr-border);
    border-top-color: var(--lr-accent);
    border-radius: 50%;
    animation: lr-spin 0.8s linear infinite;
}

.lr-loading-text {
    font-size: 14px;
    font-weight: 600;
}

.lr-loading-note {
    color: var(--lr-muted);
    font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
    .lr-loading-spinner {
        animation-duration: 2s;
    }
}

.lr-btn[hidden] {
    display: none;
}

/* ========== A document (/about, /privacy_policy, /terms_and_conditions, /content-policy: pages/document.php) ==========
   The prose is a lesson's (.learn-content) in a readable column under the title; the contents list sits beside it on wide
   screens, sticky, and is one row of links under the title on narrower ones. Drawn by the server: nothing moves. */
.doc-page {
    display: grid;
    grid-template-columns: minmax(0, 720px) 230px;
    column-gap: 56px;
    justify-content: center;
    align-items: start;
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 24px 72px;
}

.doc-head {
    grid-column: 1;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.doc-head h1 {
    margin: 0;
    font-size: clamp(34px, 4.6vw, 46px);
    line-height: 1.1;
    letter-spacing: -.02em;
}

.doc-date {
    margin: 10px 0 0;
    color: var(--ink-3);
    font-size: 14.5px;
}

.doc {
    grid-column: 1;
}

.doc .doc-lead {
    color: var(--ink-2);
    font-size: 19px;
    line-height: 1.6;
}

.doc h2 {
    margin-top: 44px;
    font-size: 24px;
}

.doc ul {
    padding-left: 22px;
}

.doc li {
    margin-bottom: 8px;
}

.doc li::marker {
    color: var(--ink-3);
}

.doc-toc {
    position: sticky;
    top: calc(var(--nav-h) + 24px);
    grid-row: 1 / span 2;
    grid-column: 2;
    max-height: calc(100vh - var(--nav-h) - 48px);
    overflow-y: auto;
    padding: 4px 0 4px 18px;
    border-left: 2px solid var(--line);
    font-size: 14px;
}

.doc-toc p {
    margin: 0 0 10px;
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 650;
}

.doc-toc ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.doc-toc a {
    color: var(--ink-2);
    line-height: 1.35;
}

.doc-toc a:hover {
    color: var(--brand);
    text-decoration: none;
}

/* The section being read (learn-nav.js): brand colour, and the bar over the list's line */
.doc-toc a[aria-current] {
    position: relative;
    color: var(--brand);
    font-weight: 600;
}

.doc-toc a[aria-current]::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -20px;
    border-left: 2px solid var(--brand);
}

/* Narrower: the links in one row under the title, scrolled sideways */
@media (max-width: 1000px) {
    .doc-page {
        grid-template-columns: minmax(0, 720px);
    }

    .doc-toc {
        position: static;
        grid-row: auto;
        grid-column: 1;
        max-height: none;
        margin: 0 0 28px;
        padding: 0;
        border: 0;
    }

    .doc-toc p {
        display: none;
    }

    .doc-toc ol {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 6px;
        scrollbar-width: thin;
    }

    .doc-toc li {
        flex: none;
    }

    .doc-toc a {
        display: block;
        padding: 6px 12px;
        border: 1px solid var(--line);
        border-radius: 999px;
        background: var(--surface);
        font-size: 13.5px;
        white-space: nowrap;
    }

    .doc-toc a[aria-current] {
        border-color: var(--brand);
    }

    .doc-toc a[aria-current]::before {
        content: none;
    }

    .doc-head {
        margin-bottom: 18px;
    }
}

@media (max-width: 600px) {
    .doc-page {
        padding: 28px 16px 56px;
    }

    .doc .doc-lead {
        font-size: 17.5px;
    }
}
