/* Les leçons interactives (musique/lecon.php). */

.lecon {
    --lecon-on: #db2777;
    --lecon-papier: #ffffff;
    max-width: 52rem;
}
@media (prefers-color-scheme: dark) {
    .lecon { --lecon-on: #f472b6; --lecon-papier: #f8f8f2; }
}

.lecon .landing-eyebrow a { color: inherit; text-decoration: none; }
.lecon .landing-eyebrow a:hover { text-decoration: underline; }
.lecon-sous-titre { font-size: 1.15rem; color: var(--color-text-light); margin-top: -0.25rem; }
.lecon-mode { color: var(--color-text-light); }

.lecon-liens { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; padding: 0; margin: 0.75rem 0 1.25rem; }

.lecon-sommaire details {
    border: 1px solid var(--color-border); border-radius: var(--radius);
    padding: 0.5rem 1rem; margin-bottom: 1.5rem; background: var(--color-surface);
}
.lecon-sommaire summary { cursor: pointer; font-weight: 600; }
.lecon-sommaire ol { margin: 0.5rem 0 0.25rem; padding-left: 1.5rem; columns: 2 16rem; }

/* ---- Le texte ------------------------------------------------------------ */

.lecon-texte { line-height: 1.6; }
.lecon-texte h2 {
    margin-top: 2.25rem; padding: 0.3rem 0.7rem; border-radius: var(--radius);
    background: var(--color-accent); color: #fff; font-size: 1.2rem;
    scroll-margin-top: 1rem;
}
.lecon-texte h3 { margin-top: 1.5rem; color: var(--color-accent); font-size: 1.05rem; scroll-margin-top: 1rem; }
.lecon-texte .remarque, .lecon-texte .ecoute, .lecon-texte details.reponses {
    border: 1px solid var(--color-border); border-left: 4px solid var(--color-accent);
    border-radius: var(--radius); background: var(--color-surface);
    padding: 0.4rem 1rem; margin: 1rem 0;
}
.lecon-texte .ecoute { border-left-color: #2563eb; }
.lecon-texte details.reponses summary {
    cursor: pointer; font-weight: 600; color: var(--color-accent); padding: 0.3rem 0;
}
.lecon-texte details.reponses[open] summary { margin-bottom: 0.4rem; }
.lecon-texte .center { text-align: center; }
.lecon-texte .center > * { margin-left: auto; margin-right: auto; }
.lecon-texte .legende, .lecon-texte figcaption {
    font-size: 0.9rem; font-style: italic; color: var(--color-text-light); text-align: center;
}
.lecon-texte .touche {
    font-family: var(--font-sans); font-size: 0.85em; padding: 0 0.3em;
    border: 1px solid var(--color-border); border-radius: 3px; background: var(--color-code-bg);
}
.lecon-texte .siecle { font-variant: small-caps; }

/* Les tableaux : défilent seuls s'ils sont trop larges. */
.lecon-texte table {
    display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse;
    margin: 1rem auto; font-size: 0.92rem; width: max-content;
}
.lecon-texte th, .lecon-texte td { padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.lecon-texte thead th { border-bottom: 2px solid var(--color-text-light); }

/* Chiffrages : V⁶₄, des chiffres empilés. */
.chiffrage { white-space: nowrap; }
.chiffrage .pile {
    display: inline-flex; flex-direction: column; vertical-align: middle;
    font-size: 0.7em; line-height: 1; text-align: center; margin-left: 0.05em;
}
.chiffrage sup.chiffre, .chiffrage sub.chiffre { font-size: 0.7em; }

/* ---- Les gravures ---------------------------------------------------------- */

.lecon-texte figure { margin: 1.25rem 0; text-align: center; }
.lecon-texte figure.gammeref { display: inline-block; width: 48%; vertical-align: top; margin: 0.5rem 0.5%; }
.partition { display: inline-block; width: var(--w, 100%); max-width: 100%; vertical-align: middle; }
figure > .partition, .center > .partition { display: block; margin: 0 auto; }
/* Une gravure trop petite sur un téléphone : toute la largeur. */
@media (max-width: 640px) {
    .partition { width: max(var(--w, 100%), 100%); }
    td .partition { width: var(--w, 100%); min-width: 14rem; }
    .lecon-texte figure.gammeref { display: block; width: auto; }
}
.partition img, .partition svg { display: block; width: 100%; height: auto; }
.partition svg { color: var(--color-text); overflow: visible; }
.partition svg tspan { white-space: pre; }
/* En image, les traits sont noirs : inversés dans le thème sombre. */
@media (prefers-color-scheme: dark) {
    .partition:not(.dessin) img { filter: invert(0.9); }
}
/* Les dessins (TikZ) gardent leurs couleurs, sur du papier. */
.partition.dessin { background: var(--lecon-papier); border-radius: var(--radius); padding: 0.5rem; }

.partition.jouable svg { cursor: pointer; }
.partition svg g.nh { transition: color 0.05s; }
.partition svg g.nh.on { color: var(--lecon-on); }

.partition-jeu { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; margin-top: 0.35rem; }
.partition-bouton {
    font: inherit; font-size: 0.85rem; line-height: 1.2; cursor: pointer;
    padding: 0.25rem 0.7rem; border-radius: 999px;
    border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
}
.partition-bouton:hover { border-color: var(--color-accent); color: var(--color-accent); }
.partition-bouton:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.partition-bouton.joue { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.partition-bouton[aria-busy="true"] { opacity: 0.6; cursor: progress; }

/* ---- Le clavier, en bas de l'écran ---------------------------------------------- */

.lecon-dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #0f172a; color: #e2e8f0; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    padding: 0.35rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
}
.lecon-dock-barre { display: flex; align-items: center; gap: 0.75rem; max-width: 52rem; margin: 0 auto 0.35rem; font-size: 0.85rem; }
.lecon-dock-titre { font-weight: 600; margin-right: auto; }
.lecon-dock select { font: inherit; margin-left: 0.3rem; }
.lecon-dock-barre button {
    font: inherit; cursor: pointer; background: transparent; color: inherit;
    border: 1px solid rgba(226, 232, 240, 0.35); border-radius: 4px; padding: 0.1rem 0.55rem;
}
.lecon-dock-barre button:hover { border-color: #f472b6; color: #f9a8d4; }
.lecon-touches { height: 6.5rem; max-width: 52rem; margin: 0 auto; }
@media (max-width: 640px) {
    .lecon-touches { height: 5.5rem; }
    .lecon-touches .smk-white:not(.smk-c) .smk-label { display: none; }
}
body.avec-clavier { padding-bottom: 9rem; }

/* ---- Les autres leçons ------------------------------------------------------------- */

.lecon-suite { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 2.5rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.lecon-apres { margin-left: auto; text-align: right; }

/* ---- La police des gravures ---------------------------------------------------- */
/* TeX Gyre Schola, du dessin de C059, la police de texte de LilyPond
   (polices/LISEZMOI.txt). */
@font-face { font-family: 'TeX Gyre Schola'; font-style: normal; font-weight: 400; font-display: swap;
    src: local('TeX Gyre Schola'), url(polices/texgyreschola-regular.woff2) format('woff2'); }
@font-face { font-family: 'TeX Gyre Schola'; font-style: italic; font-weight: 400; font-display: swap;
    src: local('TeX Gyre Schola Italic'), url(polices/texgyreschola-italic.woff2) format('woff2'); }
@font-face { font-family: 'TeX Gyre Schola'; font-style: normal; font-weight: 700; font-display: swap;
    src: local('TeX Gyre Schola Bold'), url(polices/texgyreschola-bold.woff2) format('woff2'); }
@font-face { font-family: 'TeX Gyre Schola'; font-style: italic; font-weight: 700; font-display: swap;
    src: local('TeX Gyre Schola Bold Italic'), url(polices/texgyreschola-bolditalic.woff2) format('woff2'); }

/* ---- La recherche et l'index ----------------------------------------------------- */

mark.trouve { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.trouve-premier { outline: 2px solid #f59e0b; }
@media (prefers-color-scheme: dark) {
    mark.trouve { background: #854d0e; }
}
/* Une notion atteinte depuis l'index. */
.lecon-texte [id^="n-"] { scroll-margin-top: 30vh; }
.lecon-texte [id^="n-"]:target { background: #fde68a; border-radius: 2px; box-shadow: 0 0 0 3px #fde68a; }
@media (prefers-color-scheme: dark) {
    .lecon-texte [id^="n-"]:target { background: #854d0e; box-shadow: 0 0 0 3px #854d0e; }
}

.lecon-cherche { display: flex; gap: 0.4rem; margin: 0 0 1.25rem; max-width: 30rem; }
.lecon-cherche input[type="search"] {
    flex: 1; min-width: 0; font: inherit; padding: 0.45rem 0.7rem;
    border: 1px solid var(--color-border); border-radius: var(--radius);
    background: var(--color-surface); color: var(--color-text);
}
.lecon-cherche input[type="search"]:focus { outline: 2px solid var(--color-accent); outline-offset: 0; border-color: transparent; }
.lecon-cherche button {
    font: inherit; cursor: pointer; padding: 0.45rem 0.9rem; border-radius: var(--radius);
    border: 1px solid var(--color-accent); background: var(--color-accent); color: #fff;
}

