/**
 * Floating Action Buttons – Stylesheet
 *
 * Vollständig gekapselt unter .mod-floatingbuttons.
 * Keine globalen Selektoren. Alle konfigurierbaren Werte via CSS Custom Properties.
 *
 * @package     mod_floatingbuttons
 * @version     1.0.0
 */

/* =============================================================================
   1. CSS CUSTOM PROPERTIES (Standardwerte – werden per Inline-Style überschrieben)
   ============================================================================= */

.mod-floatingbuttons {
    /* Größen */
    --fab-size:           50px;
    --fab-icon-size:      20px;
    --fab-gap:            10px;
    --fab-offset:         16px;
    --fab-radius:         25px;
    --fab-z-index:        999;
    --fab-transition:     250ms;

    /* Farben (globaler Default – werden durch Element-eigene Variablen überschrieben) */
    --fab-bg:             #ffffff;
    --fab-hover-bg:       #f0f0f0;
    --fab-icon-color:     #333333;
    --fab-text-color:     #333333;

    /* Schatten */
    --fab-shadow:         0 2px 8px rgba(0, 0, 0, 0.25);

    /* Sticky: max-width für ausgefahrenen Zustand */
    --fab-sticky-max:     200px;
}


/* =============================================================================
   2. NAV-CONTAINER
   ============================================================================= */

.mod-floatingbuttons {
    position:        fixed;
    z-index:         var(--fab-z-index);
    display:         flex;
    flex-direction:  column;
    gap:             var(--fab-gap);
    list-style:      none;
    margin:          0;
    padding:         0;
    pointer-events:  none; /* Container selbst ist nicht klickbar */
}

/* Alle Links innerhalb sind klickbar */
.mod-floatingbuttons .fab-button {
    pointer-events: all;
}


/* =============================================================================
   3. POSITIONIERUNG (Desktop)
   ============================================================================= */

/* --- Links --- */
.mod-floatingbuttons--left_top {
    left:        var(--fab-offset);
    top:         var(--fab-offset);
    align-items: flex-start;
}

.mod-floatingbuttons--left_middle {
    left:        var(--fab-offset);
    top:         50%;
    transform:   translateY(-50%);
    align-items: flex-start;
}

.mod-floatingbuttons--left_bottom {
    left:        var(--fab-offset);
    bottom:      var(--fab-offset);
    align-items: flex-start;
}

/* --- Rechts --- */
.mod-floatingbuttons--right_top {
    right:       var(--fab-offset);
    top:         var(--fab-offset);
    align-items: flex-end;
}

.mod-floatingbuttons--right_middle {
    right:       var(--fab-offset);
    top:         50%;
    transform:   translateY(-50%);
    align-items: flex-end;
}

.mod-floatingbuttons--right_bottom {
    right:       var(--fab-offset);
    bottom:      var(--fab-offset);
    align-items: flex-end;
}


/* =============================================================================
   4. NORMALER BUTTON (.fab-button--normal)
   ============================================================================= */

.mod-floatingbuttons .fab-button--normal {
    display:         flex;
    flex-direction:  row;
    align-items:     center;
    justify-content: center;
    gap:             8px;
    width:           var(--fab-size);
    height:          var(--fab-size);
    border-radius:   var(--fab-radius);
    background:      var(--fab-btn-bg, var(--fab-bg));
    box-shadow:      var(--fab-shadow);
    text-decoration: none;
    overflow:        hidden;
    white-space:     nowrap;

    /* Transition für Hover */
    transition:
        background-color var(--fab-transition) ease,
        box-shadow       var(--fab-transition) ease,
        transform        var(--fab-transition) ease;
}

/* Normaler Button: Label standardmäßig ausgeblendet (nur wenn show_label aktiv) */
.mod-floatingbuttons .fab-button--normal .fab-button__label {
    display: none;
}

/* Wenn show_label gesetzt → Label anzeigen und Button breiter */
.mod-floatingbuttons .fab-button--normal.fab-button--show-label {
    width:        auto;
    padding:      0 16px 0 12px;
    border-radius: calc(var(--fab-size) / 2);
}
.mod-floatingbuttons .fab-button--normal.fab-button--show-label .fab-button__label {
    display: inline;
}

