/* ========================================
   KATEGORIEN-KARTEN MOBILE OPTIMIERUNG
   ========================================
   Zentrale CSS-Datei für alle Kategorien-Karten
   auf Startseite und Wizard
   ======================================== */

/* Basis-Styles für Kategorien-Grid */
.categories-grid {
    display: grid;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.category-card,
.category-label {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: visible !important; /* Text darf über Karte hinaus sichtbar sein */
}

.category-title,
.category-content h3 {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
}

/* ========================================
   STARTSEITE & ALLGEMEINE KATEGORIEN
   ======================================== */

/* Desktop - Standard */
.categories-grid {
    grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
    gap: 15px !important; /* Standard Gap */
    justify-items: center !important; /* Zentriert */
    align-items: center !important;
    max-width: 100% !important; /* Keine Begrenzung */
    width: 100% !important;
    padding: 0 15px !important;
}

.category-card {
    aspect-ratio: 1 !important; /* Quadratisch */
    min-height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 15px 10px !important; /* Standard Padding */
    overflow: visible !important; /* Text darf über Karte hinaus sichtbar sein */
    width: 100% !important;
    max-width: 100% !important;
}

/* Homepage-Karten mit Bild: kein Padding, overflow hidden */
.homepage-categories .category-card {
    padding: 0 !important;
    overflow: hidden !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    aspect-ratio: unset !important;
}
.homepage-categories .category-card .category-img {
    width: 100% !important;
    height: 130px !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 0 !important;
}

.category-icon {
    font-size: 2.2rem !important; /* Standard Icon */
    margin-bottom: 8px !important;
}

.category-title {
    font-size: 0.75rem !important;
    line-height: 1.2 !important;
    margin: 0 !important;
}

/* Tablet (768px) - NUR MOBILE ÄNDERN */
@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
        gap: 8px !important; /* Angemessener Gap */
        padding: 0 12px !important; /* Container-Padding */
        justify-items: center !important; /* Zentriert */
        align-items: center !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .category-card {
        aspect-ratio: 1 !important; /* Quadratisch */
        padding: 12px 8px !important; /* Angemessenes Padding */
        min-height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Homepage-Bild-Kacheln: kein Padding, kein aspect-ratio */
    .homepage-categories .category-card {
        padding: 0 !important;
        overflow: hidden !important;
        aspect-ratio: unset !important;
        height: auto !important;
        min-height: unset !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }
    
    .category-icon {
        font-size: 1.8rem !important; /* Angemessenes Icon */
        margin-bottom: 6px !important;
    }
    
    .category-title {
        font-size: 0.5rem !important; /* Lesbare Schrift */
        line-height: 1.2 !important;
        white-space: normal !important; /* Mehrere Zeilen erlauben */
        overflow: hidden !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important; /* Max 2 Zeilen */
        -webkit-box-orient: vertical !important;
        max-height: 24px !important; /* Platz für 2 Zeilen */
        text-align: center !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* Mobile (480px) - NUR MOBILE ÄNDERN */
@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
        gap: 6px !important; /* Angemessener Gap */
        padding: 0 10px !important; /* Container-Padding */
        justify-items: center !important; /* Zentriert */
        align-items: center !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .category-card {
        aspect-ratio: 1 !important; /* Quadratisch */
        padding: 10px 6px !important; /* Angemessenes Padding */
        min-height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Homepage-Bild-Kacheln: kein Padding, kein aspect-ratio */
    .homepage-categories .category-card {
        padding: 0 !important;
        overflow: hidden !important;
        aspect-ratio: unset !important;
        height: auto !important;
        min-height: unset !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }
    
    .category-icon {
        font-size: 1.5rem !important; /* Angemessenes Icon */
        margin-bottom: 4px !important;
    }
    
    .category-title {
        font-size: 0.4rem !important; /* Lesbare Schrift */
        line-height: 1.2 !important;
        white-space: normal !important; /* Mehrere Zeilen erlauben */
        overflow: hidden !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important; /* Max 2 Zeilen */
        -webkit-box-orient: vertical !important;
        max-height: 22px !important; /* Platz für 2 Zeilen */
        text-align: center !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* iPhone 13 (428px) - NUR MOBILE ÄNDERN */
@media (max-width: 428px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
        gap: 5px !important; /* Angemessener Gap */
        padding: 0 8px !important; /* Container-Padding */
        justify-items: center !important; /* Zentriert */
        align-items: center !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* ===== IPHONE 13 (428px) - KORRIGIERTE LÖSUNG ===== */
    .category-card {
        height: 90px !important; /* ✅ HÖHER für mehr Platz für Text */
        min-height: 90px !important;
        max-height: 90px !important;
        padding: 4px 2px !important; /* ✅ WENIGER Padding = mehr Platz */
        aspect-ratio: none !important; /* ✅ Entferne Konflikt */
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important; /* ✅ Gleichmäßige Verteilung */
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important; /* ✅ Text bleibt IN der Kachel */
    }

    /* Homepage-Bild-Kacheln: eigene Höhe, kein Padding, kein aspect-ratio */
    .homepage-categories .category-card {
        padding: 0 !important;
        overflow: hidden !important;
        aspect-ratio: unset !important;
        height: auto !important;
        min-height: unset !important;
        max-height: none !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }
    
    .category-icon {
        font-size: 1rem !important; /* ✅ NOCH KLEINERES Icon = mehr Platz für Text */
        margin-bottom: 2px !important; /* ✅ Weniger Abstand */
        height: 20px !important;
        min-height: 20px !important;
        max-height: 20px !important;
        flex-shrink: 0 !important;
    }
    
    .category-title {
        font-size: 0.32rem !important; /* ✅ NOCH KLEINER - damit Text vollständig passt */
        line-height: 1.15 !important; /* ✅ Kompakter Zeilenabstand */
        white-space: normal !important; /* ✅ Mehrere Zeilen erlauben */
        overflow: hidden !important; /* ✅ Text bleibt IN der Kachel */
        display: -webkit-box !important; /* ✅ -webkit-box für Zeilenumbruch */
        -webkit-line-clamp: 2 !important; /* ✅ Max 2 Zeilen */
        -webkit-box-orient: vertical !important;
        max-height: 32px !important; /* ✅ MEHR Platz für 2 Zeilen */
        min-height: 16px !important;
        text-align: center !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0 !important; /* ✅ Kein Padding */
        margin: 0 !important;
    }
    
    /* iOS Safari spezifische Optimierungen */
    @supports (-webkit-touch-callout: none) {
        .category-title {
            -webkit-font-smoothing: antialiased !important;
            text-rendering: optimizeLegibility !important;
        }
    }
}

/* ========================================
   WIZARD STEP 1 - KATEGORIEN AUSWAHL
   ======================================== */

/* Wizard-spezifische Selektoren */
.wizard-page .categories-grid,
.wizard-content .categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.wizard-page .category-label,
.wizard-content .category-label {
    aspect-ratio: 1; /* Quadratisch */
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.wizard-page .category-content h3,
.wizard-content .category-content h3 {
    font-size: 0.8rem;
    line-height: 1.1;
}

/* Tablet (768px) - Wizard */
@media (max-width: 768px) {
    html body .wizard-page .categories-grid,
    html body .wizard-content .categories-grid,
    .wizard-page .categories-grid,
    .wizard-content .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
        gap: 6px !important; /* Kleinerer Gap */
        justify-items: center !important; /* Zentriert */
        align-items: center !important;
    }
    
    html body .wizard-page .category-label,
    html body .wizard-content .category-label,
    .wizard-page .category-label,
    .wizard-content .category-label {
        aspect-ratio: 1 !important; /* Quadratisch */
        min-height: auto !important;
        padding: 8px 5px !important; /* Kleineres Padding */
        width: 100% !important;
        max-width: 100% !important;
    }
    
    html body .wizard-page .category-content h3,
    html body .wizard-content .category-content h3,
    .wizard-page .category-content h3,
    .wizard-content .category-content h3 {
        font-size: 0.5rem !important;
        line-height: 1.0 !important;
        white-space: nowrap !important; /* Eine Zeile */
        overflow: visible !important; /* Text vollständig sichtbar */
    }
}

/* Mobile (480px) - Wizard */
@media (max-width: 480px) {
    html body .wizard-page .categories-grid,
    html body .wizard-content .categories-grid,
    .wizard-page .categories-grid,
    .wizard-content .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
        gap: 5px !important; /* Kleinerer Gap */
        justify-items: center !important; /* Zentriert */
        align-items: center !important;
    }
    
    html body .wizard-page .category-label,
    html body .wizard-content .category-label,
    .wizard-page .category-label,
    .wizard-content .category-label {
        aspect-ratio: 1 !important; /* Quadratisch */
        min-height: auto !important;
        padding: 6px 4px !important; /* Kleineres Padding */
        width: 100% !important;
        max-width: 100% !important;
    }
    
    html body .wizard-page .category-content h3,
    html body .wizard-content .category-content h3,
    .wizard-page .category-content h3,
    .wizard-content .category-content h3 {
        font-size: 0.45rem !important;
        line-height: 1.0 !important;
        white-space: nowrap !important; /* Eine Zeile */
        overflow: visible !important; /* Text vollständig sichtbar */
    }
}

/* iPhone 13 (428px) - Wizard */
@media (max-width: 428px) {
    html body .wizard-page .categories-grid,
    html body .wizard-content .categories-grid {
        grid-template-columns: repeat(3, 1fr) !important; /* 3 Spalten */
        gap: 4px !important; /* Kleinerer Gap */
        justify-items: center !important; /* Zentriert */
        align-items: center !important;
    }
    
    html body .wizard-page .category-label,
    html body .wizard-content .category-label {
        aspect-ratio: 1 !important; /* Quadratisch */
        min-height: auto !important;
        padding: 5px 3px !important; /* Kleineres Padding */
        width: 100% !important;
        max-width: 100% !important;
    }
    
    html body .wizard-page .category-content h3,
    html body .wizard-content .category-content h3 {
        font-size: 0.4rem !important;
        line-height: 1.0 !important;
        white-space: nowrap !important; /* Eine Zeile */
        overflow: visible !important; /* Text vollständig sichtbar */
    }
}
