/*
 * In-house carousel (public/js/carousel.js). Two modes:
 *   [data-carousel="glide"]  photo strip, steps one slide, loops, peeks
 *   [data-carousel="drift"]  logo strip, continuous marquee
 * All geometry is here. The JS only sets --visible and each slide's --off.
 */

.tr-carousel-block[hidden] {
    display: none !important;
}

.tr-carousel {
    --gap: 16px;
    --visible: 3.5;
    --height: 180px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    position: relative;
}

/* ---------- glide ---------- */

.tr-carousel[data-carousel="glide"]:focus-visible {
    outline: 2px solid #349d64;
    outline-offset: 4px;
    border-radius: 16px;
}
.tr-carousel[data-carousel="glide"] .tr-carousel__track {
    position: relative;
    height: var(--height);
    /* clip, not just hidden: a hidden box is still a scroll container, and
       focusing a link in an edge slide would scroll the strip off-centre. */
    overflow: hidden;
    overflow: clip;
    touch-action: pan-y;
}
.tr-carousel[data-mode="loop"] .tr-carousel__track {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
}
.tr-carousel__slide {
    position: absolute;
    top: 0;
    left: 50%;
    width: calc((100% - var(--gap) * (var(--visible) - 1)) / var(--visible));
    height: 100%;
    margin: 0;
    box-sizing: border-box;
    border: 1px solid #eef0f2;
    border-radius: 14px;
    overflow: hidden;
    background: #f5f7f9;
    /* 100% here is the slide's own width. */
    transform: translateX(calc(-50% + var(--off, 0) * (100% + var(--gap))));
    transition: transform .6s var(--ease), opacity .6s var(--ease), border-color .2s ease;
}
/* Before the JS runs every slide sits at --off 0; show only the first. */
.tr-carousel[data-carousel="glide"]:not([data-mode]) .tr-carousel__slide:not(:first-child) {
    opacity: 0;
}
.tr-carousel__slide.is-instant {
    transition: none;
}
.tr-carousel__slide.is-far {
    opacity: 0;
    pointer-events: none;
}
.tr-carousel__slide:hover {
    border-color: #349d64;
}
.tr-carousel__slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    object-fit: cover;
    cursor: pointer;
    transition: transform .5s var(--ease);
}
.tr-carousel__slide:hover img {
    transform: scale(1.08);
}

.tr-carousel__nav {
    position: absolute;
    top: calc(var(--height) / 2);
    z-index: 2;
    width: 32px;
    height: 32px;
    margin-top: -16px;
    padding: 0;
    border: 0;
    background: transparent no-repeat center / 18px 18px;
    cursor: pointer;
}
.tr-carousel__nav:focus-visible {
    outline: 2px solid #349d64;
    border-radius: 50%;
}
.tr-carousel__nav--prev {
    left: -36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='15 18 9 12 15 6'/></svg>");
}
.tr-carousel__nav--next {
    right: -36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='9 18 15 12 9 6'/></svg>");
}
.tr-carousel__nav--prev:hover {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23349d64' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='15 18 9 12 15 6'/></svg>");
}
.tr-carousel__nav--next:hover {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23349d64' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='9 18 15 12 9 6'/></svg>");
}
.tr-carousel:not([data-mode="loop"]) .tr-carousel__nav {
    display: none;
}

.tr-carousel__dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}
.tr-carousel__dots[hidden] {
    display: none;
}
.tr-carousel__dot {
    width: 7px;
    height: 7px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #d1d5db;
    cursor: pointer;
    transition: width .35s var(--ease), background-color .35s var(--ease);
}
.tr-carousel__dot.is-active {
    width: 20px;
    background: #349d64;
}

/* ---------- drift ---------- */

.tr-carousel[data-carousel="drift"] {
    --logo-w: 170px;
    --logo-h: 100px;
    overflow: hidden;
    padding: 8px 0;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
}
.tr-carousel[data-carousel="drift"] .tr-carousel__track {
    display: flex;
    width: max-content;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tr-carousel[data-mode="drift"] .tr-carousel__track {
    animation: tr-carousel-drift var(--drift-duration, 60s) linear infinite;
}
.tr-carousel[data-mode="drift"]:hover .tr-carousel__track,
.tr-carousel[data-mode="drift"]:focus-within .tr-carousel__track {
    animation-play-state: paused;
}
/* margin-right (not gap) so both halves are exactly equal in width and
   -50% lands on a seam. */
.tr-carousel__logo {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: var(--logo-w);
    height: var(--logo-h);
    margin-right: var(--gap);
    padding: 5px;
    box-sizing: border-box;
    border-radius: 12px;
    background: #fff;
    transition: transform .35s var(--ease);
}
.tr-carousel__logo:hover {
    transform: scale(1.08);
}
.tr-carousel__logo a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.tr-carousel__logo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    margin: 0;
    object-fit: contain;
}
@keyframes tr-carousel-drift {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (max-width: 768px) {
    .tr-carousel {
        --height: 140px;
    }
    .tr-carousel[data-carousel="drift"] {
        --logo-w: 130px;
        --logo-h: 80px;
    }
    .tr-carousel__nav--prev {
        left: -28px;
    }
    .tr-carousel__nav--next {
        right: -28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tr-carousel__slide,
    .tr-carousel__slide img,
    .tr-carousel__dot,
    .tr-carousel__logo {
        transition: none;
    }
    .tr-carousel__slide:hover img,
    .tr-carousel__logo:hover {
        transform: none;
    }
    .tr-carousel[data-carousel="drift"] {
        overflow-x: auto;
        -webkit-mask-image: none;
        mask-image: none;
    }
    .tr-carousel[data-carousel="drift"] .tr-carousel__track {
        animation: none;
    }
}
