/* ==============================================
   Sailer Schule Barbing – Theme
   ============================================== */

/* --- Design Tokens --- */
:root {
    /* Brand */
    --color-red:    #c8232a;
    --color-blue:   #1b4d9e;
    --color-gold:   #f0c000;

    /* Light Mode */
    --color-bg:           #fafaf8;
    --color-bg-subtle:    #f2f2ee;
    --color-surface:      #ffffff;
    --color-text:         #1a1a2e;
    --color-heading:      #1e2d5a;
    --color-text-muted:   #555568;
    --color-border:       #dde1ea;
    --color-header-bg:    #ffffff;
    --color-footer-bg:    color-mix(in hsl, hsl(217, 71%, 36%) 75%, black);
    --color-footer-text:  #e8e8f2;
    --color-link:         var(--color-blue);
    --color-link-hover:   var(--color-red);

    /* Layout */
    --width-content:  1200px;
    --pad-inline:     clamp(1rem, 4vw, 2rem);
    --pad-section:    clamp(3rem, 6vh, 5.5rem);
    --header-height:       116px;
    --radius:         12px;
    --radius-lg:      20px;
    --radius-full:    9999px;
    --shadow-sm:      0 1px 3px rgba(0 0 0 / .04), 0 2px 4px rgba(0 0 0 / .06);
    --shadow-md:      0 4px 8px rgba(0 0 0 / .05), 0 12px 24px rgba(0 0 0 / .08);
    --shadow-lg:      0 10px 20px rgba(0 0 0 / .06), 0 24px 48px rgba(0 0 0 / .10);
    --nav-breakpoint: 900px;

    /* Typography */
    --font:         system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-heading: 'Poppins', system-ui, sans-serif;
    --text-base:    1.0625rem;
    --leading:      1.72;
}

/* Dark Mode – automatisch via OS */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="high-contrast"]) {
        --color-bg:          #111118;
        --color-bg-subtle:   #1a1a24;
        --color-surface:     #1e1e2c;
        --color-text:        #e8e8f2;
        --color-heading:     #c8d4f0;
        --color-text-muted:  #9c9cb4;
        --color-border:      #2a2a3c;
        --color-header-bg:   #14141e;
        --color-footer-bg:   #0c0c14;
        --color-footer-text: #e8e8f2;
        --color-link:        #6ea8fe;
        --color-link-hover:  #ff8080;
    }                                                               
}

/* Dark Mode – manuell per Toggle */
[data-theme="dark"] {
    --color-bg:          #111118;
    --color-bg-subtle:   #1a1a24;
    --color-surface:     #1e1e2c;
    --color-text:        #e8e8f2;
    --color-heading:     #c8d4f0;
    --color-text-muted:  #9c9cb4;
    --color-border:      #2a2a3c;
    --color-header-bg:   #14141e;
    --color-footer-bg:   #0c0c14;
    --color-footer-text: #e8e8f2;
    --color-link:        #6ea8fe;
    --color-link-hover:  #ff8080;
}

/* High-Contrast – automatisch via OS */
@media (prefers-contrast: more) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --color-bg:          #ffffff;
        --color-bg-subtle:   #f0f0f0;
        --color-surface:     #ffffff;
        --color-text:        #000000;
        --color-heading:     #000000;
        --color-text-muted:  #000000;
        --color-border:      #000000;
        --color-header-bg:   #ffffff;
        --color-footer-bg:   #000000;
        --color-footer-text: #ffffff;
        --color-link:        #000000;
        --color-link-hover:  #000000;
        --color-red:         #000000;
        --color-blue:        #000000;
        --color-gold:        #000000;
        --shadow-sm:         none;
        --shadow-md:         none;
        --shadow-lg:         none;
    }
}

/* High-Contrast – manuell per Toggle */
[data-theme="high-contrast"] {
    color-scheme: light;
    --color-bg:          #ffffff;
    --color-bg-subtle:   #f0f0f0;
    --color-surface:     #ffffff;
    --color-text:        #000000;
    --color-heading:     #000000;
    --color-text-muted:  #000000;
    --color-border:      #000000;
    --color-header-bg:   #ffffff;
    --color-footer-bg:   #000000;
    --color-footer-text: #ffffff;
    --color-link:        #000000;
    --color-link-hover:  #000000;
    --color-red:         #000000;
    --color-blue:        #000000;
    --color-gold:        #000000;
    --shadow-sm:         none;
    --shadow-md:         none;
    --shadow-lg:         none;
}

/* High-Contrast: Logo in Graustufen */
[data-theme="high-contrast"] #logo img { filter: grayscale(1); }
@media (prefers-contrast: more) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) #logo img { filter: grayscale(1); }
}

/* High-Contrast: Footer-Trennlinie weiß (gold=schwarz würde auf schwarzem Footer verschwinden) */
[data-theme="high-contrast"] body > footer { border-top-color: #ffffff; }
@media (prefers-contrast: more) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) body > footer { border-top-color: #ffffff; }
}

/* High-Contrast: Links schwarz + unterstrichen statt farbig */
[data-theme="high-contrast"] a { text-decoration: underline; }
@media (prefers-contrast: more) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) a { text-decoration: underline; }
}

/* High-Contrast: SVG-Icons auf Schwarz/Blau – manuell */
[data-theme="high-contrast"] .handorgel__header__button::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}
[data-theme="high-contrast"] .handorgel__header__button[aria-expanded="true"] {
    color: var(--color-link);
    &::after {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230000cc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    }
}
[data-theme="high-contrast"] .check.content-list li::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230000cc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
}

/* High-Contrast: SVG-Icons – automatisch via OS */
@media (prefers-contrast: more) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        .handorgel__header__button::after {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
        }
        .handorgel__header__button[aria-expanded="true"] {
            color: #0000cc;
            &::after {
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230000cc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
            }
        }
        .check.content-list li::before {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230000cc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
        }
    }
}

/* High-Contrast: Alert-Banner (schwarz auf gelb) */
[data-theme="high-contrast"] .alert-banner {
    background: #ffdd00;
    color: #000;
    border-bottom: 3px solid #000;
}
[data-theme="high-contrast"] .alert-banner__close:hover {
    background: rgba(0 0 0 / .12);
}
[data-theme="high-contrast"] .alert-banner__close:focus-visible {
    outline-color: #000;
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    color-scheme: light dark;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: var(--leading);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

img, video, svg { display: block; max-width: 100%; }

figcaption {
    font-size: .8rem;
    color: var(--color-text-muted);
    padding-inline: 1rem;
    margin-block: .35rem;
}

#hero figcaption {
    background: var(--color-surface);
    padding: .4rem 1.5rem;
    margin-block: 0;
}

a {
    color: var(--color-link);
    text-underline-offset: .2em;
    text-decoration-skip-ink: auto;

    &:hover { color: var(--color-link-hover); }
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--color-heading);
    line-height: 1.15;
    text-wrap: balance;
    margin-bottom: 1.5rem;
}

