/* =====================================================================
   layout-fix.css – zentrale Layout-Korrekturen
   ---------------------------------------------------------------------
   Wird in header.php direkt nach style.css geladen.
   Behebt vor allem: Überschriften verschwinden hinter dem Header.
   ===================================================================== */

/* ---------------------------------------------------------------
   1. Header-Abstand
   Die echte Höhe misst header.php per JavaScript und schreibt sie
   in --header-h. Die Werte hier sind nur Startwerte, bis gemessen ist.
   --------------------------------------------------------------- */
:root { --header-h: 175px; }
@media (max-width: 991px) { :root { --header-h: 150px; } }
@media (max-width: 576px) { :root { --header-h: 175px; } }

/* Das erste Element jeder Seite (Hero-Bereich oder Container) beginnt
   genau unter dem Header – egal welches padding die Seite selbst setzt
   (vorher: 4rem, 5rem, 10rem, 13rem, 15rem ...). */
main#main-content > :first-child,
main#main-content > style:first-child + *,
main#main-content > script:first-child + * {
    padding-top: calc(var(--header-h) + 2.5rem) !important;
}

/* Sprungmarken (#aktuelles, #anfrageformular ...) nicht unter dem Header verstecken */
[id] { scroll-margin-top: calc(var(--header-h) + 1rem); }
html { scroll-padding-top: calc(var(--header-h) + 1rem); }

/* Schwebende Ankündigungen oben rechts unter dem Header */
.alerts-top-right { top: calc(var(--header-h) + 10px) !important; }

/* ---------------------------------------------------------------
   2. Mobiles Menü
   --------------------------------------------------------------- */
@media (max-width: 991px) {
    /* Offenes Menü scrollt in sich, statt aus dem Bildschirm zu laufen */
    #main-nav-container.active {
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Untermenüs auf dem Handy immer aufgeklappt anzeigen (kein Hover auf Touch-Geräten) */
    .nav-links .dropdown-menu {
        display: block !important;
        position: static !important;
        box-shadow: none !important;
        background: rgba(0, 86, 179, 0.04) !important;
        border: none !important;
        border-radius: 8px !important;
        padding: 0 0 0 1rem !important;
        min-width: 0 !important;
        width: 100% !important;
        animation: none !important;
        backdrop-filter: none !important;
    }
    .nav-links .dropdown-menu a { font-size: 0.95rem; padding: 10px 5px !important; }
    .nav-links .fa-chevron-down { display: none; }

    /* Scroll-Bereich innerhalb der Seite (Bildungsangebote auf der Startseite) auf dem Handy aufheben */
    .scroll-container { max-height: none !important; overflow: visible !important; padding-right: 0 !important; }
}

/* ---------------------------------------------------------------
   3. Barrierefreiheit
   --------------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 10px;
    z-index: 100000;
    background: var(--primary-color);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    text-decoration: none;
}
.skip-link:focus { left: 10px; }

input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Weniger Bewegung, wenn im Betriebssystem eingestellt */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* Endlos animierter Hintergrund auf Handys aus (spart Akku) */
@media (max-width: 768px) {
    body { animation: none; background-size: 100% 100%; }
}

/* ---------------------------------------------------------------
   4. Kleinere Korrekturen
   --------------------------------------------------------------- */
img, video, iframe { max-width: 100%; }
table { max-width: 100%; }
/* Lange Wörter/E-Mail-Adressen brechen auf schmalen Bildschirmen um */
main p, main li, main td { overflow-wrap: anywhere; }

/* Google-Maps-Platzhalter (Zwei-Klick-Lösung auf der Kontaktseite) */
.map-consent {
    height: 100%;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(0, 86, 179, 0.08), rgba(139, 92, 246, 0.08));
    color: var(--text-main);
    font-size: 0.9rem;
}
.map-consent button {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}
.map-consent a { color: var(--primary-color); font-weight: bold; }
