/**
 * SMG News Grid Widget Styles
 * Screenshot-inspired layout: Left = Color Area, Right = Image (Cover)
 * Content box sits on top of color area with padding
 * 
 * Layout Structure:
 * ┌─────────────────────────────┬─────────────────────┐
 * │ Color Area (50%)            │ Image (50%)         │
 * │  ┌──────────────────┐       │                     │
 * │  │ Content Box      │       │  [Cover Image]      │
 * │  │ (with padding)   │       │                     │
 * │  └──────────────────┘       │                     │
 * └─────────────────────────────┴─────────────────────┘
 * 
 * @package SMGMall
 * @version 1.2.0
 * @created 2025-12-18
 * @updated 2025-12-19 - Layout Redesign
 */

/* ===================================
   WIDGET BASE
   =================================== */

.smg-news-grid-widget {
    position: relative;
    padding: var(--space-12, 3rem) 0;
    width: 100%;
}

/* ===================================
   GRID CONTAINER
   =================================== */

.news-grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(1rem, 3vw, 2rem);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Letztes Item bei ungerader Anzahl über volle Breite */
.news-grid-card:last-child:nth-child(odd) {
    grid-column: 1 / -1; /* Spannt über alle Spalten */
}

/* ===================================
   CARD BASE (Screenshot Style)
   Struktur: Linke Hälfte = Farbfläche, Rechte Hälfte = Bild
   =================================== */

