.blok {
    margin-block: 0; /* Reset margin for content-flow */
    padding: 2rem;
    border-radius: 12px;
    background-color: #f9f9f9;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.blok-inner-flex {
    height: auto;
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    flex-shrink: 1;
    align-items: center; /* This is the fix */
}

.blok-inner-flex.reverse {
    flex-direction: row-reverse;
}

.blok-foto-grid {
    flex: 1.5;
    display: grid;
    gap: 1rem;
    grid-template-areas:
        'a x x'
        'b x x'
        'c d e';
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto;
}

.blok-foto-grid-reverse {
    flex: 1.5;
    display: grid;
    gap: 1rem;
    grid-template-areas:
        'x x a'
        'x x b'
        'c d e';
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto;
}

.blok-foto {        
    aspect-ratio: 16/9;
    align-self: center;
    align-items: center;
    font-size: 3rem;
    box-shadow: rgba(3, 8, 20, 0.1) 0px 0.15rem 0.5rem, rgba(2, 8, 20, 0.1) 0px 0.075rem 0.175rem;
    width: 100%;
    border-radius: 4px;
    transition: all 0.2s;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    object-fit: cover; /* Přidáno pro lepší chování obrázků */
}
    
.blok-foto:hover {
    box-shadow: rgba(2, 8, 20, 0.1) 0px 0.35em 1.175em, rgba(2, 8, 20, 0.08) 0px 0.175em 0.5em;
    transform: translateY(-1px) scale(1.001);
}
    
.blok-foto:nth-child(1) { grid-area: x; }
.blok-foto:nth-child(2) { grid-area: a; }
.blok-foto:nth-child(3) { grid-area: b; }
.blok-foto:nth-child(4) { grid-area: c; }
.blok-foto:nth-child(5) { grid-area: d; }
.blok-foto:nth-child(6) { grid-area: e; }

.blok-text {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-self: stretch; /* This is the key fix */
}

/* * OPRAVA 1: Sjednocení stylů pro normální i reverse variantu textového bloku.
 * Přidali jsme `.blok-text-flex-reverse` k selektoru, aby i reverzní verze
 * byla flex kontejner a tlačítko se tak mohlo zarovnat dolů.
*/
.blok-text-flex,
.blok-text-flex-reverse {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
}
    
.blok-text-flex_head {
    order: 0;
}
    
.blok-text-flex_body {
    order: 1;
    line-height: 1.6;
    flex-grow: 1; /* This makes the text body expand */
}

.action-divider {
    order: 2;
    border: none;
    height: 2px;
    background-color: #e0e0e0;
    border-radius: 1px;
    margin-top: 1.5rem; /* Use a fixed margin for spacing */
    margin-bottom: 1.5rem;
    width: 100%;
    opacity: 0.5;
}
    
.action-row {
    order: 3;
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 20px;
}

.blok-price {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--text-color);
}

.action-row .blok-text-flex_btn {
    margin-top: 0; /* Reset margin on the button itself */
}

/* Hide expandable text functionality on desktop */
@media (min-width: 1201px) {
    .expand-text-btn {
        display: none !important;
    }
    
    .expandable-text {
        max-height: none !important;
    }
    
    .expandable-text::after {
        display: none !important;
    }
}

/* =========================================== */
/* MOBILNÍ ZOBRAZENÍ             */
/* =========================================== */

@media (max-width: 1200px) {
    .blok{
        padding: 1.5rem 1rem;
        margin: 2rem 0.5rem;
    }

    /* * OPRAVA 2: Sjednocení stylů pro mobilní zobrazení.
     * Pravidlo nyní platí pro `.blok-inner-flex` i `.blok-inner-flex.reverse`,
     * čímž se zajistí, že se oba kontejnery na mobilu zalamují do sloupce.
    */
    .blok-inner-flex,
    .blok-inner-flex.reverse {
        flex-direction: column;
    }

    .blok-foto-grid,
    .blok-foto-grid-reverse {
        order: 2; /* Obrázky budou vždy druhé (dole) */
    }

    .blok-text{
        order: 1; /* Text bude vždy první (nahoře) */
        min-height: auto;
    }
        
    .blok-text-flex_head {
        order: 0;
        margin: 0.5rem 1rem;
    }
        
    .blok-text-flex_body {
        order: 1;
        margin: 0.5rem 1rem;
        flex-grow: 0; /* Vypneme na mobilu, aby nebyly zbytečné mezery */
    }

    /* Expandable Text for Mobile */
    .expandable-text-container {
        position: relative;
    }

    .expandable-text {
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
        max-height: 16em; /* Show approximately 10 lines (1.6 line-height * 10) */
        line-height: 1.6;
        position: relative;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .expandable-text.collapsed::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 1.6em;
        background: linear-gradient(transparent, var(--bg_l));
        pointer-events: none;
    }

    .dark .expandable-text.collapsed::after {
        background: linear-gradient(transparent, var(--bg_d));
    }

    .expandable-text.expanded {
        max-height: none;
    }

    .expand-text-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        margin: 0.5rem auto 0 auto; /* Center the button horizontally */
        padding: 0.5rem 1rem;
        background: transparent;
        border: 1px solid;
        border-radius: 20px;
        cursor: pointer;
        font-size: 0.85rem;
        transition: all 0.2s ease;
        width: fit-content; /* Button only as wide as content */
    }

    .light .expand-text-btn {
        color: #666;
        border-color: rgba(0, 0, 0, 0.2);
    }

    .light .expand-text-btn:hover {
        background: rgba(0, 0, 0, 0.05);
        color: #333;
    }

    .dark .expand-text-btn {
        color: #ccc;
        border-color: rgba(255, 255, 255, 0.2);
    }

    .dark .expand-text-btn:hover {
        background: rgba(255, 255, 255, 0.05);
        color: #fff;
    }

    .expand-icon {
        font-size: 0.7rem;
        transition: transform 0.2s ease;
    }

    .expand-text-btn.expanded .expand-icon {
        transform: rotate(180deg);
    }

    /* Show expand button only on mobile */
    .expand-text-btn {
        display: flex;
    }

    /* Extra small screens - ensure expandable text works properly */
    @media (max-width: 480px) {
        .expandable-text {
            max-height: 17em; /* Show approximately 10+ lines on very small screens where text wraps more */
            font-size: 0.95em; /* Slightly smaller font to help with overflow detection */
        }
        
        .expand-text-btn {
            font-size: 0.8rem; /* Smaller button text on very small screens */
            padding: 0.4rem 0.8rem;
        }
    }
        
    .blok-text-flex_btn {
        order: 2;
        align-self: center;
        margin-top: 1rem; /* Pevná mezera pro konzistentní vzhled */
    }
}