/* Hover-Zustand für normalen Button */
.mod-floatingbuttons .fab-button--normal:hover,
.mod-floatingbuttons .fab-button--normal:focus-visible {
    background:  var(--fab-btn-hover-bg, var(--fab-hover-bg));
    box-shadow:  var(--fab-shadow), 0 0 0 3px rgba(0, 0, 0, 0.1);
    transform:   scale(1.08);
}


/* =============================================================================
   5. STICKY BUTTON (.fab-button--sticky)
   Jeder Button hat seinen EIGENEN :hover-Zustand → keine Kopplung!
   ============================================================================= */

.mod-floatingbuttons .fab-button--sticky {
    display:         flex;
    flex-direction:  row;
    align-items:     center;
    height:          var(--fab-size);
    border-radius:   0;
    background:      var(--fab-btn-bg, var(--fab-bg));
    box-shadow:      var(--fab-shadow);
    text-decoration: none;
    overflow:        hidden;
    white-space:     nowrap;
    width:           var(--fab-size); /* Eingeklappt: nur Icon */

    transition:
        width            var(--fab-transition) ease,
        background-color var(--fab-transition) ease,
        box-shadow       var(--fab-transition) ease;
}

/* Sticky Button: Label immer vorhanden, aber unsichtbar */
.mod-floatingbuttons .fab-button--sticky .fab-button__label {
    display:    inline-block;
    max-width:  0;
    overflow:   hidden;
    opacity:    0;
    white-space: nowrap;

    transition:
        max-width var(--fab-transition) ease,
        opacity   var(--fab-transition) ease;
}

/* =============================================================================
   5a. STICKY LINKS-SEITE
   Icon links, Text fährt nach rechts aus
   ============================================================================= */

.mod-floatingbuttons .fab-button--sticky-left {
    flex-direction:  row;
    border-radius:   0 var(--fab-radius) var(--fab-radius) 0;
    /* Kein left/right hier – wird über den Container positioniert */
}

.mod-floatingbuttons .fab-button--sticky-left .fab-button__icon {
    /* Icon linksbündig, feste Breite = Buttongröße */
    flex-shrink: 0;
    width:       var(--fab-size);
    display:     flex;
    align-items: center;
    justify-content: center;
}

/* Hover: nur DIESER Button fährt aus – kein Gruppeneffekt */
.mod-floatingbuttons .fab-button--sticky-left:hover .fab-button__label,
.mod-floatingbuttons .fab-button--sticky-left:focus-visible .fab-button__label {
    max-width: var(--fab-sticky-max);
    opacity:   1;
    padding-right: 12px;
}

.mod-floatingbuttons .fab-button--sticky-left:hover,
.mod-floatingbuttons .fab-button--sticky-left:focus-visible {
    width: auto; /* Überlassen wir dem Inhalt */
    background: var(--fab-btn-hover-bg, var(--fab-hover-bg));
}

/* =============================================================================
   5b. STICKY RECHTS-SEITE
   Text fährt nach links aus (Icon ist rechts)
   ============================================================================= */

.mod-floatingbuttons .fab-button--sticky-right {
    flex-direction:  row-reverse;
    border-radius:   var(--fab-radius) 0 0 var(--fab-radius);
}

.mod-floatingbuttons .fab-button--sticky-right .fab-button__icon {
    flex-shrink: 0;
    width:       var(--fab-size);
    display:     flex;
    align-items: center;
    justify-content: center;
}

/* Hover: nur DIESER Button fährt aus */
.mod-floatingbuttons .fab-button--sticky-right:hover .fab-button__label,
.mod-floatingbuttons .fab-button--sticky-right:focus-visible .fab-button__label {
    max-width:   var(--fab-sticky-max);
    opacity:     1;
    padding-left: 12px;
}

