/**
 * Sparkles Review Components
 * Review displays, ratings, and testimonials
 * Extends: sparkles-utilities.css, sparkles-animations.css, sparkles-tokens.css
 * All 3 optimization layers applied: keyframes consolidated, patterns extracted, component organization
 */

/* ========== REVIEW ENHANCEMENTS - MIGRATED FROM MODULE ========== */

/* Review enhancement base container */
.review-enhancements {
    font-family: inherit;
}

/* Helpful votes section */
.helpful-votes-container {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
}

/* Helpful vote buttons */
.helpful-vote-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    background-color: white;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
}

.helpful-vote-btn:hover {
    background-color: var(--gray-50);
    border-color: var(--gray-400);
    transform: translateY(-1px);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.helpful-vote-btn:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--color-info);
}

.helpful-vote-btn svg {
    width: 1rem;
    height: 1rem;
    margin-right: 0.25rem;
}

.helpful-count {
    margin-left: 0.25rem;
    font-weight: 500;
}

/* ========== RATING STARS ========== */
.sparkles-rating,
.sparkles-recommendations__loading,
.sparkles-inline-flex-center,
.sparkles-inline-flex-center-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sparkles-rating {
    gap: .25rem;
}

.rating-summary {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: var(--color-primary);
    line-height: 1;
}

.rating-summary svg {
    width: 1rem;
    height: 1rem;
    display: block;
    vertical-align: middle;
}

.rating-summary svg[width="0"][height="0"] {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
}

.rating-summary span {
    display: inline-flex;
    align-items: center;
}

.rating-summary[data-rating="0"],
.rating-summary[data-reviews="0"] {
    display: none;
}

.sparkles-star {
    width: 1.25rem;
    height: 1.25rem;
    transition-property: all;
    transition-duration: .2s;
    transition-timing-function: cubic-bezier(.4,0,.2,1);
}

.sparkles-star-filled {
    fill: var(--color-primary);
}

.sparkles-star-half {
    position: relative;
}

.sparkles-star-half::before {
    content: '';
    background-color: var(--color-primary);
    /* TW v4.1 upgrade path: mask shorthand and mask-size can use native Tailwind mask-* utilities:
       mask-[url(...)] mask-cover. Useful when refactoring to utility-first approach. */
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath d='M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z'/%3E%3C/svg%3E");
    mask-size: cover;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
}

/* Interactive Rating */
.sparkles-rating-interactive {
    cursor: pointer;
}

.sparkles-rating-interactive:hover .sparkles-star {
    transform: scale(1.1);
}

/* Rating Sizes */
.sparkles-rating-sm .sparkles-star {
    width: 1rem;
    height: 1rem;
}

.sparkles-rating-lg .sparkles-star {
    width: 1.5rem;
    height: 1.5rem;
}

.sparkles-rating-xl .sparkles-star {
    width: 2rem;
    height: 2rem;
}

/* ========== REVIEW SUMMARY ========== */
.sparkles-review-summary {
    --tw-bg-opacity: 1;
    background-color: rgba(255,255,255,var(--tw-bg-opacity,1));
    border-radius: 1.5rem;
    padding: 2rem;
    --tw-shadow: 0 1px 2px 0 #0000000d;
    --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
}

/* Container query anchors for review layouts */
:where(.sparkles-review-summary, .sparkles-testimonial-grid) {
    container-type: inline-size;
}

