/*
 * J51 compatibility layer
 * -----------------------
 * Keeps legacy selectors usable while layout is handled by modern Grid/Flexbox.
 * Intentionally does NOT re-introduce old float/clearfix/inline-width logic,
 * animation libraries, Jarallax, UIkit, or old menu JavaScript.
 */

/* Legacy width wrapper names now use the modern Zillertal container width. */
.wrapper960,
.wrapper1400 {
    width: min(100% - (2 * var(--zt-gutter)), var(--zt-container));
    margin-inline: auto;
}

.module_block,
.component_block,
.container_header,
.container_footer,
.block_holder,
.block_holder_margin,
.side_margins,
.maincontent {
    min-width: 0;
}

/* J51 row wrappers are grids. The PHP sets --zt-columns to number of occupied positions. */
.block_holder_margin.zt-module-row {
    display: grid;
    grid-template-columns: repeat(var(--zt-columns, 1), minmax(0, 1fr));
    gap: var(--zt-grid-gap);
    width: 100%;
}

/* Legacy position cells + modern aliases. */
.showcase-1,
.top-1, .top-2, .top-3,
.bottom-1, .bottom-2, .bottom-3,
.base-1, .base-2,
.zt-module-cell {
    min-width: 0;
    max-width: none !important;
}

/* J51 module chrome compatibility. */
.module,
.module_surround,
.module_content {
    min-width: 0;
}

.module_surround {
    height: 100%;
}

.module_header > :first-child,
.module_content > :first-child {
    margin-top: 0;
}

.module_content > :last-child {
    margin-bottom: 0;
}

/* Content structure aliases from J51.
 * IMPORTANT: the outer .wrapper960 must stay constrained to --zt-container.
 * Only the elements *inside* that wrapper may expand to 100%.
 */
#container_main > .wrapper960.zt-container {
    width: min(100% - (2 * var(--zt-gutter)), var(--zt-container));
    max-width: var(--zt-container);
    margin-inline: auto;
}

#container_main #main,
#container_main #content_full,
#container_main .maincontent {
    width: 100%;
    max-width: 100%;
}

/* Old .clear nodes are not emitted; if old content contains one, make it harmless. */
.clear {
    clear: both;
    display: block;
    height: 0;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .block_holder_margin.zt-cols-2,
    .block_holder_margin.zt-cols-3,
    .block_holder_margin.zt-cols-4,
    .block_holder_margin.zt-cols-5,
    .block_holder_margin.zt-cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .block_holder_margin.zt-module-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Showcase-1 can intentionally break out of the legacy wrapper width.
   This rule comes after the generic .wrapper960 alias so 100% wins. */
#container_showcase1_modules > .wrapper960.zt-container-full {
    width: 100%;
    max-width: none;
    margin-inline: 0;
}
