/**
 * Testimonials: customer quotes. Several side by side as cards, one big
 * quote, or a Swiper slider with fade transition, dots and arrows.
 *
 * globalClass: 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` container around the quotes,
 *                          `swiper-slide` on each quote and a `swiper-nav`
 *                          container with the arrows and pagination (see the
 *                          pattern). js/blocks/testimonials.js initializes it.
 *
 * Structure:
 *   .testimonials.gb-container [.testimonials--slider.swiper]
 *     [.swiper-wrapper.gb-container]                       (slider only)
 *       .testimonial.gb-container[.wrapper-extra-color][.swiper-slide]
 *         p.testimonial-quote        the quote, no quotation marks needed
 *         .testimonial-author.gb-container
 *           figure > img             optional photo or logo (48px round)
 *           p.testimonial-name       "Etunimi Sukunimi"
 *           p.testimonial-role       "Toimitusjohtaja, Yritys Oy"
 *     [.swiper-nav.gb-container > html: .swiper-button-prev, .swiper-pagination, .swiper-button-next]
 *
 * Tuning: --testimonials-gap (24px), --testimonial-quote-size (fluid),
 *         --testimonial-mark-clr (opening quotation mark color, accent)
 *
 * Chain animations: the row is the chain, quotes animate in order (1…n,
 * fadeInFromDown). 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%;
}

/* Quote card */
.testimonial {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1 1 100%;
    min-width: 0;
    padding: 32px 28px 28px;
    border-radius: var(--card-radius, 12px);
}

.testimonial > * {
    margin: 0;
}

.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;
}

.testimonial-author figure,
.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;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

/* Without a photo the texts take the first column */
.testimonial-author:not(:has(figure)) .testimonial-name,
.testimonial-author:not(:has(figure)) .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-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%;
    }
}