.sparkles-review-average {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.sparkles-review-score {
    color: var(--color-secondary);
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.sparkles-review-stats {
    flex: 1 1 0%;
}

.sparkles-review-count,
.sparkles-form-helper,
.sparkles-form-step-label,
.sparkles-author-profile--inline .sparkles-author-bio,
.sparkles-author-bio,
.sparkles-admin-card-subtitle,
.sparkles-config-description,
.sparkles-rule-manager .rule-manager-description {
    font-size: .875rem;
    line-height: 1.25rem;
}

.sparkles-review-count,
.sparkles-form-helper,
.sparkles-form-step-label {
    color: var(--gray-600);
    margin-top: .5rem;
}

/* Rating Distribution */
.sparkles-rating-distribution {
    flex-direction: column;
}

.sparkles-rating-label {
    min-width: 60px;
}

.sparkles-rating-progress {
    flex: 1 1 0%;
    height: .5rem;
    background-color: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.sparkles-rating-fill {
    background-color: var(--color-primary);
    transition-property: width;
    height: 100%;
    transition-duration: .3s;
}

.sparkles-rating-percent {
    min-width: 40px;
    text-align: right;
}

/* ========== REVIEW CARD ========== */
.sparkles-review-card,
.sparkles-testimonial-card {
    --tw-bg-opacity: 1;
    background-color: rgba(255,255,255,var(--tw-bg-opacity,1));
    border-radius: 1.5rem;
    padding: 1.5rem;
    --tw-shadow: 0 1px 2px 0 #0000000d;
    --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
    transition-property: all;
    transition-duration: .3s;
    transition-timing-function: cubic-bezier(0,0,.2,1);
}

.sparkles-review-card:hover {
    --tw-shadow: 0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a;
    --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);
}

.sparkles-review-header {
    margin-bottom: 1rem;
}

.sparkles-reviewer-avatar {
    background-color: var(--gray-200);
}

.sparkles-reviewer-details {
    display: flex;
    flex-direction: column;
}

.sparkles-reviewer-name {
    font-weight: 600;
    color: var(--gray-800);
}

.sparkles-review-date,
.sparkles-dropdown-option-description,
.sparkles-file-upload-hint,
.sparkles-file-size,
.sparkles-upload-subtext,
.sparkles-author-position,
.sparkles-author-location,
.sparkles-newsletter-description {
    font-size: .875rem;
    line-height: 1.25rem;
}

.sparkles-review-date,
.sparkles-dropdown-option-description,
.sparkles-file-upload-hint,
.sparkles-file-size {
    color: var(--gray-500);
}

.sparkles-review-verified {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    font-size: .75rem;
    line-height: 1rem;
    --tw-text-opacity: 1;
    color: rgba(5,150,105,var(--tw-text-opacity,1));
    --tw-bg-opacity: 1;
    background-color: rgba(236,253,245,var(--tw-bg-opacity,1));
    padding-left: .5rem;
    padding-right: .5rem;
    padding-top: .25rem;
    padding-bottom: .25rem;
    border-radius: .25rem;
}

/* Review Content */
.sparkles-review-title,
.sparkles-megamenu-column h3,
.sparkles-sidebar-title,
.sparkles-newsletter-success-title,
.sparkles-consent-section-title {
    color: var(--color-secondary);
    line-height: 1.75rem;
    font-weight: 600;
}

.sparkles-review-title {
    font-size: 1.125rem;
    margin-bottom: .5rem;
}

.sparkles-review-content,
.sparkles-consent-section-description {
    color: var(--gray-700);
    line-height: 1.625;
    margin-bottom: 1rem;
}

.sparkles-review-images {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.sparkles-review-image {
    width: 5rem;
    height: 5rem;
    object-fit: cover;
    border-radius: .5rem;
    cursor: pointer;
    transition-property: all;
    transition-duration: .2s;
    transition-timing-function: cubic-bezier(.4,0,.2,1);
}

.sparkles-review-image:hover {
    transform: scale(1.05);
    --tw-shadow: 0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a;
    --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);
}

/* Review Actions */
.sparkles-review-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top-width: 1px;
    border-color: var(--gray-200);
}

.sparkles-review-helpful,
.sparkles-rule-list .rule-meta,
.sparkles-loading-inline {
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    line-height: 1.25rem;
}

.sparkles-review-helpful {
    display: flex;
    color: var(--gray-600);
}

.sparkles-review-vote-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding-left: .75rem;
    padding-right: .75rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
    background-color: initial;
    border-width: 1px;
    border-color: var(--gray-300);
    border-radius: .25rem;
    font-size: .875rem;
    line-height: 1.25rem;
    color: var(--gray-700);
    cursor: pointer;
    transition-property: all;
    transition-duration: .2s;
    transition-timing-function: cubic-bezier(.4,0,.2,1);
}

.sparkles-review-vote-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background-color: var(--gray-100);
}

.sparkles-review-vote-btn-active {
    background-color: var(--color-accent);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* ========== REVIEW FORM ========== */
.sparkles-review-form {
    background-color: var(--gray-50);
    border-radius: 1.5rem;
    padding: 2rem;
}

.sparkles-review-form-title {
    color: var(--color-secondary);
}

.sparkles-review-rating-input {
    margin-bottom: 1.5rem;
}

.sparkles-review-rating-label {
    display: block;
    font-weight: 500;
    margin-bottom: .75rem;
    color: var(--gray-700);
}

.sparkles-review-form-group {
    margin-bottom: 1.5rem;
}

/* ========== REVIEW FILTERS ========== */
.sparkles-review-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom-width: 1px;
    border-color: var(--gray-200);
}

