/* Logos Grid — base styles. Colours are fixed to the Figma design; only the
   layout values come from the custom properties written by module.html. */

.logos-grid {
    --logos-rule-gap: 10px;
    background-color: var(--color-secondary);
    padding-block: calc(var(--logos-padding-top, 70px) + var(--logos-rule-gap))
        calc(var(--logos-padding-bottom, 60px) + var(--logos-rule-gap));
    position: relative;
}

/* Hairlines from the design: one at each edge of the section, running the full
   viewport width and set --logos-rule-gap in from the neighbouring sections
   (the frame is 450px = 10 + 70 + logos + 60 + 10). Absolute lines, not
   borders, so the gap stays outside them and the padding above keeps the logos
   the same distance from the rule as in Figma. */
.logos-grid::before,
.logos-grid::after {
    background: var(--color-border-light);
    content: '';
    height: 1px;
    left: 0;
    position: absolute;
    right: 0;
}
.logos-grid::before {
    top: var(--logos-rule-gap);
}
.logos-grid::after {
    bottom: var(--logos-rule-gap);
}

/* min() instead of max-width + padding so the content column is exactly
   --logos-max-width wide on desktop, with a 30px gutter once the viewport is
   narrower than that — the same side gutter the header keeps.
   dnd_section's own max_width is not used here: combined with full_width it
   shrinks the section's background box too, breaking the full-bleed fill. */
.logos-grid__inner {
    width: min(100% - 60px, var(--logos-max-width, 1280px));
    margin-inline: auto;
}

.logos-grid__list {
    display: grid;
    grid-template-columns: repeat(var(--logos-columns, 7), 1fr);
    column-gap: var(--logos-column-gap, 24px);
    row-gap: var(--logos-row-gap, 48px);
    align-items: center;
}

/* The item fills its grid cell (so the logo can size itself against a definite
   width) and positions the logo with justify-content. */
.logos-grid__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: var(--logos-height, 29px);
}

.logos-grid__item--hidden {
    display: none;
}

/* Reveal animation. JS sets --logo-enter-index so the batch cascades instead
   of appearing all at once; "both" keeps the item invisible during its delay. */
@keyframes logos-grid-reveal {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.logos-grid__item--enter {
    animation: logos-grid-reveal 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    animation-delay: calc(var(--logo-enter-index, 0) * 45ms);
}

.logos-grid__link {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
}

/* Logos are constrained on both axes so wide and tall marks end up with a
   comparable optical weight, matching how they are sized in the design. */
.logos-grid__image {
    display: block;
    width: auto;
    height: auto;
    max-width: min(100%, calc(var(--logos-width, 105px) * var(--logo-scale, 1)));
    max-height: calc(var(--logos-height, 29px) * var(--logo-scale, 1));
    object-fit: contain;
    filter: grayscale(1);
}

/* Load more */

/* Stays hidden until JS confirms there is a next batch to reveal, so the button
   never flashes on a grid that is already fully visible. */
.logos-grid__actions {
    display: none;
    justify-content: center;
    margin-top: var(--logos-actions-gap, 66px);
}

.logos-grid--interactive .logos-grid__actions {
    display: flex;
}

.logos-grid__more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    line-height: 1.2;
}
.logos-grid__more:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.logos-grid__more-icon {
    display: inline-flex;
    flex: none;
    width: 16px;
    height: 16px;
    color: #292d32;
}

.logos-grid__more-icon svg {
    display: block;
    width: 16px;
    height: 16px;
    fill: transparent;
}

.logos-grid__placeholder {
    margin: 0;
    text-align: center;
    opacity: 0.6;
}

@media (max-width: 767px) {
    .logos-grid {
        padding-block: calc(var(--logos-padding-top, 70px) * 0.7 + var(--logos-rule-gap))
            calc(var(--logos-padding-bottom, 60px) * 0.7 + var(--logos-rule-gap));
    }

    /* Mobile keeps the tighter 20px gutter: 30px a side would eat too much of a
       402px frame, where the logos already sit three to a row. */
    .logos-grid__inner {
        width: min(100% - 40px, var(--logos-max-width, 1280px));
    }

    /* Equal visual weight on phones. A shared 105x26 box let wordmarks fill
       the width while round marks shrank to 26px; here every logo gets a
       height from its own aspect ratio r (set by module.html), so a square
       mark grows and a long wordmark shrinks. The 0.6 exponent shrinks wide
       wordmarks a little harder than an exact equal-area 0.5 would, which read
       too heavy in review. The cell width still caps the longest ones.
       --logo-scale is left out on purpose: it was tuned for the desktop box and
       on top of this formula it oversizes round marks. Browsers without pow()
       keep the shared box above. */
    @supports (height: calc(1px * pow(2, 0.5))) {
        .logos-grid__image[style*="--logo-ratio"] {
            --logos-weight: 43px;

            width: auto;
            height: calc(var(--logos-weight) / pow(var(--logo-ratio), 0.6));
            max-width: 100%;
            max-height: var(--logos-weight);
        }
    }

    .logos-grid__actions {
        margin-top: calc(var(--logos-actions-gap, 66px) * 0.7);
    }

    .logos-grid__more {
        padding: 16px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .logos-grid__more {
        transition: none;
    }

    .logos-grid__item--enter {
        animation: none;
    }
}
