/**
 * Testimonial cards and page — YwpTestimonialBundle.
 *
 * A complete, neutral look, usable the moment list.html.twig is included: white
 * cards on whatever ground the page has, a quote mark, the quote in large type,
 * the author in a footer closed by a hairline.
 *
 * ── The footer at the bottom ───────────────────────────────────────────────────
 *
 * A card is a column whose footer takes `margin-top: auto`, and the cards of a row
 * stretch to the tallest: the authors line up from one card to the next, and a
 * short quote just leaves more room above its footer. Keep that if you restyle.
 *
 * ── Restyling ──────────────────────────────────────────────────────────────────
 *
 * Everything visual is a custom property declared below. Redefine the ones you
 * care about on `.tm-list` / `.tm-view` (or a class you pass as `class`):
 *
 *     .tm-list, .tm-view {
 *         --tm-mark: var(--accent);
 *         --tm-font-quote: var(--font-display);
 *         --tm-surface: var(--white);
 *     }
 *
 * The defaults sit in `:where()`, which weighs nothing, so your rule wins whichever
 * stylesheet loads first. Beyond the properties, override the template.
 */

:where(.tm-list, .tm-view) {
    /* Surfaces and text */
    --tm-surface: #ffffff;
    --tm-ink: #16181d;
    --tm-text: #5b6068;
    --tm-border: rgba(22, 24, 29, 0.08);
    --tm-border-hover: #16181d;
    --tm-hairline: rgba(22, 24, 29, 0.1);
    --tm-mark: #c3c6cc;
    --tm-button-border: rgba(22, 24, 29, 0.2);
    /* Where the carousel buttons sit: center, flex-start or flex-end. */
    --tm-nav-justify: center;

    /* Frame */
    --tm-radius: 22px;
    --tm-padding: 32px;
    --tm-gap: 24px;

    /* Type — the page's fonts by default rather than imposed ones. */
    --tm-font-quote: inherit;
    --tm-font: inherit;
    --tm-font-meta: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --tm-quote-size: 20px;
    --tm-quote-line: 1.4;
    --tm-view-quote-size: clamp(18px, 1.5vw, 20px);

    /* Motion */
    --tm-ease: cubic-bezier(.2, .7, .2, 1);
}

.tm-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- The list -------------------------------------------------------------------- */

.tm-list {
    font-family: var(--tm-font);
}

.tm-list__track {
    display: grid;
    grid-template-columns: repeat(var(--tm-columns, 3), minmax(0, 1fr));
    gap: var(--tm-gap);
}

/* --- A card ---------------------------------------------------------------------- */

.tm-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
    box-sizing: border-box;
    margin: 0;
    padding: var(--tm-padding);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius);
    transition: border-color .35s var(--tm-ease);
}

.tm-card:hover {
    border-color: var(--tm-border-hover);
}

.tm-card__mark,
.tm-view__mark {
    flex: none;
    width: 32px;
    height: 26px;
    color: var(--tm-mark);
}

.tm-card__quote {
    margin: 0;
    font-family: var(--tm-font-quote);
    font-size: var(--tm-quote-size);
    line-height: var(--tm-quote-line);
    font-weight: 400;
    letter-spacing: -0.01em;
    text-wrap: pretty;
    overflow-wrap: anywhere;
    color: var(--tm-ink);
}

.tm-card__quote p {
    margin: 0;
}

.tm-card__more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    margin-top: -6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--tm-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.tm-card__more svg {
    transition: transform .25s var(--tm-ease);
}

.tm-card__more:hover svg {
    transform: translateX(3px);
}

.tm-card__more:focus-visible {
    outline: 2px solid var(--tm-ink);
    outline-offset: 3px;
}

/* The footer: pushed to the bottom of the card (see the header). */
.tm-card__foot {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--tm-hairline);
}

