/**
 * Google Reviews — native, dependency-free review showcase
 *
 * Replaces the third-party Elfsight "Google Reviews" widget (app id
 * ac70b48f-cf4b-4a8c-b570-71380c6e5c13, and previously f332e1be-…) that used to
 * render the homepage review section. The layout and behaviour below are a
 * clean-room re-implementation of that widget (extracted from
 * app-releases/google-reviews/stable/v3.56.6/widget/googleReviews.js) using the
 * widget's own configured values, so the section looks and moves the same while
 * loading no third-party code:
 *
 *   - "carousel" layout, `carouselColumnsMode: "auto"`: the number of visible
 *     cards is derived from a 240px basis — floor((width + gap) / (basis + gap))
 *     — never from a fixed column count, and every card stretches to the row
 *     height so a short review cannot leave a hole in the strip.
 *   - One card per arrow press (`carouselScrollMode: "item"`), 740ms slide
 *     transition, pointer swipe, arrows disabled at both ends (the widget's
 *     Swiper runs with loop/rewind off, so the strip stops at the first and the
 *     last card).
 *   - Card anatomy from `reviewLayout: "classic"` + `reviewSourceStyle:
 *     "iconBottom"`: avatar, author, relative date, then an indented body with
 *     the star row, the review text clamped to three lines plus a "Read more"
 *     control, and a Google attribution link at the foot.
 *   - Rating summary (`headerLayout: "header1"` with title, rating, reviews
 *     number) and the "Review us on Google" call to action.
 *
 * Colours and geometry come from the widget's theme settings, mapped onto the
 * site's own tokens so the section stays consistent with the rest of the page
 * (assets/css/style.css: --background-color, --background-secondary-color,
 * --accent-color, --text-secondary, --el-border-radius, --el-box-shadow, and the
 * .item-style card used by the portfolio and the "Our Clients" logo strip).
 *
 * @author Devv Plug Tech
 * @version 1.0.0
 */

/* ============================================
   1. TOKENS / SHELL
   ============================================ */

.google-reviews {
    --gr-basis: 240px;      /* card width that triggers another column */
    --gr-gap: 20px;         /* carouselItemSpacing */
    --gr-pad: 24px;         /* review card padding */
    --gr-avatar: 40px;
    --gr-star: 18px;        /* reviewRatingSize: "medium" */
    --gr-lines: 3;          /* reviewPreviewLinesNumber */
    --gr-speed: 0.74s;      /* carouselAnimationSpeed */
    --gr-gold: #FCBF02;     /* ratingColor */
    --gr-blank: rgba(17, 17, 17, 0.15);
    --gr-indent: calc(var(--gr-avatar) + 12px);
    --gr-ease: cubic-bezier(0.25, 0.1, 0.24, 1);

    position: relative;
    width: 100%;
    padding: 0.75rem 0 0;
    direction: ltr;
    text-align: left;
}

@media only screen and (max-width: 1024px) {
    .google-reviews {
        --gr-pad: 20px;
    }
}

@media only screen and (max-width: 768px) {
    .google-reviews {
        --gr-gap: 14px;
        --gr-pad: 18px;
        --gr-avatar: 36px;
        --gr-star: 16px;
    }
}

/* ============================================
   2. RATING SUMMARY (header1)
   ============================================ */

.google-reviews__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.25rem;
    margin-bottom: var(--gr-gap);
    padding: var(--gr-pad);
    border-radius: var(--el-border-radius);
    background-color: var(--background-secondary-color);
}

.google-reviews__summary-rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
}

.google-reviews__summary-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.google-reviews__summary-label img {
    width: 1.35rem;
    height: 1.35rem;
}

.google-reviews__score {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.google-reviews__summary-rating .gr-stars {
    --gr-star: 20px;
}

.google-reviews__count {
    font-size: 0.813rem;
    color: var(--text-secondary);
}

.google-reviews__count a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.google-reviews__count a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

/* ============================================
   3. STARS — one mask, two colour layers
   ============================================ */

/* The widget paints each star twice (blank underneath, gold clipped on top) so a
   4.8 average can fill four stars and four fifths of the fifth. A repeating mask
   does the same job from a single element, with no image request per star. */
.gr-stars {
    --gr-fill: calc(var(--gr-value, 5) / 5 * 100%);
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: calc(var(--gr-star) * 5);
    height: var(--gr-star);
    vertical-align: middle;
    background-color: var(--gr-blank);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21Z'/%3E%3C/svg%3E") repeat-x left center / var(--gr-star) var(--gr-star);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21Z'/%3E%3C/svg%3E") repeat-x left center / var(--gr-star) var(--gr-star);
}

.gr-stars::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--gr-fill);
    background-color: var(--gr-gold);
    -webkit-mask: inherit;
    mask: inherit;
}

