/* ==========================================================================
   LENDOLINO – animations.css
   Bewegung wird sparsam eingesetzt: eine Ladesequenz im Hero, Einblenden
   beim Scrollen, Antworten auf Zeiger und Touch. Alles in dieser Datei ist
   Zugabe – ohne sie bleibt die Seite vollständig benutzbar.
   ========================================================================== */

/* --- Hero: Ladesequenz ----------------------------------------------------
   Die Headline steht sofort (wichtig für den Largest Contentful Paint) und
   bekommt einen Lichtreflex. Der Rest folgt leicht versetzt. */

.hero__title {
  animation: title-shine 2.6s var(--ease-in-out) 0.45s both;
}

@keyframes title-shine {
  from { background-position: 100% 0; }
  to { background-position: 0% 0; }
}

.hero__lead,
.hero__actions,
.hero__place {
  animation: rise 1s var(--ease-out) both;
}

.hero__lead { animation-delay: 0.12s; }
.hero__actions { animation-delay: 0.22s; }
.hero__place { animation-delay: 0.32s; }

.page-head .breadcrumb,
.page-head .lead {
  animation: rise 1s var(--ease-out) both;
}

.page-head .lead { animation-delay: 0.12s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Code-Fragmente: blenden nach der Headline ein und schweben danach ruhig */
.core-chips {
  animation: fade 1.6s var(--ease-out) 0.9s both;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.code-chip > span {
  animation: drift 7s ease-in-out infinite alternate;
}

.code-chip--b > span { animation-duration: 9s; animation-delay: -3s; }
.code-chip--c > span { animation-duration: 8s; animation-delay: -5s; }

@keyframes drift {
  from { transform: translateY(-7px); }
  to { transform: translateY(7px); }
}

/* Der CSS-Kern atmet leicht, solange die 3D-Szene noch lädt */
.core-poster__orb {
  animation: breathe 5s ease-in-out infinite alternate;
}

@keyframes breathe {
  from { transform: scale(0.98); }
  to { transform: scale(1.03); }
}

/* --- Einblenden beim Scrollen ---------------------------------------------
   animations.js setzt .is-pending nur auf Elemente unterhalb des sichtbaren
   Bereichs. Ohne JavaScript ist deshalb alles sofort sichtbar. */

[data-reveal] {
  transition:
    opacity 0.9s var(--ease-out) calc(var(--i, 0) * 90ms),
    transform 1.1s var(--ease-out) calc(var(--i, 0) * 90ms);
}

[data-reveal].is-pending {
  opacity: 0;
  transform: translateY(28px);
}

/* Karten mit eigener 3D-Transformation blenden nur ein */
.svc-card[data-reveal],
.id-card[data-reveal],
.service__visual[data-reveal] {
  transition:
    opacity 0.9s var(--ease-out) calc(var(--i, 0) * 90ms),
    transform 0.7s var(--ease-out);
}

.svc-card[data-reveal].is-tilting,
.id-card[data-reveal].is-tilting,
.service__visual[data-reveal].is-tilting {
  transition-duration: 0.9s, 0.12s;
}

.svc-card[data-reveal].is-pending,
.id-card[data-reveal].is-pending,
.service__visual[data-reveal].is-pending {
  transform: perspective(1200px) rotateX(7deg) translateY(28px);
}

/* --- Lichtkante der Sektionen wandert mit dem Scrollen --------------------
   Scroll-gesteuerte Animation; Browser ohne Unterstützung zeigen den Reflex
   einfach links stehend. */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .section--edge::before {
      background:
        linear-gradient(90deg, rgba(40, 120, 255, 0), var(--cyan) 45%, rgba(40, 120, 255, 0.55) 62%, rgba(40, 120, 255, 0)) 0 0 / 34% 100% no-repeat,
        var(--line);
      animation: edge-travel linear both;
      animation-timeline: view();
      animation-range: entry 10% exit 60%;
    }
  }
}

@keyframes edge-travel {
  from { background-position: -10% 0, 0 0; }
  to { background-position: 110% 0, 0 0; }
}

/* --- Systemansicht (CSS-Variante): Daten fließen über die Leitungen ------- */

.system__fallback .flow {
  animation: flow 1.5s linear infinite;
}

.system__fallback .flow--back {
  animation-direction: reverse;
}

@keyframes flow {
  to { stroke-dashoffset: -28; }
}

/* --- Formular ------------------------------------------------------------- */

.btn__spinner {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.form-success {
  animation: rise 0.8s var(--ease-out) both;
}

.field__error.is-visible,
.form__status.is-visible {
  animation: rise 0.4s var(--ease-out) both;
}

/* --- Seitenwechsel -------------------------------------------------------- */

::view-transition-old(root) {
  animation: page-out 0.22s ease both;
}

::view-transition-new(root) {
  animation: page-in 0.5s var(--ease-out) both;
}

@keyframes page-out {
  to { opacity: 0; }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* --- Weiches Scrollen zu Sprungmarken ------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* --- Reduzierte Bewegung --------------------------------------------------
   Wer im Betriebssystem "Bewegung reduzieren" gewählt hat, bekommt keine
   Animationen und keine Übergänge. Die 3D-Szene zeigt dann ein Standbild. */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }

  [data-reveal].is-pending {
    opacity: 1;
    transform: none;
  }

  .code-chip {
    transform: none;
  }

  @view-transition {
    navigation: none;
  }
}