.tm-card__photo {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.tm-card__who {
    display: grid;
    align-content: center;
    gap: 2px;
    min-width: 0;
    /* As tall as a portrait: a card with one and a card without keep the same footer. */
    min-height: 44px;
}

.tm-card__name {
    font-size: 15px;
    font-weight: 500;
    color: var(--tm-ink);
}

.tm-card__role {
    font-family: var(--tm-font-meta);
    font-size: 13px;
    line-height: 1.45;
    color: var(--tm-text);
}

/* --- More cards than columns: a row that slides ---------------------------------- */

.tm-list--slides .tm-list__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.tm-list--slides .tm-list__track::-webkit-scrollbar {
    display: none;
}

.tm-list--slides .tm-list__track:focus-visible {
    outline: 2px solid var(--tm-ink);
    outline-offset: 3px;
}

.tm-list--slides .tm-card {
    flex: 0 0 calc((100% - (var(--tm-columns, 3) - 1) * var(--tm-gap)) / var(--tm-columns, 3));
    min-width: 0;
    scroll-snap-align: start;
}

.tm-list__nav {
    display: flex;
    justify-content: var(--tm-nav-justify);
    gap: 10px;
    padding-top: 28px;
}

/* The script shows the buttons only when the row overflows. */
.tm-list__nav[hidden] {
    display: none;
}

.tm-list__button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--tm-button-border);
    background: none;
    color: var(--tm-ink);
    cursor: pointer;
    transition: background .2s var(--tm-ease), color .2s var(--tm-ease), border-color .2s var(--tm-ease), opacity .2s var(--tm-ease);
}

.tm-list__button:hover:not(:disabled) {
    background: var(--tm-ink);
    border-color: var(--tm-ink);
    color: var(--tm-surface);
}

.tm-list__button:focus-visible {
    outline: 2px solid var(--tm-ink);
    outline-offset: 3px;
}

.tm-list__button:disabled {
    opacity: .35;
    cursor: default;
}

.tm-list__more {
    display: flex;
    justify-content: var(--tm-nav-justify);
    margin: 24px 0 0;
    font-size: 15px;
}

.tm-list__more a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--tm-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.tm-list__more a:hover svg {
    transform: translateX(3px);
}

.tm-list__more svg {
    transition: transform .25s var(--tm-ease);
}

.tm-index__empty {
    margin: 0;
    color: var(--tm-text);
}

@media (max-width: 880px) {
    .tm-list__track {
        grid-template-columns: minmax(0, 1fr);
    }

    /* One at a time, the next one showing at the edge. */
    .tm-list--slides .tm-list__track {
        gap: 12px;
    }

    .tm-list--slides .tm-card {
        flex-basis: min(86%, 420px);
    }
}

@media (max-width: 560px) {
    :where(.tm-list, .tm-view) {
        --tm-padding: 24px;
        --tm-quote-size: 18px;
    }
}

/* --- A testimonial's own page ---------------------------------------------------- */

.tm-view {
    /* About 65 characters a line at the quote's size: a long testimonial stays easy to read. */
    max-width: 36em;
    margin: 0 auto;
    font-family: var(--tm-font);
}

.tm-view__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    font-size: 14px;
    color: var(--tm-text);
    text-decoration: none;
}

.tm-view__back:hover {
    color: var(--tm-ink);
}

.tm-view__figure {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin: 0;
}

.tm-view__mark {
    width: 48px;
    height: 38px;
}

.tm-view__quote {
    margin: 0;
    font-family: var(--tm-font-quote);
    font-size: var(--tm-view-quote-size);
    line-height: 1.65;
    letter-spacing: -0.01em;
    text-wrap: pretty;
    overflow-wrap: anywhere;
    color: var(--tm-ink);
}

.tm-view__quote p {
    margin: 0 0 0.9em;
}

.tm-view__quote p:last-child {
    margin-bottom: 0;
}

.tm-view__foot {
    margin-top: 8px;
}

.tm-view__foot .tm-card__photo {
    width: 56px;
    height: 56px;
}

@media (prefers-reduced-motion: reduce) {
    .tm-card,
    .tm-card__more svg,
    .tm-list__button {
        transition: none;
    }
}
