/* F6c/F6d/F6e — public testimonials ("Cảm nhận") carousel.
   Uniform 4:3 cards (text or image), responsive visible counts on the F5 breakpoints
   (desktop 3-up edge-to-edge (max 3, CR1/F10f), tablet 2-up, phone 1-up + ~15% peek down to 360px), horizontal
   scroll-snap, autoplay/pause controls, and a "read more" modal for long text. Server-rendered and
   usable without JS; the script only enhances snap/autoplay/modal. Themed to the dark .cam-nhan teal. */

.cam-nhan {
  --tc-gap: 24px;
  --tc-visible: 3;
  --tc-slide-width: calc((100% - (var(--tc-visible) - 1) * var(--tc-gap)) / var(--tc-visible));
  --tc-border: var(--color-inverse-line);
  /* a surface role (halfway between inverse and inverse-raised), never a text role */
  --tc-surface: color-mix(in srgb, var(--color-inverse) 50%, var(--color-inverse-raised));
  /* fade zone above the overlay text; also the overlay top padding, so no text sits in the fade */
  --tc-overlay-fade: 34px;
  --tc-ink: var(--color-on-inverse);
}

/* ---- Single-item (centred static card, no track/controls) ---- */
.tc-single {
  margin-top: 44px;
  display: flex;
  justify-content: center;
}

.tc-single .tc-card {
  width: 100%;
  max-width: 460px;
}

/* ---- Carousel shell ---- */
.tc-carousel {
  margin-top: 44px;
  position: relative;
}

.tc-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--tc-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

.tc-track::-webkit-scrollbar {
  display: none;
}

.tc-slide {
  flex: 0 0 var(--tc-slide-width);
  scroll-snap-align: start;
  min-width: 0;
}

/* ---- Card (shared) ---- */
.tc-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  height: 100%;
}

.tc-card__box {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--tc-border);
  background: var(--tc-surface);
  border-radius: var(--radius-m, 6px);
}

/* ---- Text card ---- */
.tc-card--text .tc-card__box {
  display: flex;
  flex-direction: column;
  padding: 28px 26px;
}

.tc-quote-mark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 54px;
  line-height: 0.6;
  color: var(--color-on-inverse-accent);
  margin-bottom: 8px;
}

.tc-quote {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 19px;
  line-height: 1.5;
  color: var(--tc-ink);
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  /* Visual truncation to fit the 4:3 box; the full quote stays in the DOM (crawlable / no-JS safe). */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.tc-who {
  display: block;
  margin-top: 14px;
  font-size: 14px;
  color: var(--color-on-inverse-accent);
  flex: 0 0 auto;
}

.tc-readmore {
  align-self: flex-start;
  margin-top: 10px;
  padding: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-on-inverse-accent);
  color: var(--color-on-inverse-accent);
  font-size: 13px;
  cursor: pointer;
  flex: 0 0 auto;
}

.tc-readmore:hover,
.tc-readmore:focus-visible {
  color: var(--tc-ink);
  border-bottom-color: var(--tc-ink);
}

/* ---- Image card (crop-to-fill; attribution + caption overlaid inside the 4:3 box) ---- */
.tc-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Overlay sits over the image, anchored to the bottom of the 4:3 box, with a bottom-up teal scrim so
   both lines stay legible over light or busy photos. Does not affect the box's aspect ratio. */
.tc-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: var(--tc-overlay-fade, 34px) 22px 16px;
  /* The overlay box is exactly the text block plus its padding. The gradient fades over the top padding
     (--tc-overlay-fade, the same value) and reaches the solid >= .80 text scrim 6px BEFORE the text starts (stacked Vietnamese diacritics rise above the first line), so the caption and
     attribution, of any length or none, always sit on the full scrim. */
  background: linear-gradient(
    to bottom,
    transparent 0,
    var(--color-photo-scrim-text) calc(var(--tc-overlay-fade, 34px) - 6px),
    var(--color-photo-scrim-text) 100%
  );
  color: var(--tc-ink);
  text-shadow: var(--shadow-text-on-photo);
}

.tc-overlay__attribution {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-on-inverse-accent);
  line-height: 1.3;
}

.tc-overlay__caption {
  font-size: 13px;
  line-height: 1.35;
  color: var(--color-on-inverse);
}

/* ---- Controls (revealed by JS) ---- */
.tc-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.tc-controls[hidden] {
  display: none;
}

.tc-nav,
.tc-playpause {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--tc-border);
  background: var(--tc-surface);
  color: var(--tc-ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tc-nav:hover,
.tc-playpause:hover,
.tc-nav:focus-visible,
.tc-playpause:focus-visible {
  border-color: var(--color-on-inverse-accent);
  color: var(--color-on-inverse-accent);
}

/* Play/pause glyph: two bars (pause) by default; a triangle when paused (aria-pressed=true). */
.tc-playpause__icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: var(--tc-icon-pause);
  mask: var(--tc-icon-pause);
}

.tc-carousel {
  --tc-icon-pause: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14'/%3E%3Crect x='14' y='5' width='4' height='14'/%3E%3C/svg%3E");
  --tc-icon-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolygon points='7,5 19,12 7,19'/%3E%3C/svg%3E");
}

.tc-playpause[aria-pressed="true"] .tc-playpause__icon {
  -webkit-mask: var(--tc-icon-play);
  mask: var(--tc-icon-play);
}

/* ---- Read-more modal ---- */
.tc-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tc-modal[hidden] {
  display: none;
}

.tc-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-scrim);
}

.tc-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--color-inverse);
  color: var(--tc-ink);
  border: 1px solid var(--tc-border);
  border-radius: var(--radius-m, 6px);
  padding: 32px 30px;
}

.tc-modal__title {
  margin: 0 0 16px;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-on-inverse-accent);
}

.tc-modal__close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--tc-ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.tc-modal__close:hover,
.tc-modal__close:focus-visible {
  color: var(--color-on-inverse-accent);
}

.tc-modal__quote {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 22px;
  line-height: 1.55;
  margin: 0;
  white-space: pre-line;
}

.tc-modal__who {
  display: block;
  margin-top: 18px;
  font-size: 15px;
  color: var(--color-on-inverse-accent);
}

/* ---- Responsive visible counts (F5 breakpoints) ---- */
@media (max-width: 991.98px) {
  .cam-nhan {
    --tc-visible: 2;
  }
}

@media (max-width: 767.98px) {
  .cam-nhan {
    --tc-gap: 16px;
  }

  /* 1-up + ~15% peek of the next card. */
  .tc-slide {
    flex-basis: 85%;
  }

  .tc-quote {
    font-size: 18px;
  }

  .cam-nhan {
    --tc-overlay-fade: 28px;
  }

  .tc-overlay {
    padding: var(--tc-overlay-fade, 28px) 16px 14px;
  }
}

/* ---- Reduced motion: no smooth auto-scrolling; JS also suppresses autoplay. ---- */
@media (prefers-reduced-motion: reduce) {
  .tc-track {
    scroll-behavior: auto;
  }
}
