.main-row {
    display: flex;
    flex-wrap: wrap;
    /* remove fixed max-height so content can grow/shrink responsively */
    max-height: none;
}

.col-75 {
    flex: 0 0 100%;
    max-width: 100%;
    background-color: #021F5A;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.col-25 {
    flex: 0 0 100%;
    max-width: 100%;
    display: none;
}

.col-25 img {
    width: 100%;
    height: auto;
}

/* overlap helper: moves a row up to overlap previous content */
.overlap-up {
    margin-top: -30px;
    position: relative;
    z-index: 1;
    overflow: visible;
    transform: translateY(1px); /* Ensure perfect connection */
}

.overlap-up img {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: -1px; /* Eliminate any sub-pixel gaps */
}

.overlap-down {
    margin-bottom: -30px;
    position: relative;
    z-index: 1;
    overflow: visible;
    transform: translateY(-1px); /* Ensure perfect connection */
}

.overlap-down img {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 1px; /* Eliminate any sub-pixel gaps */
}

/* Ensure wave stays connected on all screen sizes */
@media (max-width: 767px) {
    .overlap-up {
        margin-top: -10px; /* Less overlap on mobile but still connected */
    }

    .overlap-down {
        margin-bottom: -10px; /* Less overlap on mobile but still connected */
    }
}

/* Prevent any gaps on high-resolution screens */
/* @media (min-width: 1024px) {
    .overlap-up {
        margin-top: -50px;
    }
} */

/* Expositores gallery */
.expositores {
    padding: 24px;
    background: transparent;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: center;
}

.gallery-grid a {
    display: block;
    padding: 8px;
    box-sizing: border-box;
    background: transparent;
    text-align: center;
}

/* Desktop styles */
@media (min-width: 1024px) {
    .col-75 {
        flex: 0 0 60%;
        max-width: 60%;
    }

    .col-25 {
        flex: 0 0 40%;
        max-width: 40%;
        display: block;
    }

    .gallery-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 1023px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile styles */
@media (max-width: 767px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Ensure first section shows only left column on mobile and removes any empty whitespace */
@media (max-width: 767px) {
    .main-row {
        display: block; /* stack content vertically */
        max-height: none;
    }

    .main-row > .col-75 {
        display: block;
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    .main-row > .col-25 {
        display: none !important; /* hide right column entirely */
        width: 0;
        height: 0;
        overflow: hidden;
    }
    /* Make the first/main section taller on mobile: double its visual height
        by increasing the left column's min-height and letting the image fill it. */
    .main-row > .col-75 {
        min-height: 50vh; /* adjust as "double" relative to previous small heights */
        display: flex !important;            /* ensure vertical centering */
        align-items: center !important;      /* vertical center */
        justify-content: center !important;  /* horizontal center */
        padding: 0 !important;
        box-sizing: border-box;
    }

    /* Force the image to fill the taller container while preserving aspect ratio
        and allow flexbox centering to work correctly (override inline styles). */
    .main-row > .col-75 img {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: cover !important; /* cover the container */
        display: block !important;
    }
}

.gallery-grid a img {
    width: 100%;
    height: auto;
    display: block;
}

/* Ensure overlay text inside gallery cells fits its parent and doesn't overflow on narrow screens */
.gallery-grid a {
    position: relative; /* ensure absolute overlays are relative to the cell */
    overflow: hidden;
}

/* Generic overlay span rules: allow wrapping and sensible sizing */
.gallery-grid a span {
    max-width: 100%;
    box-sizing: border-box;
    display: block;
    white-space: nowrap; /* keep single-line on desktop where rotated */
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    padding: 0 6px;
    -webkit-font-smoothing: antialiased;
}

/* On small/mobile screens, remove rotation and allow wrapping so text fits the cell */
@media (max-width: 767px) {
    .gallery-grid a span {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        transform: none !important; /* undo rotate(-90deg) on mobile */
        font-size: 0.95rem !important;
        padding: 2px 6px !important;
    }

    /* Tighter spacing for mobile 3-up layout */
    .gallery-grid {
        gap: 8px;
    }
}

/* Responsive: reduce columns on smaller screens */
@media (max-width: 992px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    /* Minimum height for this secion must be 20%*/
    
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Specific mobile layout for narrow phones (e.g. 393px width) — show 3 columns */
@media (max-width: 393px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .gallery-grid a { padding: 4px; }
}

/* Vertical rotated link for EXPOSTORES */
.vertical-anchor {
    position: relative;
    display: block;
    /* aspect-ratio: 353/187; */
    aspect-ratio: 16/9;
    padding: 8px;
    /* box-sizing: border-box; */
}

.vertical-expositores {
    position: absolute;
    inset: 8px;
    background: #d32f2f; /* red */
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 0px;
    transform: rotate(-90deg); /* 90deg anticlockwise */
    transform-origin: center;
    font-size: 1.2em;
}

/* Sponsors: make the sponsors strip and image scale proportionally on mobile */
/* Sponsors: ensure vertical centering even when other grid/row styles exist */
.sponsors,
.row.col-12.sponsors {
    padding: 24px;
    background-color: #A6263E;
    display: flex !important;       /* force flex if .row overrides */
    justify-content: center !important;
    align-items: center !important; /* vertically center children */
    box-sizing: border-box;
    min-height: 120px; /* ensure visible strip and vertical centering room */
}

/* Center the image both horizontally and vertically inside the sponsors strip.
    Use max-width to constrain on large screens and max-height to avoid very tall images. */
.sponsors img {
    width: auto;        /* let image keep its aspect ratio */
    max-width: 70%;     /* constrain on large screens */
    max-height: 96px;   /* keep it vertically centered without overflow */
    height: auto;
    display: block;
    margin: 0 auto;     /* horizontal centering fallback */
    object-fit: contain;
    align-self: center; /* explicit vertical centering */
}

/* Mobile adjustments: reduce padding and allow image to grow to available width while keeping height in check */
@media (max-width: 767px) {
    .sponsors,
    .row.col-12.sponsors {
        padding: 12px;
        min-height: 80px;
    }
    .sponsors img {
        max-width: 92%;
        max-height: 72px;
    }
}