h1 {
    padding-bottom: .6rem;
    border: none;
    background: linear-gradient(to right, var(--color-red), transparent) bottom / 100% 3px no-repeat;
}

/* --- Skip Link --- */
/* --- Skip-Link (Contao: class="invisible skip-link") --- */
/* Spezifität hoch genug um Nav-Linkfarben zu überschreiben */
:is(nav, header, body) a.skip-link:focus,
:is(nav, header, body) a.skip-link:focus-visible {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: auto;
    height: auto;
    padding: .6rem 2rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: nowrap;
    background: var(--color-blue) !important;
    color: #fff !important;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    box-shadow: var(--shadow-md);
    outline: 3px solid #fff;
    outline-offset: -5px;
}

/* --- Globaler Focus-Ring für Links und Buttons --- */
a:focus-visible,
button:focus-visible {
    outline: 2px dashed currentColor;
    outline-offset: 3px;
    border-radius: 2px;
}

/* Bild-Links in figure: Ring auf figure, nicht auf a/img
   (a:focus-visible outline würde von overflow:hidden am figure geclippt) */
figure a:focus-visible {
    outline: none;
}
figure:has(a:focus-visible) {
    outline: 2px dashed var(--color-blue);
    outline-offset: 3px;
}

/* Level_2-Dropdown: Outline ohne Offset (kein visuelles Aufreißen im engen Container) */
body.nav-is-desktop .navigation-main .level_2 a:focus-visible {
    outline-offset: -2px;
    border-radius: 0;
}

/* --- .inside wrapper --- */
.inside {
    max-width: var(--width-content);
    margin-inline: auto;
    padding-inline: var(--pad-inline);
}

/* --- Header --- */
body > header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    height: var(--header-height);

    & .inside {
        height: 100%;
        display: flex;
        align-items: center;
        gap: 1rem;
    }
}

/* Logo auf Header-Höhe beschränken */
#logo {
    flex-shrink: 0;
    line-height: 0;

    & a { display: block; }
    & img {
        height: calc(var(--header-height) - 12px);
        width: auto;
        max-width: none;
    }
}

/* Logo im Dark Mode: weiße Pille auf dem <a>-Element – kein Layout-Shift */
[data-theme="dark"] #logo a {
    background: rgba(255 255 255 / .9);
    border-radius: var(--radius);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="high-contrast"]) #logo a {
        background: rgba(255 255 255 / .9);
        border-radius: var(--radius);
    }
}

/* --- Navigation (Accessible Nav Module) --- */

/* Wrapper: schiebt Nav nach rechts */
.nav-wrapper {
    margin-left: auto;
    display: flex;
    align-items: center;
}

/* --- Burger-Button --- */
.nav-burger {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    z-index: 7;
}

.nav-burger__inner {
    height: 44px;
    width: 44px;
    position: relative;
}

.nav-burger .icon-line,
.nav-burger .icon-line::before,
.nav-burger .icon-line::after {
    background: var(--color-text);
    border-radius: 2px;
    height: 2px;
    left: 50%;
    position: absolute;
    width: 26px;
    transform: translateX(-50%);
    transition: transform .2s ease-in-out, top .2s ease-in-out, bottom .2s ease-in-out, background .2s;
}

.nav-burger .icon-line           { top: 50%; transform: translate(-50%, -50%); }
.nav-burger .icon-line::before   { content: ''; top: -8px; }
.nav-burger .icon-line::after    { content: ''; top:  8px; }

.nav-burger.is-active .icon-line            { background: transparent; }
.nav-burger.is-active .icon-line::before    { top: 0; transform: translateX(-50%) rotate(45deg); }
.nav-burger.is-active .icon-line::after     { top: 0; transform: translateX(-50%) rotate(-45deg); }

/* --- Mobile (< 900px) --- */
body.nav-is-mobile .nav-burger { display: flex; }

body.nav-is-mobile .navigation-main {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    padding: calc(var(--header-height) + 1.5rem) var(--pad-inline) 2rem;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s;
    z-index: 6;
}

