/**
 * Logo Showcase — native, dependency-free client logo strip
 *
 * Replaces the third-party Elfsight "Logo Showcase" widget that used to live in
 * the homepage "Our Clients" section. The behaviour below is a clean-room
 * re-implementation of how that widget works (extracted from
 * app-releases/logo-showcase widget assets):
 *
 *   - Two layouts: "ticker"  (endless CSS marquee) and "slider" (paged carousel)
 *   - Ticker:  @keyframes scroll{0%{transform:translateX(0)}100%{transform:translateX(-100%)}}
 *              applied to two side-by-side tracks, each filled with enough copies of the
 *              logo set to cover the viewport, so the hand-off between the tracks is
 *              invisible. Speed is expressed in px/second and converted to a duration
 *              (duration = trackWidth / speed) that is re-measured on resize.
 *   - Ticker hover-pause is pure CSS (animation-play-state on :hover).
 *   - Slider: clone-based infinite loop ([tail clones][real items][head clones]),
 *             paging one logo at a time with a 0.6s transform transition, arrows +
 *             pointer swipe + keyboard, optional autoplay with pause-on-hover.
 *   - Each logo keeps its own aspect ratio: items share one artwork *height*
 *             (--ls-size) plus a width cap (--ls-max-w), so a long wordmark and a
 *             compact emblem read at the same visual weight.
 *
 * Visual language is inherited from the theme (assets/css/style.css):
 * --background-color, --border-color, --accent-color, --text-secondary,
 * --el-border-radius, --el-box-shadow and the .item-style card treatment.
 *
 * @author Devv Plug Tech
 * @version 1.0.0
 */

/* ============================================
   1. TOKENS / SHELL
   ============================================ */

.logo-showcase {
    /* Artwork height, width cap, inner padding and gutter. The client marks run from
       0.75:1 (Pruntez, DOAGL emblems) to 11:1 (Lily wordmark), so height is what is
       equalised and width follows each image's own ratio up to --ls-max-w. */
    --ls-size: 64px;
    --ls-max-w: 280px;
    --ls-pad: 18px;
    --ls-gutter: 18px;
    --ls-slide-speed: 0.6s;
    /* Driven by JS (ticker) */
    --ls-duration: 30s;
    --ls-direction: normal;
    --ls-play: running;

    position: relative;
    width: 100%;
    padding: 0.75rem 0;
    direction: ltr;
}

/* Tablet — theme breakpoint used by .brands-item / hero slider */
@media only screen and (max-width: 1024px) {
    .logo-showcase {
        --ls-size: 56px;
        --ls-max-w: 220px;
        --ls-pad: 16px;
        --ls-gutter: 16px;
    }
}

/* Mobile */
@media only screen and (max-width: 768px) {
    .logo-showcase {
        --ls-size: 44px;
        --ls-max-w: 150px;
        --ls-pad: 12px;
        --ls-gutter: 12px;
    }
}

