/**
 * C4mulo5 – Welt-/Kategorie-Showcase Section
 *
 * Kachel-Grid mit konfigurierbarer Spaltenanzahl (2/3/4/6/8/9).
 * Jede Kachel mit Icon, Titel, Untertitel und Link.
 * Optional mit Hintergrundbild (als Cover hinter halbtransparentem Overlay).
 */

/* ═══ ::before/::after Reset ═══════════════════════════════════ */
.c4mulo5-category-showcase .c4m5-cs-grid::before,
.c4mulo5-category-showcase .c4m5-cs-grid::after,
.c4mulo5-category-showcase .c4m5-cs-tile::before,
.c4mulo5-category-showcase .c4m5-cs-tile::after,
.c4mulo5-category-showcase .c4m5-cs-tile-inner::before,
.c4mulo5-category-showcase .c4m5-cs-tile-inner::after {
    display: none !important;
    content: none !important;
}

/* ═══ GRID ══════════════════════════════════════════════════════ */
.c4mulo5-category-showcase .c4m5-cs-grid {
    display: grid;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.c4mulo5-category-showcase.c4m5-cs-cols-2 .c4m5-cs-grid { grid-template-columns: repeat(2, 1fr); }
.c4mulo5-category-showcase.c4m5-cs-cols-3 .c4m5-cs-grid { grid-template-columns: repeat(3, 1fr); }
.c4mulo5-category-showcase.c4m5-cs-cols-4 .c4m5-cs-grid { grid-template-columns: repeat(4, 1fr); }
.c4mulo5-category-showcase.c4m5-cs-cols-6 .c4m5-cs-grid { grid-template-columns: repeat(3, 1fr); }
.c4mulo5-category-showcase.c4m5-cs-cols-8 .c4m5-cs-grid { grid-template-columns: repeat(4, 1fr); }
.c4mulo5-category-showcase.c4m5-cs-cols-9 .c4m5-cs-grid { grid-template-columns: repeat(3, 1fr); }

@media (min-width: 992px) {
    .c4mulo5-category-showcase.c4m5-cs-cols-6 .c4m5-cs-grid { grid-template-columns: repeat(6, 1fr); }
    .c4mulo5-category-showcase.c4m5-cs-cols-8 .c4m5-cs-grid { grid-template-columns: repeat(4, 1fr); }
    .c4mulo5-category-showcase.c4m5-cs-cols-9 .c4m5-cs-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ═══ BENTO-Layout (erste Kachel groß) ═══════════════════════════ */
.c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-grid {
    grid-template-columns: 2fr 1fr 1fr;
    grid-auto-rows: minmax(180px, auto);
}
.c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-tile:first-child {
    grid-row: span 2;
    grid-column: span 2;
}
@media (max-width: 768px) {
    .c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-grid {
        grid-template-columns: 1fr;
    }
    .c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-tile:first-child {
        grid-row: auto;
        grid-column: auto;
    }
}

/* ═══ KACHEL ═════════════════════════════════════════════════════ */
.c4mulo5-category-showcase .c4m5-cs-tile {
    position: relative;
    display: block;
    min-height: 180px;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    background: #1a5490; /* Fallback, wird von data-bg überschrieben via inline style */
    color: #ffffff;
}

/* ═══ KACHELHÖHE / SEITENVERHÄLTNIS ══════════════════════════════
 * Ohne festes Verhältnis richtet sich die Kachelhöhe nach der
 * Textlänge – zweizeilige Titel machen die Kachel höher als
 * einzeilige, dadurch wirken die Boxen ungleich.
 * Mit einer der Klassen c4m5-cs-ratio-* bekommen ALLE Kacheln
 * exakt dasselbe Seitenverhältnis; das Hintergrundbild passt sich
 * per background-size:cover selbst an (kein Verzerren, kein
 * Abschneiden am Text).
 * c4m5-cs-ratio-auto = bisheriges Verhalten (inhaltsabhängig).
 * ─────────────────────────────────────────────────────────────── */
.c4mulo5-category-showcase.c4m5-cs-ratio-1-1   .c4m5-cs-tile { aspect-ratio: 1 / 1;  min-height: 0; }
.c4mulo5-category-showcase.c4m5-cs-ratio-4-3   .c4m5-cs-tile { aspect-ratio: 4 / 3;  min-height: 0; }
.c4mulo5-category-showcase.c4m5-cs-ratio-3-2   .c4m5-cs-tile { aspect-ratio: 3 / 2;  min-height: 0; }
.c4mulo5-category-showcase.c4m5-cs-ratio-16-9  .c4m5-cs-tile { aspect-ratio: 16 / 9; min-height: 0; }
.c4mulo5-category-showcase.c4m5-cs-ratio-3-4   .c4m5-cs-tile { aspect-ratio: 3 / 4;  min-height: 0; }
.c4mulo5-category-showcase.c4m5-cs-ratio-2-3   .c4m5-cs-tile { aspect-ratio: 2 / 3;  min-height: 0; }

/* Feste Pixelhöhe als Alternative zum Seitenverhältnis. */
.c4mulo5-category-showcase.c4m5-cs-ratio-fixed .c4m5-cs-tile {
    height: var(--c4m5-cs-tile-height, 260px);
    min-height: 0;
    aspect-ratio: auto;
}

/* Ausnahme Bento: Die erste Kachel ueberspannt bewusst 2x2 Felder.
 * Ein erzwungenes Seitenverhaeltnis wuerde dieses Layout zerstoeren,
 * daher fuellt sie dort weiterhin die volle Rasterflaeche. */
.c4mulo5-category-showcase.c4m5-cs-layout-bento[class*="c4m5-cs-ratio-"] .c4m5-cs-tile:first-child {
    aspect-ratio: auto;
    height: 100%;
}

/* Bei fester Höhe/Verhältnis: Text unten verankern und bei sehr
 * langen Titeln sauber begrenzen, damit nichts aus der Kachel läuft. */
.c4mulo5-category-showcase[class*="c4m5-cs-ratio-"]:not(.c4m5-cs-ratio-auto) .c4m5-cs-tile-inner {
    justify-content: flex-end;
}
.c4mulo5-category-showcase[class*="c4m5-cs-ratio-"]:not(.c4m5-cs-ratio-auto) .c4m5-cs-tile-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.c4mulo5-category-showcase[class*="c4m5-cs-ratio-"]:not(.c4m5-cs-ratio-auto) .c4m5-cs-tile-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Bild-Kacheln: Bild füllt die Kachel formatfüllend und mittig aus.
 * Gilt fuer Hintergrundbilder ebenso wie fuer echte <img>-Elemente. */
.c4mulo5-category-showcase .c4m5-cs-tile > img,
.c4mulo5-category-showcase .c4m5-cs-tile-inner > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 0;
}

.c4mulo5-category-showcase .c4m5-cs-tile:hover,
.c4mulo5-category-showcase .c4m5-cs-tile:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
    text-decoration: none !important;
    outline: none;
}