body.navigation-open .navigation-main {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.nav-is-mobile .navigation-main ul {
    display: flex;
    flex-direction: column;
    list-style: none;
    margin: 0;
    padding: 0;
}

body.nav-is-mobile .navigation-main li {
    position: relative;
    border-bottom: 1px solid var(--color-border);
}

body.nav-is-mobile .navigation-main li:last-child { border-bottom: none; }

body.nav-is-mobile .navigation-main a,
body.nav-is-mobile .navigation-main strong {
    display: inline-block;
    width: calc(100% - 44px);
    padding: .75rem .5rem;
    color: var(--color-text);
    font-size: 1.05rem;
    text-decoration: none;
}

body.nav-is-mobile .navigation-main .active > a,
body.nav-is-mobile .navigation-main .active > strong { color: var(--color-red); font-weight: 700; }

body.nav-is-mobile .navigation-main .level_2 { display: none; padding-left: 1rem; }
body.nav-is-mobile .navigation-main li.nav-expanded > .level_2 { display: flex; }

/* --- Desktop (≥ 900px) --- */
body.nav-is-desktop .nav-burger { display: none; }

body.nav-is-desktop .navigation-main {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.nav-is-desktop .navigation-main ul {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

body.nav-is-desktop .navigation-main .level_1 { align-items: center; }

body.nav-is-desktop .navigation-main .level_1 > li {
    padding: 0;
    position: relative;
}

body.nav-is-desktop .navigation-main .level_1 > li.submenu { padding-right: 20px; }

body.nav-is-desktop .navigation-main a,
body.nav-is-desktop .navigation-main strong {
    display: block;
    padding: .35rem .5rem;
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}

body.nav-is-desktop .navigation-main a:hover,
body.nav-is-desktop .navigation-main a.trail {
    background: var(--color-bg-subtle);
    color: var(--color-red);
}

body.nav-is-desktop .navigation-main .active > a,
body.nav-is-desktop .navigation-main .active > strong {
    color: var(--color-red);
    font-weight: 700;
}

/* Desktop Dropdown */
body.nav-is-desktop .navigation-main .level_2 {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    z-index: 10;
}

/* Öffnen per Maus (JS) ODER per Tastatur (:focus-within) */
body.nav-is-desktop .navigation-main li.nav-expanded > .level_2,
body.nav-is-desktop .navigation-main li.submenu:focus-within > .level_2 { display: flex; }

body.nav-is-desktop .navigation-main .level_2 a,
body.nav-is-desktop .navigation-main .level_2 strong {
    font-size: .875rem;
    padding: .6rem 1rem;
    border-radius: 0;
}

body.nav-is-desktop .navigation-main .level_2 li:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

/* Submenu-Toggle-Button */
.btn-toggle-submenu {
    all: unset;
    cursor: pointer;
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.nav-is-mobile .btn-toggle-submenu {
    width: 44px;
    height: 44px;
}

.btn-toggle-submenu::after {
    content: '';
    border: 5px solid transparent;
    border-top-color: var(--color-text-muted);
    display: block;
    margin-top: 4px;
    transition: transform .2s;
}

li.nav-expanded > .btn-toggle-submenu::after {
    transform: rotate(180deg);
    margin-top: -4px;
}

.btn-toggle-submenu:focus-visible {
    outline: 2px dashed var(--color-text-muted);
    outline-offset: 2px;
    border-radius: 2px;
}

/* --- Such-Button in der Hauptnavigation --- */

/* Desktop: Text verstecken, Icon-Button zeigen */
body.nav-is-desktop .navigation-main .level_1 > li.search > a,
body.nav-is-desktop .navigation-main .level_1 > li.search > strong {
    font-size: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-full);
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    transition: background .15s, border-color .15s;

    &::before {
        content: '';
        display: block;
        width: 18px;
        height: 18px;
        background-color: var(--color-text-muted);
        mask-image: url('/files/theme/icons/search.svg');
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
        flex-shrink: 0;
    }
}

body.nav-is-desktop .navigation-main .level_1 > li.search > a:hover {
    background: var(--color-bg-subtle);
    border-color: var(--color-text-muted);
    color: transparent;

    &::before { background-color: var(--color-text); }
}

/* Aktiver Zustand (strong) */
body.nav-is-desktop .navigation-main .level_1 > li.search > strong {
    background: var(--color-bg-subtle);
    border-color: var(--color-red);

    &::before { background-color: var(--color-red); }
}

/* Mobile: Label sichtbar lassen, Icon voranstellen */
body.nav-is-mobile .navigation-main .level_1 > li.search > a,
body.nav-is-mobile .navigation-main .level_1 > li.search > strong {
    display: inline-flex;
    align-items: center;
    gap: .5rem;

    &::before {
        content: '';
        display: block;
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        background-color: var(--color-text-muted);
        mask-image: url('/files/theme/icons/search.svg');
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
    }
}

/* --- Hero --- */
#hero {
    background-color: var(--color-bg-subtle);
    background-image: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 12px,
        rgba(0 0 0 / .01) 12px,
        rgba(0 0 0 / .01) 13px
    );

    & .mod_article {
        max-width: var(--width-content);
        margin-inline: auto;
        padding-inline: var(--pad-inline);
        padding-block: clamp(3rem, 7vh, 5.5rem);
    }

    & .content-element-group {
        align-items: center;
        gap: clamp(2rem, 5vw, 4rem);
    }

    & .content-text {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 1.25rem;
    }

    & h1 {
        font-size: clamp(1.25rem, 2vw, 3rem);
        line-height: 1.2;
    }

    & .rte p {
        font-size: 1.1rem;
        color: var(--color-text-muted);
        max-width: 52ch;
    }

    & .content-image {
        display: flex;

        & figure {
            flex: 1;
            margin: 0;
            border-radius: var(--radius-lg);
            overflow: hidden;
            box-shadow: var(--shadow-lg);
        }

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

/* --- Grid-System --- */
.cols-2,
.cols-2-1,
.cols-1-2,
.cols-3,
.cols-4 {
    display: grid;
    gap: 1.25rem;
}

.cols-2   { grid-template-columns: 1fr 1fr; }
.cols-2-1 { grid-template-columns: 2fr 1fr; }
.cols-1-2 { grid-template-columns: 1fr 2fr; }
.cols-3   { grid-template-columns: repeat(3, 1fr); }
.cols-4   { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .cols-3,
    .cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .cols-2,
    .cols-2-1,
    .cols-1-2,
    .cols-3,
    .cols-4 { grid-template-columns: 1fr; }
}

/* --- Card-Optik für .tiles-Kinder --- */
.tiles > * {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .25s, transform .25s;

    &:hover {
        box-shadow: var(--shadow-lg);
        transform: translateY(-5px);
    }
}

/* --- Icon-Kachel: Link füllt gesamte Kachel --- */
.icon_btn a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    padding: 2rem 1.25rem;
    height: 100%;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;

    &::before {
        content: '';
        display: block;
        width: 2.5rem;
        height: 2.5rem;
        background-color: var(--color-red);
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
        margin-bottom: .75rem;
        flex-shrink: 0;
    }

    & i { display: none; }

    &:hover { color: var(--color-red); }
}

/* --- Icon-Zuordnung per Klasse --- */
.btn_heart-broken a::before { mask-image: url('/files/theme/icons/heart-broken.svg'); }
.btn_book         a::before { mask-image: url('/files/theme/icons/book.svg'); }
.btn_information  a::before { mask-image: url('/files/theme/icons/info-circle.svg'); }
.btn_disabled     a::before { mask-image: url('/files/theme/icons/wheelchair.svg'); }
.btn_music        a::before { mask-image: url('/files/theme/icons/music.svg'); }
.btn_graduation   a::before { mask-image: url('/files/theme/icons/school.svg'); }
.btn_math         a::before { mask-image: url('/files/theme/icons/math.svg'); }
.btn_ball         a::before { mask-image: url('/files/theme/icons/ball.svg'); }

/* --- Element-Spacing --- */
#main .mod_article > [class*="content-"],
#main .mod_article > .ce_form {
    margin-bottom: 1.5rem;
}

/* Accordion-Ketten: kein Abstand zwischen Items, nur nach dem letzten */
#main .mod_article > .ce_accordion {
    margin-bottom: 0;
}

#main .mod_article > .ce_accordion:not(:has(+ .ce_accordion)) {
    margin-bottom: 1.5rem;
}

/* --- Container (Wrapper für main + optionale rechte Spalte) --- */
#container {
    flex: 1;
}

/* 2-Spalten-Grid, sobald #right im DOM ist */
#container:has(#right) {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 2.5rem;
    align-items: start;
    width: 100%;
    max-width: var(--width-content);
    margin-inline: auto;
    padding-inline: var(--pad-inline);
}

/* Kinder im Grid: kein overflow durch zu breiten Inhalt */
#container:has(#right) > #main,
#container:has(#right) > #right {
    min-width: 0;
}

/* .inside der Kinder nicht erneut zentrieren – #container übernimmt das */
#container:has(#right) > #main > .inside,
#container:has(#right) > #right > .inside {
    max-width: none;
    margin-inline: 0;
    padding-inline: 0;
}

/* --- Main --- */
#main {
    flex: 1;
    padding-top: var(--pad-section);

    & .mod_article {
        margin-bottom: var(--pad-section);
    }
}

/* --- Rechte Spalte --- */
#right {
    padding-top: var(--pad-section);

    & .mod_article {
        margin-bottom: 1.5rem;
    }
}

/* --- Sidebar-Navigation --- */

/* Navigationsmodul als Karte */
#right .mod_navigation {
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* h2 direkt in nav: gleiche Optik wie .mod_article.card, .mod_eventlist etc. */
#right .mod_navigation > h2 {
    margin: 0;
    padding: 1rem 1.25rem;
    background: var(--color-blue);
    color: #fff;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    background-image: none;
}

/* Listen-Reset */
#right .mod_navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--color-surface);
}

