/**
 * PID Google Reviews v2.0 — Frontend CSS
 * Pure CSS scroll-snap carousel. Zero JavaScript.
 * ~3.5KB unminified, ~1.8KB minified+gzipped
 */

/* ============================================
   Container — vertical stack: track then arrows
   ============================================ */
.pid-gr-container {
    --pid-gr-gap: 16px;
    --pid-gr-card-min: 280px;
    --pid-gr-radius: 10px;
    max-width: 100%;
    margin: 2rem 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* ============================================
   Scroll-Snap Track
   ============================================ */
.pid-gr-track {
    flex: 1;
    min-width: 0; /* Prevent flex blowout */
    display: flex;
    gap: var(--pid-gr-gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    cursor: grab;

    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE/Edge */

    /* Padding for card shadows and edge alignment */
    padding: 8px 4px 16px;
}

.pid-gr-track::-webkit-scrollbar {
    display: none;                  /* Chrome/Safari */
}

/* Drag active state */
.pid-gr-track.pid-gr-dragging {
    cursor: grabbing;
    scroll-behavior: auto;       /* Instant scroll while dragging */
    scroll-snap-type: none;      /* Disable snap while dragging */
    user-select: none;
}

/* ============================================
   Navigation Arrows — centred below track
   ============================================ */
.pid-gr-nav-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.pid-gr-nav {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e5e5;
    background: #f5f5f5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #888;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 0;
}

.pid-gr-nav svg {
    width: 16px;
    height: 16px;
}

.pid-gr-nav:hover:not(:disabled) {
    background: #eaeaea;
    border-color: #ccc;
    color: #555;
}

.pid-gr-nav:active:not(:disabled) {
    transform: scale(0.93);
}

.pid-gr-nav:disabled,
.pid-gr-nav[aria-disabled="true"] {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

.pid-gr-nav:focus-visible {
    outline: 3px solid #4285F4;
    outline-offset: 2px;
}

/* ============================================
   Review Card
   ============================================ */
.pid-gr-card {
    flex: 0 0 calc(100% - 8px);    /* Mobile: 1 card */
    min-width: var(--pid-gr-card-min);
    scroll-snap-align: start;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: var(--pid-gr-radius);
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    transition: box-shadow 0.2s ease;
}

.pid-gr-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Card Header — Avatar + Name + Google Logo
   ============================================ */
.pid-gr-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.pid-gr-reviewer {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;  /* Allow text truncation */
}

/* Avatar — image or CSS initials */
.pid-gr-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.pid-gr-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    user-select: none;
}

/* Reviewer name + date */
.pid-gr-reviewer-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pid-gr-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pid-gr-date {
    font-size: 12px;
    color: #767676; /* WCAG AA compliant: 4.54:1 on white */
    line-height: 1.3;
}

/* Google logo — inline SVG, no image request */
.pid-gr-google-link,
.pid-gr-google-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    line-height: 0;
}

.pid-gr-google-link {
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.pid-gr-google-link:hover {
    opacity: 1;
}

/* ============================================
   Stars
   ============================================ */
.pid-gr-stars {
    display: flex;
    gap: 1px;
    margin-bottom: 10px;
}

.pid-gr-star {
    font-size: 16px;
    line-height: 1;
    color: #ddd;
}

.pid-gr-star-on {
    color: #fbbf24;
}

/* ============================================
   Review Text
   ============================================ */
.pid-gr-text {
    font-size: 13.5px;
    line-height: 1.55;
    color: #444;
    margin: 0;
    flex: 1;

    /* Graceful truncation at ~5 lines */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   Empty State
   ============================================ */
.pid-gr-empty {
    text-align: center;
    color: #888;
    padding: 2rem 1rem;
    font-style: italic;
}

/* ============================================
   Dark Style Variant
   ============================================ */
.pid-gr-style-dark .pid-gr-card {
    background: #1e1e2e;
    border-color: #2e2e40;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.pid-gr-style-dark .pid-gr-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.pid-gr-style-dark .pid-gr-name {
    color: #f0f0f0;
}

.pid-gr-style-dark .pid-gr-date {
    color: #999;
}

.pid-gr-style-dark .pid-gr-text {
    color: #ccc;
}

.pid-gr-style-dark .pid-gr-star {
    color: #444;
}

.pid-gr-style-dark .pid-gr-nav {
    background: #2a2a3e;
    border-color: #3e3e55;
    color: #bbb;
}

.pid-gr-style-dark .pid-gr-nav:hover:not(:disabled) {
    background: #35354d;
    border-color: #555;
    color: #eee;
}

/* ============================================
   Auto-scroll Animation (CSS + tiny JS control)
   Applied via .pid-gr-autoscroll class when enabled.
   JS handles hover/click/touch pause — ~0.5KB, no jQuery.
   ============================================ */
@keyframes pid-gr-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Active auto-scroll: duplicate cards technique for seamless loop */
.pid-gr-autoscroll .pid-gr-track {
    animation: pid-gr-scroll 30s linear infinite;
    scroll-snap-type: none; /* Disable snap during auto-scroll */
    cursor: pointer;        /* Hint that clicking pauses */
}

/* Paused state — toggled by JS on hover / click / touch */
.pid-gr-paused .pid-gr-track {
    animation-play-state: paused;
}

/* Permanent stop via click — restore scroll-snap for manual browsing */
.pid-gr-stopped .pid-gr-track {
    animation: none;
    scroll-snap-type: x mandatory;
    cursor: grab;
}

.pid-gr-stopped .pid-gr-track:active {
    cursor: grabbing;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Mobile — hide arrows, swipe handles it */
@media (max-width: 599px) {
    .pid-gr-nav-row {
        display: none;
    }

    .pid-gr-card {
        flex: 0 0 calc(100% - 8px);    /* 1 card visible */
    }
}

/* Tablet — 2 cards visible */
@media (min-width: 600px) {
    .pid-gr-card {
        flex: 0 0 calc(50% - var(--pid-gr-gap) / 2);
    }
}

/* Small desktop — 3 cards visible */
@media (min-width: 900px) {
    .pid-gr-card {
        flex: 0 0 calc(33.333% - var(--pid-gr-gap) * 2 / 3);
    }
}

/* Large desktop — 4 cards visible (if enough reviews) */
@media (min-width: 1200px) {
    .pid-gr-card {
        flex: 0 0 calc(25% - var(--pid-gr-gap) * 3 / 4);
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .pid-gr-track {
        scroll-behavior: auto;
    }

    .pid-gr-autoscroll .pid-gr-track {
        animation: none !important;
        scroll-snap-type: x mandatory;
    }
}

/* Focus outline for keyboard navigation */
.pid-gr-card:focus-visible {
    outline: 3px solid #4285F4;
    outline-offset: 2px;
}

.pid-gr-google-link:focus-visible {
    outline: 2px solid #4285F4;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ============================================
   Print
   ============================================ */
@media print {
    .pid-gr-track {
        flex-wrap: wrap;
        overflow: visible;
    }

    .pid-gr-nav-row {
        display: none;
    }

    .pid-gr-card {
        flex: 0 0 calc(50% - 8px);
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
