/* /learn tutorial pages: layout, prose and runnable code widgets */

/* ========== Text font: Google Sans Flex (OFL), self-hosted variable font, 400-700 ========== */
@font-face {
    font-family: "Google Sans Flex";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/google-sans-flex-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Google Sans Flex";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/google-sans-flex-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Arial resized to Google Sans Flex's metrics, shown until the font arrives,
   so the swap barely moves the text (less layout shift) */
@font-face {
    font-family: "Google Sans Flex Fallback";
    src: local("Arial"), local("ArialMT");
    size-adjust: 100.8%;
    ascent-override: 95.8%;
    descent-override: 28.4%;
    line-gap-override: 0%;
}

body.learn-page {
    font-family: "Google Sans Flex", "Google Sans Flex Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* A touch of tracking makes long body text easier to read */
    letter-spacing: 0.015em;
}

/* Large headings look loose with extra tracking; keep them at the font's default */
.learn-article h1,
.learn-content h2,
.learn-content h3,
.learn-hero h1 {
    letter-spacing: 0;
}

/* Code must stay monospaced-aligned (Ace measures character widths) */
body.learn-page code,
body.learn-page pre,
body.learn-page kbd,
body.learn-page .ace_editor,
body.learn-page .lr-input {
    letter-spacing: normal;
}

body.learn-page {
    /* Light theme: one flat white page like the dark theme (no paper card);
       the sidebar sits on a soft grey panel and the code widgets carry the structure */
    --lr-bg: #ffffff;
    --lr-card: #ffffff;
    --lr-card-border: transparent;
    --lr-panel: #f8f9fa;
    --lr-surface: #ffffff;
    --lr-surface-2: #f1f3f5;
    --lr-code-bg: #ffffff;
    --lr-border: #dde2e8;
    --lr-text: #3c4043;
    --lr-heading: #2d2f31;
    --lr-muted: #5f6368;
    --lr-accent: #0678f4;
    --lr-accent-soft: #e8f1fe;
    --lr-run: #1f9d55;
    --lr-run-hover: #188a49;
    --lr-stop: #d1453b;
    --lr-err: #c62828;
    --lr-info: #6e7781;
    --lr-in: #0b6bcb;
    --lr-inline-code: #eff1f3;
    --lr-inline-code-text: #24292f;
    --lr-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    background: var(--lr-bg);
    color: var(--lr-text);
    overflow-y: auto;
}

/* Dark theme: flat charcoal page, light grey text, bright blue links */
body.learn-page.dark {
    --lr-bg: #1b1e21;
    --lr-card: #1b1e21;
    --lr-card-border: transparent;
    --lr-panel: #212529;
    --lr-surface: #212529;
    --lr-surface-2: #2b3035;
    --lr-code-bg: #181b1f;
    --lr-border: #373b3e;
    --lr-text: #cfd4da;
    --lr-heading: #eef1f4;
    --lr-muted: #adb5bd;
    --lr-accent: #6ea8fe;
    --lr-accent-soft: #2b3035;
    --lr-run: #22a35a;
    --lr-run-hover: #2bb867;
    --lr-stop: #e0574d;
    --lr-err: #ff7b72;
    --lr-info: #8a9199;
    --lr-in: #79c0ff;
    --lr-inline-code: #2b3035;
    --lr-inline-code-text: #e6c07b;
    --lr-shadow: none;
}

body.learn-page.dark .navbar-top {
    border-bottom: 1px solid var(--lr-card-border);
}

/* Flat white page: a hairline keeps the pinned navbar apart from the content */
body.learn-page:not(.dark) .navbar-top {
    border-bottom: 1px solid var(--lr-border);
}

/* ========== Layout ========== */
.learn-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 160px;
    gap: 28px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    align-items: start;
}

.learn-main {
    min-width: 0;
}

