/* =========================================================
   GOONS · PIANO PUBLIC (/play/piano)
   Markup : includes/play-piano-lite.php · JS : shared/js/goons-piano-lite.js
   Toutes les classes sont prefixees .gpl- ; la hauteur est reservee ici
   (barre + clavier + ligne d'accord) : les touches posees par le JS ne
   decalent rien. Monte par GoonsPianoLite.mount() dans un element vide
   (pages partitions, lecons, jeux) : hauteur reservee par .gpl:empty, barre
   et ligne du bas sur une seule ligne (.gpl--generated).
   ========================================================= */

/* ---------- hero des landings avec instrument ---------- */
.app-hero--instrument {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 10px 0 56px;
}

.app-hero--instrument h1 {
    margin: 14px 0 10px;
    font-size: clamp(30px, 4vw, 46px);
}

.app-hero--instrument .lede {
    max-width: 110ch;
    margin: 0 0 16px;
    font-size: 16px;
    line-height: 1.6;
}

.app-hero--instrument .app-hero-actions {
    margin-bottom: 18px;
}

/* ---------- conteneur ---------- */
.gpl {
    --gpl-keys-h: 176px;
    --gpl-bar-h: 44px;   /* barre 34 px + marge 10 px */
    --gpl-foot-h: 34px;  /* ligne du bas 26 px + marge 8 px */
    --gpl-pad-v: 24px;   /* padding 12 + 10 px, bordures 2 px */
    --gpl-accent: var(--accent, #00e5ff);
    --gpl-staff-h: 128px; /* bande de portee (goons-staff.js) */
    --gpl-next: #12b85a;
    --gpl-next-bright: #39f08a;
    box-sizing: border-box;
    margin: 0 0 20px;
    padding: 12px 12px 10px;
    border: 1px solid var(--play-border, rgba(255, 255, 255, 0.12));
    border-radius: 18px;
    background: rgba(8, 8, 18, 0.78);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    font-size: 13px;
}

/* Element vide, avant le montage : la hauteur finale (barre et ligne du bas
   sur une ligne), pour que le piano ne decale rien en arrivant. */
.gpl:empty {
    min-height: calc(var(--gpl-pad-v) + var(--gpl-bar-h) + var(--gpl-keys-h) + var(--gpl-foot-h));
}

.gpl.gpl--no-bar { --gpl-bar-h: 0px; }
.gpl.gpl--no-foot { --gpl-foot-h: 0px; }

/* Controles masques par l'option controls (et .gpl-keep / .gpl-more). */
.gpl [hidden] { display: none !important; }

/* ---------- barre de controles ---------- */
.gpl-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    margin-bottom: 10px;
}

.gpl-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--play-muted, rgba(255, 255, 255, 0.65));
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.gpl select,
.gpl-bpm {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--play-border, rgba(255, 255, 255, 0.18));
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font: inherit;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: none;
}

.gpl-bpm {
    width: 64px;
}

/* Safari (macOS, iOS) dessine les <select> en natif, fond clair et texte blanc
   illisible : sans apparence native, flèche dessinée ici, options sombres. */
.gpl select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 24px;
    background: rgba(0, 0, 0, 0.5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23e8ecff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 10px 6px;
    color-scheme: dark;
}