.logo-showcase__viewport {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

/* ============================================
   2. ITEMS (logos)
   ============================================ */

.logo-showcase__item {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    /* Width comes from the logo itself, kept inside a sane band so emblem-only
       marks still get a readable tile and wordmarks never eat the whole strip. */
    width: auto;
    min-width: calc(var(--ls-size) * 1.35 + var(--ls-pad) * 2);
    max-width: calc(var(--ls-max-w) + var(--ls-pad) * 2);
    height: calc(var(--ls-size) + var(--ls-pad) * 2);
    padding: var(--ls-pad);
    margin-right: var(--ls-gutter);
    background-color: var(--background-color);
    border-radius: var(--el-border-radius);
    transition: box-shadow 0.2s, transform 0.2s;
}

.logo-showcase__item:hover {
    box-shadow: var(--el-box-shadow);
}

/* The .item-style border overlay must not clip or double up */
.logo-showcase__item::after {
    border-radius: var(--el-border-radius);
}

.logo-showcase[data-style="plain"] .logo-showcase__item {
    background-color: transparent;
}

.logo-showcase[data-style="plain"] .logo-showcase__item::after {
    border-color: transparent;
}

.logo-showcase__item a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.logo-showcase__logo {
    display: block;
    width: auto;
    height: var(--ls-size);
    max-width: var(--ls-max-w);
    max-height: var(--ls-size);
    margin: 0;
    padding: 0;
    object-fit: contain;
    backface-visibility: hidden;
}

/* logoColor: "grayscale" in the widget — colour returns on hover */
.logo-showcase[data-monochrome="true"] .logo-showcase__logo {
    filter: grayscale(1);
    opacity: 0.7;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.logo-showcase[data-monochrome="true"] .logo-showcase__item:hover .logo-showcase__logo,
.logo-showcase[data-monochrome="true"] .logo-showcase__item:focus-within .logo-showcase__logo {
    filter: none;
    opacity: 1;
}

/* ============================================
   3. TICKER (marquee) LAYOUT
   ============================================ */

@keyframes ls-scroll {
    0% {
        transform: translateX(0%);
    }

    100% {
        transform: translateX(-100%);
    }
}

.logo-showcase--ticker .logo-showcase__track {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    flex-direction: row;
    min-width: 100%;
    z-index: 1;
    backface-visibility: hidden;
    animation: ls-scroll var(--ls-duration) linear 0s infinite;
    animation-play-state: var(--ls-play);
    animation-direction: var(--ls-direction);
}

/* carouselPauseOnHover — no JS listener required */
.logo-showcase--ticker[data-pause-on-hover="true"]:hover .logo-showcase__track,
.logo-showcase--ticker[data-pause-on-hover="true"]:focus-within .logo-showcase__track {
    animation-play-state: paused;
}

/* Reverse ticker direction (Elfsight "right") */
.logo-showcase--ticker[data-direction="right"] {
    --ls-direction: reverse;
}

/* Cloned sets are decorative only */
.logo-showcase__track [aria-hidden="true"] {
    user-select: none;
}

/* ============================================
   4. SLIDER LAYOUT
   ============================================ */

.logo-showcase--slider .logo-showcase__track {
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
    flex-direction: row;
    transition: transform var(--ls-slide-speed) ease;
    will-change: transform;
}

/* While the loop "wraps" the jump must be instant */
.logo-showcase__track.is-instant {
    transition: none;
}

/* ============================================
   5. CONTROLS (arrows / dots)
   ============================================ */

.logo-showcase__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 1.25rem;
}

.logo-showcase__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background-color: var(--background-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.logo-showcase__arrow:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: var(--el-box-shadow);
}

.logo-showcase__arrow svg {
    width: 16px;
    height: 11px;
    fill: currentColor;
}

.logo-showcase__arrow--prev svg {
    transform: rotate(180deg);
}

/* Slider arrows only make sense on the paged layout */
.logo-showcase--ticker .logo-showcase__controls,
.logo-showcase--grid .logo-showcase__controls,
.logo-showcase .logo-showcase__controls[hidden] {
    display: none;
}

.logo-showcase__dots {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.logo-showcase__dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: var(--border-color);
    cursor: pointer;
    transition: 0.3s all ease-out;
}

.logo-showcase__dot:hover,
.logo-showcase__dot.is-active {
    background-color: var(--accent-color);
    transform: scale(1.25);
}

/* ============================================
   6. STATIC GRID (prefers-reduced-motion) / FALLBACKS
   ============================================ */

/* JS swaps both animated layouts for this one when the visitor asked for less
   motion — the equivalent of the widget's "displayDeactivation" switch. */
.logo-showcase--grid .logo-showcase__viewport,
.logo-showcase--grid .logo-showcase__track {
    flex-wrap: wrap;
    justify-content: center;
    min-width: 0;
    animation: none;
    transition: none;
}

.logo-showcase--grid .logo-showcase__item {
    margin-bottom: var(--ls-gutter);
}

/* Screen-reader only status text (never a visual artefact) */
.logo-showcase__live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Safety net for the animated layouts if the OS preference changes mid-session */
@media (prefers-reduced-motion: reduce) {
    .logo-showcase--ticker .logo-showcase__track {
        animation: none;
    }

    .logo-showcase--slider .logo-showcase__track {
        transition: none;
    }
}

/* No JS: both layouts stay readable as a wrapped grid */
.logo-showcase:not(.is-ready) .logo-showcase__viewport {
    flex-wrap: wrap;
    justify-content: center;
}

.logo-showcase:not(.is-ready) .logo-showcase__track {
    min-width: 0;
    flex-wrap: wrap;
    justify-content: center;
    animation: none;
}

.logo-showcase:not(.is-ready) .logo-showcase__item {
    margin-bottom: var(--ls-gutter);
}

.logo-showcase:not(.is-ready) .logo-showcase__controls {
    display: none;
}