/* The lesson sits straight on the page (flat, in both themes) */
.learn-article {
    max-width: 1040px;
    margin: 0 auto;
    padding: 28px 48px 40px;
    background: var(--lr-card);
    border: 1px solid var(--lr-card-border);
    border-radius: 12px;
}

/* ========== Lesson nav (left) ========== */
.learn-nav {
    position: sticky;
    top: 16px;
}

.learn-nav-box {
    background: var(--lr-panel);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
}

.learn-nav-title {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 15px;
    color: var(--lr-text);
    cursor: pointer;
    list-style: none;
}

.learn-nav-title::-webkit-details-marker {
    display: none;
}

/* Long lesson lists scroll inside the sticky panel */
.learn-nav-scroll {
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    padding-bottom: 8px;
}

.learn-nav-group + .learn-nav-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--lr-border);
}

.learn-nav-part {
    padding: 8px 18px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lr-info);
}

.learn-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 4px;
}

.learn-nav-list a {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--lr-muted);
    font-size: 15px;
    line-height: 1.35;
    text-decoration: none;
}

.learn-nav-num {
    flex: none;
    min-width: 1.6em;
    color: var(--lr-info);
}

.learn-nav-list a.active .learn-nav-num {
    color: inherit;
}

.learn-nav-list a:hover {
    background: var(--lr-surface-2);
    color: var(--lr-text);
    text-decoration: none;
}

.learn-nav-list a.active {
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    font-weight: 600;
}

/* ========== Ad rail (right) ========== */
/* The rail column itself is sticky (like the lesson nav), so the ad stays
   pinned to the top of the viewport while the lesson scrolls */
.learn-rail {
    position: sticky;
    top: 16px;
}

/* Reserve ad space up front so the page does not shift when the ad loads */
.learn-rail [data-freestar-ad] {
    width: 160px;
    min-height: 600px;
}

/* ========== Article prose ========== */
.learn-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.learn-breadcrumb {
    margin: 0;
    font-size: 14px;
    color: var(--lr-muted);
}

.learn-breadcrumb a {
    color: var(--lr-accent);
}

.learn-theme-toggle {
    border: 1px solid var(--lr-border);
    background: var(--lr-surface);
    color: var(--lr-text);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
}

.learn-article h1 {
    font-size: 40px;
    font-weight: 700;
    margin: 12px 0 20px;
    color: var(--lr-heading);
}

.learn-content {
    font-size: 18px;
    line-height: 1.7;
}

.learn-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 40px 0 12px;
    padding-top: 8px;
    color: var(--lr-heading);
}

.learn-content h3 {
    font-size: 21px;
    font-weight: 600;
    margin: 28px 0 10px;
    color: var(--lr-heading);
}

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

.learn-content a {
    color: var(--lr-accent);
}

.learn-content code {
    font-family: "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 0.86em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
}

.learn-content pre {
    background: var(--lr-panel);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--lr-text);
    overflow-x: auto;
}

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

.learn-content pre.lr-static .ace_static_highlight {
    background: transparent;
    border: 0;
    font-size: 14px;
}

.learn-content table {
    width: 100%;
    margin: 0 0 20px;
    border-collapse: collapse;
    font-size: 16px;
}

.learn-content th,
.learn-content td {
    padding: 8px 12px;
    border: 1px solid var(--lr-border);
    text-align: left;
}

.learn-content th {
    background: var(--lr-surface-2);
}

.learn-content blockquote {
    margin: 0 0 16px;
    padding: 10px 16px;
    border-left: 4px solid var(--lr-accent);
    background: var(--lr-accent-soft);
    border-radius: 0 6px 6px 0;
    font-size: 17px;
}

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

/* ========== Runnable widget ========== */
.lr-runner {
    margin: 20px 0 28px;
    background: var(--lr-surface);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    box-shadow: var(--lr-shadow);
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
}

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

.lr-editor-pane,
.lr-output-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lr-output-pane {
    position: relative;
    border-left: 1px solid var(--lr-border);
}

