/*
 * Melodisches Musizieren: Farbenkarte (im Kopfbereich oder als Abschnitt) und das Glockenspiel zum Ausprobieren
 * (Handy-Ansicht unter 760 px).
 */

/* Farben der Töne; die Karte im Kopf kann sie ändern (--nw-ton-c … am Glockenspiel, inc/seite-melodisch.php) */
.nw-ton-C { --ton: var(--nw-ton-c, #2F7FC1); --ton-schrift: var(--nw-ton-c-schrift, #FFFFFF); }
.nw-ton-D { --ton: var(--nw-ton-d, #FFD166); --ton-schrift: var(--nw-ton-d-schrift, #1D3B2A); }
.nw-ton-E { --ton: var(--nw-ton-e, #8A5A3B); --ton-schrift: var(--nw-ton-e-schrift, #FFFFFF); }
.nw-ton-F { --ton: var(--nw-ton-f, #1D1D1B); --ton-schrift: var(--nw-ton-f-schrift, #FFFFFF); }
.nw-ton-G { --ton: var(--nw-ton-g, #E5483B); --ton-schrift: var(--nw-ton-g-schrift, #FFFFFF); }
.nw-ton-A { --ton: var(--nw-ton-a, #2E7D4F); --ton-schrift: var(--nw-ton-a-schrift, #FFFFFF); }
.nw-ton-H { --ton: var(--nw-ton-h, #C2357B); --ton-schrift: var(--nw-ton-h-schrift, #FFFFFF); }

/* ------------------------------------------------------- Karte im Kopfbereich */
.nw-farbkarte { padding: 22px; background: #fff; border-radius: 24px; }
.nw-farbkarte-titel { margin: 0 0 12px; color: var(--gruen); font-weight: 600; font-size: 20px; line-height: 1.25; }
.nw-farbkarte-liste { display: grid; grid-template-columns: repeat(2, max-content); gap: 10px 28px; margin: 0; padding: 0; list-style: none; white-space: nowrap; }
.nw-farbkarte-liste li { display: flex; align-items: center; gap: 10px; margin: 0; }
.nw-farbkarte-punkt { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); font-weight: 600; font-size: 13px; line-height: 1; }

/* Dieselbe Karte als eigener Abschnitt: volle Breite, alle Töne in einer Reihe */
.nw-farbkarte--breit { padding: 24px 28px; border: 2px solid var(--gruen-hell); border-radius: 28px; }
.nw-farbkarte--breit .nw-farbkarte-liste { display: flex; flex-wrap: wrap; gap: 14px 36px; font-size: 18px; }
.nw-farbkarte--breit .nw-farbkarte-punkt { width: 34px; height: 34px; font-size: 15px; }

/* Abstände: Listen schließen ohne Rand nach unten ab, der nächste Abschnitt folgt nach 72 px */
.nw-seite-melodisch .nw-abschnitt > .nw-wrap > .nw-materialliste:last-child { margin-bottom: 0; }

/* ------------------------------------------------------- Glockenspiel (Kasten) */
.nw-gs-karte { padding: 28px 32px 40px; background: #fff; border: 2px solid var(--gruen-hell); border-radius: 28px; }
.nw-gs-hinweis { margin: 0 0 20px; color: var(--grau); }

/* Mitspielen: Lied wählen, Anhören, Von vorn, darunter das Lied in Farbnotation */
.nw-ms { margin: 0 0 26px; }
.nw-ms-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 14px; }
.nw-ms-lieder, .nw-ms-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.nw-ms-lied, .nw-ms-knopf {
	display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin: 0; padding: 0 14px;
	border: 2px solid var(--gruen-hell); border-radius: 999px; background: #fff; color: var(--text);
	font: inherit; font-size: 15px; font-weight: 500; line-height: 1.2; cursor: pointer;
	transition: border-color .15s, background-color .15s, transform .1s ease-out;
}
.nw-ms-knopf { color: var(--gruen); font-weight: 600; }
.nw-ms-knopf svg { flex: none; }
.nw-ms-lied.ist-aktiv { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.nw-ms-lied:hover, .nw-ms-knopf:hover { border-color: var(--gruen); }
.nw-ms-lied:active, .nw-ms-knopf:active { transform: scale(.97); }
.nw-ms-lied:focus-visible, .nw-ms-knopf:focus-visible { outline: 3px solid var(--gruen); outline-offset: 2px; }

.nw-ms-noten { display: flex; flex-wrap: wrap; gap: 16px 6px; margin: 0; padding: 20px 20px 16px; background: var(--gruenweiss); border-radius: 18px; list-style: none; }
.nw-ms-note { display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 42px; margin: 0; transition: opacity .2s; }
.nw-ms-note.nw-ms-umbruch { min-width: 0; width: 26px; gap: 0; overflow: hidden; }
.nw-ms-note.nw-ms-reihe { flex-basis: 100%; width: auto; height: 0; }
.nw-ms-punkt {
	display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
	background: var(--ton); color: var(--ton-schrift); font-weight: 600; font-size: 14px; line-height: 1;
	box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}
.nw-ms-silbe { color: var(--grau); font-size: 14px; line-height: 1.2; white-space: nowrap; }
.nw-ms-note.ist-gespielt { opacity: .35; }
.nw-ms-note.ist-dran .nw-ms-punkt { transform: scale(1.15); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 0 0 3px #fff, 0 0 0 5px var(--gruen); }
.nw-ms-note.ist-dran .nw-ms-silbe { color: var(--text); font-weight: 600; }
.nw-ms-status { min-height: 1.5em; margin: 12px 0 0; color: var(--grau); }

/* Frei spielen: die Notenzeile wird ruhig leer (Höhe bleibt, nichts verrutscht), Anhören und Von vorn ruhen */
.nw-ms-noten { position: relative; }
.nw-ms-noten::after {
	content: attr(data-frei); position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
	color: var(--grau); text-align: center; opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.ist-frei .nw-ms-noten .nw-ms-note { opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.ist-frei .nw-ms-noten::after { opacity: 1; visibility: visible; }
.nw-ms-knopf:disabled, .nw-ms-knopf:disabled:hover { border-color: var(--gruen-hell); opacity: .45; cursor: default; transform: none; }

/* Glockenspiel: elf Platten von C bis F auf dem Holzkasten, nach rechts kürzer, jede mit Buchstabe, Nägeln und Farbpunkt */
.nw-gs { position: relative; width: max-content; max-width: 100%; margin: 0 auto; padding: 26px 28px; }
.nw-gs-rahmen { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.nw-gs-rahmen--hoch { display: none; }
/* Rand und Schienen gleich dick, wie weit der Kasten auch gestreckt ist (vector-effect erbt sich nicht von der Gruppe) */
.nw-gs-rahmen polygon, .nw-gs-rahmen line { vector-effect: non-scaling-stroke; }
.nw-gs-platten { position: relative; display: flex; align-items: center; gap: clamp(6px, 1vw, 12px); height: 250px; }
.nw-gs-platte {
	position: relative; flex: 0 1 76px; display: block; width: 76px; min-width: 0; height: calc(250px - 9px * var(--i, 0)); margin: 0; padding: 0;
	border: 2px solid var(--gruen-hell); border-radius: 10px; background: linear-gradient(180deg, #FFFFFF, #F3F7EE);
	box-shadow: 0 3px 0 rgba(29, 59, 42, .10), 0 10px 18px -12px rgba(29, 59, 42, .35);
	color: var(--grau); font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
	-webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.nw-gs-platte:hover { border-color: var(--gruen); }
.nw-gs-platte:focus-visible { outline: 3px solid var(--gruen); outline-offset: 3px; }
.nw-gs-name { position: absolute; top: 12px; left: 0; right: 0; font-weight: 600; font-size: 17px; line-height: 1; text-align: center; }
.nw-gs-nagel { position: absolute; left: calc(50% - 4.5px); top: calc(25% - 4.5px); width: 9px; height: 9px; border-radius: 50%; background: var(--gruen-hell); box-shadow: inset 0 -1px 0 rgba(29, 59, 42, .18); }
.nw-gs-nagel + .nw-gs-punkt + .nw-gs-nagel { top: calc(75% - 4.5px); }
.nw-gs-punkt { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: var(--ton); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
.nw-gs-ring { position: absolute; inset: -3px; border: 3px solid var(--ton); border-radius: 50%; opacity: 0; pointer-events: none; }

/* Anschlag: die Platte gibt kurz nach und schwingt zurück, vom Punkt läuft ein Klangring in seiner Farbe nach außen */
@keyframes nw-gs-schlag { 0% { transform: none; } 14% { transform: translateY(3px) scale(.985); } 40% { transform: translateY(-1px); } 70% { transform: translateY(.5px); } 100% { transform: none; } }
@keyframes nw-gs-ring { from { opacity: .75; transform: scale(1); } to { opacity: 0; transform: scale(2.8); } }
.nw-gs-platte.schlag { animation: nw-gs-schlag .38s cubic-bezier(.2, .8, .2, 1); background: linear-gradient(180deg, #FFFFFF, #E9F3EA); }
.nw-gs-platte.schlag .nw-gs-ring { animation: nw-gs-ring .7s cubic-bezier(.2, .8, .2, 1); }

/* Mitspielen: die Platte, die dran ist, bekommt einen pulsierenden grünen Rahmen */
.nw-gs-glanz { position: absolute; inset: -7px; border: 3px solid var(--gruen); border-radius: 15px; opacity: 0; pointer-events: none; transition: opacity .15s; }
@keyframes nw-gs-puls { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.03); } }
.nw-gs-glanz.ist-naechste { opacity: 1; animation: nw-gs-puls 1.3s ease-in-out infinite; }

/* Schmalere Fenster (Tablet): Platten werden schmaler statt aus dem Kasten zu laufen */
@media (max-width: 900px) {
	.nw-gs-karte { padding-left: 24px; padding-right: 24px; }
	.nw-gs { padding-left: 18px; padding-right: 18px; }
}

/* --------------------------------------------------------------------- Handy */
@media (max-width: 760px) {
	.nw-seite-melodisch .nw-hero-reihe { row-gap: 22px; }
	.nw-farbkarte-liste { grid-template-columns: repeat(3, max-content); gap: 10px 16px; }
	.nw-farbkarte--breit { padding: 20px; border-radius: 24px; }
	.nw-farbkarte--breit .nw-farbkarte-liste { gap: 12px 22px; font-size: 17px; }

	.nw-gs-karte { padding: 18px 16px 20px; border-radius: 24px; }
	.nw-gs-hinweis { margin-bottom: 14px; }

	.nw-ms { margin-bottom: 18px; }
	.nw-ms-lied, .nw-ms-knopf { min-height: 44px; }
	.nw-ms-noten { gap: 12px 4px; padding: 14px 10px 10px; }
	.nw-ms-note { min-width: 34px; }
	.nw-ms-note.nw-ms-umbruch { flex-basis: 100%; width: auto; height: 0; }
	.nw-ms-punkt { width: 26px; height: 26px; font-size: 13px; }
	.nw-ms-silbe { font-size: 13px; }

	/* Platten untereinander, oben die lange C-Platte (100 %), unten die kurze F-Platte (64 %) */
	.nw-gs { width: auto; padding: 14px 10px; }
	.nw-gs-rahmen--quer { display: none; }
	.nw-gs-rahmen--hoch { display: block; }
	.nw-gs-platten { flex-direction: column; gap: 8px; height: auto; }
	.nw-gs-platte { flex: none; width: calc(100% - 3.6% * var(--i, 0)); height: 40px; }
	.nw-gs-name { top: 50%; left: 12px; right: auto; transform: translateY(-50%); }
	.nw-gs-nagel { top: calc(50% - 4.5px); left: calc(25% - 4.5px); }
	.nw-gs-nagel + .nw-gs-punkt + .nw-gs-nagel { top: calc(50% - 4.5px); left: calc(75% - 4.5px); }
	.nw-gs-punkt { width: 22px; height: 22px; margin: -11px 0 0 -11px; }
}

/* sehr schmale Handys: die Farbkarte im Kopf zweispaltig, damit sie nicht aus der Karte läuft */
@media (max-width: 374px) {
	.nw-farbkarte-liste { grid-template-columns: repeat(2, max-content); }
}

@media (prefers-reduced-motion: reduce) {
	.nw-gs-platte.schlag, .nw-gs-platte.schlag .nw-gs-ring, .nw-gs-glanz.ist-naechste { animation: none; }
	.nw-ms-punkt, .nw-ms-note, .nw-gs-glanz, .nw-ms-lied, .nw-ms-knopf { transition: none; }
}
