/* learn-course.css — the /learn/ lesson layout (plan C, task C1), on top of the studio kit (studio.css, frozen).
   Loaded by templates/learn/_lesson.html after studio.css. Every lesson: the course strip (a hardware rail whose
   15 LEDs are the course, lit when done, the current lesson as the playhead), the lesson head, 66-character prose,
   the teaching blocks of templates/learn/_macros.html, the footer (mark done, previous / next, tool cards), and
   the LearnUI controls (static/learn-ui.js).

   Accent: --learn-accent is the lesson's part color (inline on .learn, from build/learn_course.py PARTS); the kit's
   --st-accent follows it inside the lesson and its widgets, unless a widget sets its own.
   Hardware (strip, done pad, number tile) keeps the kit's charcoal in both themes; surfaces follow brizm's theme. */

/* ── course root ─────────────────────────────────────────────────────── */
.st-root.learn {
    --learn-accent: var(--st-orange);
    --learn-on-accent: #16171A;
    --learn-measure: 66ch;
    --learn-top: 56px;               /* style.css .top-bar height: the strip sticks under it */
    --st-accent: var(--learn-accent);
    position: relative;
    font-size: 1.0625rem;
    line-height: 1.65;
    letter-spacing: 0;
}
.learn .learn-widget { --st-accent: var(--learn-accent); }
.learn [id] { scroll-margin-top: calc(var(--learn-top) + 5rem); }

/* ── course strip ────────────────────────────────────────────────────── */
.learn-strip-sentinel {
    display: block;
    height: 1px;
    margin-bottom: -1px;
}
.learn-strip {
    position: sticky;
    top: var(--learn-top);
    z-index: 30;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
    margin: 0 0 2.6rem;
    padding: 6px;
    border: 1px solid rgba(0, 0, 0, 0.55);
    border-radius: 14px;
    background: linear-gradient(180deg, var(--st-panel-2), var(--st-panel));
    color: var(--st-panel-ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 18px 34px -26px rgba(0, 0, 0, 0.9);
}
.learn-strip.is-stuck {
    border-top-color: transparent;
    border-radius: 0 0 14px 14px;
}
.learn-strip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--st-target);
    height: var(--st-target);
    border-radius: 10px;
    background: var(--st-key);
    color: var(--st-key-ink);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