.gpl select option { background: #0b0b16; color: #fff; }

.gpl-btn {
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--play-border, rgba(255, 255, 255, 0.18));
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.gpl-btn:hover:not(:disabled) { border-color: var(--gpl-accent); }
.gpl-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.gpl-btn.is-on,
.gpl-btn[aria-pressed="true"] { background: var(--gpl-accent); border-color: var(--gpl-accent); color: #05050a; }
.gpl-rec.is-on { background: #ff3b5c; border-color: #ff3b5c; color: #fff; }

.gpl-octave {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.gpl-range {
    min-width: 66px;
    text-align: center;
    font-family: var(--play-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    color: #fff;
}

.gpl-metro-group {
    display: inline-flex;
    gap: 4px;
}

/* Markup genere : une seule ligne, quoi qu'il arrive (la hauteur reservee
   reste juste). Le padding garde les contours de focus visibles. */
.gpl--generated .gpl-bar {
    flex-wrap: nowrap;
    height: 42px;
    min-height: 0;
    margin: -4px -2px 6px;
    padding: 4px 2px;
    overflow-x: auto;
    scrollbar-width: none;
}

.gpl--generated .gpl-bar::-webkit-scrollbar { display: none; }

.gpl--generated .gpl-foot {
    flex-wrap: nowrap;
    height: 26px;
    min-height: 0;
    overflow: hidden;
    white-space: nowrap;
}

.gpl :focus-visible {
    outline: 2px solid var(--gpl-accent);
    outline-offset: 2px;
}

/* ---------- portee en direct (shared/js/goons-staff.js) ----------
   Hauteur reservee ici, le SVG se dessine dedans sans rien decaler.
   gpl--staff-auto : visible sauf sur telephone (portrait, ou paysage bas,
   ou le clavier doit tenir sans defiler) ; le bouton Staff pose
   gpl--staff-on / gpl--staff-off. */
.gpl-staff {
    display: none;
    position: relative;
    height: var(--gpl-staff-h);
    margin: 0 0 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.32);
    --gst-bg: #07070f;
    --gst-accent: #00e5ff; /* l'accent du theme piano (#83909d) se lit mal sur la portee */
    --gst-font: var(--play-font, system-ui, sans-serif);
}

.gpl--staff-auto .gpl-staff,
.gpl.gpl--staff-on .gpl-staff { display: block; }
.gpl.gpl--staff-off .gpl-staff { display: none; }

/* ---------- clavier ---------- */
.gpl-keys {
    --gpl-whites: 15;
    position: relative;
    display: flex;
    height: var(--gpl-keys-h);
    border-radius: 10px;
    overflow: hidden;
    background: #111;
    /* Glissando et multi-touch : le clavier recoit tous les mouvements. */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.gpl-key {
    position: relative;
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.gpl-key--white {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    background: linear-gradient(180deg, #f4f4f8 0%, #ffffff 70%, #e6e6ee 100%);
    border-right: 1px solid #9a9aa8;
    border-radius: 0 0 6px 6px;
}

.gpl-key--black {
    position: absolute;
    top: 0;
    z-index: 2;
    width: calc(100% / var(--gpl-whites) * 0.62);
    left: calc(100% / var(--gpl-whites) * var(--gpl-at) - 100% / var(--gpl-whites) * 0.31);
    height: 62%;
    background: linear-gradient(180deg, #2a2a33 0%, #0b0b10 100%);
    border-radius: 0 0 5px 5px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

/* Surlignage pilote par l'API (avant .is-down : une touche jouee reste
   cyan). hint = zone ou gamme, teinte legere ; next = la touche a jouer,
   contour vert franc et point ; wrong = flash rouge court. */
.gpl-key--white.gpl-key--hint { background: linear-gradient(180deg, #fff8e2 0%, #ffe6a3 100%); }
.gpl-key--black.gpl-key--hint { background: linear-gradient(180deg, #6b5622 0%, #3a2e10 100%); }
.gpl-key--white.gpl-key--next {
    background: linear-gradient(180deg, #f2fff6 0%, #d2fadf 100%);
    box-shadow: inset 0 0 0 3px var(--gpl-next);
}
.gpl-key--black.gpl-key--next { box-shadow: inset 0 0 0 3px var(--gpl-next-bright), 0 3px 6px rgba(0, 0, 0, 0.5); }
.gpl-key--next::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 40px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gpl-next);
    transform: translateX(-50%);
    pointer-events: none;
}
.gpl-key--black.gpl-key--next::before { bottom: 20px; width: 7px; height: 7px; background: var(--gpl-next-bright); }

@keyframes gpl-wrong {
    from { box-shadow: inset 0 0 0 200px rgba(255, 59, 92, 0.85); }
    to { box-shadow: inset 0 0 0 200px rgba(255, 59, 92, 0); }
}
.gpl-key--wrong { animation: gpl-wrong 0.45s ease-out; }

.gpl-key--white.is-down { background: linear-gradient(180deg, #c9f7ff 0%, var(--gpl-accent) 100%); }
.gpl-key--black.is-down { background: linear-gradient(180deg, #5a2a8a 0%, #b14dff 100%); }

.gpl-key-label {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #555;
    pointer-events: none;
    white-space: nowrap;
}

.gpl-key--black .gpl-key-label {
    bottom: 6px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.75);
}

.gpl[data-labels="off"] .gpl-key-label { display: none; }

/* C4 discretement marque */
.gpl-key--c4::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 26px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gpl-accent);
    opacity: 0.6;
    transform: translateX(-50%);
}

/* ---------- ligne du bas ---------- */
.gpl-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    min-height: 26px;
    margin-top: 8px;
}

.gpl-chord {
    margin: 0;
    min-width: 12ch;
    color: var(--play-muted, rgba(255, 255, 255, 0.65));
}

.gpl-chord-name {
    font-size: 16px;
    color: #fff;
}

.gpl-chord-notes {
    font-family: var(--play-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
}

.gpl-status {
    font-size: 12px;
    color: var(--gpl-accent);
}

.gpl-rotate {
    display: none;
    font-size: 12px;
    color: var(--play-muted, rgba(255, 255, 255, 0.65));
}

.gpl-keep {
    font-weight: 700;
    color: var(--gpl-accent);
}

.gpl-studio {
    margin-left: auto;
    font-size: 12px;
    color: var(--play-faint, rgba(255, 255, 255, 0.5));
}

.gpl-keep[hidden],
.gpl-more[hidden] { display: none; }

/* More keys n'existe qu'a partir de 1024 px (meme seuil que le JS) : masque
   ici des le premier affichage, sinon son apparition decale la barre. */
@media (max-width: 1023px) {
    .gpl-more { display: none; }
}

.gpl-noscript { margin: 8px 0 0; color: var(--play-muted, rgba(255, 255, 255, 0.65)); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .gpl { --gpl-keys-h: 150px; --gpl-pad-v: 20px; padding: 10px 8px 8px; }
    .gpl-field span { display: none; }
    .gpl-studio { margin-left: 0; }
}

@media (orientation: portrait) and (max-width: 600px) {
    .gpl-rotate { display: inline; }
    .gpl { --gpl-staff-h: 112px; }
    .gpl--staff-auto .gpl-staff { display: none; }
}

/* Telephone en paysage : le piano doit tenir sans defiler. */
@media (orientation: landscape) and (max-height: 500px) {
    .play-page--instrument .play-breadcrumb { padding-top: 72px; }
    .app-hero--instrument { padding-top: 4px; }
    .app-hero--instrument .play-eyebrow,
    .app-hero--instrument .lede { display: none; }
    .app-hero--instrument h1 { margin: 4px 0 8px; font-size: 22px; }
    .gpl { --gpl-keys-h: 118px; --gpl-pad-v: 18px; --gpl-bar-h: 40px; --gpl-foot-h: 30px; --gpl-staff-h: 96px; padding: 8px; }
    .gpl--staff-auto .gpl-staff { display: none; }
    .gpl-bar { gap: 5px; margin-bottom: 6px; }
    .gpl--generated .gpl-bar { margin-bottom: 2px; }
    .gpl-btn, .gpl select, .gpl-bpm { height: 28px; padding: 0 8px; font-size: 12px; }
    .gpl select { padding-right: 22px; background-position: right 7px center; }
    .gpl-field span { display: none; }
    .gpl-foot { margin-top: 4px; }
    .gpl-studio { display: none; }
}

/* ---------- tableau du clavier d'ordinateur (section SEO) ---------- */
.app-keymap th[scope="col"],
.app-keymap td {
    text-align: center;
}

.app-keymap kbd {
    display: inline-block;
    min-width: 1.8em;
    padding: 2px 8px;
    border: 1px solid var(--play-border-strong, rgba(255, 255, 255, 0.16));
    border-bottom-width: 2px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    font-family: var(--play-mono, 'JetBrains Mono', monospace);
    font-size: 13px;
    color: #fff;
}

.app-keymap-note {
    margin: 16px 0 0;
    color: var(--play-muted, rgba(255, 255, 255, 0.65));
    line-height: 1.7;
}

@media (max-width: 720px) {
    .app-keymap th[scope="row"] { width: auto; }
    .app-keymap th, .app-keymap td { padding: 10px 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .gpl * { transition: none !important; }
    .gpl-key--wrong { animation: none; box-shadow: inset 0 0 0 200px rgba(255, 59, 92, 0.6); }
}