.lr-tabs {
    display: flex;
    align-items: stretch;
    background: var(--lr-surface-2);
    border-bottom: 1px solid var(--lr-border);
    height: 32px;
    flex: none;
}

.lr-tab,
.lr-tab-label {
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-weight: 600;
    font-size: 13px;
    color: var(--lr-muted);
    background: none;
    border: 0;
    border-right: 1px solid transparent;
    border-left: 1px solid transparent;
}

.lr-tab {
    cursor: pointer;
}

/* answer.py stays hidden until "Show answer" (display:flex above would override [hidden]) */
.lr-tab[hidden] {
    display: none;
}

.lr-tab-label,
.lr-tab.active {
    color: var(--lr-text);
    background: var(--lr-code-bg);
    border-color: var(--lr-border);
    margin-bottom: -1px;
}

.lr-tab:first-child,
.lr-tab-label {
    border-left-color: transparent;
}

/* Clear sits at the right end of the Output tab strip */
.lr-clear {
    margin-left: auto;
    padding: 0 12px;
    border: 0;
    background: none;
    color: var(--lr-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.lr-clear:hover {
    color: var(--lr-text);
}

.lr-clear i {
    margin-right: 3px;
}

.learn-content .lr-code,
.learn-content .lr-output {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: var(--lr-code-bg);
}

/* Ace sizes itself (12-30 lines); the output pane stretches to match it */
.learn-content .lr-code {
    flex: none;
    padding: 0;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
}

/* Ace must clip its own gutter; the generic ".learn-content pre" rules would otherwise override it */
.lr-editor-pane {
    overflow: hidden;
}

.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 widget surface 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: same rows x line height as the editor will have.
   --lr-rows (12-30) is set per runner by Lesson_markdown.php */
.learn-content pre.lr-code:not(.ace_editor) {
    height: calc(var(--lr-rows, 12) * 18px);
    padding: 0 16px 0 48px;
    white-space: pre;
    overflow: hidden;
}

/* Output is pinned below its tab strip and never taller than the editor:
   long output scrolls instead of stretching the widget */
.learn-content .lr-output {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 14px;
    overflow: auto;
    font-family: "Fira Mono", "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--lr-text);
}

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

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

.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;
}

.lr-bar {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--lr-surface-2);
    border-top: 1px solid var(--lr-border);
}

.lr-btn {
    height: 28px;
    padding: 0 12px;
    border-radius: 5px;
    border: 1px solid var(--lr-border);
    background: var(--lr-code-bg);
    color: var(--lr-text);
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.lr-btn:hover {
    border-color: var(--lr-muted);
}

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

.lr-run {
    min-width: 76px;
    background: var(--lr-run);
    border-color: var(--lr-run);
    color: #fff;
}

.lr-run:hover:not(:disabled) {
    background: var(--lr-run-hover);
    border-color: var(--lr-run-hover);
}

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

.lr-run i {
    font-size: 10px;
    margin-right: 4px;
}

/* Exercise bar: Run, Reset, status ... then Hint and Show answer on the right */
.lr-hint-btn {
    margin-left: auto;
}

.lr-hint-btn[hidden] + .lr-show-answer {
    margin-left: auto;
}

.lr-hint-btn i {
    color: #d4a017;
    margin-right: 2px;
}

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

.lr-runner[data-kind="example"] .lr-status {
    margin-left: auto;
}

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

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

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

/* Spinner while Pyodide downloads and starts (first run can take a few seconds) */
.lr-status.loading {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.lr-status.loading::before {
    content: "";
    flex: none;
    width: 13px;
    height: 13px;
    border: 2px solid var(--lr-border);
    border-top-color: var(--lr-accent);
    border-radius: 50%;
    animation: lr-spin 0.7s linear infinite;
}

@keyframes lr-spin {
    to { transform: rotate(360deg); }
}

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

/* ========== Landing page ========== */
.learn-hero {
    padding-bottom: 28px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--lr-border);
}

.learn-hero h1 {
    margin-bottom: 12px;
}

.learn-lead {
    font-size: 19px;
    line-height: 1.6;
    color: var(--lr-muted);
    max-width: 720px;
}

.learn-lead code {
    font-family: "Fira Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 0.86em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--lr-inline-code);
    color: var(--lr-inline-code-text);
}

.learn-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    list-style: none;
    margin: 18px 0 24px;
    padding: 0;
    font-size: 15px;
    color: var(--lr-text);
}

