/**
 * JeReviews — Frontend Styles
 * 6 display styles: badge, carousel, grid, list, full (hero), minimal
 * + dark theme + accessibility (WCAG AA)
 */

/* ==========================================================================
   Wrapper (réglages dynamiques font/couleur)
   ========================================================================== */

.jr-reviews-wrapper {
  --jr-accent: #fbbc04;
}
.jr-reviews-wrapper .jr-stars {
  color: var(--jr-accent);
}
.jr-reviews-wrapper .jr-badge-link,
.jr-reviews-wrapper a.jr-badge-link {
  color: inherit;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

.jr-reviews {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    color: #1a1a1a;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

.jr-reviews *,
.jr-reviews *::before,
.jr-reviews *::after {
    box-sizing: inherit;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

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

.jr-reviews :focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
    border-radius: 2px;
}

.jr-reviews [role="region"]:focus {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

/* ==========================================================================
   Common elements
   ========================================================================== */

.jr-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.jr-header-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.jr-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.jr-header-name {
    font-size: 16px;
    font-weight: 600;
    color: inherit;
    margin: 0;
}

.jr-header-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #5f6368;
}

.jr-header-rating {
    font-weight: 600;
    color: #e8710a;
}

.jr-google-logo {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-left: auto;
}

/* Stars */
.jr-stars {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    color: #fbbc04;
    line-height: 1;
}

.jr-stars svg,
.jr-stars .jr-star {
    width: 16px;
    height: 16px;
    fill: #fbbc04;
}

.jr-stars .jr-star--empty {
    fill: #dadce0;
}

.jr-stars .jr-star--half {
    fill: url(#jr-star-gradient);
}

.jr-stars-text {
    font-size: 14px;
    font-weight: 600;
    color: #e8710a;
    margin-right: 4px;
}

/* Review card (shared) */
.jr-review-card {
    padding: 16px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e8eaed;
    transition: box-shadow 200ms ease;
}

.jr-review-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.jr-review-author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.jr-review-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e8eaed;
}

.jr-review-author-info {
    flex: 1;
    min-width: 0;
}

.jr-review-author-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jr-review-time {
    font-size: 12px;
    color: #5f6368;
}

.jr-review-stars {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-bottom: 8px;
}

.jr-review-stars .jr-star {
    width: 14px;
    height: 14px;
}

.jr-review-text {
    font-size: 14px;
    line-height: 1.6;
    color: #3c4043;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.jr-review-text--expanded {
    -webkit-line-clamp: unset;
}

.jr-review-toggle {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    color: #1a73e8;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
}

.jr-review-toggle:hover {
    text-decoration: underline;
}

.jr-powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 12px;
    color: #5f6368;
}

.jr-powered-by img {
    height: 16px;
    width: auto;
}

.jr-empty {
    text-align: center;
    padding: 24px;
    color: #5f6368;
    font-size: 14px;
}

/* ==========================================================================
   Style: Badge (compact)
   ========================================================================== */

.jr-reviews--badge {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 12px;
    font-size: 14px;
    white-space: nowrap;
    transition: box-shadow 200ms ease;
}

.jr-reviews--badge:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.jr-reviews--badge .jr-badge-link {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    text-decoration: none;
    white-space: nowrap;
}

.jr-reviews--badge .jr-badge-rating {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.jr-reviews--badge .jr-badge-stars,
.jr-reviews--badge .jr-badge-rating,
.jr-reviews--badge .jr-badge-count {
    flex-shrink: 0;
}

.jr-reviews--badge .jr-badge-stars {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.jr-reviews--badge .jr-badge-count {
    font-size: 12px;
    color: #5f6368;
}

.jr-reviews--badge .jr-google-logo {
    margin-left: 4px;
}

/* ==========================================================================
   Style: Minimal (inline text)
   ========================================================================== */

.jr-reviews--minimal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #3c4043;
}

.jr-reviews--minimal .jr-stars {
    gap: 0;
}

.jr-reviews--minimal .jr-stars .jr-star {
    width: 14px;
    height: 14px;
}

.jr-reviews--minimal .jr-minimal-rating {
    font-weight: 600;
    color: #e8710a;
}

.jr-reviews--minimal .jr-minimal-count {
    color: #5f6368;
}

/* ==========================================================================
   Style: Carousel
   ========================================================================== */

.jr-reviews--carousel {
    position: relative;
    overflow: hidden;
}

.jr-reviews--carousel .jr-header {
    margin-bottom: 20px;
}

.jr-carousel-viewport {
    overflow: hidden;
    margin: 0 -8px;
    padding: 0 8px;
}

.jr-carousel-track {
    display: flex;
    gap: 16px;
    transition: transform 400ms cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform;
}

.jr-carousel-track.jr-no-transition {
    transition: none;
}

.jr-carousel-slide {
    flex: 0 0 calc(33.333% - 11px);
    min-width: 280px;
    content-visibility: auto;
    contain-intrinsic-size: 0 200px;
}

.jr-carousel-slide[aria-hidden="true"] {
    visibility: hidden;
}

.jr-carousel-slide .jr-review-card {
    height: 100%;
}

/* Carousel navigation arrows */
.jr-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e8eaed;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    font-size: 18px;
    color: #3c4043;
    transition: background 200ms ease, box-shadow 200ms ease;
    padding: 0;
    line-height: 1;
}

.jr-carousel-nav:hover {
    background: #f8f9fa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.jr-carousel-nav:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.jr-carousel-prev {
    left: 0;
}

.jr-carousel-next {
    right: 0;
}

.jr-carousel-nav[disabled] {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* Carousel dots */
.jr-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 4px 0;
}

.jr-carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dadce0;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 200ms ease, transform 200ms ease;
}

