/* ==========================================================================
   ft-motion.css - FriendsTime Bewegungs-Ebene (eigene, kleine Gestaltung)
   --------------------------------------------------------------------------
   Gehoert zu assets/js/ft-motion.js. Keine Fremdbibliothek. Alles additiv.

   WAS DIESE DATEI BEWUSST NICHT TUT (Bestand, geprueft)
   - Karten-Hover-Anhebung der echten Karten: gibt es schon (css/ft-utilities.css,
     assets/css/ft-warmth.css, assets/css/ft-buttons.css, assets/css/ft-blog.css,
     assets/css/ft-interactions.css). Hier nur als Opt-in .ftm-lift.
   - Button-Druck (.btn / button :active): css/ft-utilities.css "scale(0.96)".
     Hier nur fuer Karten-Links und Nicht-Button-Elemente (siehe 7.).
   - Fokus-Ringe fuer a/button/.btn/input/select/textarea/summary: css/ft-utilities.css.
     Hier nur die Luecken (eigene tabindex-Elemente, ARIA-Rollen, siehe 9.).

   NAMENSRAUM (wichtig)
   - Klassen .ftm-*  : css/ft-mobile-modern.css nutzt dieselbe Vorsilbe (Mobil-Layer).
     Dort existieren schon .ftm-reveal (+ .is-visible), .ftm-bubble-in, .ftm-skel,
     .ftm-stagger und die Variablen --ftm-*. Deshalb:
       * Eigene Variablen heissen --ftmo-* (nie --ftm-*, sonst wuerde der Mobil-Layer
         ueberschrieben, weil beide auf :root liegen).
       * Eigene Keyframes heissen ftmo-* (ftm-shimmer, ftm-bubble-in etc. sind belegt).
       * .ftm-reveal bleibt bestehen (Auftrag), das Skript setzt dort zusaetzlich
         .is-visible, damit der Mobil-Layer nie unsichtbar bleibt (siehe 10.).
     Der Sammel-Schalter dort ([class*="ftm-"] bei prefers-reduced-motion) trifft
     auch unsere Klassen und erzwingt Ruhe - gewollt.

   TECHNIK
   - Nur opacity + einzelne Transform-Eigenschaften (translate / scale). Die
     EINZELNEN Eigenschaften ueberschreiben kein bestehendes "transform" (Hover-
     Anhebung der Karten, Bootstrap .translate-middle der Badges bleiben intakt).
   - Keine Animation ruehrt width/height/margin an: keine Layout-Verschiebung.
   - Animationen laufen mit fill-mode "backwards": nach dem Ende gilt wieder der
     normale Stil der Seite, nichts bleibt haengen.
   - Hell/Dunkel wie die Seite: body.dark-mode, html.ft-dark-pre (Anti-FOUC),
     html[data-theme="dark"], body.dark-theme. (Die Seite nutzt KEIN CSS-
     prefers-color-scheme; das Skript im <head> entscheidet und setzt die Klassen.)
   ========================================================================== */


/* ==========================================================================
   0. TOKEN (hell + dunkel)
   ========================================================================== */
:root {
    --ftmo-ease: cubic-bezier(.22, 1, .36, 1);
    --ftmo-spring: cubic-bezier(.34, 1.56, .64, 1);
    --ftmo-dur: 520ms;
    --ftmo-dur-soft: 380ms;
    --ftmo-dur-page: 220ms;
    --ftmo-stagger: 55ms;
    --ftmo-rise: 14px;

    /* Fokus-Ring: Markenfarbe, auf Weiss ca. 4,4:1 (WCAG 1.4.11 verlangt 3:1) */
    --ftmo-focus: #0082a3;

    /* Platzhalter-Glanz */
    --ftmo-skel-base: rgba(15, 23, 42, .07);
    --ftmo-skel-shine: rgba(255, 255, 255, .70);

    /* Opt-in .ftm-lift */
    --ftmo-lift-shadow: 0 12px 30px rgba(0, 130, 163, .16), 0 3px 10px rgba(15, 23, 42, .08);
    --ftmo-lift-border: rgba(0, 160, 198, .32);

    /* Ring beim Zahlen-Puls der Badges */
    --ftmo-ring: rgba(0, 160, 198, .45);
}

