/* learn-rhythm.css — lessons 9, 14 and 15 of /learn/ (plan C, task C8): rhythm and groove, ear training, the
   practice plan and glossary. Loaded in each lesson's learn_styles block, after studio.css and learn-course.css.

   Look: the two guides on the studio kit. Hardware panels stay charcoal in both themes; the rest follows brizm's
   theme through the kit tokens (--st-ink, --st-muted, --st-line, --st-surface). Widgets take the lesson's part
   accent (--st-accent). One bold element per page: the rhythm lab's pattern bank and the groove lab's swing timeline
   (lesson 9), the score meter (14), the week plan and the letter keys (15).

   Classes: lr-* (widgets from static/learn-w-{rhythm,groove-lab,ear}.js, and the glossary page). */

/* ── shared widget head ──────────────────────────────────────────────── */
.lr-placeholder { margin: 0; padding: 1.2rem; color: var(--st-muted); }
.lr-head,
.lr-ear-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.2rem 1rem;
    margin-bottom: 1rem;
}
.learn-body .lr-title {
    margin: 0;
    font-family: var(--st-font);
    font-size: 1.3rem;
    font-weight: 800;
    font-stretch: 112%;
    letter-spacing: -0.012em;
    line-height: 1.1;
}
.lr-sub {
    margin: 0;
    color: var(--st-muted);
    font-size: 0.92rem;
    line-height: 1.4;
}
.learn-body .lr-head p,
.learn-body .lr-ear-head p { margin: 0; }
.lr-ctls {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
    gap: 0.9rem 1.4rem;
    align-items: end;
    margin: 1.1rem 0 1.2rem;
}
.lr-ctls .st-slider { margin: 0; }
.lr-ctl-toggle { display: flex; align-items: flex-end; }

/* ── rhythm lab: the pattern bank ────────────────────────────────────── */
.lr-bank {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.15rem;
}
.lr-fam {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}
.learn-body .lr-fam-name {
    margin: 0 0 0.05rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--st-panel-line);
    color: var(--st-panel-muted);
    font-size: 0.8rem;
    font-weight: 700;
    font-stretch: 90%;
}
.lr-pad.st-pad {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    min-height: 3.35rem;
    padding: 0.45rem 0.7rem;
}
.lr-pad .st-pad-name {
    font-size: 0.93rem;
    font-weight: 780;
    font-stretch: 94%;
    line-height: 1.12;
}
.lr-pad .st-pad-meta { margin-top: 0.15rem; font-size: 0.72rem; }
.lr-pad[aria-current="true"]:not(.is-on) {
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.3), 0 0 0 2px var(--st-panel), 0 0 0 4px var(--st-panel-ink);
}
.lr-pad:focus-visible,
.lr-answer:focus-visible,
.lr-ask:focus-visible,
.lr-reset:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 3px; }