/* Trennlinie zwischen Items */
#right .mod_navigation li {
    border-bottom: 1px solid var(--color-border);
}

#right .mod_navigation li:last-child {
    border-bottom: none;
}

/* Links und aktives Element (skip-Link ist .invisible – nicht betroffen) */
#right .mod_navigation ul a,
#right .mod_navigation ul strong {
    display: block;
    padding: .6rem 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 400;
    transition: background .15s, color .15s;
}

#right .mod_navigation ul a:hover {
    background: var(--color-bg-subtle);
    color: var(--color-red);
}

/* Trail (Elternseiten der aktiven Seite) */
#right .mod_navigation .trail > a {
    color: var(--color-blue);
}

/* Aktive Seite: roter Akzent-Streifen links */
#right .mod_navigation .active > a,
#right .mod_navigation .active > strong {
    font-weight: 600;
    color: var(--color-red);
    background: color-mix(in srgb, var(--color-red) 6%, transparent);
    border-left: 3px solid var(--color-red);
    padding-left: calc(1.25rem - 3px);
}

/* Ebene 3+: einrücken */
#right .mod_navigation ul ul a,
#right .mod_navigation ul ul strong {
    padding-left: 1.75rem;
    font-size: .825rem;
    color: var(--color-text-muted);
}

#right .mod_navigation ul ul .active > a,
#right .mod_navigation ul ul .active > strong {
    padding-left: calc(1.75rem - 3px);
}

/* Desktop: Sidebar klebt oben beim Scrollen */
@media (min-width: 901px) {
    #container:has(#right) > #right {
        position: sticky;
        top: calc(var(--header-height) + 1.5rem);
        max-height: calc(100dvh - var(--header-height) - 3rem);
        overflow-y: auto;
    }
}

/* Mobile: untereinander, Trennlinie */
@media (max-width: 900px) {
    #container:has(#right) {
        grid-template-columns: 1fr;
    }

    #container:has(#right) > #right {
        border-top: 1px solid var(--color-border);
        padding-top: 2rem;
    }
}

/* --- Back-to-Top --- */
.to_top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 50;
}

.to_top a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-red);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    font-size: 0;
    transition: background .15s, transform .2s, box-shadow .2s;

    &::before {
        content: '';
        display: block;
        width: 10px;
        height: 10px;
        border-top: 2.5px solid #fff;
        border-right: 2.5px solid #fff;
        transform: translateY(2px) rotate(-45deg);
        flex-shrink: 0;
    }

    &:hover {
        background: color-mix(in srgb, var(--color-red) 85%, black);
        transform: translateY(-3px);
        box-shadow: var(--shadow-lg);
        color: transparent;
    }
}

/* --- Footer --- */
body > footer {
    background: var(--color-footer-bg);
    color: var(--color-footer-text);
    padding-block: 2.5rem;
    border-top: 3px solid var(--color-gold);
    font-size: .9rem;

    & a {
        color: var(--color-footer-text);
        opacity: .75;

        &:hover { opacity: 1; color: var(--color-gold); }
    }
}

/* --- Button --- */
/* Gemeinsame Basis für .btn und .content-hyperlink.btn a */
.btn,
.content-hyperlink.btn a {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1.4rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    border: 2px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}

.btn {
    cursor: pointer;

    &--primary {
        background: var(--color-red);
        color: #fff;

        &:hover {
            background: color-mix(in srgb, var(--color-red) 85%, black);
            color: #fff;
        }

        &:focus-visible { outline-color: var(--color-red); }
    }

    &--outline {
        border-color: var(--color-red);
        color: var(--color-red);

        &:hover {
            background: var(--color-red);
            color: #fff;
        }
    }

    &--secondary {
        border-color: var(--color-link);
        color: var(--color-link);

        &:hover {
            background: var(--color-link);
            color: #fff;
        }
    }
}

/* --- content-hyperlink --- */
.content-hyperlink {
    &.text--center { text-align: center; }

    &.btn {
        display: block;
    }

    &.btn a {
        &::after {
            content: '';
            width: 7px;
            height: 7px;
            border-top: 2px solid currentColor;
            border-right: 2px solid currentColor;
            transform: rotate(45deg);
            flex-shrink: 0;
            transition: translate .2s ease;
        }

        &:hover::after { translate: 4px 0; }
    }

    &.btn--primary a {
        background: var(--color-red);
        color: #fff;

        &:hover {
            background: color-mix(in srgb, var(--color-red) 85%, black);
            color: #fff;
        }

        &:focus-visible { outline-color: var(--color-red); }
    }

    &.btn--secondary a {
        border-color: var(--color-link);
        color: var(--color-link);

        &:hover {
            background: var(--color-link);
            color: #fff;
        }
    }
}

/* --- Dark-Mode-Toggle --- */
.btn-theme {
    all: unset;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-bg-subtle);
    color: var(--color-text-muted);
    flex-shrink: 0;
    transition: background .15s, color .15s;

    &:hover {
        background: var(--color-border);
        color: var(--color-text);
    }

    &:focus-visible {
        outline: 2px dashed var(--color-text-muted);
        outline-offset: 3px;
    }
}

.btn-theme .icon-theme {
    display: block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-image: url('/files/theme/icons/moon.svg');
}

.btn-theme .icon-theme--light         { mask-image: url('/files/theme/icons/moon.svg');     }
.btn-theme .icon-theme--dark          { mask-image: url('/files/theme/icons/contrast.svg'); }
.btn-theme .icon-theme--high-contrast { mask-image: url('/files/theme/icons/sun.svg');      }

[data-theme="high-contrast"] .btn-theme:hover {
    background: var(--color-bg-subtle);
    color: var(--color-text);
    outline: 2px solid var(--color-text);
    outline-offset: 1px;
}

/* --- Contao Legacy-Akkordeon --- */
.ce_accordion {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: .5rem;

    & .toggler {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        font-weight: 600;
        font-size: .95rem;
        font-family: var(--font-heading);
        background: var(--color-surface);
        cursor: pointer;
        transition: background .15s;

        &::after {
            content: '';
            border: 5px solid transparent;
            border-top-color: var(--color-text-muted);
            transition: transform .2s;
            margin-top: 3px;
            flex-shrink: 0;
        }

        &:hover { background: var(--color-bg-subtle); }

        &.active::after {
            transform: rotate(180deg);
            margin-top: -3px;
        }
    }

    & > .accordion {
        all: unset;
        display: none;
        padding: 0 1.25rem 1rem;
        background: var(--color-surface);
    }

    & .toggler.active + .accordion {
        display: block;
    }
}

/* --- Akkordeon --- */
.accordion {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-block: .5rem;
}

.accordion__trigger {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: .95rem;
    font-family: var(--font-heading);
    background: var(--color-surface);
    transition: background .15s;

    &:hover { background: var(--color-bg-subtle); }

    &::after {
        content: '';
        border: 5px solid transparent;
        border-top-color: var(--color-text-muted);
        transition: transform .2s;
        margin-top: 3px;
        flex-shrink: 0;
    }
}