.learn a.learn-strip-btn { color: var(--st-key-ink); text-decoration: none; }
.learn a.learn-strip-btn:hover { background: #41464C; }
.learn a.learn-strip-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.3); }
.learn-strip-btn.is-off { opacity: 0.25; box-shadow: none; }
.learn-strip-mid {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    min-width: 0;
}
.learn-strip-where {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
    line-height: 1.15;
}
.learn a.learn-strip-part {
    overflow: hidden;
    color: var(--learn-accent);
    color: color-mix(in srgb, var(--learn-accent) 68%, #fff);
    font-size: 0.78rem;
    font-weight: 750;
    font-stretch: 90%;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-decoration: none;
}
.learn a.learn-strip-part:hover { text-decoration: underline; }
.learn-strip-pos {
    font-size: 0.98rem;
    font-weight: 800;
    font-stretch: 112%;
    letter-spacing: -0.005em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.learn-strip-of { font-weight: 600; color: var(--st-panel-muted); }

/* the 15 LEDs: tinted by part while unlit, lit in the part color when done, the current lesson taller and ringed */
.learn-dots {
    display: flex;
    flex: 1 1 auto;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    margin: 0;
    padding: 0 0.2rem 0 0;
    list-style: none;
}
.learn-dot {
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #2C3035;
    background: color-mix(in srgb, var(--dot) 20%, #2A2D31);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
    transition: background-color 0.25s, box-shadow 0.25s;
}
.learn-dot.is-part-start { margin-inline-start: 9px; }
.learn-dot.is-done {
    background: var(--dot);
    box-shadow: 0 0 8px 1px var(--dot), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 8px 1px color-mix(in srgb, var(--dot) 75%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.learn-dot.is-current {
    height: 24px;
    box-shadow: inset 0 0 0 2px var(--st-panel-ink), inset 0 1px 1px rgba(0, 0, 0, 0.6);
}
.learn-dot.is-current.is-done {
    box-shadow: inset 0 0 0 2px var(--st-panel-ink), 0 0 8px 1px var(--dot);
}

/* ── lesson head ─────────────────────────────────────────────────────── */
.learn-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 1.15rem;
    margin: 0 0 1.5rem;
}
.learn-num {                     /* the lesson number as a pad in the part color; its LED lights when done */
    position: relative;
    display: flex;
    align-items: flex-end;
    width: 4.3rem;
    height: 4.3rem;
    padding: 0 0.5rem 0.55rem;
    border-radius: 9px;
    background: var(--learn-accent);
    color: var(--learn-on-accent);
    font-size: 1.75rem;
    font-weight: 850;
    font-stretch: 125%;
    line-height: 1;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums lining-nums;
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.learn-num::before {
    content: "";
    position: absolute;
    top: 0.6rem;
    left: 0.62rem;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.32);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4);
}
.learn.is-done .learn-num::before { background: var(--st-led); box-shadow: 0 0 9px 2px var(--st-led); }
.learn-title {
    margin: 0.1rem 0 0;
    font-family: var(--st-font);
    font-size: clamp(2.05rem, 4.4vw, 3.3rem);
    font-weight: 820;
    font-stretch: 116%;
    line-height: 0.98;
    letter-spacing: -0.03em;
    color: var(--st-ink);
    text-wrap: balance;
}

/* ── prose ───────────────────────────────────────────────────────────── */
.learn-lead {
    max-width: 58ch;
    margin: 0 0 1.5em;
    font-size: 1.22rem;
    line-height: 1.5;
    color: var(--st-ink);
}
.learn-body { color: var(--st-ink); }
.learn-body > :where(p, ul, ol, h2, h3, h4, dl, blockquote) { max-width: var(--learn-measure); }
.learn-body p,
.learn-body ul,
.learn-body ol { margin: 0 0 1em; }
.learn-body ul,
.learn-body ol { padding-inline-start: 1.3em; }
.learn-body li { margin-bottom: 0.35em; }
.learn-body strong { font-weight: 720; }
.learn-body h2 {
    margin: 2.2em 0 0.55em;
    font-family: var(--st-font);
    font-size: 1.55rem;
    font-weight: 780;
    font-stretch: 112%;
    line-height: 1.12;
    letter-spacing: -0.018em;
}
.learn-body h3 {
    margin: 1.7em 0 0.4em;
    font-family: var(--st-font);
    font-size: 1.16rem;
    font-weight: 740;
    font-stretch: 105%;
    line-height: 1.25;
}
.learn-body dl { display: grid; grid-template-columns: minmax(7.5rem, max-content) 1fr; gap: 0.5rem 1.4rem; }
.learn-body dt { font-weight: 720; }
.learn-body dd { margin: 0; }

/* ── teaching blocks (templates/learn/_macros.html) ──────────────────── */
.learn .st-try { border-inline-start-color: var(--learn-accent); }
.learn-callout { max-width: var(--learn-measure); }
.learn-numbers {
    max-width: 54rem;
    margin: 1.7em 0;
    padding: 0.15rem 0 0.15rem 1rem;
    border-inline-start: 3px solid var(--learn-accent);
    overflow-x: auto;
}
/* Two class names (0,2,0) so the block's own heading beats .learn-body h3 (0,1,1), the prose heading look. */
.learn-numbers .learn-numbers-title {
    margin: 0 0 0.45em;
    font-family: var(--st-font);
    font-size: 1rem;
    font-weight: 760;
    font-stretch: 105%;
}
.learn-numbers p { color: var(--st-muted); }
.learn-numbers p strong { color: var(--st-ink); font-variant-numeric: tabular-nums; }
.learn-numbers table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.94rem;
    line-height: 1.4;
}
.learn-numbers th,
.learn-numbers td {
    padding: 0.5rem 0.85rem 0.5rem 0;
    border-bottom: 1px solid var(--st-line);
    text-align: start;
    vertical-align: top;
}
.learn-numbers th {
    border-bottom: 2px solid var(--st-ink);
    color: var(--st-muted);
    font-size: 0.85rem;
    font-weight: 700;
    font-stretch: 88%;
}
.learn-numbers td:first-child { font-weight: 680; white-space: nowrap; }

.learn-recipe {
    max-width: var(--learn-measure);
    margin: 0.75rem 0;
    padding: 0.85rem 1.1rem 0.95rem;
    border: 1px solid var(--st-line);
    border-inline-start: 4px solid var(--learn-accent);
    border-radius: 12px;
    background: var(--st-surface);
}
.learn-recipe-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.35rem;
}
.learn-recipe .learn-recipe-name {   /* (0,2,0) beats .learn-body h3: the name stays on its Play button's row */
    margin: 0;
    font-family: var(--st-font);
    font-size: 1.06rem;
    font-weight: 760;
    font-stretch: 106%;
}
.learn-recipe-icon {
    width: 0;
    height: 0;
    border-inline-start: 11px solid var(--learn-accent);
    border-block: 7px solid transparent;
}
.learn-recipe p { margin: 0 0 0.6em; font-size: 0.97rem; }
.learn-recipe-link,
.learn-groove-link { font-size: 0.88rem; font-weight: 650; }

.learn-groove {
    display: inline-flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0.5rem 0.75rem 0.5rem 0;
    vertical-align: top;
}
.learn-groove-pad { min-width: 11rem; }

.learn .learn-widget { margin: 2rem 0; }

/* ── LearnUI controls (static/learn-ui.js) ───────────────────────────── */
.learn-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.learn-field-label {
    font-size: 0.85rem;
    font-weight: 650;
    font-stretch: 92%;
    color: var(--st-muted);
}
.learn-select {
    max-width: 100%;
    min-height: var(--st-target);
    padding: 0 0.6rem;
    border: 1px solid var(--st-line);
    border-radius: 9px;
    background: var(--st-raised);
    color: var(--st-ink);
    font: inherit;
    font-family: var(--st-font);
    font-size: 0.95rem;
    font-weight: 600;
    color-scheme: dark;
}
[data-theme="light"] .learn-select { color-scheme: light; }
.st-panel .learn-select { color-scheme: dark; }
.learn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.learn-chip,
.learn-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--st-target);
    padding: 0 0.95rem;
    border: 1px solid var(--st-line);
    border-radius: 999px;
    background: var(--st-raised);
    color: var(--st-ink);
    font: inherit;
    font-family: var(--st-font);
    font-size: 0.9rem;
    font-weight: 650;
    font-stretch: 92%;
    cursor: pointer;
}
.learn-chip:hover,
.learn-toggle:hover { border-color: var(--st-muted); }
.learn-chip[aria-pressed="true"] {
    border-color: var(--st-accent);
    background: var(--st-accent);
    color: var(--st-on-accent);
}
.learn-toggle { border-radius: 9px; }
.learn-toggle::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--st-sunk);
    box-shadow: inset 0 0 0 1px var(--st-line);
}
.learn-toggle[aria-pressed="true"]::before { background: var(--st-accent); box-shadow: 0 0 6px var(--st-accent); }
.learn-hold { touch-action: none; }

