/* wegweiser.studio — animationen.css
   Stufen-Animationen auf Projektseiten (Stadtmodell, Erreichbarkeit, Einwohner-Wärmebild). Nutzt die Variablen aus base.css und die
   Steuerleiste .ll-label / .ll-bar / .ll-steps / .ll-pause aus components.css (Ebenen-Animation der Startseite).
   Zum Übernehmen: an components.css anhängen oder separat nach components.css einbinden. */

.stage-figure { grid-column: 1 / -1; margin: 0; }
.stage-loop .ll-bar[hidden] { display: none; }   /* .ll-bar setzt display:flex und würde [hidden] überstimmen */
.stage-loop { position: relative; }
.stage-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.stage-frame .ll-label { top: .9rem; right: .9rem; }
.stage-figure figcaption { margin-top: .7rem; color: var(--muted); font-size: .9rem; }
.stage-figure figcaption small { display: block; margin-top: .2rem; font-size: .8rem; }

/* ---------------------------------------------------------------- Stadtmodell: Weißmodell → Massenmodell → Luftbild */
.ml-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ml-layer + .ml-layer {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.4s cubic-bezier(.6, 0, .2, 1), opacity .45s ease;
}
.ml-scan {
  position: absolute;
  z-index: 1;
  top: 0; bottom: 0; left: 0;
  width: 2px;
  background: var(--cyan-ink);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .7), 0 0 18px 4px rgba(41, 224, 255, .45);
  opacity: 0;
  pointer-events: none;
}
@keyframes ml-scan-a { 0% { left: 0; opacity: 1; } 92% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
@keyframes ml-scan-b { 0% { left: 0; opacity: 1; } 92% { opacity: 1; } 100% { left: 100%; opacity: 0; } }

/* Zustände: reset → 0 Weißmodell → 1 Massenmodell → 2 Luftbild; „all“ = Standbild (Luftbild) */
.model-loop[data-stage="0"] .ml-layer { transition: none; }
.model-loop[data-stage="reset"] .ml-layer + .ml-layer { clip-path: inset(0); opacity: 0; transition: opacity .45s ease; }
.model-loop[data-stage="1"] .ml-massen,
.model-loop[data-stage="2"] .ml-massen,
.model-loop[data-stage="2"] .ml-luft,
.model-loop[data-stage="all"] .ml-layer { clip-path: inset(0); }
.model-loop[data-stage="1"] .ml-scan { animation: ml-scan-a 1.4s cubic-bezier(.6, 0, .2, 1) both; }
.model-loop[data-stage="2"] .ml-scan { animation: ml-scan-b 1.4s cubic-bezier(.6, 0, .2, 1) both; }

/* ---------------------------------------------------------------- Erreichbarkeit */
.reach-loop canvas { display: block; width: 100%; height: 100%; background: #f7f9fb; }
.reach-loop.is-error .stage-frame::after {
  content: "Animation konnte nicht geladen werden.";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: .9rem;
}
.rl-pin {
  position: absolute;
  z-index: 1;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 1px 4px rgba(11, 21, 32, .35);
  opacity: 0;
  transition: opacity .4s ease;
}
.rl-pin::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 1.5px solid var(--cyan-ink);
  border-radius: 50%;
  opacity: 0;
}
.reach-loop.is-ready .rl-pin { opacity: 1; }
.reach-loop[data-stage="0"] .rl-pin::after { animation: rl-pulse 1.8s ease-out .3s infinite; }
@keyframes rl-pulse { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(3.4); } }
.rl-pin span {
  position: absolute;
  left: 50%; bottom: calc(100% + 6px);
  transform: translateX(-50%);
  padding: .25rem .45rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  font: 700 .66rem/1 var(--mono);
  letter-spacing: .04em;
  white-space: nowrap;
}
.rl-scale {
  position: absolute;
  z-index: 1;
  right: .9rem; bottom: .8rem;
  height: 6px;
  border: 1.5px solid var(--ink);
  border-top: 0;
  font: 600 .66rem/1 var(--mono);
  text-align: center;
}
.rl-scale span { position: relative; top: -1.05rem; }
.rl-tag, .rl-profil {
  position: absolute;
  z-index: 2;
  left: .9rem; bottom: .8rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-1);
  font-size: .8rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
}
.rl-tag strong, .rl-profil strong { font: 700 .66rem/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.rl-tag dl { display: grid; grid-template-columns: auto auto; gap: .15rem .8rem; margin: .35rem 0 0; }
.rl-tag dt { color: var(--muted); }
.rl-tag dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.reach-loop[data-stage="4"] .rl-tag { opacity: 1; transform: none; transition-delay: .9s; }

.rl-profil { width: min(360px, 46%); }
/* Profil wird von links aufgedeckt (Clip statt Strichlänge: verträgt non-scaling-stroke) */
.rl-profil svg { display: block; width: 100%; height: auto; margin: .4rem 0 .3rem; clip-path: inset(-4px 100% -4px -4px); }
.rl-profil-flaeche { fill: rgba(41, 224, 255, .16); }
.rl-profil-linie { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.rl-achse { display: flex; justify-content: space-between; color: var(--muted); font: .66rem/1 var(--mono); }
.rl-profil-kopf { display: grid; gap: .25rem; }
.rl-profil-kopf span { color: var(--muted); font: .66rem/1 var(--mono); }
.rl-werte { display: grid; grid-template-columns: repeat(2, auto); gap: .1rem .8rem; margin: .45rem 0 0; }
.rl-werte dt { color: var(--muted); }
.rl-werte dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.reach-loop[data-stage="5"] .rl-profil,
.reach-loop[data-stage="all"] .rl-profil { opacity: 1; transform: none; }
.reach-loop[data-stage="5"] .rl-profil svg { clip-path: inset(-4px); transition: clip-path 2.6s cubic-bezier(.33, 1, .68, 1) .1s; }
.reach-loop[data-stage="all"] .rl-profil svg { clip-path: inset(-4px); }

.rl-legende { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .7rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .8rem; }
.rl-legende li { display: inline-flex; align-items: center; gap: .4rem; }
.rl-legende i { width: 18px; height: 4px; border-radius: 2px; background: var(--c); }
.rl-legende i.kreis { height: 0; border-top: 1.5px dashed var(--ink); background: none; }
.rl-legende i.haus { width: 10px; height: 10px; border-radius: 2px; }

/* ---------------------------------------------------------------- Einwohner-Wärmebild (Zensus) */
.heat-loop canvas { display: block; width: 100%; height: 100%; background: #f7f9fb; }
.heat-loop.is-error .stage-frame::after {
  content: "Animation konnte nicht geladen werden.";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: .9rem;
}
.hl-tag {
  position: absolute;
  z-index: 2;
  left: .9rem; bottom: .8rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-1);
  font-size: .8rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
}
.hl-tag strong { font: 700 .66rem/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.hl-tag dl { display: grid; grid-template-columns: auto auto; gap: .15rem .8rem; margin: .35rem 0 0; }
.hl-tag dt { color: var(--muted); }
.hl-tag dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.heat-loop[data-stage="3"] .hl-tag { opacity: 1; transform: none; transition-delay: .3s; }
.heat-loop[data-stage="all"] .hl-tag { opacity: 1; transform: none; }
.hl-legende { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; margin: .7rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .8rem; }
.hl-legende li { display: inline-flex; align-items: center; gap: .45rem; }
.hl-skala {
  width: 120px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(191, 241, 251, .35), rgba(127, 230, 248, .6) 25%, rgba(41, 196, 224, .74) 50%,
                                     rgba(0, 128, 154, .84) 75%, rgba(11, 58, 74, .92));
}
.hl-legende .zahl { font: 600 .7rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.hl-legende .hl-feld { width: 12px; height: 12px; border-radius: 2px; background: var(--c); opacity: .86; }
.hl-legende .hl-feld.ohne { opacity: .45; }
.hl-legende .hl-notiz { flex-basis: 100%; font-size: .74rem; }

/* Ebenen-Umschalter (Einwohner · Altenquotient · … · Quartierstyp) */
.hl-wahl { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0 0; }
.hl-wahl[hidden] { display: none; }
.hl-wahl button {
  padding: .4rem .75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
@media (hover: hover) { .hl-wahl button:hover { border-color: var(--ink); } }
.hl-wahl button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.hl-wahl button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Kennzahl der gewählten Ebene statt der Einwohner-Kennzahlen */
.heat-loop:not([data-ebene]) .hl-info { display: none; }
.heat-loop[data-ebene] .hl-tag:not(.hl-info) { display: none; }
.heat-loop[data-ebene] .hl-info { opacity: 1; transform: none; transition-delay: .2s; }
.hl-info { max-width: 18rem; }
.hl-info p { margin: .25rem 0 0; color: var(--muted); }

/* Schmale Bildschirme: Kennzahlen und Profil unter die Karte statt darüber */
@media (max-width: 640px) {
  .stage-frame .ll-label { top: .6rem; right: .6rem; padding: .45rem .6rem; font-size: .64rem; }
  .rl-pin span { display: none; }
  .reach-loop .stage-panels, .heat-loop .stage-panels { display: grid; gap: .6rem; margin-top: .6rem; }
  .rl-tag, .rl-profil, .hl-tag { position: static; width: auto; opacity: 1; transform: none; box-shadow: none; }
  .rl-profil svg { clip-path: inset(-4px); }
}
@media (min-width: 641px) {
  /* Deckungsgleich über der Karte (die Karte ist das erste Kind und gleich breit) */
  .reach-loop .stage-panels, .heat-loop .stage-panels { position: absolute; z-index: 2; top: 0; left: 0; right: 0; aspect-ratio: 16 / 9; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ml-scan, .rl-pin::after { animation: none !important; }
}