.accordion--open .accordion__trigger::after {
    transform: rotate(180deg);
    margin-top: -3px;
}

.accordion__content {
    padding: 0 1.25rem 1rem;
    background: var(--color-surface);
}

/* --- Handorgel Akkordeon --- */
.content-accordion {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.content-accordion > h2 {
    margin: 0;
    padding: 1rem 1.5rem;
    background: var(--color-blue);
    color: #fff;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--color-border);
}

.content-accordion .handorgel__header {
    margin: 0;
}

.content-accordion .handorgel__content + .handorgel__header,
.content-accordion .handorgel__header + .handorgel__header {
    border-top: 1px solid var(--color-border);
}

.handorgel__header__button {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: 1rem 1.25rem 1rem 1.5rem;
    font-weight: 600;
    font-size: .95rem;
    font-family: var(--font-heading);
    background: var(--color-surface);
    border-left: 3px solid transparent;
    transition: background .15s, border-left-color .2s;

    &::after {
        content: '';
        display: block;
        width: 1.1rem;
        height: 1.1rem;
        flex-shrink: 0;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23555568' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") center/contain no-repeat;
        transition: transform .25s ease;
    }

    &:hover { background: var(--color-bg-subtle); }

    &:focus-visible {
        outline: 2px dashed var(--color-blue);
        outline-offset: -4px;
    }

    &[aria-expanded="true"] {
        border-left-color: var(--color-gold);
        color: var(--color-blue);

        &::after {
            transform: rotate(180deg);
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%231b4d9e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
        }
    }
}

.handorgel__content {
    overflow: hidden;
    background: var(--color-surface);
}

/* Geschlossene Panels: Inhalte aus Tab-Order nehmen */
.handorgel__content:not(.handorgel__content--open):not(.handorgel__content--opened) {
    visibility: hidden;
}

.handorgel__content__inner {
    padding: .25rem 1.5rem 1.25rem;
}


/* Dark Mode Icons – manuell */
[data-theme="dark"] .check.content-list li::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236ea8fe' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
}
[data-theme="dark"] .handorgel__header__button::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239c9cb4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}
[data-theme="dark"] .handorgel__header__button[aria-expanded="true"] {
    color: var(--color-link);
    &::after {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236ea8fe' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    }
}

/* Dark Mode Icons – automatisch via OS */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="high-contrast"]) {
        .check.content-list li::before {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236ea8fe' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
        }
        .handorgel__header__button::after {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239c9cb4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
        }
        .handorgel__header__button[aria-expanded="true"] {
            color: var(--color-link);
            &::after {
                background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236ea8fe' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
            }
        }
    }
}

/* --- Card-Scroll-Animation --- */
.card-animate {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .5s ease, transform .5s ease;
}

.card-animate.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.card-animate:nth-child(2) { transition-delay: .08s; }
.card-animate:nth-child(3) { transition-delay: .16s; }
.card-animate:nth-child(4) { transition-delay: .24s; }

/* --- Listen (rte + content-list) --- */
.rte ul,
.ce_accordion .accordion ul,
.content-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.rte ul li,
.ce_accordion .accordion ul li,
.content-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    line-height: 1.5;
}

/* Flache Selektoren – kein :is()-Spezifitäts-Boost durch CSS-Nesting */
.rte ul li::before,
.ce_accordion .accordion ul li::before,
.content-list li::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--color-blue);
    border-radius: 50%;
    flex-shrink: 0;
}

.rte ul ul,
.ce_accordion .accordion ul ul {
    margin-top: .5rem;
    padding-left: 1.25rem;
}

.rte ul ul li::before,
.ce_accordion .accordion ul ul li::before {
    width: 8px;
    height: 8px;
    border: 2px solid var(--color-blue);
    background: transparent;
    border-radius: 50%;
}

/* --- content-list Variante: Check-Haken --- */
.check.content-list li::before {
    width: 1rem;
    height: 1rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%231b4d9e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E") center/contain no-repeat;
    border-radius: 0;
    transform: none;
    margin-bottom: 0;
}

/* Alpine.js: verhindert FOUC bei x-cloak */
[x-cloak] { display: none !important; }

/* --- Galerie --- */
.content-gallery > ul {
    display: grid;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.content-gallery--cols-1 > ul { grid-template-columns: 1fr; }
.content-gallery--cols-2 > ul { grid-template-columns: repeat(2, 1fr); }
.content-gallery--cols-3 > ul { grid-template-columns: repeat(3, 1fr); }
.content-gallery--cols-4 > ul { grid-template-columns: repeat(4, 1fr); }
.content-gallery--cols-5 > ul { grid-template-columns: repeat(5, 1fr); }
.content-gallery--cols-6 > ul { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 900px) {
    .content-gallery--cols-3 > ul,
    .content-gallery--cols-4 > ul { grid-template-columns: repeat(2, 1fr); }
    .content-gallery--cols-5 > ul,
    .content-gallery--cols-6 > ul { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 500px) {
    .content-gallery--cols-2 > ul,
    .content-gallery--cols-3 > ul,
    .content-gallery--cols-4 > ul { grid-template-columns: 1fr; }
    .content-gallery--cols-5 > ul,
    .content-gallery--cols-6 > ul { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
    .content-gallery--cols-5 > ul,
    .content-gallery--cols-6 > ul { grid-template-columns: 1fr; }
}

.content-gallery figure {
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius);
}

.content-gallery figure img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.content-gallery figure a:hover img {
    transform: scale(1.04);
}

.content-gallery figcaption {
    font-size: .8rem;
    color: var(--color-text-muted);
    padding: .4rem .25rem 0;
    text-align: center;
}

/* --- Article als Card --- */
.mod_article.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;

    & > .ce_text > h2,
    & > .ce_text > h3 {
        margin-bottom: 0;
        padding: 1rem 1.5rem;
        background: var(--color-blue);
        color: #fff;
        font-size: 1.1rem;
    }

    & > .ce_text > .teaser,
    & > .ce_text > p,
    & > .ce_text > ul,
    & > .ce_text > ol {
        padding: 1.25rem 1.5rem;
    }
}

/* --- Artikel-Cards: Icon im blauen Header passend zur Navigations-Kachel --- */
#inklusion .ce_text h2,
#musikalische-grundschule .ce_text h2,
#partnerschule .ce_text h2,
#quamath .ce_text h2,
#spielen .ce_text h2,
#schulbibliothek .ce_text h2 {
    display: flex;
    align-items: center;
    gap: .6rem;

    &::before {
        content: '';
        flex-shrink: 0;
        width: 1.3rem;
        height: 1.3rem;
        background-color: currentColor;
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
        opacity: .9;
    }
}

#inklusion            .ce_text h2::before { mask-image: url('/files/theme/icons/wheelchair.svg'); }
#musikalische-grundschule .ce_text h2::before { mask-image: url('/files/theme/icons/music.svg'); }
#partnerschule        .ce_text h2::before { mask-image: url('/files/theme/icons/school.svg');    }
#quamath              .ce_text h2::before { mask-image: url('/files/theme/icons/math.svg');      }
#spielen              .ce_text h2::before { mask-image: url('/files/theme/icons/ball.svg');      }
#schulbibliothek      .ce_text h2::before { mask-image: url('/files/theme/icons/book.svg');      }

