/**
 * Tala Cosmetics — Homepage product train (infinite horizontal carousel)
 */

/* ===== Section header ===== */
.tala-product-train {
  padding: clamp(36px, 6vw, 64px) 0 clamp(48px, 8vw, 72px);
  background: linear-gradient(180deg, #fff9f3 0%, #faf6f1 100%);
  position: relative;
  overflow: hidden;
  margin-top: 0;
}

.tala-product-train__inner {
  width: min(100% - clamp(16px, 4vw, 32px), 1280px);
  max-width: 100%;
  margin-inline: auto;
  padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
}

.tala-product-train__head {
  text-align: center;
  margin-bottom: clamp(24px, 4vw, 36px);
  padding-top: max(8px, env(safe-area-inset-top));
}

.tala-product-train__title {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 4.5vw, 2.1rem);
  font-weight: 900;
  color: #781323;
  line-height: 1.25;
}

.tala-product-train__subtitle {
  margin: 0 auto 16px;
  max-width: 36ch;
  font-size: clamp(0.92rem, 2.4vw, 1.05rem);
  line-height: 1.7;
  color: #8a6f66;
  font-weight: 600;
}

.tala-product-train__ornament {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.tala-product-train__rail {
  display: block;
  width: min(120px, 28vw);
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #62632d, #941a2e, #62632d);
}

.tala-product-train__dots {
  display: block;
  width: min(200px, 50vw);
  height: 6px;
  background-image: radial-gradient(circle, #941a2e 2px, transparent 2px);
  background-size: 14px 6px;
  background-position: center;
  opacity: 0.45;
}

/* ===== Train viewport ===== */
.tala-train {
  position: relative;
  margin-inline: calc(-1 * max(12px, env(safe-area-inset-left)));
  padding-inline: 0;
}

.tala-train__viewport {
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 6%,
    #000 94%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 6%,
    #000 94%,
    transparent 100%
  );
}

.tala-train__viewport--manual {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  direction: ltr;
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 5%,
    #000 95%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 5%,
    #000 95%,
    transparent 100%
  );
}

.tala-train__viewport--manual::-webkit-scrollbar {
  display: none;
}

.tala-train__viewport--manual .tala-train__track {
  animation: none !important;
  transform: none !important;
}

html[dir="rtl"] .tala-product-train .product-card {
  direction: rtl;
}

.tala-train__track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: talaTrainMarquee var(--tala-train-duration, 38s) linear infinite;
}

.tala-train__track.is-paused {
  animation-play-state: paused;
}

.tala-train__group {
  display: flex;
  gap: clamp(14px, 2.5vw, 20px);
  padding-inline: clamp(12px, 3vw, 20px);
  flex-shrink: 0;
}

html[dir="rtl"] .tala-train__track {
  animation-name: talaTrainMarqueeRtl;
}

@keyframes talaTrainMarquee {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-50%, 0, 0); }
}

@keyframes talaTrainMarqueeRtl {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(50%, 0, 0); }
}

/* ===== Product card ===== */
.tala-product-train .product-card {
  position: relative;
  flex: 0 0 clamp(250px, 24vw, 320px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: clamp(16px, 2.5vw, 20px);
  border: 1px solid rgba(148, 26, 46, 0.1);
  box-shadow: 0 10px 28px rgba(76, 44, 38, 0.08);
  overflow: hidden;
  scroll-snap-align: start;
  min-width: 0;
  height: auto;
  min-height: 100%;
}

.tala-product-train .product-card__link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.tala-product-train .product-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #fbecef, #fff9f2);
  overflow: hidden;
}

.tala-product-train .product-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.tala-product-train .product-card__badges {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  max-width: calc(100% - 70px);
}

