/**
 * Testimonials: customer quotes. Several side by side as cards, one big
 * quote, or a Swiper slider with fade transition, dots and arrows.
 *
 * Two builds with the same classes:
 *   query loop  patterns testimonials, -single, -slider: a GenerateBlocks 2
 *               Query over the site's customer experiences (applari-core,
 *               post type applari_kokemus) with the plugin's dynamic tags,
 *               and Google's summary above the row. Topic and count are set
 *               in the Query block.
 *   static      patterns testimonials-static, -static-single,
 *               -static-slider: GB 1 containers with written quotes, for
 *               prototypes and special cases.
 *
 * class: testimonials (the row) and testimonial (each quote)
 *
 * Row variants:
 *   testimonials--single   one quote: big centered text up to 800px wide
 *   testimonials--slider   Swiper slider; needs the class `swiper` on the row,
 *                          a `swiper-wrapper` around the quotes, `swiper-slide`
 *                          on each quote and a `swiper-nav` with the arrows and
 *                          pagination (see the patterns).
 *                          js/blocks/testimonials.js initializes it.
 *
 * Structure (query loop; static has the same classes without the summary
 * and the rating, and GB 1 containers in place of Query, Looper and Loop item):
 *   .testimonials-summary              Google summary, centered
 *     p.testimonials-summary-rating    {{applari_google_tahdet}} {{applari_google_keskiarvo}} · {{applari_google_maara}}
 *     a.testimonials-summary-link      href {{applari_google_linkki}}, its own block
 *   Query [.testimonials.testimonials--slider.swiper]
 *     Looper .testimonials[.testimonials--single]   slider: .swiper-wrapper
 *       Loop item .testimonial[.wrapper-extra-color][.swiper-slide]
 *         .testimonial-rating          stars and p.testimonial-source ("Google")
 *         p.testimonial-quote          the quote, no quotation marks needed
 *         .testimonial-author
 *           img or figure > img        optional photo or logo (48px round)
 *           p.testimonial-name         "Etunimi Sukunimi"
 *           p.testimonial-role         "Toimitusjohtaja, Yritys Oy"
 *     [.swiper-nav > html: .swiper-button-prev, .swiper-pagination, .swiper-button-next]
 *
 * Empty values: GenerateBlocks drops a block whose tag has no value, so a
 * kokemus without stars, role or photo leaves no gap, and the summary shows
 * only when Google reviews are imported (its link only with a maps link).
 * An empty Query prints no cards: add the pattern when the site has
 * kokemukset.
 *
 * Tuning: --testimonials-gap (24px), --testimonial-quote-size (fluid),
 *         --testimonial-mark-clr (opening quotation mark color, accent),
 *         --rating-clr (stars, colors.css)
 *
 * Chain animations: quotes animate in order (fadeInFromDown). In the query
 * loop the Loop item carries the animation and GB renders it for every card.
 * In the slider the row itself fades in as one.
 *
 * Editor: the row's flex layout is repeated on GB's editor layout element;
 * the slider shows its slides stacked.
 */

:root {
    --testimonials-gap: 24px;
    --testimonial-quote-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
    --testimonial-mark-clr: var(--accent-clr);
}

/* Row */
.testimonials,
.testimonials > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: flex;
    flex-wrap: wrap;
    gap: var(--testimonials-gap);
    align-items: stretch;
}

.testimonials > .block-editor-inner-blocks {
    width: 100%;
}

/* Stars from applari-core (span.applari-tahdet): the theme's colors */
.testimonials-summary,
.testimonial {
    --applari-tahti: var(--rating-clr);
    --applari-tahti-pois: color-mix(in srgb, currentColor 20%, transparent);
}

/* Google summary above the row. Spacing as padding: GB's editor styles
   zero the margins of GB 2 blocks. */
.testimonials-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 4px 16px;
    padding-bottom: 40px;
    text-align: center;
}

.testimonials-summary > * {
    margin: 0;
}

/* Without Google reviews both texts are gone: keep the heading's spacing */
.testimonials-summary:not(:has(*)) {
    padding-bottom: 20px;
}

.testimonials-summary .applari-tahdet {
    margin-right: 4px;
    font-size: 1.15em;
}

.testimonials-summary-link {
    font-size: 0.9rem;
}

/* Quote card */
.testimonial {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1 1 100%;
    min-width: 0;
    box-sizing: border-box; /* the editor's GB 2 Loop item is content-box */
    padding: 32px 28px 28px;
    border-radius: var(--card-radius, 12px);
}

.testimonial > * {
    margin: 0;
}

/* Rating: stars and the source on one line */
.testimonial-rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
}

.testimonial-rating > * {
    margin: 0;
}

.testimonial-rating:not(:has(*)) {
    display: none;
}

