/* ============================================================================
   meldo-griffbrett.css — realistischer Hals für Gitarre, E-Bass, Ukulele
   (ab 1.113.2, Wunsch Manuel: «fotorealistischer»)

   Wird von den drei Werkzeugen NACH ihren eigenen Stilen geladen und gilt nur
   mit der Body-Klasse mg-gitarre / mg-bass / mg-ukulele. Nur Darstellung –
   Aufbau (.neck, .fret, .string, .note, .fret-marker) und Skripte bleiben.

   - Holz: Maserung aus SVG-Rauschen (feTurbulence, im Browser erzeugt – keine
     Bilddatei, keine Lizenz) über einem Holzton je Instrument; Wölbung des
     Halses als Licht von oben, Kanten dunkler.
   - Bundstäbchen: Neusilber als Zylinder (Glanzlinie) mit Schatten aufs Holz.
   - Einlagen: Perlmutt (hell, leicht schimmernd).
   - Saiten über den Bünden: blanke Stahlsaiten, umsponnene Bronze- bzw.
     Nickelsaiten (Wicklung als feine Schräglinien), Nylon bei der Ukulele;
     jede Saite wirft einen Schatten aufs Griffbrett.
   - Sattel aus Knochen, links davon der Kopf (dunkler, lackiert).
   - Leersaiten-Töne als helle Plättchen – gut lesbar.
   ========================================================================= */

