/* =======================================================
   HAUPTSTYLESHEET - GLD JAKOBI (TYPO3 v13 OPTIMIERT)
   BEHEBTES PROBLEM: Bild links/rechts neben Text
   ======================================================= */

/* ===== RESET & GRUNDLAGEN ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #5a8a3a url(/fileadmin/img/HGseite.png) repeat;
    font-family: 'Comic Sans MS', 'Comic Sans', 'Chalkboard SE', 'Bradley Hand', cursive;
    font-size: 20px;
    color: #333;
    line-height: 1.6;
}

table.rahmenbody {
    background: #fff;
    margin: 0 auto;
    width: 100%;
    max-width: 1000px;
}

/* Container für Sidebar+Content Clearfix */
div.layout-container {
    overflow: hidden;
}

/* ===== TYPOGRAFIE ===== */
h1, h2, h3 {
    color: #4a7c2f;
    margin-bottom: 8px;
    line-height: 1.3;
}

p {
    margin-bottom: 10px;
    line-height: 1.6;
}

a {
    color: #4a7c2f;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Rand um verlinkte Bilder entfernen */
a img, ul.side-nav li a img {
    border: none;
    outline: none;
}

/* ===== TOP NAVIGATION ===== */
ul.top-nav {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0;
    margin: 0;
    background-color: rgba(0,0,0,0.1);
}

ul.top-nav li a {
    display: block;
    padding: 10px 14px;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.2s;
}

ul.top-nav li a:hover,
ul.top-nav li.active a {
    background-color: rgba(0,0,0,0.4);
}

/* ===== SIDE NAVIGATION ===== */
ul.side-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 250px;
    float: left; /* Sidebar links positionieren */
}

ul.side-nav li {
    border-bottom: 1px solid #ccc;
}

ul.side-nav li a {
    display: block;
    text-decoration: none;
    color: #fff;
    background-color: #4a7c2f;
    font-weight: bold;
    font-size: 13px;
    padding: 12px 10px;
    transition: background 0.2s;
}

ul.side-nav li a:hover {
    background-color: #3a6020;
}

ul.side-nav li.active a {
    background-color: #2d4a18;
}

/* Untermenü */
ul.sub-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #e6e6e6;
    clear: both;
}

ul.sub-nav li {
    border-bottom: 1px solid #ccc;
}

ul.sub-nav li a {
    display: block;
    padding: 7px 10px 7px 20px;
    color: #ffffff;
    text-decoration: none;
    font-size: 17px;
    font-weight: bold;
    background: #f0f0f0;
}

ul.sub-nav li a:hover,
ul.sub-nav li.active a,
ul.sub-nav li.current a {
    background: #ddd;
    color: #2d4a18;
}

/* =======================================================
   TYPO3 TEXT & MEDIEN (CType textpic) - KORREKTUR
   ======================================================= */

/* BASIS: Flexbox aktivieren für alle Text&Medien Elemente */
/* Wichtig: Wir setzen dies sehr stark, um interne Typo3 Styles zu überschreiben */
body div.csc-textpic,
body div.ce-textpic {
    display: flex !important;
    align-items: flex-start !important; /* Start-aligned statt center, damit Texte fließend bleiben */
    gap: 25px !important;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 20px;
}

/* --- FALL 1: BILD LINKS ODER RECHTS (Nebeneinander 50/50) --- */

/* 
   WICHTIG: Spezifität erhöhen durch Body + Container Wrapper.
   Falls TYPO3 die Klasse anders setzt (z.B. auf einem Parent), 
   muss man eventuell den Namen anpassen. 
*/

/* Regel für CE-LEFT (Bild links, Text rechts) */
body div.csc-textpic.ce-left,
body div.ce-textpic.ce-left,
body div.csc-textpic .ce-left, /* Fallback falls Klasse auf Child liegt */
body div.ce-textpic .ce-left {
    flex-direction: row !important;
    align-items: center  !important;
    flex-wrap: nowrap !important; /* Verhindert Umbruch auf Desktop */
}

/* Regel für CE-RIGHT (Text links, Bild rechts) */
body div.csc-textpic.ce-right,
body div.ce-textpic.ce-right,
body div.csc-textpic .ce-right,
body div.ce-textpic .ce-right {
    flex-direction: row-reverse !important; /* Text zuerst, Bild dann rechts */
    align-items: center  !important;
    flex-wrap: nowrap !important;
}

