.nmso-grid {
    display: grid;
    width: 100%;
    /* Odczyt zmiennych przekazywanych z PHP */
    grid-template-columns: repeat(var(--nmso-cols, 3), 1fr);
    gap: var(--nmso-gap, 20px);
}

.nmso-item {
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    display: block; 
    text-decoration: none;
    /* Odczyt zmiennej z PHP */
    height: var(--nmso-height, 300px);
}

/* Nakładka */
.nmso-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform: translate(-100%, -100%); 
    
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    
    transition: transform 0.3s ease-out;
    pointer-events: none; 
    
    /* Odczyt koloru tła z PHP */
    background-color: var(--nmso-bg, rgba(34, 34, 34, 0.9));
}

/* Kolorystyka tekstu (zmienna z PHP) */
.nmso-title, .nmso-desc {
    color: var(--nmso-color, #ffffff);
}

.nmso-content {
    max-width: 100%;
}

.nmso-title {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    font-weight: 700;
}

.nmso-desc {
    font-size: 1em;
    line-height: 1.4;
}

/* --- WERSJA MOBILNA I TABLETOWA (poniżej 1024px) --- */
@media (max-width: 1024px) {
    .nmso-grid {
        /* Wymuszenie 2 kolumn na tablecie niezależnie od ustawień desktopowych */
        grid-template-columns: repeat(2, 1fr); 
    }

    .nmso-overlay {
        transform: translate(0, 0) !important;
        transition: none !important;
        top: auto;
        bottom: 0;
        height: auto;
        min-height: 30%; 
        align-items: center;
        padding: 15px;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    }

    .nmso-title {
        font-size: 1.2em; 
        margin-bottom: 5px;
    }
    
    .nmso-desc {
        font-size: 0.9em;
    }
}

/* --- WERSJA TELEFON (poniżej 767px) --- */
@media (max-width: 767px) {
    .nmso-grid {
        /* Wymuszenie 1 kolumny na telefonach */
        grid-template-columns: 1fr; 
    }
}