/* Hintergrundbild wenn gesetzt */
.c4mulo5-category-showcase .c4m5-cs-tile[style*="background-image"] {
    background-size: cover;
    background-position: center;
}

/* Overlay bei Bild-Kacheln */
.c4mulo5-category-showcase .c4m5-cs-tile[style*="background-image"]::after {
    content: "" !important;
    display: block !important;
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0.55) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.c4mulo5-category-showcase .c4m5-cs-tile-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    padding: 24px;
    box-sizing: border-box;
}

/* ═══ ICON ═══════════════════════════════════════════════════════ */
.c4mulo5-category-showcase .c4m5-cs-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transition: background 0.25s ease, transform 0.25s ease;
}
.c4mulo5-category-showcase .c4m5-cs-tile:hover .c4m5-cs-tile-icon {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.08);
}

.c4mulo5-category-showcase .c4m5-cs-tile-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ═══ TEXT ═══════════════════════════════════════════════════════ */
.c4mulo5-category-showcase .c4m5-cs-tile-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.c4mulo5-category-showcase .c4m5-cs-tile-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.c4mulo5-category-showcase .c4m5-cs-tile-subtitle {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.45;
    opacity: 0.9;
}

/* ═══ Bento-Layout: erste Kachel etwas größerer Text ═══════════ */
.c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-tile:first-child .c4m5-cs-tile-title {
    font-size: 1.5rem;
}
.c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-tile:first-child .c4m5-cs-tile-icon {
    width: 56px;
    height: 56px;
}
.c4mulo5-category-showcase.c4m5-cs-layout-bento .c4m5-cs-tile:first-child .c4m5-cs-tile-icon svg {
    width: 32px;
    height: 32px;
}

/* ═══ RESPONSIVE ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .c4mulo5-category-showcase .c4m5-cs-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    .c4mulo5-category-showcase .c4m5-cs-tile {
        min-height: 140px;
    }
    .c4mulo5-category-showcase .c4m5-cs-tile-inner {
        padding: 16px;
    }
    .c4mulo5-category-showcase .c4m5-cs-tile-title {
        font-size: 1rem;
    }
    .c4mulo5-category-showcase .c4m5-cs-tile-subtitle {
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .c4mulo5-category-showcase .c4m5-cs-grid {
        grid-template-columns: 1fr !important;
    }
}
