.testimonials-wrap-5-main-item {
  border-radius: 65px;
  align-items: center;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 42px 50px 52px;
  background: var(--bp-surface);
  overflow: hidden; /* prevent any child from escaping the card */
}

.testimonials-wrap-5-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.testimonials-wrap-5-heading {
  flex: 0 0 auto;
  margin-bottom: 30px;
}

.testimonials-wrap-5-slider {
  flex: 0 1 auto;
}

.testimonials-wrap-5-slide-title {
  width: 100%;
}

.testimonials-wrap-5-slide-title h2 {
  font-size: 42px;
  margin-bottom: 0;
  padding-bottom: 0;
}

.testimonials-wrap-5-layout {
  width: 100%;
  min-width: 0;
}

.testimonials-wrap-5-layout > [class*="col-"] {
  min-width: 0;
}

.testimonials-wrap-5-image-column {
  align-items: center;
  display: flex;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.testimonials-wrap-5-image-frame {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.testimonials-wrap-5-author-frame {
  height: 360px;
  max-width: 260px;
}

.testimonials-wrap-5-author-image,
.testimonials-wrap-5-main-item-book {
  display: block;
  height: calc(100% - 24px);
  max-height: 300px;
  max-width: 100%;
  object-fit: contain;
  position: relative;
  transition: filter 0.3s ease, transform 0.3s ease;
  width: auto;
}

.testimonials-wrap-5-author-image {
  border-radius: 0;
  box-shadow: none;
}

.testimonials-wrap-5-book-frame {
  height: 360px;
  max-width: 260px;
}

/* ---------- Book gallery (the main overflow culprit) ---------- */
.testimonials-wrap-5-book-gallery {
  height: 240px;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: visible; /* allow slight overlap but stay inside parent */
}

.testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
  left: 50%;
  position: absolute;
  top: 0;
  transform: translateX(calc(-50% + var(--book-offset, 0px))) rotate(var(--book-rotation, 0deg));
  height: 220px;
  max-width: 150px;
  width: 100%;
  z-index: calc(10 + var(--book-index, 0));
  /* keep the frame itself from pushing layout */
  will-change: transform;
}

.testimonials-wrap-5-main-item-book {
  border: 6px solid #fff;
  border-radius: 16px;
  box-shadow: 0 7px 7px rgb(0 0 0 / 20%);
  margin: 0 auto;
}

.testimonials-wrap-5-image-frame:hover {
  transform: none;
}

.testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame:hover {
  transform: translateX(calc(-50% + var(--book-offset, 0px))) rotate(var(--book-rotation, 0deg));
  z-index: 30;
}

.testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame:hover .testimonials-wrap-5-main-item-book {
  filter: saturate(1.04);
  transform: scale(1.06);
}

.testimonials-wrap-5-main-item-content {
  display: flex;
  gap: 10px;
  flex-direction: column;
  min-width: 0;
}

.testimonials-wrap-5-main-item h3 {
  font-size: 40px;
  text-align: left !important;
}

.testimonials-wrap-5-main-item h4 {
  font-size: 24px;
  text-align: left !important;
  margin-bottom: 0 !important;
}

.testimonials-wrap-5-main-item p {
  height: 150px;
  overflow-y: auto;
  padding-right: 10px;
  text-align: left !important;
  margin-bottom: 0 !important;
}

.testimonials-wrap-5-main-inner-item h6 {
  font-size: 16px;
  padding: 5px 0;
}

.testimonials-wrap-5-main-inner-item p {
  font-size: 12px;
}

.testimonials-wrap-5-social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.testimonials-wrap-5-social-link {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(25, 44, 54, 0.12);
  display: inline-flex;
  height: 54px;
  justify-content: center;
  padding: 10px;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  width: 54px;
}

.testimonials-wrap-5-social-link img {
  border-radius: 10px;
  display: block;
  height: 42px;
  object-fit: contain;
  width: 42px;
  transition: transform 0.2s ease;
}

.testimonials-wrap-5-social-link:hover img,
.testimonials-wrap-5-social-link:focus-visible img {
  transform: scale(1.12);
}

.testimonials-wrap-5-social-link i {
  font-size: 19px;
}

.testimonials-wrap-5-social-link:hover,
.testimonials-wrap-5-social-link:focus-visible {
  border-color: var(--bp-primary);
  box-shadow: 0 12px 24px rgba(25, 44, 54, 0.2);
  transform: translateY(-2px);
}

.testimonials-wrap-5-social-link:focus-visible {
  outline: 3px solid var(--bp-primary-mid);
  outline-offset: 3px;
}

.testimonials-wrap-5-main-item h2 {
  font-size: 60px;
}

.testimonials-wrap-5 {
  /* min-height: 100vh; */
  overflow: hidden;
  padding: 70px 0 60px;
}

/* ========== Desktop grid (≥992px) ========== */
@media screen and (min-width: 992px) {
  .testimonials-wrap-5-layout {
    display: grid;
    gap: clamp(16px, 2.2vw, 36px);
    grid-template-columns: minmax(140px, 0.75fr) minmax(0, 1.8fr) minmax(140px, 0.75fr);
    margin-left: 0;
    margin-right: 0;
  }

  .testimonials-wrap-5-layout:not(.has-author) {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 0.75fr);
  }

  .testimonials-wrap-5-layout:not(.has-book) {
    grid-template-columns: minmax(140px, 0.75fr) minmax(0, 1fr);
  }

  .testimonials-wrap-5-layout:not(.has-author):not(.has-book) {
    display: block;
  }

  .testimonials-wrap-5-layout > [class*="col-"] {
    width: auto;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }

  .testimonials-wrap-5-image-column,
  .testimonials-wrap-5-main-item-content {
    align-self: center;
  }

  .testimonials-wrap-5-author-frame,
  .testimonials-wrap-5-book-frame {
    width: min(100%, 220px);
    height: clamp(200px, 22vw, 340px);
  }

  .testimonials-wrap-5-author-image,
  .testimonials-wrap-5-main-item-book {
    max-height: calc(clamp(200px, 22vw, 340px) - 24px);
  }

  /* Scale the book offset so it never overflows the column */
  .testimonials-wrap-5-book-gallery {
    height: clamp(200px, 22vw, 260px);
  }

  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    height: clamp(180px, 20vw, 230px);
    max-width: clamp(110px, 12vw, 150px);
    /* scale the original 42px offset down on narrower desktops */
    --book-offset-scale: 1;
    transform: translateX(calc(-50% + (var(--book-offset, 0px) * var(--book-offset-scale)))) 
               rotate(var(--book-rotation, 0deg));
  }

  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame:hover {
    transform: translateX(calc(-50% + (var(--book-offset, 0px) * var(--book-offset-scale)))) 
               rotate(var(--book-rotation, 0deg));
  }
}