.mod-floatingbuttons .fab-button--sticky-right:hover,
.mod-floatingbuttons .fab-button--sticky-right:focus-visible {
    width: auto;
    background: var(--fab-btn-hover-bg, var(--fab-hover-bg));
}


/* =============================================================================
   6. ICON UND TEXT
   ============================================================================= */

.mod-floatingbuttons .fab-button__icon {
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}

.mod-floatingbuttons .fab-button__icon i {
    font-size:  var(--fab-icon-size);
    color:      var(--fab-btn-icon-color, var(--fab-icon-color));
    line-height: 1;
}

.mod-floatingbuttons .fab-button__label {
    font-size:   0.875rem; /* 14px */
    font-weight: 500;
    color:       var(--fab-btn-text-color, var(--fab-text-color));
    line-height: 1.2;
}

/* Fokus-Ring: sichtbarer Fokus-Zustand für Tastaturbedienung */
.mod-floatingbuttons .fab-button:focus-visible {
    outline:        2px solid #0066cc;
    outline-offset: 2px;
}

/* Fokus nicht für Mausbenutzer übersteuern */
.mod-floatingbuttons .fab-button:focus:not(:focus-visible) {
    outline: none;
}


/* =============================================================================
   7. MOBILE DARSTELLUNG
   @media (max-width: 768px) – Standard-Breakpoint
   Wird durch data-module-id-spezifisches CSS überschrieben wenn Breakpoint angepasst
   ============================================================================= */

@media (max-width: 768px) {
    .mod-floatingbuttons {
        /* Am unteren Rand des Browsers */
        position:        fixed;
        bottom:          0;
        left:            0;
        right:           0;
        top:             auto;
        width:           100%;

        /* Horizontale Verteilung */
        flex-direction:  row;
        align-items:     stretch;
        justify-content: center;

        /* Hintergrund für die Bottom-Bar */
        background:      var(--fab-bg);
        padding:         0;
        border-radius:   0;
        gap:             1px;

        /* Koordinaten-Reset: kein left/right/top durch Positions-Klassen */
        transform:       none !important;
        box-shadow:      0 -2px 8px rgba(0, 0, 0, 0.15);
    }

    /* Safe Area: iPhone Home Indicator / Notch berücksichtigen */
    .mod-floatingbuttons--safe-area {
        padding-bottom: env(safe-area-inset-bottom);
        padding-left:   env(safe-area-inset-left);
        padding-right:  env(safe-area-inset-right);
    }

    /* Auf Mobile: alle Buttons als gleich breite Boxen */
    .mod-floatingbuttons .fab-button--sticky,
    .mod-floatingbuttons .fab-button--normal {
        flex:            1;
        flex-direction:  column;
        width:           auto;
        height:          auto;
        min-height:      var(--fab-size);
        border-radius:   0;
        box-shadow:      none;
        gap:             2px;
        padding:         8px 4px;
    }

    /* Sticky-Buttons: kein seitliches Ausfahren auf Mobile */
    .mod-floatingbuttons .fab-button--sticky .fab-button__label {
        max-width: none;
        opacity:   0;
        padding:   0;
        overflow:  hidden;
        height:    0;
        transform: none;
    }

    /* Mobile: nur Icon standard */
    .mod-floatingbuttons .fab-button__icon {
        width:  calc(var(--fab-size) - 12px);
        height: calc(var(--fab-size) - 12px);
    }

    /* Mobile: Hover/Focus deaktiviert (Touch-Geräte haben kein Hover) */
    .mod-floatingbuttons .fab-button--sticky:hover .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky:focus-visible .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-left:hover .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-left:focus-visible .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-right:hover .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-right:focus-visible .fab-button__label {
        max-width: none;
        opacity:   0;
        padding:   0;
        height:    0;
    }

    /* Mobile Text-Modus: wenn --mobile-text Klasse gesetzt */
    .mod-floatingbuttons--mobile-text .fab-button__label,
    .mod-floatingbuttons--mobile-text .fab-button--sticky .fab-button__label {
        display:    block;
        max-width:  none;
        opacity:    1;
        height:     auto;
        font-size:  0.65rem;
        text-align: center;
        padding:    0 2px;
        overflow:   hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Normale Button-Labels auf Mobile standardmäßig ausblenden */
    .mod-floatingbuttons .fab-button--normal .fab-button__label {
        display: none;
    }

    /* Mit Mobile-Text-Option: auch normale Button-Labels zeigen */
    .mod-floatingbuttons--mobile-text .fab-button--normal .fab-button__label {
        display:    block;
        font-size:  0.65rem;
        text-align: center;
    }

    /* Touch-Ziele: mindestens 44x44px (WCAG 2.5.5) */
    .mod-floatingbuttons .fab-button {
        min-width:  44px;
        min-height: 44px;
    }
}

/* =============================================================================
   8. PREFERS-REDUCED-MOTION
   Alle Animationen und Transitions deaktivieren
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    .mod-floatingbuttons .fab-button,
    .mod-floatingbuttons .fab-button--sticky,
    .mod-floatingbuttons .fab-button--normal,
    .mod-floatingbuttons .fab-button--sticky .fab-button__label {
        transition: none !important;
        animation:  none !important;
    }

    /* Sticky-Hover dennoch ermöglichen, aber ohne Animation */
    .mod-floatingbuttons .fab-button--sticky-left:hover .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-left:focus-visible .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-right:hover .fab-button__label,
    .mod-floatingbuttons .fab-button--sticky-right:focus-visible .fab-button__label {
        max-width: var(--fab-sticky-max);
        opacity:   1;
    }
}


