/* ==========================================================================
   Master's Touch - Product category cards (scoped component)
   All selectors are prefixed with .mt-pcard* so they can safely coexist with
   legacy styles.css / bootstrap. Do NOT add generic selectors here.
   ========================================================================== */

.mt-pcard-section {
  --mt-pcard-accent: #e90029;
  --mt-pcard-surface: #141414;
  --mt-pcard-border: rgba(255, 255, 255, .08);
  --mt-pcard-radius: 20px;
  --mt-pcard-font: var(--heading-font-family, "Oxanium"), sans-serif;
  padding: 72px 0 96px;
}

/* Flex + centred wrap: an incomplete last row (1, 2, 4, 5... cards) is always
   centred, and every card keeps the exact same width. */
.mt-pcard-grid {
  --mt-pcard-gap: 28px;
  --mt-pcard-cols: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--mt-pcard-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.mt-pcard-grid>li {
  display: flex;
  flex: 0 0 calc((100% - (var(--mt-pcard-cols) - 1) * var(--mt-pcard-gap)) / var(--mt-pcard-cols));
  max-width: calc((100% - (var(--mt-pcard-cols) - 1) * var(--mt-pcard-gap)) / var(--mt-pcard-cols));
  margin: 0;
  padding: 0;
}

/* ---------- card shell ---------- */
.mt-pcard {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  text-decoration: none;
  background: var(--mt-pcard-surface);
  border: 1px solid var(--mt-pcard-border);
  border-radius: var(--mt-pcard-radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
  transition: transform .4s cubic-bezier(.2, .7, .2, 1), border-color .4s ease, box-shadow .4s ease;
}

.mt-pcard:hover,
.mt-pcard:focus-visible {
  color: #fff;
  text-decoration: none;
  border-color: rgba(233, 0, 41, .55);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .55), 0 0 40px rgba(233, 0, 41, .14);
  transform: translateY(-8px);
}

.mt-pcard:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

/* ---------- photo + overlay + title ---------- */
.mt-pcard__media {
  position: relative;
  aspect-ratio: 4 / 3.2;
  overflow: hidden;
  background: #0d0d0d;
}

.mt-pcard__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform .9s cubic-bezier(.2, .7, .2, 1), filter .5s ease;
}

.mt-pcard:hover .mt-pcard__media img,
.mt-pcard:focus-visible .mt-pcard__media img {
  transform: scale(1.08);
}

.mt-pcard__media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to top, rgba(10, 10, 10, .94) 0%, rgba(10, 10, 10, .55) 38%, rgba(10, 10, 10, 0) 70%),
    linear-gradient(to bottom, rgba(0, 0, 0, .35) 0%, rgba(0, 0, 0, 0) 28%);
  pointer-events: none;
}

.mt-pcard__index,
.mt-pcard__tag {
  position: absolute;
  top: 18px;
  z-index: 2;
  font-family: var(--mt-pcard-font);
  line-height: 1;
}

.mt-pcard__index {
  left: 20px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
  color: #fff;
  background: rgba(10, 10, 10, .55);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.mt-pcard__tag {
  right: 20px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  background: var(--mt-pcard-accent);
  border-radius: 6px;
}

.mt-pcard__title {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  z-index: 2;
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-family: var(--mt-pcard-font);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .6);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- optional description ---------- */
.mt-pcard__desc {
  margin: 0;
  padding: 18px 24px 0;
  font-family: var(--body-font-family, "Sarabun"), sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .7);
}

/* ---------- footer bar ---------- */
.mt-pcard__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 16px 24px;
}

.mt-pcard__label {
  font-family: var(--mt-pcard-font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .72);
  transition: color .3s ease;
}

.mt-pcard__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  transition: background-color .3s ease, border-color .3s ease, transform .4s cubic-bezier(.2, .7, .2, 1);
}

.mt-pcard__arrow svg {
  width: 18px;
  height: 18px;
}

.mt-pcard:hover .mt-pcard__label,
.mt-pcard:focus-visible .mt-pcard__label {
  color: #fff;
}

.mt-pcard:hover .mt-pcard__arrow,
.mt-pcard:focus-visible .mt-pcard__arrow {
  background: var(--mt-pcard-accent);
  border-color: var(--mt-pcard-accent);
  transform: translateX(4px) rotate(-45deg);
}

/* red progress line along the bottom edge */
.mt-pcard__line {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  width: 100%;
  height: 3px;
  background: var(--mt-pcard-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}

.mt-pcard:hover .mt-pcard__line,
.mt-pcard:focus-visible .mt-pcard__line {
  transform: scaleX(1);
}

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
  .mt-pcard-section {
    padding: 56px 0 72px;
  }

  .mt-pcard-grid {
    --mt-pcard-cols: 2;
    --mt-pcard-gap: 22px;
  }

  .mt-pcard__title {
    font-size: 21px;
  }
}

@media (max-width: 575.98px) {
  .mt-pcard-section {
    padding: 40px 0 56px;
  }

  .mt-pcard-grid {
    --mt-pcard-cols: 1;
    --mt-pcard-gap: 20px;
  }

  .mt-pcard__title {
    left: 20px;
    right: 20px;
    font-size: 21px;
  }

  .mt-pcard__foot {
    padding: 14px 16px 14px 20px;
  }

  .mt-pcard__desc {
    padding: 16px 20px 0;
  }
}

/* touch screens have no hover: keep the cards calm and tappable */
@media (hover: none) {

  .mt-pcard:hover {
    transform: none;
  }

  .mt-pcard:active {
    border-color: rgba(233, 0, 41, .55);
  }
}

@media (prefers-reduced-motion: reduce) {

  .mt-pcard,
  .mt-pcard__media img,
  .mt-pcard__arrow,
  .mt-pcard__line {
    transition: none;
  }

  .mt-pcard:hover,
  .mt-pcard:focus-visible,
  .mt-pcard:hover .mt-pcard__media img,
  .mt-pcard:focus-visible .mt-pcard__media img,
  .mt-pcard:hover .mt-pcard__arrow,
  .mt-pcard:focus-visible .mt-pcard__arrow {
    transform: none;
  }
}