/* ── footer: mark done, previous / next, tool cards ──────────────────── */
.learn-foot {
    display: grid;
    gap: 2.2rem;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--st-line);
}
.learn-done-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.2rem;
}
.learn-done {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 3.5rem;
    padding: 0 1.45rem 0 1.15rem;
    border: 0;
    border-radius: 10px;
    background: var(--st-key);
    color: var(--st-key-ink);
    font: inherit;
    font-family: var(--st-font);
    font-size: 1.02rem;
    font-weight: 780;
    font-stretch: 108%;
    cursor: pointer;
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: transform 0.06s, box-shadow 0.06s, background-color 0.15s;
}
.learn-done:hover { filter: brightness(1.08); }
.learn-done:active,
.learn-done[aria-pressed="true"] {
    transform: translateY(2px);
    box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.28);
}
.learn-done[aria-pressed="true"] { background: var(--learn-accent); color: var(--learn-on-accent); }
.learn-done-led {
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.42);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.5);
}
.learn-done[aria-pressed="true"] .learn-done-led { background: var(--st-led); box-shadow: 0 0 10px 2px var(--st-led); }
.learn-done-status {
    margin: 0;
    color: var(--st-muted);
    font-size: 0.92rem;
}

.learn-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.learn a.learn-pager-link {
    --pager: var(--learn-accent);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    min-height: 5.25rem;
    padding: 0.9rem 1.15rem;
    border: 1px solid var(--st-line);
    border-inline-start: 4px solid var(--pager);
    border-radius: 12px;
    background: var(--st-surface);
    color: var(--st-ink);
    text-decoration: none;
}
.learn a.learn-pager-link--next {
    align-items: flex-end;
    text-align: end;
    border-inline-start-width: 1px;
    border-inline-start-color: var(--st-line);
    border-inline-end: 4px solid var(--pager);
}
.learn a.learn-pager-link:hover { border-color: var(--pager); }
.learn-pager-dir {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--st-muted);
    font-size: 0.84rem;
    font-weight: 650;
    font-stretch: 92%;
}
.learn-pager-title {
    font-size: 1.15rem;
    font-weight: 780;
    font-stretch: 110%;
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.learn-pager-n {
    margin-inline-end: 0.5em;
    color: var(--st-muted);
    font-variant-numeric: tabular-nums;
}

.learn-tools-title {
    margin: 0 0 0.8rem;
    font-family: var(--st-font);
    font-size: 1.15rem;
    font-weight: 760;
    font-stretch: 108%;
}
.learn-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.75rem;
}
.learn-cards .st-card-link { align-content: start; }   /* a card stretched to its row keeps title over text */

