/*
 * Black Friday / Cyber Monday sale pages (page-blackfriday-v2).
 * Loaded after master.css / sport-category-page.css / allDiscountedCourses.css:
 * replaces the bxSlider carousels with CSS scroll rows (overview) and a grid (sport page).
 * Card markup comes from _layouts/saleCourseCard.html (same classes as courseCard.html).
 * Behaviour: /public/newdesign1/js/sale-page.js.
 */

.sale-courses {
  padding-bottom: 40px;
}

/* Section heading: half of the 30px bottom margin (allDiscountedCourses.css) moved to the top. */
.sale-courses h2.popular_heading {
  margin-top: 15px;
  margin-bottom: 15px;
}

.sale-courses ul.courses {
  list-style: none;
  padding: 0;
}

/* Cards: master.css fixes .carousel_slide at 255px and .course-widget at
   display:inline-block!important; the layout below owns width and spacing. */
.sale-courses .carousel_slide.course-widget {
  width: auto;
  margin: 0;
}

/* [hidden] must beat master.css `.course-widget { display: inline-block!important }`. */
.sale-courses .carousel_slide.course-widget[hidden] {
  display: none !important;
}

.sale-card .course-card-info {
  overflow: hidden;
  border-radius: 5px;
}

/* One image height for S3 banners and legacy thumbs (the inline max-height of courseCard.html). */
.sale-card .course-card-image img {
  display: block;
  width: 100%;
  height: 126px;
  object-fit: cover;
}

/* ---- Columns: whole cards per row, from the width of the white content box ----
   Overview rows and the sport grid share one column count, so cards are always whole and
   flush with both edges. Breakpoint for N columns = N * 245px cards + (N-1) * 20px gaps. */

.sale-courses {
  --sale-cols: 2;
  --sale-gap: 20px;
  container-type: inline-size;
}

@container (max-width: 509px) {
  .sale-courses > * { --sale-cols: 1; }
}

@container (min-width: 775px) {
  .sale-courses > * { --sale-cols: 3; }
}

@container (min-width: 1040px) {
  .sale-courses > * { --sale-cols: 4; }
}

@container (min-width: 1305px) {
  .sale-courses > * { --sale-cols: 5; }
}

/* ---- Overview: one horizontal scroll row per sport ---- */

.sale-courses .sale-sport + .sale-sport {
  margin-top: 50px;
}

.sale-row {
  position: relative;
}

/* ul.sale-row-track: must out-rank `.sale-courses ul.courses { padding: 0 }` above. */
.sale-courses ul.sale-row-track {
  display: flex;
  gap: var(--sale-gap);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  margin: 0;
  /* vertical room for the card hover shadow, which the scroll container clips;
     no horizontal padding: the first card sits flush with the section heading */
  padding: 14px 0 18px;
}

.sale-courses ul.sale-row-track > .course-widget {
  flex: 0 0 calc((100% - (var(--sale-cols) - 1) * var(--sale-gap)) / var(--sale-cols));
  scroll-snap-align: start;
}

.sale-row-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 44px;
  height: 44px;
  margin-top: -24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #383b69;
  font-size: 18px;
  line-height: 44px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.sale-row-arrow.prev {
  left: -56px;
}

.sale-row-arrow.next {
  right: -56px;
}

.sale-row-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

.sale-row-arrow[hidden] {
  display: none;
}

@media (max-width: 991px) {
  .sale-row-arrow.prev {
    left: -14px;
  }

  .sale-row-arrow.next {
    right: -14px;
  }
}

/* Arrow scroll animation in sale-page.js sets scrollLeft every frame:
   snap and CSS smooth scrolling would fight it. */
.sale-row.is-animating .sale-row-track {
  scroll-snap-type: none;
  scroll-behavior: auto;
}

/* Arrows stay visible on touch devices too: with one card per row they are
   the only hint that the row scrolls (swipe works as well). */

/* ---- Sport page: grid + filter ---- */

.sale-courses ul.sale-grid {
  display: grid;
  grid-template-columns: repeat(var(--sale-cols), minmax(0, 1fr));
  gap: var(--sale-gap);
  margin: 0;
}

/* Desktop: match counter on the left, field + buttons on the right. */
.sale-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 25px;
}

.sale-filter-count {
  margin-right: auto;
  color: #494d55;
  font-size: 15px;
  font-weight: bold;
}

.sale-filter-input {
  flex: 0 1 380px;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 15px;
  color: #383b69;
  background: #fff;
}

.sale-filter-input:focus {
  outline: none;
  border-color: #8b8fd7;
  box-shadow: 0 0 0 3px rgba(139, 143, 215, 0.4);
}

.sale-filter-button,
.sale-filter-reset {
  height: 42px;
  padding: 0 24px;
  border-radius: 5px;
  font-size: 15px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
}

.sale-filter-button {
  border: none;
  background: #8b8fd7;
  color: #fff;
}

.sale-filter-button:hover,
.sale-filter-button:focus {
  background: #7479c9;
}

.sale-filter-reset {
  border: 1px solid #8b8fd7;
  background: #fff;
  color: #8b8fd7;
}

.sale-filter-reset:hover,
.sale-filter-reset:focus {
  background: #f1f1fb;
}

.sale-filter-reset[hidden] {
  display: none;
}

.sale-empty {
  margin: 30px 0;
  color: #494d55;
  font-size: 18px;
  text-align: center;
}

@media (max-width: 594px) {
  .sale-filter-input {
    flex-basis: 100%;
  }

  .sale-filter-button,
  .sale-filter-reset {
    flex: 1 1 auto;
  }

  .sale-filter-count {
    order: 1;
    width: 100%;
  }
}