/* --- Contact-Card --- */
.contact.content-text {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-self: start;

    & h2,
    & h3 {
        order: -1;
        margin-bottom: 0;
        padding: .75rem 1.25rem;
        background: var(--color-blue);
        color: #fff;
        font-size: 1rem;
    }

    & figure {
        margin: 0;

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

    & .rte {
        padding: 1rem 1.25rem;
        flex: 1;
    }
}

/* --- Image-Card --- */
.content-image.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-self: start;

    & h2,
    & h3 {
        order: -1;
        margin-bottom: 0;
        padding: .75rem 1.25rem;
        background: var(--color-blue);
        color: #fff;
        font-size: 1rem;
    }

    & figure {
        margin: 0;

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

    & figcaption {
        padding: .75rem 1.25rem;
        font-size: .8rem;
        color: var(--color-text-muted);
        margin: 0;
    }
}

/* --- Info-Card --- */
.information.content-text {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: color-mix(in srgb, var(--color-blue) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-blue) 30%, transparent);
    border-radius: var(--radius-lg);

    &::before {
        content: '';
        display: block;
        flex-shrink: 0;
        width: 1.4rem;
        height: 1.4rem;
        margin-top: .15rem;
        background-color: var(--color-blue);
        mask-image: url('/files/theme/icons/info-circle.svg');
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
    }

    & .rte p { margin: 0; }

    &:has(> h2),
    &:has(> h3) {
        flex-wrap: wrap;
        padding: 0;
        gap: 0;
        overflow: hidden;

        &::before {
            order: 1;
            margin: 1rem 0 1rem 1.25rem;
        }

        & > h2,
        & > h3 {
            order: 0;
            flex-basis: 100%;
            margin: 0;
            padding: 1rem 1.25rem;
            background: var(--color-blue);
            color: #fff;
            font-size: 1.1rem;
        }

        & .rte {
            order: 2;
            flex: 1;
            padding: 1rem 1.25rem 1rem .75rem;
        }
    }
}

/* --- Media-Text (Bild links/rechts) --- */
.content-text.media {
    display: grid;
    gap: 1.5rem;
    align-items: start;

    & > h2,
    & > h3 {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }

    & figure {
        border-radius: var(--radius);
        overflow: hidden;

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

.content-text.media--right {
    grid-template-columns: 1fr auto;

    & figure { grid-column: 2; grid-row: 2; }
    & .rte   { grid-column: 1; grid-row: 2; }
}

.content-text.media--left {
    grid-template-columns: auto 1fr;

    & figure { grid-column: 1; grid-row: 2; }
    & .rte   { grid-column: 2; grid-row: 2; }
}

@media (max-width: 640px) {
    .content-text.media--right,
    .content-text.media--left {
        grid-template-columns: 1fr;

        & figure,
        & .rte { grid-column: 1; grid-row: auto; }
    }

    .content-text.media--right figure { order: -1; }
}

/* --- Teaser --- */
.teaser .more {
    margin-top: 1.25rem;

    & a {
        font-weight: 600;
        font-size: .95rem;
        color: var(--color-link);
        text-decoration: none;

        &:hover { color: var(--color-link-hover); text-decoration: underline; }
    }
}

/* --- Blockquote --- */
blockquote {
    margin-block: 1.5rem;
    padding: 1rem 1.25rem 1rem 1.5rem;
    border-left: 4px solid var(--color-gold);
    background: var(--color-bg-subtle);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--color-text-muted);

    & p { margin: 0; }
}

/* --- Formulare --- */
.formbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.widget label:not(.checkbox_container label) {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: .35rem;
}

.widget input.text,
.widget textarea,
.widget select {
    width: 100%;
    padding: .6rem .9rem;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    line-height: 1.5;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;

    &:focus {
        outline: none;
        border-color: var(--color-blue);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-blue) 20%, transparent);
    }
}

.widget textarea {
    resize: vertical;
    min-height: 8rem;
}

.widget-checkbox .checkbox_container {
    border: none;
    padding: 0;
    margin: 0;

    & span {
        display: flex;
        align-items: center;
        gap: .5rem;
        font-size: .9rem;
    }

    & input[type="checkbox"] {
        width: 1.1rem;
        height: 1.1rem;
        flex-shrink: 0;
        accent-color: var(--color-blue);
        cursor: pointer;
    }
}

.widget-submit button.submit {
    display: inline-flex;
    align-items: center;
    padding: .65rem 1.4rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .95rem;
    font-family: var(--font);
    text-decoration: none;
    border: 2px solid transparent;
    background: var(--color-red);
    color: #fff;
    cursor: pointer;
    transition: background .15s;

    &:hover {
        background: color-mix(in srgb, var(--color-red) 85%, black);
    }
}

/* --- Downloads --- */
.content-downloads ul {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.content-downloads .download-element {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: background .15s;

    &:last-child { border-bottom: none; }
    &:hover { background: var(--color-bg-subtle); }

    &::before {
        content: '';
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
    }

    &.ext-pdf::before  { background-image: url('/files/theme/icons/pdf.png'); }
    &.ext-doc::before,
    &.ext-docx::before { background-image: url('/files/theme/icons/doc.png'); }
    &.ext-mp3::before  { background-image: url('/files/theme/icons/mp3.png'); }
    &.ext-png::before,
    &.ext-jpg::before,
    &.ext-jpeg::before { background-image: url('/files/theme/icons/png.png'); }

    &.ext-xls::before,
    &.ext-xlsx::before {
        background-color: var(--color-text);
        mask-image: url('/files/theme/icons/file-spreadsheet.svg');
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
    }
    &.ext-ppt::before,
    &.ext-pptx::before {
        background-color: var(--color-text);
        mask-image: url('/files/theme/icons/file-powerpoint.svg');
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
    }
    &.ext-zip::before,
    &.ext-rar::before {
        background-color: var(--color-text);
        mask-image: url('/files/theme/icons/file-zip.svg');
        mask-size: contain;
        mask-repeat: no-repeat;
        mask-position: center;
    }

    & a {
        flex: 1;
        color: var(--color-text);
        text-decoration: none;
        font-size: .95rem;

        &:hover {
            color: var(--color-blue);
            text-decoration: underline;
        }
    }
}

/* --- Lightbox --- */
#lightbox-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    background: transparent;
    border: none;
    padding: 0;
    outline: none;
}

#lightbox-dialog::backdrop {
    background: rgba(0 0 0 / .88);
    backdrop-filter: blur(3px);
}

.lightbox-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 5rem;
    max-width: 100%;
    position: relative;
}

#lightbox-img {
    max-width: min(90vw, 1200px);
    max-height: 78dvh;
    width: auto;
    height: auto;
    border-radius: var(--radius);
    display: block;
    box-shadow: 0 8px 40px rgba(0 0 0 / .6);
    object-fit: contain;
}