html.ft-dark-pre,
body.dark-mode,
html[data-theme="dark"],
body.dark-theme {
    --ftmo-focus: #36e0ee;
    --ftmo-skel-base: rgba(255, 255, 255, .07);
    --ftmo-skel-shine: rgba(255, 255, 255, .16);
    --ftmo-lift-shadow: 0 12px 30px rgba(0, 0, 0, .50), 0 3px 10px rgba(0, 0, 0, .35);
    --ftmo-lift-border: rgba(86, 204, 242, .38);
    --ftmo-ring: rgba(54, 224, 238, .50);
}


/* ==========================================================================
   1. SEITEN-EINBLENDUNG (kurz, nur opacity)
   --------------------------------------------------------------------------
   Bewusst KEIN transform/translate auf <main>: ein Transform wuerde
   position:fixed-Kinder (z. B. das feste Chat-Eingabefeld) fuer die Dauer der
   Animation am Container statt am Fenster verankern und danach springen lassen.
   opacity hat diese Nebenwirkung nicht. Live-/Video-Seiten sind ausgenommen
   (Video-Flaechen nicht unnoetig compositen). Abschalten pro Seite:
   <main data-ftm-still>.
   ========================================================================== */
body:not([class*="ft-page-live"]):not([class*="ft-page-video"]) main:not([data-ftm-still]) {
    animation: ftmo-page-in var(--ftmo-dur-page) ease-out backwards;
}

@keyframes ftmo-page-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}


/* ==========================================================================
   2. REVEAL: Elemente blenden beim Scrollen ein
   --------------------------------------------------------------------------
   Versteckt wird NUR, wenn das Skript lief (html.ftm-js). Ohne Skript, ohne
   IntersectionObserver oder bei reduzierter Bewegung bleibt alles sichtbar.
     .ftm-reveal  Element, das Entwickler von Hand markieren
     .ftm-pre     vom Skript automatisch vergeben (Feed-/Listen-Karten)
     .ftm-in      "jetzt einblenden" (Skript, per IntersectionObserver)
     .ftm-soft    schon beim Laden im Bild: sanfter, nie ganz unsichtbar
     .ftm-done    Animation fertig (Skript), Klasse nimmt die Animation weg
   ========================================================================== */
html.ftm-js .ftm-reveal:not(.ftm-in),
html.ftm-js .ftm-pre:not(.ftm-in) {
    opacity: 0;
    translate: 0 var(--ftmo-rise);
}

.ftm-in:not(.ftm-done) {
    animation: ftmo-rise var(--ftmo-dur) var(--ftmo-ease) backwards;
    animation-delay: calc(var(--ftmo-i, 0) * var(--ftmo-stagger));
}

.ftm-in.ftm-soft:not(.ftm-done) {
    animation-name: ftmo-rise-soft;
    animation-duration: var(--ftmo-dur-soft);
}