.testimonial-stars {
    font-size: 1.1rem;
    line-height: 1;
}

.testimonial-source {
    font-size: 0.85rem;
    opacity: 0.8;
}

.testimonial-quote {
    position: relative;
    font-size: var(--testimonial-quote-size);
    line-height: 1.5;
    padding-top: 28px;
}

/* Opening quotation mark */
.testimonial-quote::before {
    content: '\201C';
    position: absolute;
    top: -8px;
    left: -4px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 4rem;
    line-height: 1;
    color: var(--testimonial-mark-clr);
    opacity: 0.6;
}

/* Author: photo on the left, name and role stacked next to it */
.testimonial-author,
.testimonial-author > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-auto-rows: min-content;
    align-items: center;
    column-gap: 14px;
    row-gap: 2px;
    margin-top: auto;
}

/* Photo: GB 1 image (figure > img) or GB 2 media (img) */
.testimonial-author figure,
.testimonial-author > img,
.testimonial-author [data-type="generateblocks/image"] {
    grid-row: 1 / span 2;
    margin: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
}

.testimonial-author img {
    display: block;
    object-fit: cover;
}

.testimonial-author figure img {
    width: 100%;
    height: 100%;
}

.testimonial-name,
.testimonial-role {
    grid-column: 2;
    margin: 0;
}

/* Without a photo the texts take the first column */
.testimonial-author:not(:has(figure, img)) .testimonial-name,
.testimonial-author:not(:has(figure, img)) .testimonial-role {
    grid-column: 1 / -1;
}

.testimonial-name {
    font-weight: 600;
    align-self: end;
}

.testimonial-role {
    font-size: 0.9rem;
    opacity: 0.8;
    align-self: start;
}

/* ---- Single big quote ---- */
.testimonials--single .testimonial {
    padding: 0;
    background: none;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    align-items: center;
}

.testimonials--single .testimonial-quote {
    font-size: clamp(1.4rem, 1.1rem + 1.5vw, 2.2rem);
    line-height: 1.4;
    padding-top: 60px;
}

.testimonials--single .testimonial-quote::before {
    left: 50%;
    transform: translateX(-50%);
    font-size: 6rem;
    top: 0;
}

/* Centered author: photo and name side by side, role below */
.testimonials--single .testimonial-author,
.testimonials--slider .testimonial-author,
.testimonials--single .testimonial-author > .block-editor-inner-blocks > .block-editor-block-list__layout,
.testimonials--slider .testimonial-author > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 14px;
}

.testimonials--single .testimonial-rating,
.testimonials--slider .testimonial-rating {
    justify-content: center;
}

.testimonials--single .testimonial-name,
.testimonials--slider .testimonial-name {
    flex: 0 0 auto;
    align-self: center;
}

.testimonials--single .testimonial-role,
.testimonials--slider .testimonial-role {
    flex-basis: 100%;
    text-align: center;
}

/* ---- Slider. Swiper's own CSS sets margin: auto on .swiper, which lets
   a flex child shrink to its content (all slides side by side); the row must
   keep the full width. Slides are full width, their content is capped. ---- */
.testimonials--slider.swiper {
    display: block;
    position: relative;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.testimonials--slider .swiper-wrapper {
    display: flex;
}

.testimonials--slider .testimonial {
    flex: 0 0 100%;
    width: 100%;
    max-width: none;
    margin: 0;
    text-align: center;
    align-items: center;
    background: none;
    padding: 0 0 20px;
}

.testimonials--slider .testimonial > * {
    width: 100%;
    max-width: 800px;
}

/* The slider clips overflow, so the quotation mark sits inside the quote box */
.testimonials--slider .testimonial-quote {
    font-size: clamp(1.3rem, 1rem + 1.2vw, 2rem);
    line-height: 1.4;
    padding-top: 60px;
}

.testimonials--slider .testimonial-quote::before {
    left: 50%;
    transform: translateX(-50%);
    font-size: 6rem;
    top: 0;
}

.testimonials--slider .swiper-nav {
    margin-top: 20px;
}

.testimonials--slider .swiper-nav .swiper-button-prev,
.testimonials--slider .swiper-nav .swiper-button-next {
    box-shadow: none;
}

/* Editor: slides stacked, no Swiper */
.editor-styles-wrapper .testimonials--slider .swiper-wrapper,
.testimonials--slider .swiper-wrapper > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media only screen and (min-width: 768px) {
    .testimonial {
        flex-basis: calc((100% - var(--testimonials-gap)) / 2);
    }

    .testimonials--single .testimonial {
        flex-basis: 100%;
    }
}

@media only screen and (min-width: 990px) {
    .testimonial {
        flex-basis: calc((100% - 2 * var(--testimonials-gap)) / 3);
    }

    .testimonials--single .testimonial {
        flex-basis: 100%;
    }
}
