/* ===================================
   BRANDS SECTION
   brands.css
   Matches categories.css design pattern exactly:
   white section bg, flat gray tiles, title-left/link-right header.
   Slider: 6 visible on desktop, 3 on tablet, 4 on mobile,
   with prev/next controls in the section header.
   =================================== */

section.brands.section {
  padding: var(--space-20) 0;
  background: var(--color-white);
  position: relative;
  overflow: hidden;
}

section.brands .container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* ===================================
   SECTION HEADER - title left, actions right
   =================================== */
section.brands .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  text-align: left;
  margin-bottom: var(--space-12);
}

section.brands .section-header-text {
  flex: 1;
}

section.brands .section-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-dark);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

section.brands .section-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--color-text-light);
  margin: 0;
  max-width: 600px;
  line-height: 1.6;
}

/* Header actions wrapper: prev/next + View All link, all in one row */
section.brands .section-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

section.brands .section-header-link.btn-outline {
  flex-shrink: 0 !important;
  align-self: center !important;
  min-height: 2.75rem !important;
  max-height: 2.75rem !important;
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  padding: 0 2rem !important;
  font-family: var(--font-body) !important;
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  border: none !important;
  border-radius: 0.625rem !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  transform: none !important;
  transition: background-color 0.2s ease !important;
  background: #f0f1f3 !important;
  color: #16181d !important;
}

section.brands .section-header-link.btn-outline:hover {
  background: #e5e7ea !important;
  color: #16181d !important;
  transform: none !important;
  box-shadow: none !important;
}

section.brands .section-header-link svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0 !important;
}

/* ===================================
   NAV BUTTONS (prev/next) - flat pill, same row as title
   =================================== */
section.brands .brands-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  min-width: 3rem;
  min-height: 3rem;
  max-width: 3rem;
  max-height: 3rem;
  box-sizing: border-box;
  padding: 0;
  border: none;
  border-radius: 0.625rem;
  background: #f0f1f3;
  color: #16181d;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  box-shadow: none;
}

section.brands .brands-nav-btn:hover:not(:disabled) {
  background: #e5e7ea;
}

section.brands .brands-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

section.brands .brands-nav-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ===================================
   BRANDS SLIDER
   =================================== */
section.brands .brands-slider-wrap {
  position: relative;
}

section.brands .brands-slider {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  /* Hide scrollbar across browsers */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

section.brands .brands-slider::-webkit-scrollbar {
  display: none;
}

section.brands .brands-track {
  display: flex;
  gap: var(--space-4);
  margin: 0 auto;
}

/* ===================================
   BRAND CARD - flat tile, matches category-card
   Sized so exactly 4 / 3 / 6 are visible per breakpoint below.
   (4 on mobile, 3 on tablet, 6 on desktop)
   =================================== */
section.brands .brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 calc((100% - (var(--space-4) * 3)) / 4);
  scroll-snap-align: start;
  background: #f0f1f3;
  border-radius: 18px;
  padding: 1rem 0.75rem;
  text-decoration: none;
  box-shadow: none;
  border: none;
  transition: background-color 0.2s ease;
}

section.brands .brand-card:hover {
  background: #e5e7ea;
}

@media (min-width: 640px) {
  section.brands .brand-card {
    flex: 0 0 calc((100% - (var(--space-4) * 2)) / 3);
  }
}

@media (min-width: 1024px) {
  section.brands .brands-track {
    gap: var(--space-6);
  }

  section.brands .brand-card {
    flex: 0 0 calc((100% - (var(--space-6) * 5)) / 6);
  }
}

section.brands .brand-card__image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 0.625rem;
}

section.brands .brand-card__image {
  max-width: 75%;
  max-height: 75%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 0;
}

/* Fallback text-only tile when a brand has no logo image */
section.brands .brand-card__name-fallback {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text-dark);
  text-align: center;
}

section.brands .brand-card__name {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text-dark);
  text-align: center;
  line-height: 1.3;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 768px) {
  section.brands.section {
    padding: 1.5rem 0 !important;
  }

  /* Keep title-left / actions-right row layout, just smaller */
  section.brands .section-header {
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem !important;
  }

  section.brands .section-header-text {
    min-width: 0;
  }

  section.brands .section-title {
    font-size: 1.125rem;
    margin: 0 0 0.125rem;
    white-space: nowrap;
  }

  section.brands .section-subtitle {
    font-size: 0.8125rem;
  }

  section.brands .section-header-actions {
    gap: 0.375rem;
  }

  /* Smaller nav buttons on mobile */
  section.brands .brands-nav-btn {
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    min-height: 2rem !important;
    max-width: 2rem !important;
    max-height: 2rem !important;
    border-radius: 0.5rem;
  }

  section.brands .brands-nav-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Smaller "View All Brands" button on mobile */
  section.brands .section-header-link.btn-outline {
    padding: 0 0.625rem !important;
    font-size: 0.6875rem !important;
    min-height: 2rem !important;
    max-height: 2rem !important;
    gap: 0.1875rem !important;
    border-radius: 0.5rem !important;
  }

  section.brands .section-header-link svg {
    width: 12px !important;
    height: 12px !important;
  }
}

/* True mobile only (below tablet breakpoint): 4 cards per row, tighter gap */
@media (max-width: 639px) {
  section.brands .brands-track {
    gap: var(--space-2);
  }

  section.brands .brand-card {
    flex: 0 0 calc((100% - (var(--space-2) * 3)) / 4);
    padding: 0.625rem 0.375rem;
  }

  section.brands .brand-card__name,
  section.brands .brand-card__name-fallback {
    font-size: 0.6875rem;
  }
}

@media (max-width: 480px) {
  section.brands.section {
    padding: 1.25rem 0 !important;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  section.brands .brand-card,
  section.brands .brands-nav-btn {
    transition: none;
  }

  section.brands .brands-slider {
    scroll-behavior: auto;
  }
}