#lightbox-caption {
    color: rgba(255 255 255 / .85);
    text-align: center;
    padding: .625rem 1rem 0;
    font-size: .875rem;
    min-height: 1.5rem;
}

.lightbox-btn {
    all: unset;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: rgba(255 255 255 / .12);
    border: 2px solid rgba(255 255 255 / .3);
    border-radius: var(--radius-full);
    color: #fff;
    cursor: pointer;
    transition: background .15s, border-color .15s;

    & svg { width: 22px; height: 22px; flex-shrink: 0; }

    &:hover {
        background: rgba(255 255 255 / .25);
        border-color: rgba(255 255 255 / .6);
    }

    &:focus-visible {
        outline: 3px solid #fff;
        outline-offset: 3px;
    }

    &:disabled {
        opacity: .3;
        cursor: default;
        pointer-events: none;
    }
}

.lightbox-close {
    top: 1rem;
    right: 1rem;
}

.lightbox-prev {
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

#lightbox-dialog[data-single] .lightbox-prev,
#lightbox-dialog[data-single] .lightbox-next { display: none; }

.lightbox-counter {
    position: absolute;
    top: .75rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255 255 255 / .65);
    font-size: .8rem;
    white-space: nowrap;
}

#lightbox-dialog[data-single] .lightbox-counter { display: none; }

.lightbox-figure.is-loading::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255 255 255 / .2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lb-spin .7s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes lb-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

@media (max-width: 600px) {
    .lightbox-figure { padding: 3rem 1rem 1rem; }
    .lightbox-prev { left: .5rem; }
    .lightbox-next { right: .5rem; }
}

/* --- Screenreader only --- */
.invisible {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Galerie-Variante: Logos --- */
.content-gallery.logos > ul {
    gap: 1.25rem;
}

.content-gallery.logos li {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, transform .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    aspect-ratio: 3 / 2;
}

.content-gallery.logos li:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.content-gallery.logos figure {
    overflow: visible;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.content-gallery.logos figure img {
    object-fit: contain;
    width: 100%;
    height: 100%;
    max-height: 80px;
    transition: none;
}

.content-gallery.logos figure a:hover img { transform: none; }

.content-gallery.logos figcaption { display: none; }

/* --- News-Grid --- */
.mod_newslist.news-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.mod_newslist.news-grid > h2,
.mod_newslist.news-grid > h3 {
    grid-column: 1 / -1;
}

.mod_newslist.news-grid .layout_latest {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .25s, transform .25s;

    &:hover {
        box-shadow: var(--shadow-lg);
        transform: translateY(-4px);
    }

    & .image_container {
        float: none;
        margin: 0;
        order: -1;

        & a {
            display: block;
            aspect-ratio: 4 / 3;
            overflow: hidden;
        }

        & img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            transition: transform .4s;
        }
    }

    &:hover .image_container img { transform: scale(1.04); }

    & > h2,
    & > .ce_text,
    & > .more { padding-inline: 1.25rem; }

    & > .info {
        position: relative;
        z-index: 1;
        padding: .4rem 1.25rem;
        color: var(--color-text-muted);
        font-size: .8rem;
    }

    &:has(.image_container) > .info {
        margin-top: -2.2rem;
        background: linear-gradient(transparent, rgba(0 0 0 / .55));
        color: #fff;
    }

    & > .more  { padding-bottom: 1.25rem; margin-top: auto; }

    & h2 {
        font-size: 1.05rem;
        padding-top: .875rem;
        margin-bottom: .75rem;

        & a {
            color: var(--color-heading);
            text-decoration: none;

            &:hover { color: var(--color-red); }
        }
    }

    & .more a {
        font-weight: 600;
        font-size: .85rem;
        color: var(--color-link);
        text-decoration: none;

        &:hover { color: var(--color-link-hover); text-decoration: underline; }
    }
}

/* --- Pagination (gemeinsam für News, Suche, Events …) --- */
.pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    margin-top: 2rem;

    & p {
        color: var(--color-text-muted);
        font-size: .875rem;
    }

    & ul {
        display: flex;
        gap: .375rem;
        list-style: none;
        flex-wrap: wrap;
        justify-content: center;
    }

    & li a,
    & li strong {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 2.25rem;
        height: 2.25rem;
        padding-inline: .5rem;
        border-radius: var(--radius);
        border: 1px solid var(--color-border);
        font-size: .875rem;
        text-decoration: none;
        color: var(--color-text);
        background: var(--color-surface);
        transition: background .15s, border-color .15s;
    }

    & li strong {
        background: var(--color-blue);
        border-color: var(--color-blue);
        color: #fff;
        font-weight: 700;
    }

    & li a:hover {
        background: var(--color-bg-subtle);
        border-color: var(--color-blue);
        color: var(--color-blue);
    }

    & li.next a,
    & li.last a,
    & li.first a,
    & li.previous a {
        font-weight: 600;
        color: var(--color-blue);
    }
}

/* Im News-Grid: Pagination über alle Spalten */
.mod_newslist.news-grid .pagination {
    grid-column: 1 / -1;
    margin-top: 0;
}

@media (max-width: 900px) {
    .mod_newslist.news-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .mod_newslist.news-grid { grid-template-columns: 1fr; }
}

/* --- Event-Liste --- */
.mod_eventlist {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;

    & > h2,
    & > h3 {
        margin: 0;
        padding: 1rem 1.25rem;
        background: var(--color-blue);
        color: #fff;
        font-size: 1.1rem;
    }
}

.mod_eventlist .event {
    display: grid;
    grid-template-columns: 10rem 1fr;
    align-items: center;
    gap: 1rem;
    padding: .875rem 1.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    transition: background .15s;

    &:last-child { border-bottom: none; }
    &:hover { background: var(--color-bg-subtle); }

    & .date {
        font-size: .8rem;
        font-weight: 600;
        color: var(--color-blue);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    & a {
        font-weight: 500;
        color: var(--color-heading);
        text-decoration: none;

        &:hover { color: var(--color-link-hover); }
    }
}

/* Dark Mode: --color-blue wäre zu dunkel auf dunklem Hintergrund */
[data-theme="dark"] .mod_eventlist .event .date {
    color: var(--color-link);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="high-contrast"]) {
        .mod_eventlist .event .date { color: var(--color-link); }
    }
}

/* --- News-Reader / Event-Reader --- */

/* Inhalt auf 800px einengen und zentrieren */
.mod_newsreader .layout_full,
.mod_eventreader .layout_full {
    max-width: 800px;
    margin-inline: auto;
}

/* Zurück-Link: max-width bündig mit dem Artikel */
.mod_newsreader .back,
.mod_eventreader .back {
    max-width: 800px;
    margin-inline: auto;
    margin-top: 2rem;

    & a {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        font-size: .9rem;
        font-weight: 500;
        color: var(--color-text-muted);
        text-decoration: none;
        transition: color .15s;

        &::before {
            content: '';
            width: 8px;
            height: 8px;
            border-bottom: 2px solid currentColor;
            border-left: 2px solid currentColor;
            transform: rotate(45deg);
            flex-shrink: 0;
        }

        &:hover { color: var(--color-link); }
    }
}