.mg-gitarre, .mg-bass, .mg-ukulele {
  /* Maserung: lange Streifen entlang des Halses (x tief, y hoch). */
  --mg-maser: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='320'><filter id='m' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' stitchTiles='stitch' baseFrequency='0.0025 0.085' numOctaves='5' seed='11'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  2.6 0 0 0 -1.15'/></filter><rect width='100%25' height='100%25' filter='url(%23m)'/></svg>");
  /* Poren: feine, kurze Striche. */
  --mg-poren: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='160'><filter id='p' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' stitchTiles='stitch' baseFrequency='0.03 0.9' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  3.2 0 0 0 -1.9'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>");
  --mg-holz-1: #4a2b1b;  /* Palisander */
  --mg-holz-2: #5c3824;
  --mg-kopf-1: #1f1a17;
  --mg-kopf-2: #3a302a;
}
.mg-ukulele { --mg-holz-1: #5e3a22; --mg-holz-2: #74492b; --mg-kopf-1: #6e4426; --mg-kopf-2: #8a5a34; }  /* Walnuss, Kopf Koa */
.mg-bass    { --mg-holz-1: #211915; --mg-holz-2: #2e231d; }                                              /* Ebenholz */

/* --- Griffbrett ----------------------------------------------------------- */
.mg-gitarre .neck, .mg-bass .neck, .mg-ukulele .neck {
  background:
    /* Wölbung: oben Licht, Kanten dunkel */
    linear-gradient(180deg, rgba(0,0,0,.42) 0%, rgba(0,0,0,0) 9%, rgba(255,235,210,.07) 34%, rgba(0,0,0,0) 70%, rgba(0,0,0,.18) 91%, rgba(0,0,0,.5) 100%),
    var(--mg-poren),
    var(--mg-maser),
    linear-gradient(90deg, var(--mg-holz-1) 0%, var(--mg-holz-2) 38%, var(--mg-holz-1) 70%, var(--mg-holz-2) 100%) !important;
  background-size: 100% 100%, 300px 160px, 900px 100%, 100% 100% !important;
  border: 0 !important;
  /* Einfassung oben und unten (Binding) und Schatten: der Hals liegt über der Fläche */
  box-shadow:
    inset 0 3px 0 #e8dcc2, inset 0 4px 0 rgba(0,0,0,.35),
    inset 0 -3px 0 #e8dcc2, inset 0 -4px 0 rgba(0,0,0,.35),
    0 16px 28px rgba(0,0,0,.28), 0 4px 8px rgba(0,0,0,.25) !important;
}
.mg-bass .neck { box-shadow: 0 16px 28px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.06), inset 0 -2px 0 rgba(0,0,0,.4) !important; }

/* --- Kopf (Leersaitenfeld links vom Sattel) und Sattel aus Knochen ------- */
.mg-gitarre .fret.open-string, .mg-bass .fret.open-string, .mg-ukulele .fret.open-string {
  background:
    linear-gradient(180deg, rgba(255,255,255,.16) 0%, rgba(255,255,255,0) 22%, rgba(0,0,0,0) 78%, rgba(0,0,0,.35) 100%),
    linear-gradient(90deg, var(--mg-kopf-1), var(--mg-kopf-2) 60%, var(--mg-kopf-1)) !important;
  border-right: 0 !important;
  box-shadow: none !important;
}
.mg-gitarre .fret.open-string::after, .mg-bass .fret.open-string::after, .mg-ukulele .fret.open-string::after {
  content: ''; position: absolute; top: -1px; bottom: -1px; right: -5px; width: 10px; z-index: 1; pointer-events: none;
  border-radius: 2px;
  background: linear-gradient(90deg, #cdbf9f 0%, #f6efdc 35%, #fffaf0 50%, #e4d7b9 75%, #bfae8a 100%);
  box-shadow: 4px 0 6px rgba(0,0,0,.55), -1px 0 2px rgba(0,0,0,.3);
}

/* --- Bundstäbchen: Neusilber, Zylinder mit Glanzlinie --------------------- */
.mg-gitarre .fret, .mg-bass .fret, .mg-ukulele .fret {
  border-right: 0 !important;
  border-image: none !important;
  background: transparent !important;
}
.mg-gitarre .fret:not(.open-string):not(:last-child)::after,
.mg-bass .fret:not(.open-string):not(:last-child)::after,
.mg-ukulele .fret:not(.open-string):not(:last-child)::after {
  content: ''; position: absolute; top: 2px; bottom: 2px; right: -2.5px; width: 5px; z-index: 1; pointer-events: none;
  border-radius: 2.5px;
  background: linear-gradient(90deg, #4e5457 0%, #9aa1a4 22%, #f7f9fa 45%, #ffffff 52%, #b9bfc2 70%, #5a6063 100%);
  box-shadow: 3px 0 4px rgba(0,0,0,.55), -1px 0 1px rgba(0,0,0,.25);
}

/* --- Einlagen: Perlmutt --------------------------------------------------- */
.mg-gitarre .fret-marker, .mg-bass .fret-marker, .mg-ukulele .fret-marker,
.mg-gitarre .fret:nth-child(13) .fret-marker::after, .mg-bass .fret:nth-child(13) .fret-marker::after, .mg-ukulele .fret:nth-child(13) .fret-marker::after {
  z-index: 0 !important;
  background:
    conic-gradient(from 40deg, rgba(180,220,255,.35), rgba(255,210,235,.3), rgba(210,255,220,.3), rgba(180,220,255,.35)),
    radial-gradient(circle at 34% 30%, #ffffff 0%, #f4f1ea 35%, #ddd7cc 70%, #c8c0b2 100%) !important;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.8), inset 0 -1px 2px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.35) !important;
  opacity: .92;
}

/* --- Saiten ---------------------------------------------------------------- */
.mg-gitarre .string, .mg-bass .string, .mg-ukulele .string {
  z-index: 2; pointer-events: none;
  border-radius: 3px;
}
/* Konzertgitarre (1.114.1): Nylon im Diskant (e, h, g) */
.mg-gitarre .string:nth-child(-n+3) {
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(245,240,228,.93) 40%, rgba(196,186,166,.9) 80%, rgba(140,130,112,.88) 100%) !important;
  box-shadow: 0 4px 3px rgba(0,0,0,.5) !important;
}
/* Bässe (d, A, E): Nylonkern, mit Silberdraht umsponnen */
.mg-gitarre .string:nth-child(n+4) {
  background:
    repeating-linear-gradient(78deg, rgba(0,0,0,.32) 0 1px, rgba(255,255,255,.16) 1px 1.6px, rgba(0,0,0,0) 1.6px 2.6px),
    linear-gradient(180deg, #ffffff 0%, #dde1e4 28%, #9aa1a6 62%, #50565b 100%) !important;
  box-shadow: 0 4px 4px rgba(0,0,0,.55) !important;
}
/* umsponnenes Nickel (E-Bass, Roundwound) */
.mg-bass .string {
  background:
    repeating-linear-gradient(78deg, rgba(0,0,0,.34) 0 1.2px, rgba(255,255,255,.14) 1.2px 2px, rgba(0,0,0,0) 2px 3.2px),
    linear-gradient(180deg, #ffffff 0%, #d9dde0 28%, #8f969b 65%, #474c50 100%) !important;
  box-shadow: 0 5px 5px rgba(0,0,0,.6) !important;
}
/* Nylon/Fluorocarbon (Ukulele): hell, leicht durchscheinend */
.mg-ukulele .string {
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(245,240,228,.92) 40%, rgba(196,186,166,.88) 80%, rgba(140,130,112,.85) 100%) !important;
  box-shadow: 0 3px 3px rgba(0,0,0,.45) !important;
}

/* --- Töne ----------------------------------------------------------------- */
/* Leersaiten: helle Plättchen mit dunkler Schrift – auf dem dunklen Kopf gut lesbar */
.mg-gitarre .note.open-string-note, .mg-bass .note.open-string-note, .mg-ukulele .note.open-string-note {
  background: radial-gradient(circle at 35% 28%, #ffffff 0%, #f4f6f5 55%, #dfe4e3 100%) !important;
  color: #005f5b !important;
  border: 2px solid #95C11F !important;
  font-weight: 800 !important;
  text-shadow: none !important;
  box-shadow: 0 3px 6px rgba(0,0,0,.55), inset 0 -2px 0 rgba(0,0,0,.08) !important;
}
/* Leere Griffpunkte: kaum sichtbar, damit das Holz wirkt; beim Darüberfahren deutlich */
.mg-gitarre .note:empty:not(.marked):not(.chord-marked):not(.open-string-note),
.mg-ukulele .note:empty:not(.marked):not(.chord-marked):not(.open-string-note) {
  background: rgba(255,255,255,.05) !important;
  border-color: transparent !important;
}
.mg-gitarre .note:empty:hover, .mg-ukulele .note:empty:hover {
  background: rgba(255,255,255,.22) !important;
  border-color: rgba(255,255,255,.55) !important;
}
/* Bass: Tonnamen bleiben unsichtbar, bis «Noten markieren» an ist (wie bisher). */
.mg-bass .note:not(.open-string-note):not(.active):not(.marked) {
  background: rgba(255,255,255,.05) !important;
}

@media (prefers-reduced-motion: reduce) {
  .mg-gitarre .note, .mg-bass .note, .mg-ukulele .note { transition: none !important; }
}

/* --- Kopf (1.113.3, optional) -------------------------------------------- */
.mg-gitarre .headstock, .mg-bass .headstock, .mg-ukulele .headstock,
.mg-gitarre .string-labels, .mg-bass .string-labels, .mg-ukulele .string-labels { display: none !important; }
.mg-kopf { position: absolute; pointer-events: none; z-index: 0; line-height: 0; }
.mg-kopf[hidden] { display: none; }
.mg-kopf svg { display: block; overflow: visible; }
.mg-gitarre .neck, .mg-bass .neck, .mg-ukulele .neck { transition: margin-left .25s ease; }
.mg-kopf-leiste { position: sticky; left: 0; display: flex; justify-content: flex-end; margin: -24px 0 12px; }
@media (max-width: 768px) { .mg-kopf-leiste { margin: -8px 0 10px; } }
@media (prefers-reduced-motion: reduce) { .mg-gitarre .neck, .mg-bass .neck, .mg-ukulele .neck { transition: none; } }
/* Platz für die Mechanikflügel unter dem Hals, wenn der Kopf sichtbar ist */
.mg-mit-kopf { padding-bottom: 52px !important; }

/* --- Saitenschwingung (1.113.5) ---------------------------------------- */
/* Die Schwingung zeichnet eine eigene Ebene über den Saiten, unter den Tönen.
   Das alte Wackeln der ganzen Saite (auch des gegriffenen Teils) entfällt. */
.mg-schwingung { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; }
.mg-gitarre .string.vibrate, .mg-bass .string.vibrate, .mg-ukulele .string.vibrate { animation: none !important; }

/* --- 3D-Rendering (1.114.0) ------------------------------------------- */
/* Griffbrett-Bild bringt Holz, Wölbung, Bundstäbchen und Einfassung mit:
   gezeichnete Bundstäbchen und Einfassung aus. Sattel und Einlagen bleiben. */
.mg-foto .fret:not(.open-string)::after { display: none !important; }
.mg-foto.mg-gitarre .neck, .mg-foto.mg-bass .neck, .mg-foto.mg-ukulele .neck {
  box-shadow: 0 16px 28px rgba(0,0,0,.28), 0 4px 8px rgba(0,0,0,.25) !important;
}
.mg-foto .fret.open-string {
  background: linear-gradient(180deg, rgba(255,255,255,.14) 0%, rgba(255,255,255,0) 22%, rgba(0,0,0,0) 78%, rgba(0,0,0,.3) 100%) !important;
}

/* --- Schlitzkopf im Anschnitt (1.114.1) ---------------------------------- */
/* Kopfbild reicht bis zum Sattel und läuft links weich aus; die Saiten
   zeichnet der Kopf ab dem Sattel schräg zu den Walzen. */
.mg-anschnitt .mg-kopf {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 96px);
          mask-image: linear-gradient(90deg, transparent 0, #000 96px);
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.mg-anschnitt .string {
  left: calc(var(--mg-sattel, 72px) + 5px) !important; width: calc(100% - var(--mg-sattel, 72px) - 5px) !important;
  border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important;
}
/* Saiten im Kopf liegen über dem Sattel (z 1), unter den Tönen (z 10) */
.mg-kopf.mg-kopf-saiten { z-index: 3; }
.mg-anschnitt .fret.open-string { background: none !important; }
/* E-Bass: Flügel der Wirbel ragen unten weiter über den Hals hinaus */
.mg-bass .mg-mit-kopf.mg-anschnitt { padding-bottom: 72px !important; }
/* Schatten nur unter dem Griffbrett: Um das ganze Halsrechteck gelegt, zeichnet
   er neben der geschwungenen Kopfkante ein helles Rechteck ab. */
.mg-foto .mg-anschnitt .neck { box-shadow: none !important; isolation: isolate; }
.mg-foto .mg-anschnitt .neck::before {
  content: ''; position: absolute; top: 0; bottom: 0; right: 0; left: var(--mg-sattel, 72px);
  z-index: -1; pointer-events: none;
  box-shadow: 0 16px 28px -6px rgba(0,0,0,.28), 0 4px 8px -2px rgba(0,0,0,.25);
}

/* --- Gespielter Ton leuchtet auf (1.114.3) -------------------------------- */
@keyframes mg-leuchten {
  0%   { transform: scale(1.32); box-shadow: 0 0 0 5px rgba(149,193,31,.55), 0 0 26px 10px rgba(149,193,31,.85), 0 0 4px 2px #fff inset; }
  35%  { transform: scale(1.2);  box-shadow: 0 0 0 4px rgba(149,193,31,.45), 0 0 20px 7px rgba(149,193,31,.6), 0 0 3px 1px #fff inset; }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(149,193,31,0), 0 0 0 0 rgba(149,193,31,0), 0 0 0 0 #fff inset; }
}
/* :not(#…) hebt die Gewichtung über die Regeln für leere Griffpunkte */
.mg-gitarre .note.mg-leuchten:not(#mg-x), .mg-bass .note.mg-leuchten:not(#mg-x), .mg-ukulele .note.mg-leuchten:not(#mg-x) {
  background: radial-gradient(circle at 40% 35%, #ffffff 0%, #e9f6c8 35%, #95C11F 100%) !important;
  border-color: #ffffff !important;
  color: #1f4d1a !important;
  z-index: 12 !important;
  animation: mg-leuchten .85s cubic-bezier(.2,.7,.3,1) both;
}
@media (prefers-reduced-motion: reduce) {
  .mg-gitarre .note.mg-leuchten:not(#mg-x), .mg-bass .note.mg-leuchten:not(#mg-x), .mg-ukulele .note.mg-leuchten:not(#mg-x) {
    animation: none; box-shadow: 0 0 0 4px rgba(149,193,31,.6) !important;
  }
}