.tala-product-train .product-card__badge {
  position: static;
  padding: 5px 10px;
  border-radius: 999px;
  font-family: 'Tajawal', 'Cairo', system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff9f2;
  line-height: 1.2;
  max-width: calc(100% - 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  unicode-bidi: plaintext;
  letter-spacing: 0;
  text-align: center;
}

.tala-product-train .product-card::after {
  display: none !important;
}

.tala-product-train .product-card__badge--new {
  background: linear-gradient(135deg, #62632d, #4f5124);
}

.tala-product-train .product-card__badge--bestseller {
  background: linear-gradient(135deg, #c9a56a, #a88442);
}

.tala-product-train .product-card__badge--exclusive,
.tala-product-train .product-card__badge--discount {
  background: linear-gradient(135deg, #941a2e, #781323);
}

.tala-product-train .product-card__top-actions {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tala-product-train .product-card__share,
.tala-product-train .product-card__wish {
  position: relative;
  z-index: 5;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(148, 26, 46, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: #941a2e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tala-product-train .product-card__wish.wished {
  background: #941a2e;
  color: #fff9f2;
  border-color: transparent;
}

.tala-product-train .product-card__wish.wished svg {
  fill: currentColor;
}

.tala-product-train .product-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 2.5vw, 16px);
  min-width: 0;
  text-align: start;
}

.tala-product-train .product-card__title {
  margin: 0 0 8px;
  min-height: calc(1.4em * 2);
  font-size: clamp(0.92rem, 2.4vw, 1.02rem);
  font-weight: 800;
  line-height: 1.4;
  color: #781323;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  position: relative;
  z-index: 2;
}

.tala-product-train .product-card__desc {
  margin: 0 0 12px;
  font-size: clamp(0.78rem, 2vw, 0.86rem);
  line-height: 1.65;
  color: #786866;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  position: relative;
  z-index: 2;
}

.tala-product-train .product-card__pricing {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}

.tala-product-train .product-card__price {
  font-size: clamp(1.05rem, 2.8vw, 1.2rem);
  font-weight: 900;
  color: #941a2e;
  line-height: 1.2;
  white-space: nowrap;
}

.tala-product-train .product-card__price-old {
  font-size: 0.78rem;
  color: #9a8580;
  text-decoration: line-through;
  white-space: nowrap;
}

.tala-product-train .product-card__discount {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 26, 46, 0.1);
  color: #781323;
}

.tala-product-train .product-card__actions {
  margin-top: auto;
  position: relative;
  z-index: 5;
}

.tala-product-train .product-card__cart {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #941a2e, #781323);
  color: #fff9f2;
  font-size: clamp(0.86rem, 2.2vw, 0.94rem);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.tala-product-train .product-card__cart:hover:not(:disabled) {
  background: linear-gradient(135deg, #781323, #62632d);
}

.tala-product-train .product-card__cart--oos,
.tala-product-train .product-card__cart:disabled {
  background: #eadccd;
  color: #786866;
  cursor: not-allowed;
}

/* Track decoration */
.tala-product-train__track-deco {
  margin-top: clamp(16px, 3vw, 24px);
  padding-inline: clamp(12px, 3vw, 20px);
  opacity: 0.35;
  pointer-events: none;
}

.tala-product-train__track-line {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #62632d 20%, #62632d 80%, transparent);
  margin-bottom: 6px;
}

.tala-product-train__track-line--2 {
  width: 70%;
  margin-inline: auto;
  background: linear-gradient(90deg, transparent, #941a2e 30%, #941a2e 70%, transparent);
}

.tala-product-train__footer {
  text-align: center;
  margin-top: clamp(20px, 4vw, 28px);
}

.tala-product-train__view-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #941a2e, #781323);
  color: #fff9f2;
  font-weight: 800;
  text-decoration: none;
  font-size: 0.95rem;
}

.tala-product-train__empty {
  text-align: center;
  color: #786866;
  padding: 32px 16px;
}

/* Desktop nav (small) */
.tala-train__nav {
  display: none;
}

@media (min-width: 1024px) {
  .tala-train__nav {
    display: grid;
    place-items: center;
    position: absolute;
    top: 42%;
    transform: translateY(-50%);
    z-index: 6;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(148, 26, 46, 0.14);
    background: rgba(255, 255, 255, 0.95);
    color: #941a2e;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(76, 44, 38, 0.1);
  }

  .tala-train__nav--prev {
    inset-inline-end: 4px;
  }

  .tala-train__nav--next {
    inset-inline-start: 4px;
  }

  .tala-train__nav:not([hidden]) {
    display: grid;
  }
}

/* Mobile card width */
@media (max-width: 767px) {
  .tala-product-train .product-card {
    flex: 0 0 min(82vw, 310px);
  }

  .tala-train__viewport {
    touch-action: pan-x pan-y;
  }

  .tala-train__viewport:not(.tala-train__viewport--manual) {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    direction: ltr;
  }

  .tala-train__viewport:not(.tala-train__viewport--manual) .tala-train__track {
    animation: none !important;
  }

  .tala-train__viewport--manual .tala-product-train .product-card,
  .tala-train__viewport:not(.tala-train__viewport--manual) .product-card {
    scroll-snap-align: center;
  }

  .tala-product-train {
    padding-bottom: calc(var(--mobile-nav-height, var(--tala-dock-h, 64px)) + env(safe-area-inset-bottom, 0px) + 24px);
  }
}

@media (max-width: 360px) {
  .tala-product-train .product-card {
    flex: 0 0 min(88vw, 300px);
  }
}

/* Override legacy index.php / responsive grid rules */
.tala-product-train .products-track,
.tala-product-train .products-carousel-wrap,
.featured-section.tala-product-train::before {
  display: none !important;
}

/* Override legacy index.php featured-section rules */
.featured-section.tala-product-train {
  border-radius: 0;
  overflow: visible;
  margin-top: 0;
  padding: clamp(36px, 6vw, 64px) 0 clamp(48px, 8vw, 72px);
  background: linear-gradient(180deg, #fff9f3 0%, #faf6f1 100%);
}

.featured-section.tala-product-train::before {
  display: none !important;
}

.featured-section.tala-product-train > .container {
  display: none;
}

.tala-product-train .products-carousel-bg,
.tala-product-train .carousel-btn,
.tala-product-train .carousel-dots,
.tala-product-train .carousel-counter {
  display: none !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tala-train__track {
    animation: none !important;
  }

  .tala-train__viewport {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    mask-image: none;
    -webkit-mask-image: none;
  }
}

/* Dark theme */
[data-theme="dark"] .tala-product-train {
  background: linear-gradient(180deg, #140c0c 0%, #1a1010 100%);
}

[data-theme="dark"] .tala-product-train__title {
  color: #f0d5da;
}

[data-theme="dark"] .tala-product-train__subtitle {
  color: #c4a8a8;
}

[data-theme="dark"] .tala-product-train .product-card {
  background: rgba(30, 18, 18, 0.96);
  border-color: rgba(224, 96, 112, 0.15);
}

[data-theme="dark"] .tala-product-train .product-card__title {
  color: #f0d5da;
}