@keyframes ftmo-rise {
    from { opacity: 0; translate: 0 var(--ftmo-rise); }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes ftmo-rise-soft {
    from { opacity: .45; translate: 0 8px; }
    to   { opacity: 1; translate: 0 0; }
}


/* ==========================================================================
   3. CHAT-BLASEN: neue Nachricht fliegt ein
   --------------------------------------------------------------------------
   Das Skript setzt .ftm-new nur auf wirklich NEUE Blasen (data-message-id noch
   nicht gesehen). Der Verlauf beim Oeffnen und das komplette Neu-Rendern bei
   jedem Poll (messages.php: area.innerHTML = ...) lassen nichts aufblitzen.
   Richtung ueber data-own (ajax/load_chat_messages_modular.php:112):
   eigene Blase von rechts, fremde von links (physisch, wie margin-left:auto).
   ========================================================================== */
.message-bubble.ftm-new {
    transform-origin: 0 100%;
    animation: ftmo-bubble-other 360ms var(--ftmo-ease) backwards;
}

.message-bubble.ftm-new[data-own="1"] {
    transform-origin: 100% 100%;
    animation-name: ftmo-bubble-own;
}

@keyframes ftmo-bubble-other {
    from { opacity: 0; translate: -14px 8px; scale: .92; }
    to   { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes ftmo-bubble-own {
    from { opacity: 0; translate: 14px 8px; scale: .92; }
    to   { opacity: 1; translate: 0 0; scale: 1; }
}


/* ==========================================================================
   4. ZAHLEN-PULS (.ftm-bump) + Hochzaehlen ([data-ftm-count])
   --------------------------------------------------------------------------
   Das Skript setzt .ftm-bump, wenn sich ein Zaehler aendert (Header-Badges,
   #likes-count-N, #comments-count-N, [data-ftm-bump]). Badge mit Bootstrap
   .translate-middle: Skalierung um die Ecke, sonst wandert die Mitte.
   ========================================================================== */
.ftm-bump {
    animation: ftmo-bump 420ms var(--ftmo-spring) backwards;
}

.badge.ftm-bump {
    animation: ftmo-bump 420ms var(--ftmo-spring) backwards,
               ftmo-ring 620ms ease-out backwards;
}

.translate-middle.ftm-bump {
    transform-origin: 0 0;
}

@keyframes ftmo-bump {
    0%   { scale: 1; }
    35%  { scale: 1.28; }
    100% { scale: 1; }
}

@keyframes ftmo-ring {
    from { box-shadow: 0 0 0 0 var(--ftmo-ring); }
    to   { box-shadow: 0 0 0 9px rgba(0, 0, 0, 0); }
}

/* Ziffern gleich breit, damit das Hochzaehlen nichts verschiebt */
[data-ftm-count] {
    font-variant-numeric: tabular-nums;
}


/* ==========================================================================
   5. PLATZHALTER-GLANZ (.ftm-shimmer, Opt-in)
   --------------------------------------------------------------------------
   Laeuft nur ueber transform (Compositor). Bestehende Skeletons (.ft-skeleton,
   .ft-skel-box, .ft-shimmer-card) haben schon eigenen Glanz und bleiben
   unberuehrt; das hier ist fuer neue Platzhalter gedacht.
   ========================================================================== */
.ftm-shimmer {
    position: relative;
    overflow: hidden;
    background-color: var(--ftmo-skel-base);
}

.ftm-shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(100deg, transparent 20%, var(--ftmo-skel-shine) 50%, transparent 80%);
    transform: translateX(-100%);
    animation: ftmo-shine 1.4s ease-in-out infinite;
}

@keyframes ftmo-shine {
    to { transform: translateX(100%); }
}


/* ==========================================================================
   6. KARTEN-ANHEBUNG (.ftm-lift, Opt-in)
   --------------------------------------------------------------------------
   Nur fuer NEUE Bausteine. Die echten Karten der Seite heben sich bereits.
   Nutzt "translate" statt "transform", stoert also kein vorhandenes Transform.
   Nur bei Maus (hover: hover), damit auf Touch nichts "klebt".
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
    .ftm-lift {
        transition: translate 240ms var(--ftmo-ease),
                    box-shadow 240ms var(--ftmo-ease),
                    border-color 240ms ease;
    }

    .ftm-lift:hover,
    .ftm-lift:focus-visible {
        translate: 0 -4px;
        box-shadow: var(--ftmo-lift-shadow);
        border-color: var(--ftmo-lift-border);
    }
}


/* ==========================================================================
   7. DRUCK-EFFEKT fuer Karten-Links und Nicht-Button-Elemente
   --------------------------------------------------------------------------
   .btn und <button> haben schon "scale(0.96)" (css/ft-utilities.css) - hier
   NICHT doppelt. Per Animation statt transition, damit keine bestehende
   transition-Liste ueberschrieben wird. :where() = Spezifitaet 0: jede
   Seitenregel mit eigener Animation gewinnt.
   Karten-Links nur ab 992px: darunter drueckt css/ft-mobile-modern.css schon.
   ========================================================================== */
@media (min-width: 992px) {
    :where(a.card, a.ft-blog-card, a.ft-explore-card, a.mp-featured-card):active {
        animation: ftmo-press-card 140ms var(--ftmo-ease) both;
    }
}

:where(.ftm-press, [role="button"]:not(button, .btn)):active {
    animation: ftmo-press 120ms var(--ftmo-ease) both;
}

@keyframes ftmo-press-card {
    to { scale: .985; }
}

@keyframes ftmo-press {
    to { scale: .97; }
}


/* ==========================================================================
   8. (frei)
   ========================================================================== */


/* ==========================================================================
   9. FOKUS-RINGE: nur die LUECKEN
   --------------------------------------------------------------------------
   a, button, .btn, [role="button"], input, textarea, select, summary,
   .dropdown-item decken css/ft-utilities.css (outline 3px #1FC8D8 !important)
   schon ab. Hier: eigene tabindex-Elemente und ARIA-Rollen ohne Button-Tag.
   tabindex="-1" (z. B. <main id="main-content">, Sprungziel) bekommt bewusst
   keinen Ring. Farbe mit ausreichendem Kontrast (siehe Token).
   Hinweis: Der Bestand nutzt #1FC8D8 (auf Weiss nur ca. 2:1). Wer das
   vereinheitlichen will, setzt dort outline-color auf var(--ftmo-focus).
   ========================================================================== */
[tabindex]:not([tabindex="-1"]):focus-visible,
[role="tab"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="switch"]:focus-visible,
[role="checkbox"]:focus-visible,
[role="radio"]:focus-visible,
[role="option"]:focus-visible,
[role="link"]:focus-visible,
[role="slider"]:focus-visible,
[contenteditable="true"]:focus-visible {
    outline: 3px solid var(--ftmo-focus);
    outline-offset: 2px;
}


/* ==========================================================================
   10. ZUSAMMENSPIEL MIT css/ft-mobile-modern.css (.ftm-reveal dort vorhanden)
   --------------------------------------------------------------------------
   Dort gilt unter body.ft-view-mobile: .ftm-reveal { opacity:0; transform;
   transition } und erst .is-visible zeigt es. Kein Markup und kein Skript
   nutzte das bisher. Damit beides nicht doppelt bewegt oder haengen bleibt:
   - Wir nehmen dort Transform + Transition weg (Bewegung kommt von uns).
   - Ohne unser Skript (html:not(.ftm-js)) bleibt .ftm-reveal sichtbar.
   - Das Skript setzt zusaetzlich .is-visible (siehe ft-motion.js).
   Hoehere Spezifitaet statt !important, unabhaengig von der Link-Reihenfolge.
   ========================================================================== */
html body.ft-view-mobile .ftm-reveal,
html body.ft-view-mobile .ftm-reveal.is-visible {
    transition: none;
    transform: none;
}

html:not(.ftm-js) body.ft-view-mobile .ftm-reveal {
    opacity: 1;
}


/* ==========================================================================
   11. DRUCK: alles sichtbar, keine Bewegung
   ========================================================================== */
@media print {
    html.ftm-js .ftm-reveal:not(.ftm-in),
    html.ftm-js .ftm-pre:not(.ftm-in) {
        opacity: 1;
        translate: none;
    }

    main,
    .ftm-in,
    .message-bubble.ftm-new,
    .ftm-bump {
        animation: none;
    }
}


/* ==========================================================================
   12. REDUZIERTE BEWEGUNG (Pflicht): schaltet ALLE Bewegungen ab
   --------------------------------------------------------------------------
   Greift bei prefers-reduced-motion und bei der seiteneigenen Einstellung
   html.a11y-no-motion (siehe css/ft-mobile-modern.css). Endzustand = sichtbar,
   kein halber Zustand. Das ist der einzige Ort mit !important.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    main,
    .ftm-reveal,
    .ftm-pre,
    .ftm-in,
    .ftm-soft,
    .ftm-bump,
    .message-bubble.ftm-new,
    .ftm-shimmer,
    .ftm-lift,
    .ftm-lift:hover,
    .ftm-lift:focus-visible,
    .ftm-press:active,
    a.card:active,
    a.ft-blog-card:active,
    a.ft-explore-card:active,
    a.mp-featured-card:active,
    [role="button"]:not(button, .btn):active {
        animation: none !important;
        transition: none !important;
        translate: none !important;
        scale: none !important;
    }

    .ftm-shimmer::after {
        animation: none !important;
    }

    .ftm-reveal,
    .ftm-pre {
        opacity: 1 !important;
    }
}

html.a11y-no-motion :is(
    main,
    .ftm-reveal,
    .ftm-pre,
    .ftm-in,
    .ftm-soft,
    .ftm-bump,
    .message-bubble.ftm-new,
    .ftm-shimmer,
    .ftm-lift,
    .ftm-lift:hover,
    .ftm-lift:focus-visible,
    .ftm-press:active,
    a.card:active,
    a.ft-blog-card:active,
    a.ft-explore-card:active,
    a.mp-featured-card:active,
    [role="button"]:not(button, .btn):active
) {
    animation: none !important;
    transition: none !important;
    translate: none !important;
    scale: none !important;
}

html.a11y-no-motion .ftm-shimmer::after {
    animation: none !important;
}

html.a11y-no-motion :is(.ftm-reveal, .ftm-pre) {
    opacity: 1 !important;
}
