/*
 * TrustESD - Testimonials & Reviews
 * Testimonial section, cards, star ratings (animated + legacy),
 * reviews masonry, review cards, dark mode overrides
 */

/* ========== TESTIMONIALS ========== */
.testimonial-section {
    padding: 4rem 0;
    background: var(--color-bg-alt);
}

.testimonial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.testimonial-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.testimonial-quote {
    position: relative;
    margin-bottom: 1.5rem;
}

.testimonial-quote .lucide {
    position: absolute;
    top: -10px;
    left: -5px;
    width: 32px;
    height: 32px;
    color: var(--color-secondary);
    opacity: 0.2;
}

.testimonial-quote p {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--color-text);
    font-style: italic;
    padding-left: 1.5rem;
}

.testimonial-author {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 1.5rem;
    border-left: 3px solid var(--color-secondary);
}

.testimonial-author strong {
    color: var(--color-primary);
    font-weight: 600;
}

.testimonial-author span {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ========== REVIEWS / TESTIMONIALS PAGE ========== */
.featured-review {
    border: 1px solid var(--color-accent);
    position: relative;
}

/* Legacy star styles (kept for compatibility) */
.testimonial-stars,
.review-stars {
    display: flex;
    gap: 2px;
    margin-bottom: 0.75rem;
}

.testimonial-stars .lucide,
.review-stars .lucide {
    width: 16px;
    height: 16px;
    color: #f59e0b;
    fill: #f59e0b;
}

/* ========== ANIMATED STAR RATING ========== */
.star-rating {
    display: flex;
    gap: 2px;
    margin-bottom: 0.75rem;
}

.star-rating__star {
    display: block;
    overflow: visible;
    width: 18px;
    height: 18px;
}

.star-rating__star-ring {
    opacity: 0;
    transform: scale(0);
}

.star-rating__star-fill {
    fill: #f59e0b;
    transform: scale(1);
    transform-origin: center;
}

.star-rating__star-stroke {
    fill: none;
    stroke: #d4d4d8;
    stroke-width: 1;
    transform: scale(1);
    transform-origin: center;
}

.star-rating__star-line {
    stroke: #f59e0b;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 0 20;
    stroke-dashoffset: 0;
}

/* Pre-animation: stars start scaled to 0 */
.star-rating:not(.star-rating--no-anim) .star-rating__star-fill {
    transform: scale(0);
}

.star-rating:not(.star-rating--no-anim) .star-rating__star-stroke {
    transform: scale(1);
}

/* When animated, trigger all keyframes */
.star-rating--animated .star-rating__star-ring {
    animation: starRing 1s ease-in-out forwards;
}

.star-rating--animated .star-rating__star-fill {
    animation: starFill 1s ease-in-out forwards;
}

.star-rating--animated .star-rating__star-stroke {
    animation: starStroke 1s ease-in-out forwards;
}

.star-rating--animated .star-rating__star-line {
    animation: starLine 1s ease-in-out forwards;
}

/* Stagger delays per star */
.star-rating--animated .star-rating__star:nth-child(2) .star-rating__star-ring,
.star-rating--animated .star-rating__star:nth-child(2) .star-rating__star-fill,
.star-rating--animated .star-rating__star:nth-child(2) .star-rating__star-stroke,
.star-rating--animated .star-rating__star:nth-child(2) .star-rating__star-line {
    animation-delay: 0.08s;
}

.star-rating--animated .star-rating__star:nth-child(3) .star-rating__star-ring,
.star-rating--animated .star-rating__star:nth-child(3) .star-rating__star-fill,
.star-rating--animated .star-rating__star:nth-child(3) .star-rating__star-stroke,
.star-rating--animated .star-rating__star:nth-child(3) .star-rating__star-line {
    animation-delay: 0.16s;
}

.star-rating--animated .star-rating__star:nth-child(4) .star-rating__star-ring,
.star-rating--animated .star-rating__star:nth-child(4) .star-rating__star-fill,
.star-rating--animated .star-rating__star:nth-child(4) .star-rating__star-stroke,
.star-rating--animated .star-rating__star:nth-child(4) .star-rating__star-line {
    animation-delay: 0.24s;
}

.star-rating--animated .star-rating__star:nth-child(5) .star-rating__star-ring,
.star-rating--animated .star-rating__star:nth-child(5) .star-rating__star-fill,
.star-rating--animated .star-rating__star:nth-child(5) .star-rating__star-stroke,
.star-rating--animated .star-rating__star:nth-child(5) .star-rating__star-line {
    animation-delay: 0.32s;
}

/* No-animation fallback: stars just show filled */
.star-rating--no-anim .star-rating__star-fill {
    transform: scale(1);
}

.star-rating--no-anim .star-rating__star-stroke {
    transform: scale(0);
}

/* Keyframes adapted from CodePen burst star animation */
@keyframes starRing {
    from, 20% {
        animation-timing-function: ease-in;
        opacity: 1;
        r: 8;
        stroke-width: 16;
        transform: scale(0);
    }
    35% {
        animation-timing-function: ease-out;
        opacity: 0.5;
        r: 8;
        stroke-width: 16;
        transform: scale(1);
    }
    50%, to {
        opacity: 0;
        r: 16;
        stroke-width: 0;
        transform: scale(1);
    }
}

@keyframes starFill {
    from, 40% {
        animation-timing-function: ease-out;
        transform: scale(0);
    }
    60% {
        animation-timing-function: ease-in-out;
        transform: scale(1.2);
    }
    80% {
        transform: scale(0.9);
    }
    to {
        transform: scale(1);
    }
}

@keyframes starStroke {
    from {
        transform: scale(1);
    }
    20%, to {
        transform: scale(0);
    }
}

@keyframes starLine {
    from, 40% {
        animation-timing-function: ease-out;
        stroke-dasharray: 0 20;
        stroke-dashoffset: 0;
    }
    60%, to {
        stroke-dasharray: 8 12;
        stroke-dashoffset: -12;
    }
}

.review-service-tag {
    display: inline-block;
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: capitalize;
}

.reviews-masonry {
    columns: 3;
    column-gap: 1.25rem;
}

.review-card {
    break-inside: avoid;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.review-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.review-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}

.review-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.review-author strong {
    color: var(--color-text);
}

@media (max-width: 900px) {
    .reviews-masonry {
        columns: 2;
    }
}

@media (max-width: 600px) {
    .reviews-masonry {
        columns: 1;
    }
}

html[data-dark="true"] .review-card {
    background: #1a1a2e;
    border-color: #2a2a3e;
}

html[data-dark="true"] .review-service-tag {
    background: #2a2a3e;
    color: #aaa;
}
