/* =====================================================================
   Icon-Leiste animiert (B10), eigene Datei, ergaenzt public/css/site.css
   Nora/Lina, Muster 2026-12-04. Nichts hier aendert site.css.

   Prinzip
   - Die Icons sind Inline-SVG (Klasse .ikon). Ohne JavaScript, mit
     prefers-reduced-motion: reduce und mit "Animationen anhalten" im
     Barrierefreiheits-Panel sind sie sofort vollstaendig sichtbar.
   - Der Startzustand "unsichtbar" gilt nur, wenn icons-animiert.js die
     Klasse html.ikon-an gesetzt hat (nur bei erlaubter Bewegung).
   - Ablauf je Icon:   Startzustand -> .ikon--lauf (Linien zeichnen, dann
     Symbol-Detail) -> .ikon--fertig (statischer Endzustand)
     Wiederholung bei Hover/Fokus: .ikon--wieder (nur das Symbol-Detail).
   - Kein SMIL, kein <style> und kein style-Attribut im SVG (CSP).
   ===================================================================== */

/* ---------- Grundwerte ------------------------------------------------ */
.ikon { color: var(--c-primary, #E6585E); overflow: visible; }
.ikon .ikon__f { fill: var(--ik-flaeche, #E6E6E5); }

/* Kachelfarbe = Flaechenfarbe des Symbols (wie im Original-PNG) */
.icons__spalte:nth-child(1) { --ik-flaeche: var(--c-icon-1, #DFE0DF); }
.icons__spalte:nth-child(2) { --ik-flaeche: var(--c-icon-2, #E6E6E5); }
.icons__spalte:nth-child(3) { --ik-flaeche: var(--c-icon-3, #ECECEC); }
.icons__spalte:nth-child(4) { --ik-flaeche: var(--c-icon-4, #F2F3F2); }
.icons__spalte:nth-child(5) { --ik-flaeche: var(--c-icon-5, #F9F9F9); }

/* Staffelung von links nach rechts nur, wenn die Kacheln nebeneinander stehen */
@media (min-width: 768px) {
  .icons__spalte:nth-child(2) { --ik-t: 140ms; }
  .icons__spalte:nth-child(3) { --ik-t: 280ms; }
  .icons__spalte:nth-child(4) { --ik-t: 420ms; }
  .icons__spalte:nth-child(5) { --ik-t: 560ms; }
}

/* Das Symbol-Detail dreht/skaliert um die eigene Mitte */
.ikon__d, .ikon__p1, .ikon__p2 { transform-box: fill-box; transform-origin: 50% 50%; }
.ikon--beduerfnisse .ikon__d { transform-origin: 18% 92%; } /* Sprechblase waechst aus der Spitze */

.ikon__glut { opacity: 0; }

/* ---------- Startzustand (nur mit JS und erlaubter Bewegung) ---------- */
html.ikon-an .ikon .ikon__l { stroke-dasharray: 1.01 1.01; stroke-dashoffset: 1.01; }
html.ikon-an .ikon .ikon__f { fill-opacity: 0; }
html.ikon-an .ikon .ikon__punkt { opacity: 0; }

/* ---------- Endzustand nach dem Lauf ---------------------------------- */
html.ikon-an .ikon--fertig .ikon__l { stroke-dasharray: none; stroke-dashoffset: 0; } /* none: gegen gestrichelte Kreise/Ellipsen in Safari (pathLength) */
html.ikon-an .ikon--fertig .ikon__f { fill-opacity: 1; }
html.ikon-an .ikon--fertig .ikon__punkt { opacity: 1; }

/* ---------- 1. Lauf: Linien zeichnen, gestaffelt ---------------------- */
.ikon--lauf {
  --ik-ease: cubic-bezier(.4, 0, .2, 1);
  --ik-aus: cubic-bezier(.22, .61, .36, 1);
  --ik-detail: calc(var(--ik-t, 0ms) + 1500ms);
}
.ikon--lauf .ikon__l { animation: ikon-zeichnen 700ms var(--ik-ease) calc(var(--ik-t, 0ms) + var(--v, 0ms)) both; }
.ikon--lauf .ikon__gesicht { --v: 0ms;   animation-duration: 900ms; }
.ikon--lauf .ikon__rand    { --v: 150ms; animation-duration: 700ms; }
.ikon--lauf .ikon__ohr     { --v: 650ms; animation-duration: 450ms; }
.ikon--lauf .ikon__auge    { --v: 800ms; animation-duration: 450ms; }
.ikon--lauf .ikon__nase    { --v: 950ms; animation-duration: 400ms; }
.ikon--lauf .ikon__symbol .ikon__l { --v: 700ms; animation-timing-function: var(--ik-aus); }
.ikon--lauf .ikon__fragez  { --v: 1100ms; animation-duration: 450ms; }
.ikon--lauf .ikon__text    { --v: 1300ms; animation-duration: 450ms; }

/* Flaechen blenden kurz vor den Konturen ein; das Symbol verdeckt so den hinteren Rand */
.ikon--lauf .ikon__f.ikon__l {
  animation: ikon-zeichnen 700ms var(--ik-aus) calc(var(--ik-t, 0ms) + 700ms) both,
             ikon-fuellen 350ms linear calc(var(--ik-t, 0ms) + 600ms) both;
}
.ikon--lauf .ikon__f:not(.ikon__l) { animation: ikon-fuellen 350ms linear calc(var(--ik-t, 0ms) + 600ms) both; }
.ikon--lauf .ikon__punkt { animation: ikon-ein 300ms var(--ik-aus) calc(var(--ik-t, 0ms) + 1550ms) both; }

@keyframes ikon-zeichnen { from { stroke-dashoffset: 1.01; } to { stroke-dashoffset: 0; } }
@keyframes ikon-fuellen  { from { fill-opacity: 0; } to { fill-opacity: 1; } }
@keyframes ikon-ein      { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Symbol-Details, 1. Lauf (nach dem Zeichnen) ---------------- */
/* Beziehungen: zwei Personen ruecken zusammen */
.ikon--lauf .ikon__p1 { animation: ikon-p1 900ms var(--ik-aus) var(--ik-detail) both; }
.ikon--lauf .ikon__p2 { animation: ikon-p2 900ms var(--ik-aus) var(--ik-detail) both; }
@keyframes ikon-p1 { from { transform: translateX(-11px); } to { transform: none; } }
@keyframes ikon-p2 { from { transform: translateX(11px); }  to { transform: none; } }

/* Verhalten: Puzzleteil rastet ein */
.ikon--lauf.ikon--verhalten .ikon__d { animation: ikon-rastet 900ms cubic-bezier(.5, 0, .75, 1) var(--ik-detail) both; }
@keyframes ikon-rastet {
  from { transform: translateY(-18px); }
  62%  { transform: translateY(0); animation-timing-function: ease-out; }
  78%  { transform: translateY(1.5px); animation-timing-function: ease-out; }
  to   { transform: none; }
}

/* Gedanken: Gluehbirne leuchtet auf und klingt sanft aus */
.ikon--lauf .ikon__glut { animation: ikon-leuchten 1700ms ease-in-out var(--ik-detail) both; }
@keyframes ikon-leuchten {
  0%   { opacity: 0; fill-opacity: 0; filter: none; }
  35%  { opacity: 1; fill-opacity: 1; filter: drop-shadow(0 0 9px #FFD966); }
  60%  { opacity: 1; fill-opacity: 1; filter: drop-shadow(0 0 7px #FFD966); }
  100% { opacity: 0; fill-opacity: 1; filter: none; }
}

/* Emotionen: das Herz schlaegt einmal (zwei Schlaege kurz hintereinander) */
.ikon--lauf.ikon--emotionen .ikon__d { animation: ikon-herz 900ms ease-in-out var(--ik-detail) both; }
@keyframes ikon-herz {
  0%   { transform: scale(1); }
  16%  { transform: scale(1.11); }
  32%  { transform: scale(1); }
  48%  { transform: scale(1.065); }
  70%  { transform: scale(1); }
  100% { transform: scale(1); }
}

/* Beduerfnisse: die Sprechblase ploppt auf */
.ikon--lauf.ikon--beduerfnisse .ikon__d { animation: ikon-plopp 800ms cubic-bezier(.3, 1.4, .5, 1) var(--ik-detail) both; }
@keyframes ikon-plopp { from { transform: scale(.84); } to { transform: none; } }

/* ---------- Wiederholung bei Hover/Fokus (nur das Detail, ruhiger) ---- */
.ikon--wieder .ikon__p1 { animation: ikon-p1-w 800ms var(--ik-aus) both; }
.ikon--wieder .ikon__p2 { animation: ikon-p2-w 800ms var(--ik-aus) both; }
@keyframes ikon-p1-w { 35% { transform: translateX(-6px); } to { transform: none; } }
@keyframes ikon-p2-w { 35% { transform: translateX(6px); }  to { transform: none; } }

.ikon--wieder.ikon--verhalten .ikon__d { animation: ikon-rastet-w 850ms ease-in-out both; }
@keyframes ikon-rastet-w {
  35%  { transform: translateY(-11px); }
  72%  { transform: translateY(0); }
  84%  { transform: translateY(1.5px); }
  to   { transform: none; }
}

.ikon--wieder .ikon__glut { animation: ikon-leuchten 1400ms ease-in-out both; }
.ikon--wieder.ikon--emotionen .ikon__d { animation: ikon-herz 900ms ease-in-out both; }
.ikon--wieder.ikon--beduerfnisse .ikon__d { animation: ikon-plopp-w 700ms ease-in-out both; }
@keyframes ikon-plopp-w { 28% { transform: scale(.95); } 62% { transform: scale(1.05); } to { transform: none; } }

/* ---------- Bewegung aus: sofort alles sichtbar ------------------------ */
/* Doppelte Absicherung. site.css setzt dort schon "animation: none !important".
   Hier wird zusaetzlich der Startzustand aufgehoben, falls html.ikon-an
   doch gesetzt waere (zum Beispiel beim Umschalten im Panel). */
@media (prefers-reduced-motion: reduce) {
  .ikon .ikon__l { stroke-dashoffset: 0 !important; }
  .ikon .ikon__f { fill-opacity: 1 !important; }
  .ikon .ikon__punkt { opacity: 1 !important; }
  .ikon .ikon__glut { opacity: 0 !important; }
}
html[data-a11y-animationen="aus"] .ikon .ikon__l { stroke-dashoffset: 0 !important; }
html[data-a11y-animationen="aus"] .ikon .ikon__f { fill-opacity: 1 !important; }
html[data-a11y-animationen="aus"] .ikon .ikon__punkt { opacity: 1 !important; }
html[data-a11y-animationen="aus"] .ikon .ikon__glut { opacity: 0 !important; }
/* Druck: statisch */
@media print {
  .ikon .ikon__l { stroke-dashoffset: 0 !important; animation: none !important; }
  .ikon .ikon__f { fill-opacity: 1 !important; }
  .ikon .ikon__punkt { opacity: 1 !important; }
}