.learn-features i {
    color: var(--lr-run);
    margin-right: 4px;
}

.learn-hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.learn-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 22px;
    border-radius: 8px;
    background: var(--lr-run);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
}

.learn-cta:hover,
.learn-cta:focus {
    background: var(--lr-run-hover);
    color: #fff;
    text-decoration: none;
}

.learn-cta-secondary {
    color: var(--lr-accent);
    font-weight: 600;
    font-size: 15px;
}

.learn-stats {
    margin: 18px 0 0;
    font-size: 14px;
    color: var(--lr-muted);
}

.learn-part {
    margin-top: 36px;
}

.learn-part-head {
    margin-bottom: 14px;
}

.learn-part-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lr-accent);
}

.learn-part-head h2 {
    margin: 2px 0 4px;
    font-size: 26px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-part-head p {
    margin: 0;
    font-size: 16px;
    color: var(--lr-muted);
}

.learn-topics {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.learn-topics > li {
    display: flex;
}

.learn-topic {
    flex: 1;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    background: var(--lr-surface);
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    color: var(--lr-text);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}

a.learn-topic:hover {
    border-color: var(--lr-accent);
    color: var(--lr-text);
    text-decoration: none;
    transform: translateY(-1px);
}

.learn-topic-num {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--lr-accent-soft);
    color: var(--lr-accent);
    font-weight: 700;
    font-size: 14px;
}

.learn-topic-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.learn-topic-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--lr-heading);
}

.learn-topic-desc {
    font-size: 14px;
    line-height: 1.45;
    color: var(--lr-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.learn-topic.is-soon {
    background: transparent;
    border-style: dashed;
}

.learn-topic.is-soon .learn-topic-num {
    background: var(--lr-surface-2);
    color: var(--lr-info);
}

.learn-topic.is-soon .learn-topic-title {
    color: var(--lr-muted);
    font-weight: 600;
}

.learn-soon {
    font-size: 12px;
    font-weight: 600;
    color: var(--lr-info);
}

/* ========== Prev / Next ========== */
.learn-pager {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--lr-border);
}

.learn-pager-link {
    display: flex;
    flex-direction: column;
    max-width: 48%;
    padding: 12px 16px;
    border: 1px solid var(--lr-border);
    border-radius: 8px;
    background: var(--lr-surface);
    text-decoration: none;
}

.learn-pager-link:hover {
    border-color: var(--lr-accent);
    text-decoration: none;
}

.learn-pager-link.next {
    margin-left: auto;
    text-align: right;
}

.learn-pager-label {
    font-size: 13px;
    color: var(--lr-muted);
}

.learn-pager-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--lr-accent);
}

/* ========== Responsive ========== */
@media (max-width: 1199px) {
    .learn-layout {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .learn-rail {
        display: none;
    }
}

@media (max-width: 899px) {
    .learn-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 16px 16px 48px;
    }

    .learn-nav {
        position: static;
    }

    .learn-nav-scroll {
        max-height: 60vh;
    }

    .learn-nav-title::after {
        content: "\25BE";
        float: right;
        color: var(--lr-muted);
    }

    .learn-article {
        padding: 20px 16px 28px;
        border-radius: 10px;
    }

    .learn-article h1 {
        font-size: 32px;
    }
}

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

    .lr-output-pane {
        border-left: 0;
        border-top: 1px solid var(--lr-border);
    }

    /* Stacked on phones: the output gets its own fixed height */
    .learn-content .lr-output {
        position: static;
        height: 200px;
    }

    .learn-content {
        font-size: 17px;
    }

    /* Phones: the article card already pads its text, so keep the outer gutter thin */
    .learn-layout {
        padding-left: 6px;
        padding-right: 6px;
    }
}

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