.jr-carousel-dot:hover {
    background: #9aa0a6;
}

.jr-carousel-dot:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.jr-carousel-dot--active {
    background: #1a73e8;
    transform: scale(1.25);
}

/* Live region for screen readers */
.jr-carousel-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive carousel slides */
@media (max-width: 1024px) {
    .jr-carousel-slide {
        flex: 0 0 calc(50% - 8px);
    }
}

@media (max-width: 640px) {
    .jr-carousel-slide {
        flex: 0 0 100%;
        min-width: 0;
    }
}

/* ==========================================================================
   Style: Grid
   ========================================================================== */

.jr-reviews--grid .jr-grid {
    display: grid;
    grid-template-columns: repeat(var(--jr-columns, 3), 1fr);
    gap: 16px;
}

.jr-reviews--grid .jr-review-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.jr-reviews--grid .jr-review-text {
    flex: 1;
}

@media (max-width: 1024px) {
    .jr-reviews--grid .jr-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .jr-reviews--grid .jr-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Style: List
   ========================================================================== */

.jr-reviews--list .jr-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jr-reviews--list .jr-review-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.jr-reviews--list .jr-review-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.jr-reviews--list .jr-review-body {
    flex: 1;
    min-width: 0;
}

.jr-reviews--list .jr-review-body .jr-review-author {
    margin-bottom: 4px;
}

.jr-reviews--list .jr-review-text {
    -webkit-line-clamp: 3;
}

/* ==========================================================================
   Style: Full (Hero)
   ========================================================================== */

.jr-reviews--full {
    position: relative;
}

.jr-reviews--full .jr-full-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border: 1px solid #e8eaed;
    border-radius: 16px;
    margin-bottom: 24px;
}

.jr-reviews--full .jr-full-photo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.jr-reviews--full .jr-full-info {
    flex: 1;
}

.jr-reviews--full .jr-full-name {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    color: inherit;
}

.jr-reviews--full .jr-full-address {
    font-size: 13px;
    color: #5f6368;
    margin: 0 0 8px;
}

.jr-reviews--full .jr-full-rating-block {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jr-reviews--full .jr-full-rating-number {
    font-size: 28px;
    font-weight: 700;
    color: #e8710a;
    line-height: 1;
}

.jr-reviews--full .jr-full-rating-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.jr-reviews--full .jr-full-rating-count {
    font-size: 13px;
    color: #5f6368;
}

.jr-reviews--full .jr-carousel-viewport {
    margin: 0;
    padding: 0;
}

@media (max-width: 640px) {
    .jr-reviews--full .jr-full-header {
        flex-direction: column;
        text-align: center;
    }

    .jr-reviews--full .jr-full-rating-block {
        justify-content: center;
    }
}

/* ==========================================================================
   Dark theme
   ========================================================================== */

.jr-theme-dark {
    color: #e8eaed;
}

.jr-theme-dark .jr-review-card {
    background: #1e1e1e;
    border-color: #333;
}

.jr-theme-dark .jr-review-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.jr-theme-dark .jr-review-author-name {
    color: #e8eaed;
}

.jr-theme-dark .jr-review-time {
    color: #9aa0a6;
}

.jr-theme-dark .jr-review-text {
    color: #bdc1c6;
}

.jr-theme-dark .jr-review-toggle {
    color: #8ab4f8;
}

.jr-theme-dark .jr-header-meta {
    color: #9aa0a6;
}

.jr-theme-dark .jr-header-name {
    color: #e8eaed;
}

.jr-theme-dark .jr-stars .jr-star--empty {
    fill: #5f6368;
}

.jr-theme-dark .jr-powered-by {
    color: #9aa0a6;
}

/* Badge dark */
.jr-theme-dark.jr-reviews--badge {
    background: #1e1e1e;
    border-color: #333;
}

.jr-theme-dark.jr-reviews--badge:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.jr-theme-dark.jr-reviews--badge .jr-badge-rating {
    color: #e8eaed;
}

.jr-theme-dark.jr-reviews--badge .jr-badge-count {
    color: #9aa0a6;
}

/* Minimal dark */
.jr-theme-dark.jr-reviews--minimal {
    color: #bdc1c6;
}

.jr-theme-dark.jr-reviews--minimal .jr-minimal-count {
    color: #9aa0a6;
}

/* Carousel dark */
.jr-theme-dark .jr-carousel-nav {
    background: #2d2d2d;
    border-color: #444;
    color: #e8eaed;
}

.jr-theme-dark .jr-carousel-nav:hover {
    background: #3c3c3c;
}

.jr-theme-dark .jr-carousel-dot {
    background: #5f6368;
}

.jr-theme-dark .jr-carousel-dot--active {
    background: #8ab4f8;
}

/* Full hero dark */
.jr-theme-dark .jr-full-header {
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    border-color: #333;
}

.jr-theme-dark .jr-full-name {
    color: #e8eaed;
}

.jr-theme-dark .jr-full-address {
    color: #9aa0a6;
}

.jr-theme-dark .jr-full-rating-count {
    color: #9aa0a6;
}

/* Grid dark — inherits review card dark styles */

/* List dark — inherits review card dark styles */

/* ==========================================================================
   Lazy loading (content-visibility)
   ========================================================================== */

.jr-review-card img[data-src] {
    opacity: 0;
    transition: opacity 300ms ease;
}

.jr-review-card img.jr-loaded {
    opacity: 1;
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    .jr-carousel-nav,
    .jr-carousel-dots {
        display: none;
    }

    .jr-carousel-slide {
        content-visibility: visible;
    }

    .jr-carousel-slide[aria-hidden="true"] {
        visibility: visible;
    }
}