.news-grid-card {
    position: relative;
    display: flex;
    flex-direction: row; /* Explizit: Horizontal */
    align-items: stretch; /* Beide Hälften gleiche Höhe */
    width: 100%;
    height: 600px; /* Erhöht für mehr Platz */
    min-height: 600px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.news-grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* ===================================
   COLOR AREA (Left Half - 50%)
   Linke Hälfte mit Farbfläche
   =================================== */

.news-grid-card-color-area {
    position: relative;
    flex: 0 0 50%; /* Nicht schrumpfen, nicht wachsen, exakt 50% */
    width: 50%;
    height: 100%;
    min-height: 100%;
    background-color: #005D81; /* Dunkelblau wie im Screenshot */
    z-index: 2;
}

/* ===================================
   IMAGE WRAPPER (Right Half - 50%)
   Rechte Hälfte mit Bild (Cover)
   WICHTIG: Muss Bild komplett füllen
   =================================== */

.news-grid-card-image-wrapper {
    position: relative;
    flex: 0 0 50%; /* Nicht schrumpfen, nicht wachsen, exakt 50% */
    width: 50% !important; /* Force 50% */
    height: 100% !important; /* Force volle Höhe */
    min-width: 50%;
    min-height: 100%;
    max-width: 50%;
    max-height: 100%;
    z-index: 1;
    overflow: hidden;
    background-color: #f0f0f0; /* Fallback-Farbe wenn Bild nicht lädt */
}

.news-grid-card-image {
    display: block !important; /* Entfernt inline spacing */
    position: absolute; /* Absolute positioning für perfektes Cover */
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover !important; /* WICHTIG: Bild füllt Container komplett */
    object-position: center center; /* Default: Mitte */
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.news-grid-card:hover .news-grid-card-image {
    transform: scale(1.08);
}

/* Image Position Variants (für Elementor Controls) */
.news-grid-card[data-image-position="left"] .news-grid-card-image {
    object-position: left center;
}

.news-grid-card[data-image-position="right"] .news-grid-card-image {
    object-position: right center;
}

.news-grid-card[data-image-position="center"] .news-grid-card-image {
    object-position: center center;
}

.news-grid-card[data-image-position="top"] .news-grid-card-image {
    object-position: center top;
}

.news-grid-card[data-image-position="bottom"] .news-grid-card-image {
    object-position: center bottom;
}

/* ===================================
   CONTENT BOX (Floating, ragt in rechte Hälfte)
   Box "floatet" über Card, hat Abstand links, ragt rechts raus
   Farbe wird inline gesetzt (gleiche wie Color Area)
   =================================== */

.news-grid-card-content {
    position: absolute;
    left: clamp(2rem, 5vw, 3rem);
    top: clamp(2rem, 5vw, 3rem);
    bottom: clamp(2rem, 5vw, 3rem);
    width: auto;
    max-width: 55%; /* Ragt leicht in rechte Hälfte (55% von Card = 5% Überlappung) */
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(0.75rem, 2vw, 1.25rem);
    z-index: 10; /* Über allem */
    height: auto;
    /* Background wird inline gesetzt via style="background-color: ..." */
}

/* ===================================
   CATEGORY LABEL (Weiß, Klein, Uppercase)
   =================================== */

.news-grid-card-label {
    font-size: clamp(0.625rem, 1.5vw, 0.75rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #FFFFFF;
    opacity: 0.9;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

/* ===================================
   TITLE (Gelb/Orange, Bold)
   Screenshot-Style: Große gelbe Headlines
   =================================== */

.news-grid-card-title {
    font-size: clamp(1.25rem, 3.5vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
    color: #FFB800; /* Gelb wie im Screenshot */
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===================================
   SUBTITLE (Weiß, Normal Weight)
   =================================== */

.news-grid-card-subtitle {
    font-size: clamp(0.875rem, 2vw, 1.125rem);
    font-weight: 400;
    line-height: 1.5;
    color: #FFFFFF;
    margin: 0;
    opacity: 0.95;
}

/* ===================================
   BUTTON (Pink/Orange, Abgerundet)
   Screenshot-Style: Farbige Buttons wie "MEHR NEWS"
   =================================== */

.news-grid-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 3vw, 2rem);
    background-color: #D91C5D; /* Pink wie im Screenshot */
    color: #FFFFFF;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    margin-top: auto; /* Push to bottom */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.news-grid-card-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

.news-grid-card-btn:active {
    transform: translateY(0);
}

/* ===================================
   LOGO (Bottom Right Corner)
   Optional: Partner-Logo wie im Screenshot
   =================================== */

.news-grid-card-logo {
    position: absolute;
    bottom: clamp(1rem, 3vw, 2rem);
    right: clamp(1rem, 3vw, 2rem);
    z-index: 3;
    max-width: clamp(60px, 15vw, 120px);
    max-height: clamp(40px, 10vw, 80px);
}

.news-grid-card-logo img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* ===================================
   EXTENDED MODE - HEADER
   =================================== */

.news-grid-extended-view {
    width: 100%;
    animation: fadeIn 0.4s ease-in-out;
}

.news-grid-extended-header {
    display: flex;
    align-items: center;
    gap: clamp(1rem, 3vw, 2rem);
    margin-bottom: clamp(2rem, 4vw, 3rem);
    padding-bottom: clamp(1rem, 2vw, 1.5rem);
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.news-grid-back-btn {
    flex-shrink: 0;
    padding: 0.75rem 1.5rem;
    background-color: var(--smg-gray-100, #f3f4f6);
    color: var(--smg-gray-800, #1f2937);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.news-grid-back-btn:hover {
    background-color: var(--smg-gray-200, #e5e7eb);
    transform: translateX(-4px);
}

.news-grid-extended-title h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--smg-gray-900, #111827);
    margin: 0 0 0.5rem 0;
}

.news-grid-extended-title p {
    font-size: clamp(0.875rem, 2vw, 1.125rem);
    color: var(--smg-gray-600, #4b5563);
    margin: 0;
}

/* ===================================
   EXTENDED MODE - CARDS (Smaller)
   =================================== */

.news-grid-extended-view .news-grid-card {
    height: 500px; /* Kleiner als Haupt-View */
    min-height: 500px;
}

.news-grid-extended-view .news-grid-card-color-area {
    width: 60%; /* Breitere Farbfläche in Extended View */
}

.news-grid-extended-view .news-grid-card-image-wrapper {
    width: 40%; /* Kleineres Bild in Extended View */
}

.news-grid-extended-view .news-grid-card-content {
    left: 1.5rem;
    top: 1.5rem;
    bottom: 1.5rem;
    max-width: 58%;
    padding: 1.5rem;
}

.news-grid-extended-view .news-grid-card-title {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.news-grid-extended-view .news-grid-card-subtitle {
    font-size: clamp(0.75rem, 1.5vw, 1rem);
}

/* ===================================
   ANIMATIONS
   =================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   RESPONSIVE
   =================================== */

/* Tablet */
@media (max-width: 1024px) {
    .news-grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(1rem, 2.5vw, 1.5rem);
    }

    /* Letztes Item bei ungerader Anzahl über volle Breite */
    .news-grid-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .news-grid-card {
        height: 550px;
        min-height: 550px;
    }

    /* Content Box anpassen */
    .news-grid-card-content {
        left: clamp(1.5rem, 4vw, 2rem);
        top: clamp(1.5rem, 4vw, 2rem);
        bottom: clamp(1.5rem, 4vw, 2rem);
        max-width: 60%; /* Etwas breiter auf Tablet */
        padding: clamp(1.25rem, 3vw, 2rem);
    }

    /* Extended View */
    .news-grid-extended-view .news-grid-card {
        height: 450px;
        min-height: 450px;
    }

    .news-grid-extended-view .news-grid-card-content {
        max-width: 65%;
    }
}

/* Medium Tablet / Large Mobile */
@media (max-width: 900px) {
    .news-grid-container {
        grid-template-columns: 1fr; /* Einspaltiges Layout ab 900px */
        gap: 1.5rem;
    }

    /* Reset full-width rule (nicht mehr nötig bei 1 Spalte) */
    .news-grid-card:last-child:nth-child(odd) {
        grid-column: auto;
    }

    .news-grid-card {
        height: 580px;
        min-height: 580px;
    }

    /* Noch Desktop-Layout (horizontal) */
    .news-grid-card-content {
        max-width: 65%;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .smg-news-grid-widget {
        padding: var(--space-8, 2rem) 0;
    }

    .news-grid-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .news-grid-card {
        flex-direction: column;
        height: 550px;
        min-height: 550px;
    }

    /* Mobile: Bild oben, Farbe unten */
    .news-grid-card-color-area {
        flex: 0 0 60% !important;
        width: 100% !important;
        height: 60%;
        min-width: 100%;
        max-width: 100%;
        order: 2;
    }

    .news-grid-card-image-wrapper {
        flex: 0 0 40% !important;
        width: 100% !important;
        height: 40%;
        min-width: 100%;
        max-width: 100%;
        order: 1;
    }

    .news-grid-card-image {
        width: 100% !important;
        height: 100% !important;
    }

    /* Content Box unten positioniert */
    .news-grid-card-content {
        left: 1.5rem;
        right: 1.5rem;
        top: auto;
        bottom: 1.5rem;
        max-width: calc(100% - 3rem);
        padding: 1.5rem;
    }

    .news-grid-extended-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .news-grid-back-btn {
        width: 100%;
        text-align: center;
    }

    .news-grid-extended-view .news-grid-card {
        height: 500px;
        min-height: 500px;
    }

    /* Extended View auf Mobile */
    .news-grid-extended-view .news-grid-card-color-area {
        height: 70%;
    }

    .news-grid-extended-view .news-grid-card-image-wrapper {
        height: 30%;
    }

    .news-grid-extended-view .news-grid-card-content {
        left: 1.25rem;
        right: 1.25rem;
        bottom: 1.25rem;
        max-width: calc(100% - 2.5rem);
        padding: 1.25rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .news-grid-card {
        height: 500px;
        min-height: 500px;
    }

    /* Kleinere Paddings auf sehr kleinen Screens */
    .news-grid-card-content {
        left: 1.25rem;
        right: 1.25rem;
        bottom: 1.25rem;
        max-width: calc(100% - 2.5rem);
        padding: 1.25rem;
        gap: 0.625rem; /* Weniger Abstand zwischen Elementen */
    }

    /* Kleinere Schrift */
    .news-grid-card-label {
        font-size: 0.625rem;
        padding-bottom: 0.375rem;
        margin-bottom: 0.375rem;
    }

    .news-grid-card-title {
        font-size: 1.125rem;
        line-height: 1.3;
    }

    .news-grid-card-subtitle {
        font-size: 0.8125rem;
        line-height: 1.4;
    }

    .news-grid-card-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.6875rem;
        margin-top: 0.5rem;
    }

    /* Extended View */
    .news-grid-extended-view .news-grid-card {
        height: 450px;
        min-height: 450px;
    }

    .news-grid-extended-view .news-grid-card-content {
        padding: 1rem;
        gap: 0.5rem;
    }

    /* Logo */
    .news-grid-card-logo {
        max-width: 60px;
        max-height: 40px;
        bottom: 0.75rem;
        right: 0.75rem;
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .news-grid-card {
        page-break-inside: avoid;
    }

    .news-grid-back-btn {
        display: none;
    }
}