/* ── small screens: the strip folds to label over LEDs between its buttons ── */
@media (max-width: 640px) {
    .st-root.learn { font-size: 1rem; }
    .learn-strip {
        gap: 0.5rem;
        margin-bottom: 1.8rem;
        padding: 5px;
    }
    .learn-strip-mid {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    .learn-strip-where {
        flex-direction: row;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.5rem;
    }
    .learn-strip-pos { font-size: 0.82rem; font-stretch: 100%; }
    .learn-strip-word {          /* "4 of 15" on screen; still read as "Lesson 4 of 15" */
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .learn-dots { justify-content: flex-start; gap: 3px; padding: 0; }
    .learn-dot { width: 9px; height: 9px; border-radius: 2px; }
    .learn-dot.is-part-start { margin-inline-start: 6px; }
    .learn-dot.is-current { height: 15px; }
    .learn-head { gap: 0.8rem; }
    .learn-num { width: 3.3rem; height: 3.3rem; font-size: 1.35rem; padding: 0 0.4rem 0.42rem; }
    .learn-num::before { top: 0.45rem; left: 0.48rem; width: 7px; height: 7px; }
    .learn-title { font-size: clamp(1.75rem, 8.4vw, 2.3rem); }
    .learn-lead { font-size: 1.1rem; }
    .learn-pager { grid-template-columns: 1fr; }
    .learn-done { width: 100%; justify-content: center; }
}

/* ── room for the Studio transport bar (task C5, controller ruling) ───────
   The bar (studio.css, frozen) is the last child of main, position: sticky at bottom 0, or 56 px above the fixed
   .bottom-bar at <= 1024 px; it measures 58.8 px tall at 390, 768, 1024 and 1440 px. Sticky, it already sits below
   the page's last content at the page end. While it shows on a /learn/ page, the scrollport also ends above it, so
   anything scrolled into view (focus, scrollIntoView, an anchor) lands clear of it: a step grid's last row stays
   visible above the bar instead of behind it. */
html:has(.st-root.learn):has(main > .st-transport:not([hidden])) {
    scroll-padding-bottom: calc(59px + 0.75rem);
}
@media (max-width: 1024px) {
    html:has(.st-root.learn):has(main > .st-transport:not([hidden])) {
        scroll-padding-bottom: calc(56px + 59px + 0.75rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .learn-dot,
    .learn-done,
    .learn a.learn-strip-btn { transition: none; }
}

@media print {
    .learn-strip,
    .learn-strip-sentinel,
    .learn-done-row,
    .learn-pager { display: none !important; }
}