/* =============================================================================
   9. TABLET (zwischen Mobile und Desktop)
   z. B. 769px – 1024px: Desktop-Verhalten, aber kompaktere Darstellung
   ============================================================================= */

@media (min-width: 769px) and (max-width: 1024px) {
    .mod-floatingbuttons {
        --fab-size:    44px;
        --fab-gap:     8px;
        --fab-offset:  12px;
    }
}


/* =============================================================================
   10. HOHE PIXEL-DICHTE (Retina etc.)
   ============================================================================= */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mod-floatingbuttons .fab-button {
        /* Schärfere Schatten auf HiDPI-Displays */
        --fab-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }
}


/* =============================================================================
   11. TOUCH-ACTIVE-ZUSTAND (per JavaScript bei Touch-Geräten gesetzt)
   Spiegelt den CSS-:hover-Zustand für Sticky-Buttons auf Touch.
   Jeder Button ist UNABHÄNGIG – nur der getappte Button ändert sich.
   ============================================================================= */

/* Touch-aktiver Sticky-Links-Button */
.mod-floatingbuttons .fab-button--sticky-left.fab-button--touch-active .fab-button__label {
    max-width:    var(--fab-sticky-max);
    opacity:      1;
    padding-right: 12px;
}

.mod-floatingbuttons .fab-button--sticky-left.fab-button--touch-active {
    width:      auto;
    background: var(--fab-btn-hover-bg, var(--fab-hover-bg));
}

/* Touch-aktiver Sticky-Rechts-Button */
.mod-floatingbuttons .fab-button--sticky-right.fab-button--touch-active .fab-button__label {
    max-width:  var(--fab-sticky-max);
    opacity:    1;
    padding-left: 12px;
}

.mod-floatingbuttons .fab-button--sticky-right.fab-button--touch-active {
    width:      auto;
    background: var(--fab-btn-hover-bg, var(--fab-hover-bg));
}

/* Kein touch-active auf Mobile (Breakpoint) */
@media (max-width: 768px) {
    .mod-floatingbuttons .fab-button--touch-active .fab-button__label {
        max-width: none;
        opacity:   0;
        height:    0;
        padding:   0;
    }

    .mod-floatingbuttons .fab-button--touch-active {
        width:      var(--fab-size);
    }
}


/* =============================================================================
   12. SHOW-LABEL (Klasse für dauerhaft angezeigte Labels bei normalen Buttons)
   ============================================================================= */

.mod-floatingbuttons .fab-button--normal.fab-button--show-label .fab-button__label {
    display:     inline;
    white-space: nowrap;
}