/* Critical range that was breaking (992–1150px) */
@media screen and (min-width: 992px) and (max-width: 1150px) {
  .testimonials-wrap-5-main-item {
    padding-left: 24px;
    padding-right: 24px;
  }

  .testimonials-wrap-5-layout {
    grid-template-columns: minmax(110px, 0.6fr) minmax(0, 1.8fr) minmax(110px, 0.6fr);
    gap: 12px;
  }

  .testimonials-wrap-5-layout:not(.has-author) {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 0.6fr);
  }

  .testimonials-wrap-5-layout:not(.has-book) {
    grid-template-columns: minmax(110px, 0.6fr) minmax(0, 1fr);
  }

  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    --book-offset-scale: 0.55; /* much smaller spread */
    max-width: 120px;
  }
}

/* 1024px specific safety (and a bit wider) */
@media screen and (min-width: 992px) and (max-width: 1100px) {
  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    --book-offset-scale: 0.45;
    max-width: 110px;
  }
}

/* Larger desktop – restore fuller offset */
@media screen and (min-width: 1200px) {
  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    --book-offset-scale: 0.85;
  }
}

@media screen and (min-width: 1400px) {
  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    --book-offset-scale: 1;
  }
}

/* ========== Tablet & below ========== */
@media screen and (max-width: 1537px) {
  .testimonials-wrap-5-main-item h3 { font-size: 30px; }
  .testimonials-wrap-5-main-item h4 { font-size: 18px; }
  .testimonials-wrap-5-main-item .p-custom { padding-bottom: 5px; }
  .testimonials-wrap-5-main-inner-item p { font-size: 11px; }
}