/* the pattern now loaded: play key, name, tempo, what to listen for */
.lr-now {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.4rem 1rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    background: var(--st-well);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
}
.lr-now-top {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.85rem;
}
.learn-body .lr-now-name {
    margin: 0;
    font-size: clamp(1.3rem, 2.6vw, 1.75rem);
    font-weight: 830;
    font-stretch: 116%;
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--st-panel-ink);
}
.learn-body .lr-now-bpm {
    margin: 0;
    color: var(--st-accent);
    color: color-mix(in srgb, var(--st-accent) 70%, #fff);
    font-size: 0.95rem;
}
.learn-body .lr-now-text {
    max-width: 64ch;
    margin: 0.3rem 0 0;
    color: var(--st-panel-muted);
    font-size: 0.95rem;
    line-height: 1.45;
}
.lr-grid { margin-top: 0.4rem; }

/* ── groove lab ──────────────────────────────────────────────────────── */
.lr-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}
.learn-body .lr-cap {
    max-width: 70ch;
    margin: 0.6rem 0 0;
    color: var(--st-panel-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

/* the swing timeline: ticks are the straight grid, marks where each hit lands */
.lr-timeline { margin: 1.1rem 0 0; }
.lr-ruler {
    position: relative;
    height: 5rem;
    border-radius: 10px;
    background: var(--st-well);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}
.lr-ruler-line {
    position: absolute;
    top: 2.1rem;
    left: 1.5%;
    right: 1.5%;
    height: 1px;
    background: var(--st-panel-line);
}
.lr-tick,
.lr-mark,
.lr-beat-n {
    position: absolute;
    transform: translateX(-50%);
}
.lr-tick {
    top: 1.65rem;
    width: 1px;
    height: 0.95rem;
    background: #4A4F56;
}
.lr-tick.is-beat { top: 1.35rem; height: 1.55rem; background: var(--st-panel-muted); }
.lr-lag {
    position: absolute;
    top: 3.5rem;
    height: 2px;
    border-radius: 1px;
    background: var(--st-accent);
    opacity: 0.7;
    transition: width 0.08s;
}
.lr-mark {
    top: 1.93rem;
    width: 4px;
    height: 0.35rem;
    border-radius: 2px;
    background: #3C4045;
    transition: left 0.08s;
}
.lr-mark.has-hit {                 /* height = the loudest hit at the step: ghost, normal, accent */
    --lv: 2;
    top: calc(2.1rem - var(--lv) * 0.42rem);
    width: 6px;
    height: calc(var(--lv) * 0.84rem);
    background: var(--st-accent);
}
.lr-mark.is-now {
    width: 8px;
    background: var(--st-led);
    box-shadow: 0 0 9px 2px rgba(255, 59, 40, 0.65);
}
.lr-beat-n {
    bottom: 0.3rem;
    color: var(--st-panel-muted);
    font-size: 0.74rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.learn-body .lr-timeline-cap {
    margin: 0.45rem 0 0;
    color: var(--st-panel-muted);
    font-size: 0.84rem;
    line-height: 1.4;
}

/* ── ear trainer ─────────────────────────────────────────────────────── */
.lr-ear {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
    gap: 1rem;
}
.lr-quiz { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.learn-body .lr-quiz-title {
    margin: 0;
    font-family: var(--st-font);
    font-size: 1.12rem;
    font-weight: 780;
    font-stretch: 108%;
    color: var(--st-panel-ink);
}
.lr-quiz-opts { display: grid; gap: 0.7rem; }
.lr-quiz-go { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: stretch; }
.lr-ask.st-pad {
    flex: 1 1 11rem;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    min-height: 3.5rem;
    padding: 0.5rem 0.9rem;
}
.lr-ask .st-pad-name { font-size: 1.05rem; }
.lr-replay { flex: 0 0 auto; min-height: 3.5rem; padding: 0 1.2rem; }
.lr-answers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.2rem, 1fr));
    gap: 0.45rem;
}
.lr-answer {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: var(--st-target);
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--st-panel-line);
    border-radius: 8px;
    background: var(--st-key);
    color: var(--st-key-ink);
    font: inherit;
    font-family: var(--st-font);
    font-size: 0.9rem;
    font-weight: 700;
    font-stretch: 92%;
    line-height: 1.15;
    text-align: start;
    cursor: pointer;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.28);
}
.lr-answer:hover { border-color: var(--st-panel-muted); }
.lr-answer:active { transform: translateY(1px); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.28); }
.lr-answer-led {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #2C3035;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
}
.lr-answer.is-right { border-color: #2F8A4C; background: #1F3A29; }
.lr-answer.is-right .lr-answer-led { background: #3DDC6E; box-shadow: 0 0 8px 1px #3DDC6E; }
.lr-answer.is-wrong { border-color: var(--st-808-red); background: #3E1F1C; }
.lr-answer.is-wrong .lr-answer-led { background: var(--st-led); box-shadow: 0 0 8px 1px var(--st-led); }
.learn-body .lr-feedback {
    min-height: 3.1em;
    margin: 0;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    border-inline-start: 3px solid var(--st-panel-line);
    background: var(--st-well);
    color: var(--st-panel-ink);
    font-size: 0.93rem;
    line-height: 1.4;
}
.learn-body .lr-feedback.is-right { border-inline-start-color: #3DDC6E; }
.learn-body .lr-feedback.is-wrong { border-inline-start-color: var(--st-led); }
.lr-score {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
}
.lr-score-main { display: grid; gap: 0.4rem; flex: 1 1 12rem; }
.learn-body .lr-score-text { margin: 0; color: var(--st-panel-ink); font-size: 0.95rem; }
.lr-meter.st-leds { position: relative; max-width: 15rem; margin: 0.9rem 0 0; gap: 3px; }
.lr-meter .st-led { min-height: 14px; }
.lr-meter .st-led.is-mark { position: relative; }
.lr-meter .st-led.is-mark::after {      /* the guide's bar: move up a level above 80 % */
    content: "80%";
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    color: var(--st-panel-muted);
    font-size: 0.66rem;
    font-weight: 750;
    line-height: 1;
}
.lr-meter.is-pass .st-led.is-on { background: #3DDC6E; box-shadow: 0 0 8px 1px #3DDC6E; }
.lr-reset {
    min-height: var(--st-target);
    padding: 0 0.85rem;
    border: 1px solid var(--st-panel-line);
    border-radius: 8px;
    background: transparent;
    color: var(--st-panel-muted);
    font: inherit;
    font-family: var(--st-font);
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
}
.lr-reset:hover:not(:disabled) { color: var(--st-panel-ink); border-color: var(--st-panel-muted); }
.lr-reset:disabled { opacity: 0.45; cursor: default; }

/* ── glossary page: the four-week plan ───────────────────────────────── */
.learn-body .lr-weeks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 0.9rem;
    max-width: 62rem;
    margin: 1.2rem 0 1.6rem;
    padding: 0;
    list-style: none;
}
.lr-week {
    margin: 0;
    padding: 1rem 1.15rem 0.6rem;
    border: 1px solid var(--st-line);
    border-top: 4px solid var(--lr-acc);
    border-radius: 12px;
    background: var(--st-surface);
}
.lr-week-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.7rem; }
.lr-week-n {
    display: flex;
    align-items: flex-end;
    flex: none;
    width: 2.7rem;
    height: 2.7rem;
    padding: 0 0.4rem 0.35rem;
    border-radius: 8px;
    background: var(--lr-acc);
    color: #16171A;
    font-size: 1.35rem;
    font-weight: 860;
    font-stretch: 122%;
    line-height: 1;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.learn-body .lr-week-title { margin: 0; font-size: 1.15rem; }
.lr-tiles { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.7rem; }
.learn a.lr-tile {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    padding: 0.15rem 0.6rem 0.15rem 0.3rem;
    border: 1px solid var(--st-line);
    border-radius: 7px;
    color: var(--st-ink);
    font-size: 0.82rem;
    font-weight: 680;
    font-stretch: 94%;
    text-decoration: none;
}
.learn a.lr-tile:hover { border-color: var(--lr-acc); }
.lr-tile-n {
    padding: 0.12rem 0.32rem;
    border-radius: 4px;
    background: var(--lr-acc);
    color: #16171A;
    font-size: 0.74rem;
    font-weight: 820;
    font-variant-numeric: tabular-nums;
}
.learn-body .lr-week-list { margin: 0 0 0.4rem; font-size: 0.96rem; }

/* the daily routine: one bar, each part as long as its minutes */
.learn-body .lr-routine {
    display: flex;
    gap: 4px;
    max-width: 52rem;
    margin: 0.8rem 0 1.8rem;
    padding: 0;
    list-style: none;
}
.lr-routine li {
    flex: var(--lr-min) 1 0;
    min-width: 0;
    margin: 0;
    padding: 0.7rem 0.8rem 0.8rem;
    border-radius: 6px;
    background: var(--st-surface);
    border: 1px solid var(--st-line);
    border-top: 4px solid var(--learn-accent);
    font-size: 0.9rem;
    line-height: 1.35;
}
.lr-routine-min {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1.7rem;
    font-weight: 850;
    font-stretch: 118%;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* ── glossary: letter keys, letters, terms ───────────────────────────── */
.lr-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    max-width: 52rem;
    margin: 1rem 0 0.6rem;
}
.learn .lr-letters a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--st-target);
    height: var(--st-target);
    border-radius: 8px;
    background: var(--st-key);
    color: var(--st-key-ink);
    font-size: 1.05rem;
    font-weight: 820;
    font-stretch: 112%;
    text-decoration: none;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
.learn .lr-letters a:hover { background: var(--learn-accent); color: var(--learn-on-accent); }
.learn .lr-letters a:active { transform: translateY(1px); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.3); }
.lr-gloss-group {
    display: grid;
    grid-template-columns: 3.4rem minmax(0, 1fr);
    gap: 0 1.1rem;
    max-width: 50rem;
    padding: 1.05rem 0 1.15rem;
    border-top: 1px solid var(--st-line);
}
.lr-letters + .lr-gloss-group { margin-top: 1.2rem; }
.learn-body .lr-letter {
    margin: 0;
    color: var(--learn-accent);
    font-size: 2.3rem;
    font-weight: 860;
    font-stretch: 122%;
    line-height: 0.9;
}
.learn-body .lr-gloss {
    max-width: none;
    grid-template-columns: minmax(8rem, 11rem) minmax(0, 1fr);
    gap: 0.75rem 1.3rem;
    margin: 0;
}
.lr-gloss dt { font-weight: 760; font-stretch: 104%; }
.lr-gloss dd { line-height: 1.5; }
.lr-gloss dt[id]:target,
.lr-gloss dt[id]:target + dd { color: var(--learn-accent); }
.learn a.lr-term-lesson {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-inline-start: 0.2rem;
    padding: 0.05rem 0.5rem 0.05rem 0.15rem;
    border: 1px solid var(--st-line);
    border-radius: 999px;
    color: var(--st-muted);
    font-size: 0.8rem;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
    text-decoration: none;
    vertical-align: 0.05em;
}
.learn a.lr-term-lesson:hover { border-color: var(--lr-acc); color: var(--st-ink); }
.lr-term-n {
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--lr-acc);
    color: #16171A;
    font-size: 0.72rem;
    font-weight: 820;
    font-variant-numeric: tabular-nums;
}

/* ── small screens ───────────────────────────────────────────────────── */
@media (max-width: 760px) {
    .lr-bank { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem 0.6rem; }
}
@media (max-width: 640px) {
    .lr-now { grid-template-columns: auto minmax(0, 1fr); padding: 0.75rem; }
    .lr-pad.st-pad { min-height: 3.2rem; padding: 0.4rem 0.55rem; gap: 0.45rem; }
    .lr-pad .st-pad-name { font-size: 0.86rem; font-stretch: 88%; }
    .lr-ctls { grid-template-columns: 1fr; }
    .lr-routine li { padding: 0.55rem 0.55rem 0.65rem; font-size: 0.82rem; }
    .lr-routine-min { font-size: 1.35rem; }
    .lr-gloss-group { grid-template-columns: 2.4rem minmax(0, 1fr); gap: 0 0.8rem; }
    .learn-body .lr-letter { font-size: 1.9rem; }
    .learn-body .lr-gloss { grid-template-columns: 1fr; gap: 0.15rem; }
    .lr-gloss dd + dt { margin-top: 0.75rem; }
}

@media print {
    .lr-letters,
    .lr-term-lesson { display: none !important; }
}