.sparkles-review-filter-btn {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
    --tw-bg-opacity: 1;
    background-color: rgba(255,255,255,var(--tw-bg-opacity,1));
    border-width: 1px;
    border-color: var(--gray-300);
    border-radius: var(--radius-full);
    font-size: .875rem;
    line-height: 1.25rem;
    color: var(--gray-700);
    cursor: pointer;
    transition-property: all;
    transition-duration: .2s;
    transition-timing-function: cubic-bezier(.4,0,.2,1);
}

.sparkles-review-filter-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.sparkles-review-sort {
    margin-left: auto;
}

/* ========== TESTIMONIAL VARIATIONS ========== */
.sparkles-testimonial-grid {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 1.5rem;
}

.sparkles-testimonial-card {
    text-align: center;
}

.sparkles-testimonial-card:hover,
.sparkles-card:hover,
.sparkles-feature-card:hover,
.sparkles-blog-card:hover,
.sparkles-masonry-item:hover {
    --tw-translate-y: -0.25rem;
    --tw-shadow: 0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a;
    --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);
}

.sparkles-testimonial-quote {
    font-size: 1.125rem;
    font-style: italic;
    color: var(--gray-700);
    line-height: 1.625;
    margin-bottom: 1.5rem;
    position: relative;
}

.sparkles-testimonial-quote::before,
.sparkles-testimonial-quote::after {
    content: '"';
    color: var(--color-primary);
    position: absolute;
    font-size: 3rem;
    line-height: 1;
    opacity: .2;
}

.sparkles-testimonial-author {
    align-items: center;
    gap: .75rem;
}

.sparkles-testimonial-avatar {
    width: 4rem;
    height: 4rem;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.sparkles-testimonial-name {
    color: var(--color-secondary);
    font-weight: 600;
}

/* ========== RESPONSIVE DESIGN ========== */
@container (max-width: 768px) {
    .sparkles-review-summary {
        padding: 1.5rem;
    }
    
    .sparkles-review-average {
        flex-direction: column;
        text-align: center;
    }
    
    .sparkles-review-filters {
        flex-wrap: wrap;
    }
    
    .sparkles-testimonial-grid {
        grid-template-columns: repeat(1,minmax(0,1fr));
    }
}

/* ========== ENHANCED RATING STARS COMPONENT ========== */

/* Base rating stars container */
.sparkles-rating-stars,
.sparkles-action-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Enhanced interactive rating */
.sparkles-enhanced {
    cursor: pointer;
}

/* Empty star state */
.sparkles-star-empty {
    fill: var(--gray-300);
    color: var(--gray-300);
}

/* Interactive star with hover capability */
.sparkles-star-interactive {
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sparkles-star-interactive:hover {
    transform: scale(1.1);
}

/* Star hover state */
.sparkles-star-hover {
    color: var(--color-warning, var(--color-warning));
    transform: scale(1.1);
}

/* Focused rating container */
.sparkles-rating-focused {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--color-primary);
}

/* Read-only rating (no interactions) */
.sparkles-rating-readonly {
    pointer-events: none;
}

/* Rating container with spacing */
.sparkles-rating-styles {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Star hover animation */
@keyframes sparkles-star-hover {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1.1);
    }
}

.sparkles-star-hover-animate {
    animation: sparkles-star-hover 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Star select animation */
@keyframes sparkles-star-select {
    0% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.3) rotate(-5deg);
    }
    50% {
        transform: scale(1.25) rotate(5deg);
    }
    75% {
        transform: scale(1.2) rotate(-3deg);
    }
    100% {
        transform: scale(1.1) rotate(0deg);
    }
}

.sparkles-star-select-animate {
    animation: sparkles-star-select 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Particle burst animation */
@keyframes sparkles-particle-burst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0);
    }
    50% {
        opacity: 0.8;
        transform: translate(var(--tx, 20px), var(--ty, -20px)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(var(--tx, 20px) * 1.5), calc(var(--ty, -20px) * 1.5)) scale(0.5);
    }
}

.sparkles-rating-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-warning, var(--color-warning));
    border-radius: 50%;
    pointer-events: none;
    animation: sparkles-particle-burst 0.6s ease-out forwards;
}

/* ========== ANIMATIONS ========== */
.sparkles-star-animate {
    animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
}

/* Note: All keyframes consolidated to sparkles-animations.css - using shared animations */

/* ========== ACCESSIBILITY ========== */
.sparkles-rating[role="img"] {
    position: relative;
}

@media (prefers-reduced-motion: reduce) {
    .sparkles-review-card,
    .sparkles-testimonial-card,
    .sparkles-star {
        animation: none;
        transition-property: none;
    }
}