/* --- Breitenaufteilung für NEBENEINANDER --- */
/* Galerie (Bildbereich) bei Links/Rechts -> EXAKT 50% minus halbes Gap */
body div.csc-textpic.ce-left .ce-gallery,
body div.csc-textpic.ce-right .ce-gallery,
body div.ce-textpic.ce-left .ce-gallery,
body div.ce-textpic.ce-right .ce-gallery,
body div.csc-textpic .ce-left .ce-gallery,
body div.csc-textpic .ce-right .ce-gallery,
body div.ce-textpic .ce-left .ce-gallery,
body div.ce-textpic .ce-right .ce-gallery {
    float: none !important;
    margin: 0 !important;
    /* Gap ist 25px, also 12.5px pro Seite abziehen */
    flex: 0 0 calc(50% - 12.5px) !important;
    max-width: calc(50% - 12.5px) !important;
    min-width: 0 !important; /* Verhindert Overflows */
    order: 1 !important; /* Standard: Bild zuerst (wird bei ce-right durch reverse gedreht) */
}

/* Text-Bereich bei Links/Rechts -> EXAKT 50% minus halbes Gap */
body div.csc-textpic.ce-left .ce-bodytext,
body div.csc-textpic.ce-right .ce-bodytext,
body div.ce-textpic.ce-left .ce-bodytext,
body div.ce-textpic.ce-right .ce-bodytext,
body div.csc-textpic .ce-left .ce-bodytext,
body div.csc-textpic .ce-right .ce-bodytext,
body div.ce-textpic .ce-left .ce-bodytext,
body div.csc-textpic .ce-right .ce-bodytext {
    float: none !important;
    overflow: visible !important;
    flex: 0 0 calc(50% - 12.5px) !important;
    max-width: calc(50% - 12.5px) !important;
    min-width: 0 !important;
    width: 100% !important;
    order: 2 !important; /* Text kommt nach dem Bild */
}

/* Spezialfall: Wenn .ce-right genutzt wird, tauschen wir die Order nicht über CSS,
   sondern nutzen flex-direction: row-reverse im Parent. 
   Falls du manuelle Order brauchst:
   body div.csc-textpic.ce-right .ce-gallery { order: 2; }
   body div.csc-textpic.ce-right .ce-bodytext { order: 1; }
   Aber row-reverse ist sauberer.
*/

/* --- FALL 2: OBEN MITTIG / OBEN / UNTEN (100% Bild über Text) --- */
/* Nur gültig wenn KEINE .ce-left oder .ce-right Klasse vorhanden ist */
body div.csc-textpic:not(.ce-left):not(.ce-right):not(.ce-top):not(.ce-bottom),
body div.ce-textpic:not(.ce-left):not(.ce-right):not(.ce-top):not(.ce-bottom) {
    flex-direction: column !important;
    align-items: stretch !important;
}

/* Bild bei Oben -> VOLLBREITE 100% */
body div.csc-textpic:not(.ce-left):not(.ce-right) .ce-gallery,
body div.ce-textpic:not(.ce-left):not(.ce-right) .ce-gallery {
    float: none !important;
    margin: 0 !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    order: 1 !important;
}

/* Text bei Oben -> Auch volle Breite darunter */
body div.csc-textpic:not(.ce-left):not(.ce-right) .ce-bodytext,
body div.ce-textpic:not(.ce-left):not(.ce-right) .ce-bodytext {
    float: none !important;
    overflow: visible !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    order: 2 !important;
}

/* Bilder skalieren innerhalb ihrer Container */
body div.csc-textpic .ce-gallery img,
body div.ce-textpic .ce-gallery img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    width: 100%;
}

/* =======================================================
   RESPONSIVE DESIGN (Mobile < 900px)
   Alle Layouts werden untereinander angeordnet
   ======================================================= */

@media (max-width: 800px) {
    /* Sidebar auf Mobile anpassen */
    ul.side-nav {
        width: 100%;
        float: none;
        margin-bottom: 20px;
    }
    
    div.layout-container {
        overflow: visible;
    }

    /* Alle Text&Media Elemente: Untereinander */
    body div.csc-textpic,
    body div.ce-textpic {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    /* Bild und Text nehmen volle Breite auf Mobile */
    body div.csc-textpic .ce-gallery,
    body div.csc-textpic .ce-bodytext,
    body div.ce-textpic .ce-gallery,
    body div.ce-textpic .ce-bodytext {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: auto !important;
        order: auto !important; /* Order reset für Mobile */
    }
}

/* Footer-Stile */
footer {
    margin-top: 40px;
    padding: 20px;
    background: #4a7c2f;
    color: #fff;
    clear: both;
}

footer p {
    margin-bottom: 0;
}
/* Schriftart global erzwingen */
* {
    font-family: 'Comic Sans MS', 'Comic Sans', 'Chalkboard SE', 'Bradley Hand', cursive !important;
}