/* =========================================
   Jenga Carousel - Frontend Styles
   Full-width, responsive, accessible
   ========================================= */

/* Reset & Container */
.jenga-carousel {
    position: relative;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    height: var(--jenga-height, 500px);
    overflow: hidden;
    background: #000; /* fallback; overridden by inline style */
    direction: ltr;
    -webkit-user-select: none;
    user-select: none;
    box-sizing: border-box;
}

/* Track */
.jenga-carousel__track {
    display: flex;
    height: 100%;
    transition: transform 0.5s ease;
    will-change: transform;
}

.jenga-carousel[data-effect="fade"] .jenga-carousel__track {
    display: block;
    position: relative;
}

/* Slide */
.jenga-carousel__slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
}

.jenga-carousel[data-effect="fade"] .jenga-carousel__slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.jenga-carousel[data-effect="fade"] .jenga-carousel__slide.active {
    opacity: 1;
    pointer-events: auto;
    position: relative;
}

.jenga-carousel__slide a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.jenga-carousel__slide img {
    display: block;
    max-width: 100%;
    object-fit: cover;
}

/* ---------- Arrows ---------- */
.jenga-carousel__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.25s, background 0.25s, transform 0.25s;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.jenga-carousel__arrow:hover,
.jenga-carousel__arrow:focus-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
}

.jenga-carousel__arrow:active {
    transform: translateY(-50%) scale(0.92);
}

.jenga-carousel__arrow--prev {
    left: 16px;
}

.jenga-carousel__arrow--next {
    right: 16px;
}

.jenga-carousel__arrow svg {
    display: block;
}

/* ---------- Dots ---------- */
.jenga-carousel__dots {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
}

.jenga-carousel__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: background 0.3s, border-color 0.3s, transform 0.2s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.jenga-carousel__dot:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.4);
}

.jenga-carousel__dot.active {
    background: #fff;
    border-color: #fff;
    transform: scale(1.2);
}

.jenga-carousel__dot:focus-visible {
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.6);
}

/* ---------- Touch / grab cursor ---------- */
.jenga-carousel.grabbing {
    cursor: grabbing;
}

.jenga-carousel:not(.grabbing) {
    cursor: grab;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .jenga-carousel__arrow {
        width: 40px;
        height: 40px;
    }
    .jenga-carousel__arrow--prev { left: 10px; }
    .jenga-carousel__arrow--next { right: 10px; }
    .jenga-carousel__dots { bottom: 12px; gap: 8px; }
    .jenga-carousel__dot { width: 10px; height: 10px; }
}

@media (max-width: 767px) {
    .jenga-carousel__arrow {
        width: 36px;
        height: 36px;
    }
    .jenga-carousel__arrow--prev { left: 8px; }
    .jenga-carousel__arrow--next { right: 8px; }
    .jenga-carousel__arrow svg { width: 20px; height: 20px; }
    .jenga-carousel__dots { bottom: 10px; gap: 6px; padding: 4px 10px; }
    .jenga-carousel__dot { width: 9px; height: 9px; }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .jenga-carousel__track,
    .jenga-carousel[data-effect="fade"] .jenga-carousel__slide {
        transition-duration: 0.01ms !important;
    }
}