/* ============================================
   4. CAROUSEL
   ============================================ */

.google-reviews__viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
    outline: none;
    /* Horizontal drags belong to the carousel, vertical ones to the page. */
    touch-action: pan-y;
}

.google-reviews__track {
    display: flex;
    align-items: stretch;
    gap: var(--gr-gap);
    transition: transform var(--gr-speed) var(--gr-ease);
    will-change: transform;
}

/* While a drag is in progress the track must follow the pointer immediately */
.google-reviews__track.is-instant {
    transition: none;
}

.google-reviews__item {
    /* Width is set in px by JS (one row-basis per breakpoint); flex keeps the
       cards on one line and equal, height comes from the tallest visible card. */
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: var(--gr-pad);
    font-size: 1rem;
    line-height: 1.5;
}

/* .item-style keeps the border overlay; reviews need their own radius rhythm */
.google-reviews__item::after {
    border-radius: var(--el-border-radius);
}

/* ---- author block (top of the card) ---- */

.google-reviews__author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.google-reviews__avatar-link {
    display: block;
    flex: 0 0 auto;
    width: var(--gr-avatar);
    height: var(--gr-avatar);
    border-radius: 50%;
    text-decoration: none;
}

.google-reviews__avatar-wrap {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background-color: var(--background-secondary-color);
}

.google-reviews__avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Shown when Google's avatar URL no longer resolves (JS adds .is-failed) */
.google-reviews__avatar-initials {
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: calc(var(--gr-avatar) * 0.42);
    font-weight: 700;
    color: var(--accent-color);
}

.google-reviews__avatar-wrap.is-failed .google-reviews__avatar {
    display: none;
}

.google-reviews__avatar-wrap.is-failed .google-reviews__avatar-initials {
    display: flex;
}

.google-reviews__author-info {
    min-width: 0;
}

.google-reviews__author-name {
    display: block;
    font-size: 0.938rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
    text-decoration: none;
}

.google-reviews__author-name:hover {
    color: var(--accent-color);
}

.google-reviews__date {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ---- body, indented so it lines up under the author name ---- */

.google-reviews__body {
    flex: 1 1 auto;
    margin-left: var(--gr-indent);
}

.google-reviews__rating {
    margin-bottom: 6px;
}

.google-reviews__text {
    margin: 0;
    color: var(--text-primary);
    overflow-wrap: break-word;
    white-space: pre-line;
}

/* JS only applies .is-clamped to text that really does overflow, so short
   reviews keep their natural height and no control is offered for them. */
.google-reviews__text.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--gr-lines);
    line-clamp: var(--gr-lines);
    overflow: hidden;
}

.google-reviews__more {
    display: inline-block;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.google-reviews__more:hover,
.google-reviews__more:focus-visible {
    color: var(--accent-color);
}

/* ---- source row (iconBottom) ---- */

.google-reviews__source {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    text-decoration: none;
}

.google-reviews__source img {
    width: 24px;
    height: 24px;
}

.google-reviews__source-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.google-reviews__source:hover .google-reviews__source-name {
    color: var(--accent-color);
}

/* ============================================
   5. CONTROLS
   ============================================ */

.google-reviews__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 1.25rem;
}

.google-reviews__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background-color: var(--background-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-reviews__arrow:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: var(--el-box-shadow);
}

.google-reviews__arrow svg {
    width: 16px;
    height: 11px;
    fill: currentColor;
}

.google-reviews__arrow--prev svg {
    transform: rotate(180deg);
}

.google-reviews__arrow:focus-visible {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: var(--el-box-shadow);
}

/* Swiper runs loop-less here, so the arrows really do stop at the ends */
.google-reviews__arrow[disabled] {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* ============================================
   6. FALLBACKS / A11Y
   ============================================ */

/* Screen-reader only status text (never a visual artefact) */
.google-reviews__live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* All cards fit without paging: nothing to scroll, no arrows to show */
.google-reviews.is-paged .google-reviews__viewport {
    cursor: grab;
}

.google-reviews[data-arrows="false"] .google-reviews__controls {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .google-reviews__track {
        transition: none;
    }
}

/* No JS: the track degrades into a wrapped grid so every review stays readable,
   and the paging controls (which JS builds) are simply absent. */
.google-reviews:not(.is-ready) .google-reviews__track {
    flex-wrap: wrap;
}

.google-reviews:not(.is-ready) .google-reviews__item {
    flex: 1 1 260px;
}