/* Meta-Zeile (Datum, Kategorie) */
.mod_newsreader .info,
.mod_eventreader .info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1.75rem;
    color: var(--color-text-muted);
    font-size: .875rem;
}

/* Datum als Chip */
.mod_newsreader .info time,
.mod_eventreader .info time {
    display: inline-flex;
    align-items: center;
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: .2rem .85rem;
    font-weight: 500;
    font-size: .875rem;
    color: var(--color-heading);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Bild-Container im News-Reader */
.mod_newsreader .image_container {
    margin-bottom: 1.75rem;
    border-radius: var(--radius-lg);
    overflow: hidden;

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

    & figcaption {
        padding: .4rem 1rem;
    }
}

/* --- Suchseite --- */

/* Formular: Input + Button nebeneinander */
.mod_search .formbody {
    flex-direction: row;
    gap: .5rem;
    align-items: stretch;
    margin-bottom: 2rem;
}

.mod_search .formbody .widget-text {
    flex: 1;
}

.mod_search .formbody .widget-text input {
    height: 100%;
}

/* Treffer-Kopfzeile */
.mod_search > p.header {
    font-size: .95rem;
    color: var(--color-text-muted);
    margin-bottom: .5rem;

    & strong { color: var(--color-text); }
}

/* Hinweis-Box (Suchbegriff zu kurz etc.) */
.mod_search > p.info {
    padding: .65rem 1rem;
    background: color-mix(in srgb, var(--color-blue) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-blue) 25%, transparent);
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
}

/* Einzelnes Suchergebnis – ohne Bild: reine Spalte */
.mod_search .search_default {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-border);

    &:first-of-type { border-top: 1px solid var(--color-border); }
}

/* Mit Bild: Grid (Thumbnail links, Text rechts) */
.mod_search .search_default:has(.image_container) {
    display: grid;
    grid-template-columns: 72px 1fr;
    grid-template-rows: auto auto 1fr;
    column-gap: 1rem;
    row-gap: .2rem;
    align-items: start;
}

/* Thumbnail: gesamte Höhe der drei Zeilen belegen */
.mod_search .search_default .image_container {
    grid-row: 1 / 4;
    align-self: start;

    & figure {
        margin: 0;
        border-radius: var(--radius);
        overflow: hidden;
        aspect-ratio: 1;
    }

    & img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    & a { display: block; }
}

.mod_search .search_default h3 {
    font-size: 1rem;
    margin: 0;

    & a {
        color: var(--color-heading);
        text-decoration: none;

        &:hover { color: var(--color-red); }
    }
}

.mod_search .search_default .context {
    font-size: .875rem;
    color: var(--color-text-muted);
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}

.mod_search .search_default .url {
    font-size: .75rem;
    color: var(--color-text-muted);
    opacity: .65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin: 0;
}

/* Suchbegriff-Hervorhebung */
.mod_search mark.highlight {
    background: color-mix(in srgb, var(--color-gold) 45%, transparent);
    color: inherit;
    border-radius: 2px;
    padding: 0 .15em;
}

/* --- Tabelle --- */
.content-table,
.rte:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.content-table table,
.rte table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.content-table thead tr,
.rte table thead tr {
    background: var(--color-blue);
    color: #fff;
}

.content-table th,
.rte table th {
    padding: .75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .875rem;
}

.content-table td,
.rte table td {
    padding: .7rem 1rem;
    vertical-align: top;
    border-bottom: 1px solid var(--color-border);
}

.content-table tbody tr:last-child td,
.rte table tbody tr:last-child td {
    border-bottom: none;
}

.content-table tbody tr:nth-child(even),
.rte table tbody tr:nth-child(even) {
    background: var(--color-bg-subtle);
}

.content-table tbody tr:hover,
.rte table tbody tr:hover {
    background: color-mix(in srgb, var(--color-blue) 6%, transparent);
}

/* --- Utilities --- */

/* Spacing scale: 1=0.25rem 2=0.5rem 3=1rem 4=1.5rem 5=2rem 6=3rem */
.m-t-1 { margin-top:    .25rem; }
.m-t-2 { margin-top:    .5rem;  }
.m-t-3 { margin-top:    1rem;   }
.m-t-4 { margin-top:    1.5rem; }
.m-t-5 { margin-top:    2rem;   }
.m-t-6 { margin-top:    3rem;   }

.m-b-1 { margin-bottom: .25rem; }
.m-b-2 { margin-bottom: .5rem;  }
.m-b-3 { margin-bottom: 1rem;   }
.m-b-4 { margin-bottom: 1.5rem; }
.m-b-5 { margin-bottom: 2rem;   }
.m-b-6 { margin-bottom: 3rem;   }

.m-y-1 { margin-block:  .25rem; }
.m-y-2 { margin-block:  .5rem;  }
.m-y-3 { margin-block:  1rem;   }
.m-y-4 { margin-block:  1.5rem; }
.m-y-5 { margin-block:  2rem;   }
.m-y-6 { margin-block:  3rem;   }

.p-t-1 { padding-top:    .25rem; }
.p-t-2 { padding-top:    .5rem;  }
.p-t-3 { padding-top:    1rem;   }
.p-t-4 { padding-top:    1.5rem; }
.p-t-5 { padding-top:    2rem;   }
.p-t-6 { padding-top:    3rem;   }

.p-b-1 { padding-bottom: .25rem; }
.p-b-2 { padding-bottom: .5rem;  }
.p-b-3 { padding-bottom: 1rem;   }
.p-b-4 { padding-bottom: 1.5rem; }
.p-b-5 { padding-bottom: 2rem;   }
.p-b-6 { padding-bottom: 3rem;   }

/* Text */
.text--left   { text-align: left;   }
.text--center { text-align: center; }
.text--right  { text-align: right;  }

/* --- Inline Icons (phone / fax / www / email) --- */
span.icon-phone::before,
span.icon-fax::before,
span.icon-www::before,
a[href^="mailto:"]::before {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    margin-right: 0.25em;
    background-color: currentColor;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}
span.icon-phone::before      { mask-image: url('/files/theme/icons/phone.svg'); }
span.icon-fax::before        { mask-image: url('/files/theme/icons/fax.svg');   }
span.icon-www::before        { mask-image: url('/files/theme/icons/www.svg');   }
a[href^="mailto:"]::before   { mask-image: url('/files/theme/icons/email.svg'); }

a[target="_blank"]::after {
    content: '';
    display: inline-block;
    width: .8em;
    height: .8em;
    vertical-align: 0.05em;
    margin-left: 0.3em;
    background-color: currentColor;
    mask-image: url('/files/theme/icons/external.svg');
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    opacity: .6;
}

.content-markdown h2 {
    margin-top: 2rem;
}

.content-markdown hr {
    margin-block: 2rem;
}