@media screen and (max-width: 1441px) {
  .testimonials-wrap-5-main-item h3 { font-size: 25px; }
  .testimonials-wrap-5-main-item h4 { font-size: 16px; }
  .testimonials-wrap-5-main-item .p-custom { padding-bottom: 0; }
  .testimonials-wrap-5-main-inner-item h6 { font-size: 14px; padding: 3px 0 1px; }
  .testimonials-wrap-5-main-inner-item p { font-size: 10px; }
}

@media screen and (max-width: 1367px) {
  .testimonials-wrap-5-main-item h3 { font-size: 20px; }
  .testimonials-wrap-5-main-item h4 { font-size: 15px; }
  .testimonials-wrap-5-main-item-book { max-height: 280px; }
  .testimonials-wrap-5-main-item { padding: 50px 40px 65px; }
  .testimonials-wrap-5-main-item h2 { font-size: 35px; }
}

@media screen and (max-width: 1180px) {
  .testimonials-wrap-5-main-item h2 { font-size: 35px; }
}

@media screen and (max-width: 1024px) {
  .testimonials-wrap-5-main-item-content {
    gap: 10px;
  }

  .testimonials-wrap-5-social-link {
    height: 52px;
    width: 52px;
  }

  .testimonials-wrap-5-social-link img {
    height: 30px;
    width: 30px;
  }

  .testimonials-wrap-5-main-item-book,
  .testimonials-wrap-5-author-image {
    box-shadow: none;
    height: auto;
  }
}

/* Mobile */
@media screen and (max-width: 991.98px) {
  .testimonials-wrap-5-layout {
    display: block; /* fall back to normal Bootstrap stacking */
  }
}

@media screen and (max-width: 768px) {
  .testimonials-wrap-5 {
    min-height: auto;
    padding: 60px 0 50px;
  }

  .testimonials-wrap-5-container {
    min-height: auto;
  }

  .testimonials-wrap-5-heading {
    margin-bottom: 22px;
  }

  .testimonials-wrap-5-main-item {
    display: block;
    padding: 32px 24px 42px;
  }

  .testimonials-wrap-5-slide-title h2 {
    font-size: 30px;
  }

  .testimonials-wrap-5-image-column {
    margin: 14px auto;
  }

  .testimonials-wrap-5-author-frame,
  .testimonials-wrap-5-book-frame {
    height: 220px;
  }

  .testimonials-wrap-5-author-image,
  .testimonials-wrap-5-main-item-book {
    max-height: 220px;
  }

  .testimonials-wrap-5-book-gallery {
    height: 230px;
    max-width: 280px;
    margin: 0 auto;
  }

  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    height: 200px;
    max-width: 130px;
    --book-offset-scale: 0.7;
    transform: translateX(calc(-50% + (var(--book-offset, 0px) * var(--book-offset-scale)))) 
               rotate(var(--book-rotation, 0deg));
  }

  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame:hover {
    transform: translateX(calc(-50% + (var(--book-offset, 0px) * var(--book-offset-scale)))) 
               rotate(var(--book-rotation, 0deg));
  }

  .testimonials-wrap-5-social-links {
    justify-content: center;
  }

  .testimonials-wrap-5-main-item h3,
  .testimonials-wrap-5-main-item h4,
  .testimonials-wrap-5-main-item p {
    text-align: center !important;
  }

  .testimonials-wrap-5-main-item p {
    height: 140px;
  }
}

@media screen and (max-width: 576px) {
  .testimonials-wrap-5-main-item p {
    height: 120px;
  }
}

@media screen and (max-width: 576px) {
  .testimonials-wrap-5-main-item h2 {
    font-size: 22px;
  }

  .testimonials-wrap-5-main-item {
    padding: 28px 18px 36px;
    border-radius: 43px;
  }

  .testimonials-wrap-5-slide-title h2 {
    font-size: 23px;
  }

  .testimonials-wrap-5-author-frame,
  .testimonials-wrap-5-book-frame {
    height: 180px;
  }

  .testimonials-wrap-5-author-image,
  .testimonials-wrap-5-main-item-book {
    max-height: 180px;
  }

  .testimonials-wrap-5-book-gallery {
    height: 200px;
    max-width: 240px;
  }

  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    height: 170px;
    max-width: 110px;
    --book-offset-scale: 0.55;
  }
}

@media screen and (max-width: 400px) {
  .testimonials-wrap-5-book-gallery .testimonials-wrap-5-book-frame {
    --book-offset-scale: 0.4;
    max-width: 95px;
  }
}