/* ========== Bottom ad ========== */
.learn-bottom-ad {
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 20px 32px;
    text-align: center;
}

/* In-content unit (336x280): reserve its height so the page does not shift */
/* Cap the width at the placement's largest size (970px). Native ads stretch to fill
   their container; at full page width they grew taller than their iframe and the
   bottom row (sponsor name, AdChoices icon) was clipped. */
.learn-bottom-ad [data-freestar-ad] {
    max-width: 970px;
    min-height: 280px;
    margin: 0 auto;
}

/* ========== Site footer ========== */
.site-footer {
    background: var(--lr-card);
    border-top: 1px solid var(--lr-border);
    color: var(--lr-muted);
    font-size: 15px;
    /* Room for Freestar's sticky footer ad so it never covers the footer */
    padding-bottom: 120px;
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px 20px 20px;
}

.site-footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--lr-heading);
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
}

.site-footer-logo:hover {
    color: var(--lr-heading);
    text-decoration: none;
}

.site-footer-brand p {
    margin: 6px 0 0;
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}

.site-footer-links a {
    color: var(--lr-muted);
    text-decoration: none;
}

.site-footer-links a:hover {
    color: var(--lr-accent);
    text-decoration: none;
}

.site-footer-copy {
    max-width: 1480px;
    margin: 0 auto;
    padding: 14px 20px 22px;
    border-top: 1px solid var(--lr-border);
    font-size: 13px;
}

@media (max-width: 639px) {
    .site-footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 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;
}

/* Divider between runs in the Output pane */
.lr-output .lr-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--lr-info);
    white-space: nowrap;
    user-select: none;
}

.lr-output .lr-sep::before,
.lr-output .lr-sep::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--lr-border);
}

.lr-output .lr-sep::before {
    flex: 0 0 12px;
}

/* 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 ========== */
body.learn-page {
    --lr-hint-bg: #fff8e1;
    --lr-hint-border: #f3d98b;
    --lr-ok-bg: #e9f7ef;
    --lr-ok-border: #a7dcba;
    --lr-bad-bg: #fdf0ef;
    --lr-bad-border: #f2c0bb;
}

body.learn-page.dark {
    --lr-hint-bg: #2c2a1f;
    --lr-hint-border: #5a5030;
    --lr-ok-bg: #1d2b22;
    --lr-ok-border: #2f5a3c;
    --lr-bad-bg: #2f2020;
    --lr-bad-border: #5c3431;
}

.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: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    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: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    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 {
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--lr-heading);
    cursor: pointer;
}

.learn-deeper > summary i {
    margin-right: 6px;
    color: var(--lr-accent);
}

.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;
}

/* ========== Fixed top navbar on lesson pages ========== */
body.learn-page {
    --learn-nav-h: 40px;
}

body.learn-page .navbar-top {
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Side columns stick just below the navbar instead of sliding under it */
body.learn-page .learn-nav,
body.learn-page .learn-rail {
    top: calc(var(--learn-nav-h) + 16px);
}

body.learn-page .learn-nav-scroll {
    max-height: calc(100vh - var(--learn-nav-h) - 90px);
}

@media (max-width: 899px) {
    body.learn-page .learn-nav-scroll {
        max-height: 60vh;
    }
}

/* Wide reference tables (methods at a glance) scroll sideways on phones
   instead of squeezing their code into unreadable columns */
@media (max-width: 639px) {
    .learn-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .learn-content td code {
        white-space: nowrap;
    }
}

/* In-page links (#section) land below the pinned navbar, not under it */
.learn-content h2[id],
.learn-content h3[id] {
    scroll-margin-top: calc(var(--learn-nav-h) + 16px);
}
