/* ===== Le piano — support de cours ===== */
:root {
  --ivoire: #faf6ee;
  --papier: #fffdf8;
  --encre: #2a211b;
  --encre-douce: #5d5048;
  --acajou: #7a3418;
  --acajou-clair: #a4532c;
  --or: #b8892b;
  --or-clair: #f3e6c4;
  --noir: #1b1714;
  --vert: #2f7d4f;
  --rouge: #b23a2a;
  --bord: #e6dccb;
  --ombre: 0 2px 4px rgba(60, 35, 15, .06), 0 8px 24px rgba(60, 35, 15, .08);
  --rayon: 14px;
  --titre: "Fraunces", Georgia, "Times New Roman", serif;
  --texte: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ivoire);
  color: var(--encre);
  font-family: var(--texte);
  font-size: 18px;
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: var(--acajou); }
h1, h2, h3 { font-family: var(--titre); line-height: 1.15; color: var(--noir); }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin: 0 0 .4em; font-weight: 700; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); margin: 0 0 .5em; }
h3 { font-size: 1.3rem; margin: 0 0 .4em; }
p { margin: 0 0 1em; }

/* ----- Barre de navigation ----- */
.entete {
  position: sticky; top: 0; z-index: 50;
  background: var(--noir);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.entete-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; min-height: 60px;
}
.logo {
  font-family: var(--titre); font-weight: 700; font-size: 1.35rem;
  color: #fff; text-decoration: none; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.logo-touches { display: inline-flex; height: 26px; }
.logo-touches i { width: 9px; background: #fff; border: 1px solid var(--noir); border-radius: 0 0 2px 2px; position: relative; }
.logo-touches i.n { width: 6px; background: var(--noir); height: 16px; margin: 0 -3px; z-index: 1; border-color: #fff3; }
.menu { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.menu a {
  color: #e9e1d6; text-decoration: none; padding: 8px 12px; border-radius: 8px;
  font-weight: 700; font-size: .95rem;
}
.menu a:hover { background: #ffffff1a; color: #fff; }
.menu a[aria-current="page"] { background: var(--or); color: var(--noir); }
.menu-bouton { display: none; margin-left: auto; background: none; border: 1px solid #fff5; color: #fff; border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 700; cursor: pointer; }

/* Bande de touches décorative */
.bande-clavier {
  height: 18px;
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, var(--noir) 22px 24px),
    linear-gradient(#fff, #f1ebe1);
  border-bottom: 3px solid var(--acajou);
}

/* ----- Mise en page ----- */
main { max-width: 1180px; margin: 0 auto; padding: 32px 16px 64px; }
section { margin: 0 0 64px; scroll-margin-top: 80px; }
.chapo { font-size: 1.2rem; color: var(--encre-douce); max-width: 760px; }
.surtitre { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; font-weight: 800; color: var(--acajou); margin-bottom: .4em; }

.grille { display: grid; gap: 24px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.centre-v { align-items: center; }

.carte {
  background: var(--papier); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 24px; position: relative;
}
.carte > img, .carte figure img { border-radius: 10px; }
figure { margin: 0; }
figcaption { font-size: .85rem; color: var(--encre-douce); margin-top: 8px; font-style: italic; }

.encadre {
  border-left: 6px solid var(--or); background: var(--or-clair);
  padding: 16px 20px; border-radius: 0 var(--rayon) var(--rayon) 0; margin: 0 0 24px;
}
.encadre.astuce { border-color: var(--vert); background: #e3f1e8; }
.encadre.probleme { border-color: var(--rouge); background: #f8e3df; }
.encadre strong:first-child { display: block; font-family: var(--titre); font-size: 1.1rem; margin-bottom: 4px; }

.mot { font-weight: 800; color: var(--acajou); }
.gros-chiffre { font-family: var(--titre); font-size: 2.6rem; font-weight: 700; color: var(--acajou); line-height: 1; }

/* ----- Accueil ----- */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: center;
  margin-bottom: 56px;
}
.hero img { filter: drop-shadow(0 18px 30px rgba(60,30,10,.25)); }
.chapitres a.carte { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.chapitres a.carte:hover { transform: translateY(-4px); box-shadow: 0 14px 34px rgba(60,35,15,.16); }
.chapitres .num { font-family: var(--titre); font-size: 2.4rem; color: var(--or); font-weight: 700; line-height: 1; }
.chapitres .icone { font-size: 2rem; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.chiffres .carte { text-align: center; padding: 18px; }

/* ----- Boutons ----- */
.bouton {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--acajou); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; font: inherit; font-weight: 800; cursor: pointer;
  text-decoration: none; transition: background .15s, transform .1s;
}
.bouton:hover { background: var(--acajou-clair); }
.bouton:active { transform: scale(.97); }
.bouton.secondaire { background: var(--papier); color: var(--acajou); border: 2px solid var(--acajou); }
.bouton.secondaire:hover { background: var(--or-clair); }
.bouton[aria-pressed="true"] { background: var(--or); color: var(--noir); }
.bouton.petit { padding: 6px 14px; font-size: .9rem; }
.rangee { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ----- Frise chronologique ----- */
.frise { position: relative; padding-left: 36px; }
.frise::before { content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 4px; background: linear-gradient(var(--or), var(--acajou)); border-radius: 2px; }
.etape { position: relative; margin-bottom: 22px; }
.etape::before {
  content: ""; position: absolute; left: -32px; top: 22px; width: 18px; height: 18px;
  background: var(--papier); border: 4px solid var(--acajou); border-radius: 50%;
}
.etape .date { font-family: var(--titre); font-weight: 700; font-size: 1.5rem; color: var(--acajou); }
.etape .carte { padding: 18px 22px; }

/* ----- Repères sur image (anatomie) ----- */
.reperes { position: relative; }
.reperes img { width: 100%; border-radius: 10px; }
.repere {
  position: absolute; transform: translate(-50%, -50%);
  width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff;
  background: var(--acajou); color: #fff; font-weight: 800; font-size: .95rem;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.4);
  display: grid; place-items: center; padding: 0; font-family: var(--texte);
  animation: pulse 2.4s infinite;
}
.repere.actif, .repere:hover { background: var(--or); color: var(--noir); animation: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(184,137,43,.7), 0 2px 8px rgba(0,0,0,.4);} 50% { box-shadow: 0 0 0 10px rgba(184,137,43,0), 0 2px 8px rgba(0,0,0,.4);} }
.legende-active { min-height: 150px; }
.legende-active h3 { color: var(--acajou); }
.liste-pieces { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.liste-pieces button { font: inherit; font-size: .85rem; border: 1px solid var(--bord); background: var(--papier); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.liste-pieces button.actif { background: var(--acajou); color: #fff; border-color: var(--acajou); }

/* ----- Mécanisme animé ----- */
.meca svg { width: 100%; height: auto; background: linear-gradient(#fdfaf3, #f3ece0); border-radius: 12px; border: 1px solid var(--bord); }
.meca .etiq { font: 700 15px var(--texte); fill: var(--encre); }
.meca .etiq-fine { font: 600 13px var(--texte); fill: var(--encre-douce); }
.meca .fleche { stroke: var(--encre-douce); stroke-width: 1.5; fill: none; marker-end: url(#pointe); }
.etat-meca { font-weight: 700; color: var(--acajou); min-height: 1.6em; }

/* ----- Clavier jouable ----- */
.clavier-zone { background: var(--noir); padding: 18px 16px 22px; border-radius: var(--rayon); box-shadow: var(--ombre); }
.clavier-reglages { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: center; color: #eee; margin-bottom: 16px; }
.clavier-reglages label { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.clavier-reglages input[type=range] { accent-color: var(--or); width: 160px; }
.nuance-aff { font-family: var(--titre); font-style: italic; font-weight: 700; font-size: 1.4rem; color: var(--or); min-width: 2.5em; display: inline-block; }
.choix-instr { display: inline-flex; background: #ffffff14; border-radius: 999px; padding: 4px; }
.choix-instr button { background: none; border: 0; color: #ddd; font: inherit; font-weight: 800; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.choix-instr button[aria-pressed="true"] { background: var(--or); color: var(--noir); }
.pedale-btn { background: #ffffff14; color: #eee; border: 2px solid #ffffff30; border-radius: 10px; padding: 6px 14px; font: inherit; font-weight: 800; cursor: pointer; }
.pedale-btn[aria-pressed="true"] { background: var(--or); color: var(--noir); border-color: var(--or); }
.pedale-btn:disabled { opacity: .35; cursor: not-allowed; }
.clavier { position: relative; height: 190px; display: flex; user-select: none; -webkit-user-select: none; touch-action: none; overflow: hidden; border-radius: 0 0 8px 8px; }
.clavier .b {
  flex: 1; background: linear-gradient(#fff 80%, #ece6dc); border: 1px solid #333; border-radius: 0 0 6px 6px;
  position: relative; cursor: pointer; display: flex; align-items: flex-end; justify-content: center;
  font-size: .75rem; color: #888; padding-bottom: 6px; font-weight: 700;
}
.clavier .n {
  position: absolute; top: 0; height: 62%; background: linear-gradient(#333, #111 85%, #2a2a2a);
  border-radius: 0 0 4px 4px; z-index: 2; cursor: pointer; border: 1px solid #000;
  display: flex; align-items: flex-end; justify-content: center; font-size: .65rem; color: #999; padding-bottom: 4px; font-weight: 700;
}
.clavier .b.enfonce { background: linear-gradient(#f3e6c4, #e2c98a); }
.clavier .n.enfonce { background: linear-gradient(#6a4a2a, #3a2412); }
.aide-clavier { color: #aaa; font-size: .85rem; margin-top: 10px; }

/* ----- Pédales ----- */
.pedales-visuel { display: flex; justify-content: center; gap: 22px; padding: 22px 0 8px; }
.pedale {
  width: 64px; height: 100px; border-radius: 30px 30px 10px 10px; border: 0; cursor: pointer;
  background: linear-gradient(160deg, #f5dc8e, #b8892b 55%, #8a6114); box-shadow: 0 6px 0 #5e420c, 0 10px 18px rgba(0,0,0,.25);
  transition: transform .12s, box-shadow .12s; font: 800 .8rem var(--texte); color: #4a3408; padding-top: 40px;
}
.pedale.actif, .pedale:active { transform: translateY(5px); box-shadow: 0 1px 0 #5e420c, 0 4px 8px rgba(0,0,0,.2); }
.pedale-info { min-height: 130px; }

/* ----- Types de pianos ----- */
.type-carte { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.type-carte .visuel { background: #f4efe5; aspect-ratio: 4/3; display: grid; place-items: center; overflow: hidden; }
.type-carte .visuel img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.type-carte .visuel.photo img { object-fit: cover; padding: 0; }
.type-carte .visuel .vide { font-size: 4rem; opacity: .6; }
.type-carte .corps { padding: 18px 22px 22px; flex: 1; }
.type-carte .epoque { display: inline-block; font-size: .78rem; font-weight: 800; background: var(--or-clair); color: var(--acajou); padding: 2px 10px; border-radius: 999px; margin-bottom: 8px; }
.type-carte .fiche { list-style: none; padding: 0; margin: 10px 0 0; font-size: .92rem; }
.type-carte .fiche li { padding: 4px 0; border-top: 1px dashed var(--bord); }
.filtres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }

.tailles { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.taille { text-align: center; font-size: .85rem; font-weight: 700; }
.taille .barre { background: linear-gradient(90deg, var(--acajou), var(--acajou-clair)); height: 22px; border-radius: 4px 40px 40px 4px; margin-bottom: 6px; }

/* ----- Comparaison ----- */
table.compare { width: 100%; border-collapse: collapse; background: var(--papier); border-radius: var(--rayon); overflow: hidden; box-shadow: var(--ombre); }
.compare th, .compare td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--bord); vertical-align: top; }
.compare thead th { background: var(--noir); color: #fff; font-family: var(--titre); font-size: 1.1rem; }
.compare tbody th { background: var(--or-clair); width: 22%; }
.tableau-defile { overflow-x: auto; }

/* ----- Écoute ----- */
.lecteur { display: flex; flex-direction: column; gap: 10px; }
audio { width: 100%; }
.manquant { font-size: .85rem; color: var(--encre-douce); background: #f4efe5; border: 1px dashed var(--bord); padding: 10px 12px; border-radius: 10px; }
.manquant code { background: #fff; padding: 1px 6px; border-radius: 4px; }
.jeu-reponses { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.retour { font-weight: 800; min-height: 1.6em; }
.retour.bon { color: var(--vert); }
.retour.faux { color: var(--rouge); }
.score { font-family: var(--titre); font-size: 1.3rem; }

/* ----- Quiz ----- */
.question { margin-bottom: 20px; }
.question .choix { display: grid; gap: 8px; margin-top: 12px; }
.question .choix button {
  text-align: left; font: inherit; padding: 10px 16px; border-radius: 10px; border: 2px solid var(--bord);
  background: var(--papier); cursor: pointer; transition: border-color .15s, background .15s;
}
.question .choix button:hover:not(:disabled) { border-color: var(--or); }
.question .choix button.bon { background: #e3f1e8; border-color: var(--vert); }
.question .choix button.faux { background: #f8e3df; border-color: var(--rouge); }
.question .choix button:disabled { cursor: default; }
.question .explication { display: none; margin-top: 10px; font-size: .95rem; color: var(--encre-douce); }
.question.repondu .explication { display: block; }
.barre-score { position: sticky; top: 70px; z-index: 5; background: var(--noir); color: #fff; border-radius: var(--rayon); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 8px; }
.barre-score .score { color: var(--or); }

/* ----- Navigation bas de page ----- */
.suite { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-top: 2px solid var(--bord); padding-top: 24px; }
.pied { background: var(--noir); color: #a99f94; text-align: center; padding: 22px 16px; font-size: .85rem; }

/* ----- Mode projection (vidéoprojecteur) ----- */
body.projection { font-size: 22px; }
body.projection main { max-width: 1400px; }
.bouton-projection { margin-left: 8px; background: none; border: 1px solid #fff5; color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.bouton-projection[aria-pressed="true"] { background: var(--or); color: var(--noir); border-color: var(--or); }

/* ----- Responsive ----- */
@media (max-width: 900px) {
  .menu-bouton { display: block; }
  .menu { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--noir); flex-direction: column; padding: 8px 16px 16px; }
  .menu.ouvert { display: flex; }
  .bouton-projection { display: none; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 17px; }
  .clavier { height: 150px; }
  .clavier .b, .clavier .n { font-size: 0; }
  .repere { width: 26px; height: 26px; font-size: .8rem; }
}
@media print {
  .entete, .pied, .suite, .bande-clavier { display: none; }
  .carte { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .repere { animation: none; }
  html { scroll-behavior: auto; }
}

[hidden] { display: none !important; }

/* ----- Mécaniques complètes (v2) ----- */
.meca2 svg { cursor: pointer; }
.meca2 .surligne { filter: drop-shadow(0 0 2px #f0a800) drop-shadow(0 0 5px #f0a800); }
.meca2 .etiq { font: 700 15px var(--texte); fill: var(--encre); pointer-events: none; }
.meca2 .etiq-fine { font: 600 13px var(--texte); fill: var(--encre-douce); pointer-events: none; }
.meca2 .fleche { stroke: var(--encre-douce); stroke-width: 1.5; fill: none; }
.onglets-meca { display: inline-flex; background: var(--noir); border-radius: 999px; padding: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.onglets-meca button { background: none; border: 0; color: #ddd; font: inherit; font-weight: 800; padding: 8px 16px; border-radius: 999px; cursor: pointer; }
.onglets-meca button[aria-selected="true"] { background: var(--or); color: var(--noir); }

/* ----- Ateliers de mécanismes ----- */
.atelier .indice-texte { fill: var(--acajou); animation: clignote 1.4s ease-in-out infinite; }
@keyframes clignote { 50% { opacity: .35; } }
.atelier .g-touche:hover rect:first-child { filter: brightness(1.06); }
.atelier svg { touch-action: none; }
.onglets-meca { display: flex; flex-wrap: wrap; gap: 4px; border-radius: 18px; }
.panneau-intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; margin-bottom: 16px; align-items: start; }
@media (max-width: 800px) { .panneau-intro { grid-template-columns: 1fr; } }
.sources { font-size: .85rem; color: var(--encre-douce); }
.sources li { margin-bottom: 4px; }

/* ----- Schémas toujours visibles en entier ----- */
.meca2 .dessin svg {
  display: block; width: 100%; height: auto;
  max-height: calc(100vh - 300px);   /* repli pour les anciens navigateurs */
  max-height: calc(100svh - 300px);  /* le schéma tient dans l'écran, sans défiler */
  min-height: 160px;
}
.astuce-rotation { display: none; margin: 8px 0 0; font-weight: 700; color: var(--acajou); text-align: center; }
@media (max-width: 700px) and (orientation: portrait) {
  .astuce-rotation { display: block; }
  .meca2 .reglages-meca { gap: 8px 14px; font-size: .9rem; }
}

/* Mode « Agrandir » : le schéma prend tout l'écran */
body.fige { overflow: hidden; }
.meca2.agrandi {
  position: fixed; inset: 0; z-index: 1000; margin: 0; border-radius: 0;
  background: var(--ivoire); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; overflow: hidden;
}
.meca2.agrandi .dessin { flex: 1 1 auto; min-height: 0; display: flex; }
.meca2.agrandi .dessin svg { height: 100%; max-height: none; min-height: 0; }
.meca2.agrandi .pieces-meca { display: none; }
.meca2.agrandi .etat-meca { flex: 0 0 auto; margin: 6px 0 0 !important; font-size: .95rem; }
.meca2.agrandi .reglages-meca { margin-bottom: 6px !important; }
@media (orientation: landscape) and (max-height: 500px) {
  .meca2.agrandi .astuce-rotation { display: none; }
  .meca2.agrandi .etat-meca { font-size: .85rem; }
}

/* Onglets toujours accessibles en haut de l'écran */
.onglets-meca { position: sticky; top: 64px; z-index: 40; margin-bottom: 12px; }
.panneau-titre { margin: 0 0 10px; font-size: clamp(1.25rem, 3vw, 1.8rem); }
@media (max-width: 700px) {
  .onglets-meca { top: 60px; overflow-x: auto; flex-wrap: nowrap; border-radius: 999px; -webkit-overflow-scrolling: touch; }
  .onglets-meca button { white-space: nowrap; padding: 7px 12px; font-size: .9rem; }
}

/* ----- Pas de sélection au double tap sur les éléments interactifs ----- */
html { touch-action: manipulation; }                 /* pas de zoom au double tap (iPhone) */
.meca, .meca2, .clavier-zone, .flute-interactive, .tailles-flutes,
.onglets-meca, .choix-instr, .pedales-visuel, .jeu-reponses, .question .choix,
.liste-pieces, .reperes, button, svg {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;                       /* pas de menu « copier » en appui long */
  -webkit-tap-highlight-color: transparent;
}
