
.testimonials__layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}
.testimonials__left {
  text-align: center;
  max-width: 620px;
}

.testimonials__right {
  position: relative;
  width: min(1500px, 96vw);
  perspective: 1100px;
}

.tm-rows {
  display: flex;
  flex-direction: column;
  gap: 24px;
  transform-style: preserve-3d;

  transform: rotateX(16deg) rotateY(-7deg);
}

.tm-row {
  position: relative;
  overflow: hidden;

  -webkit-mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent);
}

.tm-row__track {
  display: flex;
  flex-direction: row;
  width: max-content;
  align-items: stretch;
}

.tm-row .testimonial-card {
  width: 640px;
  flex: 0 0 640px;
  margin-right: 28px;
  height: auto;
  padding: 38px 44px;
  cursor: pointer;
}
.tm-row .testimonial-card__content {
  font-size: 1.05rem;
  margin-bottom: 20px;
  /* limita a prévia; o texto completo abre no modal ao clicar */
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* no modal, mostra o depoimento completo */
.tm-modal .testimonial-card__content {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.tm-row .testimonial-card:hover {
  transform: none;
}
.tm-row .testimonial-card__stars { margin-bottom: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .tm-row__track {
    animation: tmScrollX var(--tm-duration, 75s) linear infinite;
    will-change: transform;
  }

  .tm-row--rev .tm-row__track { animation-direction: reverse; }

  .tm-row:hover .tm-row__track { animation-play-state: paused; }

  body.tm-modal-open .tm-row__track { animation-play-state: paused; }
}

@keyframes tmScrollX {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .tm-row {
    overflow-x: auto;
    -webkit-mask-image: none;
            mask-image: none;
  }
}

.tm-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 13, 13, 0.6);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.tm-modal.open { opacity: 1; visibility: visible; }

/* trava a rolagem da página atrás enquanto o depoimento está aberto */
body.tm-modal-open { overflow: hidden; }

/* avatar sem foto: mostra a inicial do nome */
.testimonial-card__initial {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--red);
  background: rgba(198, 28, 28, 0.10);
}

.tm-modal__inner {
  position: relative;
  width: 100%;
  max-width: 540px;
  /* nunca ultrapassa a altura da tela (desconta o padding de 24px do overlay) */
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  transform: scale(0.92) translateY(8px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.tm-modal.open .tm-modal__inner { transform: scale(1) translateY(0); }

/* o corpo rola internamente quando o depoimento é longo */
.tm-modal__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 18px;
}

.tm-modal .testimonial-card {
  height: auto;
  padding: 40px;
  cursor: default;
  border-color: var(--red);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.tm-modal .testimonial-card:hover { transform: none; }
.tm-modal .testimonial-card__content { font-size: 1.05rem; }

.tm-modal__close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.tm-modal__close:hover { transform: scale(1.1) rotate(90deg); }

@media (max-width: 767px) {
  .testimonials__right {
    width: 100%;
    perspective: 900px;
  }
  .tm-rows {
    gap: 14px;
    align-items: center;
    /* mantém a inclinação 3D do desktop ("um pouco de lado") */
    transform: rotateX(14deg) rotateY(-7deg);
  }

  /* Duas fileiras deslizando de lado (sentidos opostos) — mesmo estilo do desktop */
  .tm-rows .tm-row { display: none; }
  .tm-rows .tm-row:nth-child(-n+2) {
    display: block;
    width: 100%;
    /* mantém a máscara horizontal padrão (fade nas laterais) */
  }
  .tm-rows .tm-row:nth-child(-n+2) .tm-row__track {
    flex-direction: row;
    width: max-content;
  }
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card {
    width: min(78vw, 380px);   /* menor */
    flex: 0 0 auto;
    margin-right: 14px;
    margin-bottom: 0;
    padding: 14px 18px;        /* menor / menos alto */
  }
  /* menos alto: prévia de 3 linhas (o resto abre no modal ao tocar) */
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card__content {
    font-size: 0.86rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
  }
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card__stars { margin-bottom: 6px; }
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card__quote {
    font-size: 1.5rem;
    margin-bottom: 2px;
  }
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card__sep { margin-bottom: 10px; }
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card__avatar { width: 38px; height: 38px; }
  /* cargo/empresa em 1 linha, p/ não esticar o card */
  .tm-rows .tm-row:nth-child(-n+2) .testimonial-card__author span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
  }

  /* passa mais rápido no celular; a 2ª fileira num ritmo diferente pra não sincronizar */
  .tm-rows .tm-row:nth-child(-n+2) .tm-row__track {
    animation-duration: 30s;
  }
  .tm-rows .tm-row:nth-child(2) .tm-row__track {
    animation-duration: 38s;
  }

  /* modal ocupa a largura útil e o card fica menos "gordo" no celular */
  .tm-modal { padding: 16px; }
  .tm-modal__inner {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
  }
  .tm-modal .testimonial-card {
    padding: 26px 22px;
  }
  /* celular: largura padrão, a LETRA diminui (--tm-fs do JS) nos textos longos */
  .tm-modal .testimonial-card__content { font-size: var(--tm-fs, 0.95rem); }
}
