/* ================================
   DECODE Testimonials (CSS only)
   - Uses your palette vars: --accent, --muted, --ring, --radius, --shadow
   - CSS-only marquee fallback + optional JS-controlled mode
   - Square cards on desktop, readable cards on mobile
   - Edge fade, hover polish, a11y + reduced-motion support
   ================================ */

/* ---------- Root section ---------- */
.testi {
    width: 100%;
    margin: 28px 0 68px;
    text-align: left;

    /* Speeds for CSS fallback (lower = faster) */
    --row-speed-1: 22s;
    --row-speed-2: 26s;

    /* Card sizing (desktop target) */
    --card-size-desktop: 280px;
    --card-size-tablet: 250px;
    --card-size-min: 230px;

    /* Layout */
    --testi-gap: 14px;
}

/* ---------- Header ---------- */
.testi__head {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.testi__head h2 {
    font-size: clamp(22px, 7.5vw, 26px);
    font-weight: 800;
    color: #fff;
    line-height: 1.15;
    text-align: center;
}

.testi__rating {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    color: var(--muted);
}

.testi__stars .star {
    width: 20px;
    height: 20px;
    fill: var(--accent);
    filter: drop-shadow(0 0 6px rgba(255, 0, 0, 0.35));
}

.testi__count {
    color: var(--muted);
    font-weight: 700;
}

/* ---------- Marquee container ---------- */
.testi__marquee {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: var(--testi-gap);
    margin-top: 10px;
    border-radius: var(--radius);

    /* Soft edge fade so items enter/exit smoothly */
    -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}

/* ---------- Rows (CSS fallback animation) ---------- */
.testi__row {
    display: flex;
    align-items: stretch;
    gap: var(--testi-gap);
    padding: 6px 2px;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    cursor: grab;
    /* better affordance for per-row drag when JS is on */
    touch-action: pan-x;
    /* horizontal drag does not block page vertical scroll */

    /* CSS-only marquee (disabled if .testi--js is present) */
    animation: testi-scroll var(--row-speed-1) linear infinite;
}

.testi__row:active {
    cursor: grabbing;
}

.testi__row--reverse {
    animation-duration: var(--row-speed-2);
    animation-direction: reverse;
}

/* If JS engine takes control, kill CSS animation cleanly */
.testi.testi--js .testi__row {
    animation: none !important;
}

/* ---------- Cards ---------- */
/* Desktop: square footprint, tighter grid */
.testi__card {
    /* Visuals */
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    border: 1px solid var(--ring);
    border-radius: var(--radius);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);

    /* Layout */
    display: flex;
    flex-direction: column;
    padding: 14px;

    /* Square on desktop; text is clamped to keep density */
    width: var(--card-size-desktop);
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

/* Tablet */
@media (min-width: 540px) and (max-width: 859.98px) {
    .testi__card {
        width: clamp(var(--card-size-tablet), 28vw, var(--card-size-desktop));
    }
}

/* Desktop large */
@media (min-width: 860px) {
    .testi__card {
        width: var(--card-size-desktop);
    }
}

/* Phone: readable mode (no cropping) */
@media (max-width: 539.98px) {
    .testi__card {
        aspect-ratio: auto;
        /* allow natural height */
        width: min(92vw, 260px);
        /* wide on small screens */
        overflow: visible;
        /* show full text */
    }
}

/* ---------- Card header (avatar + name + mini stars) ---------- */
.testi__top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex: 0 0 auto;
    /* prevent stretching */
}

.testi__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #fff;
    background:
        radial-gradient(120% 120% at 20% 20%, rgba(255, 80, 80, .9), transparent 55%),
        linear-gradient(180deg, var(--accent), #b10000);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 18px rgba(255, 0, 0, 0.25);
    flex: 0 0 36px;
}

.testi__name {
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}

.testi__mini-stars {
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--accent);
    filter: drop-shadow(0 0 4px rgba(255, 0, 0, 0.35));
}

/* ---------- Card body ---------- */
.testi__text {
    color: #e9e9e9;
    font-size: 14.5px;
    line-height: 1.45;
    flex: 1 1 auto;

    /* Clamp on desktop to keep square neat */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 7;
    /* adjust to taste */
    overflow: hidden;
}

/* Phone: remove clamp for full readability */
@media (max-width: 539.98px) {
    .testi__text {
        display: block;
        -webkit-line-clamp: unset;
        overflow: visible;
    }
}

/* ---------- Disclaimer ---------- */
.testi__disclaimer {
    text-align: center;
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--muted);
}

/* ---------- Interactions ---------- */
/* Pause CSS fallback animation on hover/focus (desktop readability) */
.testi__marquee:hover .testi__row,
.testi__marquee:focus-within .testi__row {
    animation-play-state: paused;
}

/* Subtle lift/glow on card hover without shifting layout */
@media (hover:hover) {
    .testi__card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 22px rgba(255, 0, 0, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
}

/* ---------- Keyframes (CSS fallback) ---------- */
@keyframes testi-scroll {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }

    /* requires content >= 2x width */
}

/* ---------- Accessibility ---------- */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 1px, 1px);
    white-space: nowrap;
    border: 0;
}

/* ---------- Reduced-motion fallback ---------- */
@media (prefers-reduced-motion: reduce) {
    .testi__row {
        animation: none;
    }

    .testi__marquee {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .testi__card {
        scroll-snap-align: start;
    }
}

/* Remove horizontal padding that vira 'vazio' no início/fim do loop */
.testi__row {
    padding: 0 !important;
}

/* Deixe o fade de borda mais curto para não parecer 'vazio' na entrada */
.testi.testi--js .testi__marquee {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 2%, #000 98%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 2%, #000 98%, transparent);
}

.testi__row {
    touch-action: pan-y;
    /* permite scroll vertical, só bloqueia horizontal */
}