/* ==========================================================================
   Surf Coast Academy — courses.css
   Catalogue page: compact hero with search, sticky filter bar, course grid,
   "Popular this month" carousel.
   ========================================================================== */

/* Page hero */
.catalogue-hero {
  padding-top: clamp(3rem, 7vw, 6rem);
  padding-bottom: clamp(2.5rem, 5vw, 4rem);
  background: var(--paper-2);
}

.catalogue-hero__grid {
  display: grid;
  gap: var(--space-6);
  align-items: end;
}

.catalogue-hero__title {
  font-size: clamp(2.75rem, 1.5rem + 4.6vw, 5.5rem);  /* a touch smaller than .display so two words fit per line */
  max-width: 17ch;       /* "Find something / worth learning." — two balanced lines */
  text-wrap: balance;
}

.catalogue-hero__copy {
  display: grid;
  gap: var(--space-5);
}

.search {
  position: relative;
}

.search__input {
  padding-left: 3rem;
  padding-right: 3rem;
  background: var(--white);
}

.search__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.125rem;
  height: 1.125rem;
  color: var(--muted);
  pointer-events: none;
}

.search__clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.search__clear svg {
  width: 1rem;
  height: 1rem;
}

.search__clear:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.search.has-value .search__clear {
  display: inline-flex;
}

@media (min-width: 900px) {
  .catalogue-hero__grid {
    grid-template-columns: 7fr 5fr;
    gap: var(--space-8);
  }
}

/* Filter bar */
.filter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: rgba(248, 246, 242, 0.92);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.filter-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 3.75rem;
}

.chips {
  display: flex;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin-left: calc(var(--gutter) * -1);
  padding-left: var(--gutter);
  padding-right: 1.5rem;
  mask-image: linear-gradient(to right, transparent, #000 var(--gutter), #000 calc(100% - 1.5rem), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--gutter), #000 calc(100% - 1.5rem), transparent);
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.9rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.chip:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.filter-bar__sort {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.filter-bar__sort label {
  display: none;
  white-space: nowrap;
}

.filter-bar__sort .input {
  min-height: 2.5rem;
  max-width: 11rem;
  padding: 0 2.25rem 0 0.875rem;
  font-size: 0.875rem;
  background-color: transparent;
  border-color: transparent;
  background-position: right 0.75rem center;
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
}

.filter-bar__sort .input:hover {
  border-color: var(--line-strong);
}

.filter-bar__sort .input:focus {
  border-color: var(--ink);
  box-shadow: none;
}

@media (min-width: 640px) {
  .filter-bar__sort label {
    display: inline;
  }
}

/* Level chips: a fixed group next to the (scrolling) category chips on wide
   screens, their own scrolling row underneath on narrow ones. */
@media (min-width: 1100px) {
  .chips--levels {
    flex: none;
    overflow: visible;
    margin-left: 0;
    padding-left: 0.75rem;
    padding-right: 0;
    border-left: 1px solid var(--line);
    mask-image: none;
    -webkit-mask-image: none;
  }
}

@media (max-width: 1099px) {
  .filter-bar__inner {
    flex-wrap: wrap;
    row-gap: 0;
    padding-bottom: 0.5rem;
  }

  .chips:not(.chips--levels) {
    flex: 1 1 100%;   /* categories: their own (scrolling) row */
  }

  .chips--levels {
    order: 3;
    flex: 1 1 auto;   /* second row, with the sort control on its right */
  }

  .filter-bar__sort {
    order: 4;
  }
}

/* Results header */
.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--muted);
}

.results-head strong {
  color: var(--ink);
  font-weight: 600;
}

/* Course grid */
.course-grid {
  display: grid;
  gap: clamp(2rem, 4vw, 3rem) var(--space-5);
}

.course-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;   /* media, then a body that stretches — footers line up across the row */
  gap: var(--space-4);
  align-content: start;
  opacity: 0;
  transform: translateY(10px);
  animation: card-in var(--dur-slow) var(--ease-out) forwards;
}

.course-card:nth-child(2) { animation-delay: 40ms; }
.course-card:nth-child(3) { animation-delay: 80ms; }
.course-card:nth-child(4) { animation-delay: 120ms; }
.course-card:nth-child(5) { animation-delay: 160ms; }
.course-card:nth-child(6) { animation-delay: 200ms; }
.course-card:nth-child(n+7) { animation-delay: 240ms; }

@keyframes card-in {
  to {
    opacity: 1;
    transform: none;
  }
}

.course-card__media {
  border-radius: var(--radius-sm);
}

.course-card:hover .course-card__media img {
  transform: scale(1.04);
}

.course-card__body {
  display: flex;            /* a column: the footer's margin-top:auto pushes it to the bottom */
  flex-direction: column;
  gap: 0.5rem;
}

.course-card__eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.course-card__title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.course-card__title a:hover {
  color: var(--accent-ink);
}

.course-card__instructor {
  font-size: var(--text-sm);
  color: var(--muted);
}

.course-card__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
}

@media (min-width: 640px) {
  .course-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .course-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Empty state */
.empty {
  display: none;
  padding: clamp(3rem, 6vw, 5rem) 0;
  text-align: left;
  max-width: 40ch;
}

.empty.is-visible {
  display: block;
}

.empty__title {
  margin-bottom: 0.5rem;
}

.empty p {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* Popular carousel */
.popular {
  overflow: hidden;
  border-top: 1px solid var(--line);
}

.popular__head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.popular .swiper {
  overflow: visible;
}

.popular .swiper-slide {
  width: clamp(280px, 38vw, 480px);
}

.popular-card {
  position: relative;
  display: block;
  color: var(--paper);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--ink);
  aspect-ratio: 4 / 3;
  isolation: isolate;
}

.popular-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1000ms var(--ease-out);
  z-index: -1;
}

.popular-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(12, 12, 10, 0.8) 0%, rgba(12, 12, 10, 0.2) 55%, rgba(12, 12, 10, 0) 80%);
  z-index: -1;
}

.popular-card:hover img {
  transform: scale(1.04);
}

.popular-card__rank {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
}

.popular-card__body {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.25rem;
  display: grid;
  gap: 0.35rem;
}

.popular-card__eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.popular-card__title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.popular-card__meta {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.8);
}

.popular-card__meta strong {
  color: var(--white);
  font-weight: 600;
}

/* Phase 11 QA: 44px tap targets for the filter chips on phones (overrides the 2.5rem above). */
@media (max-width: 600px) and (pointer: coarse) {
  .chip { min-height: 44px; }
}

/* Footer pinned to the bottom of the card so buttons line up across a row */
.course-card__foot { margin-top: auto !important; }
