/**
 * Category page — "הטיפולים" dynamic listing.
 *
 * Cards reuse the exact design of the Treatments Directory (page-197.php)
 * — same class names, restated here because that page defines them inline and
 * they are not available on the category single. Desktop lays every related
 * treatment out in centred rows of up to five, each card a fixed fifth of the
 * row (no slider). Mobile turns the row into the
 * pinned card-stack used on the homepage (#why / #process), driven by
 * assets/js/category-treatments-stack.js; without JS or under reduced-motion
 * the cards simply stack vertically.
 *
 * Loaded by category-treatments-listing.php, only on single dmc_category.
 */

.dmc-cat-treatments {
  direction: rtl;
  font-family: 'Polin', sans-serif;
  padding: 64px 20px 72px;
  position: relative;
}
.dmc-cat-treatments .dmc-container {
  max-width: 1460px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.dmc-cat-treatments__head {
  text-align: center;
  margin: 0 auto 40px;
}
.dmc-cat-treatments__title {
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.15;
  font-weight: 700;
  color: #283565;
  margin: 0;
}

/* Desktop: rows of up to five, centred. Every card is one fifth of the
   row whatever the count (260px at 1440), so one or two treatments no
   longer stretch across the page; a sixth wraps to a centred second row. */
.dmc-cat-treatments__grid {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
  justify-content: center;
}
.dmc-cat-treatments__grid > .dmc-treatment-dir-card {
  flex: 0 0 calc((100% - 4 * 24px) / 5);
  min-width: 0;
}

/* ── Card design (restated from page-197.php) ── */
.dmc-cat-treatments .dmc-treatment-dir-card {
  background: #FFFFFF;
  border: 1px solid #E2EAF2;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(40, 53, 101, 0.03);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.dmc-cat-treatments .dmc-treatment-dir-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(40, 53, 101, 0.07);
}
.dmc-cat-treatments .dmc-treatment-dir-card__img-wrap {
  background-color: #F8FBFE;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* The treatment photo fills the whole top of the card, edge to edge. */
  padding: 0;
  overflow: hidden;
  position: relative;
  flex: 0 0 auto;
}
.dmc-cat-treatments .dmc-treatment-dir-card__img-wrap::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #E2EAF2, transparent);
}
.dmc-cat-treatments .dmc-treatment-dir-card__img-wrap a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.dmc-cat-treatments .dmc-treatment-dir-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.dmc-cat-treatments .dmc-treatment-dir-card:hover .dmc-treatment-dir-card__img {
  transform: scale(1.08);
}
.dmc-cat-treatments .dmc-treatment-dir-card__content {
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1 1 auto;
}

/* Fixed two-line title so every button lands on the same baseline. */
.dmc-cat-treatments .dmc-treatment-dir-card__title {
  font-size: 19px;
  font-weight: 700;
  color: #283565;
  margin: 0 0 18px 0;
  line-height: 1.3;
  height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.dmc-cat-treatments .dmc-treatment-dir-card__title a {
  color: inherit;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dmc-cat-treatments .dmc-treatment-dir-card__btn {
  margin-top: auto;
  background: #087CF5;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 500;
  border-radius: 50px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  flex-direction: row-reverse;
  padding: 10px 18px 10px 10px;
}
.dmc-cat-treatments .dmc-treatment-dir-card__btn:hover {
  background-color: #0660C2;
  box-shadow: 0 4px 15px rgba(8, 124, 245, 0.3);
  transform: translateY(-2px);
}
.dmc-cat-treatments .dmc-treatment-dir-card__btn-icon {
  width: 32px;
  height: 32px;
  background: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex: 0 0 auto;
}
.dmc-cat-treatments .dmc-treatment-dir-card__btn-icon svg {
  display: block;
  transform: scale(0.9);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.dmc-cat-treatments .dmc-treatment-dir-card__btn:hover .dmc-treatment-dir-card__btn-icon svg {
  animation: dmcCatArrowSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes dmcCatArrowSlide {
  0%   { transform: scale(0.9) translateX(0); opacity: 1; }
  49%  { transform: scale(0.9) translateX(-150%); opacity: 0; }
  50%  { transform: scale(0.9) translateX(150%); opacity: 0; }
  100% { transform: scale(0.9) translateX(0); opacity: 1; }
}

/* Empty state */
.dmc-cat-treatments__empty {
  text-align: center;
  color: #283565;
  opacity: 0.7;
  font-size: 16px;
}

/* ── Tablet: rows of three, same rule — a last odd card does not grow ── */
@media (max-width: 991px) {
  .dmc-cat-treatments__grid > .dmc-treatment-dir-card {
    flex: 0 0 calc((100% - 2 * 24px) / 3);
  }
}

/* ── Mobile: plain vertical list by default (JS-off / reduced-motion fallback) ── */
@media (max-width: 767px) {
  .dmc-cat-treatments {
    padding: 40px 16px 48px;
  }
  .dmc-cat-treatments__grid {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 16px;
  }
  .dmc-cat-treatments__grid > .dmc-treatment-dir-card {
    max-width: 100%;
    flex: 0 0 auto;
  }
  .dmc-cat-treatments .dmc-treatment-dir-card__img-wrap { height: 150px; }

  /* Enhanced (JS on, motion allowed): pin the stage and stack the cards.
     JS adds .is-stack, sets the section height (scroll length) and the grid
     height (one card tall). Cards are absolutely stacked and transformed. */
  @media (prefers-reduced-motion: no-preference) {
    /* The category template wraps content in .dmc-category-page-wrapper with
       overflow:hidden, which establishes a scroll container and breaks the
       sticky stage. Switch it to clip-x / visible-y on mobile so no scroll
       container is created (same shape body already uses) and the stage can
       pin. !important + html body to win over the template's own rule. */
    html body .dmc-category-page-wrapper {
      overflow-x: clip !important;
      overflow-y: visible !important;
    }

    /* top clears the 96px fixed site header with ~20px of breathing room. */
    .dmc-cat-treatments.is-stack .dmc-cat-treatments__stage {
      position: -webkit-sticky;
      position: sticky;
      top: 116px;
    }
    .dmc-cat-treatments.is-stack .dmc-cat-treatments__head {
      margin-bottom: 12px;
    }
    .dmc-cat-treatments.is-stack .dmc-cat-treatments__grid {
      position: relative;
      display: block;
    }
    .dmc-cat-treatments.is-stack .dmc-cat-treatments__grid > .dmc-treatment-dir-card {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      width: 100%;
      will-change: transform, opacity;
    }
  }
}
