/* ============================================================
   Category Carousel — carousel.css
   Slider layout, card styles, controls, dots.  Mobile-first.
   Initialised by assets/js/carousel.js (BFCarousel class).
   ============================================================ */


/* ── Section wrapper ───────────────────────────────────────── */

.category-carousel {
  padding-block: var(--space-24);
  background-color: var(--color-surface);
  overflow: hidden;          /* prevent horizontal scroll leak */
}

.category-carousel__heading {
  margin-bottom: var(--space-12);
}

.category-carousel__wrapper {
  /* extra horizontal breathing room for the controls */
  position: relative;
}


/* ── Carousel root ─────────────────────────────────────────── */

.carousel {
  position: relative;
}


/* ── Viewport (clips the overflowing slides) ───────────────── */

.carousel__viewport {
  overflow: hidden;
  border-radius: var(--radius-lg);
  /* Promote to its own GPU layer so overflow:hidden correctly clips the
     composited track (will-change:transform child) on iOS/Android. */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* On desktop the viewport fills the container */
@media (min-width: 1024px) {
  .carousel__viewport {
    border-radius: 0;
  }
}


/* ── Track (the sliding row of slides) ────────────────────── */

.carousel__track {
  display: flex;
  will-change: transform;
  /* Transition applied only when JS is active (via .js-carousel class) */
}

.carousel.is-animating .carousel__track {
  transition: transform var(--duration-slow) var(--ease-out);
}


/* ── Slides ────────────────────────────────────────────────── */

.carousel__slide {
  /* Default (CSS fallback, no JS): show as auto-fill grid columns */
  flex: 0 0 100%;
  padding-inline: var(--space-3);
  box-sizing: border-box;
}

/* Static grid fallback (no JS) */
.carousel__track:not([style]) .carousel__slide {
  flex: 0 0 calc(33.333% - var(--space-6));
}


/* ── Card ──────────────────────────────────────────────────── */

.carousel__card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--color-white);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition:
    box-shadow  var(--duration-normal) var(--ease-out),
    transform   var(--duration-normal) var(--ease-out);
}

.carousel__card:hover,
.carousel__card:focus-visible {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.carousel__card:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}


/* ── Card image ────────────────────────────────────────────── */

.carousel__image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: var(--color-surface);
  flex-shrink: 0;
}

.carousel__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform var(--duration-slow) var(--ease-out);
}

.carousel__card:hover .carousel__img {
  transform: scale(1.06);
}

.carousel__image-placeholder {
  width: 100%;
  height: 100%;
  background-color: var(--color-surface);
  background-image: linear-gradient(
    135deg,
    var(--color-border) 25%,
    transparent 25%,
    transparent 75%,
    var(--color-border) 75%
  );
  background-size: 20px 20px;
}


/* ── Card content ──────────────────────────────────────────── */

.carousel__content {
  padding: var(--space-6);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.carousel__title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-heading);
  line-height: var(--leading-tight);
  margin: 0;
}

.carousel__tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  flex: 1;
  margin: 0;
}

.carousel__link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  margin-top: var(--space-2);
  display: inline-block;
  transition: color var(--duration-fast);
}

.carousel__card:hover .carousel__link {
  color: var(--color-primary-dark);
}


/* ── Controls (prev/next) ──────────────────────────────────── */

.carousel__controls {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.carousel__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background-color: var(--color-white);
  color: var(--color-heading);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color     var(--duration-fast) var(--ease-out),
    color            var(--duration-fast) var(--ease-out),
    transform        var(--duration-fast) var(--ease-out);
}

.carousel__btn:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-button-text-hover);
}

.carousel__btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.carousel__btn:active {
  transform: scale(0.94);
}

.carousel__btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}


/* ── Dots ──────────────────────────────────────────────────── */

.carousel__dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.carousel__dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  border: none;
  background-color: var(--color-border);
  cursor: pointer;
  padding: 0;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    transform        var(--duration-fast) var(--ease-out);
}

.carousel__dot:hover {
  background-color: var(--color-text-muted);
}

.carousel__dot.is-active,
.carousel__dot[aria-selected="true"] {
  background-color: var(--color-primary);
  transform: scale(1.35);
}

.carousel__dot:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}


/* ── Hero carousel (product category page) ─────────────────── */

/*
 * Full-viewport-width hero variant of the carousel.
 * Activated by adding .carousel--hero to the .carousel root element.
 * Used on single-custom_category.php to replace the static header image.
 *
 * Layout layers (z-index):
 *   1 — slides (images, object-fit: cover)
 *   2 — .carousel__hero-overlay (dark gradient)
 *   3 — .carousel__hero-content (title + tagline)
 *   4 — .carousel__controls / .carousel__dots (interactive)
 */

.carousel--hero {
  position: relative;
  /* Pull up behind the sticky header, same as .hero on the front page */
  margin-top: calc(-1 * var(--header-height-tall));
  /* Fixed viewport height so portrait images are cropped, not expanded */
  height: 100svh;
  overflow: hidden;
  color: var(--color-white);
}

.carousel--hero .carousel__viewport {
  border-radius: 0;
  overflow: hidden;
  height: 100%;             /* fill the fixed height set on .carousel--hero */
}

/* Slides occupy the full viewport height — width determined by image aspect ratio */
.carousel--hero .carousel__slide {
  padding: 0;               /* no inter-slide gap */
  flex: 0 0 auto;           /* slide width = content width (not a fixed fraction) */
  height: 100svh;           /* explicit, independent of cascade */
  position: relative;
}

.carousel--hero .carousel__img {
  width: auto;              /* natural width derived from aspect ratio + height */
  height: 100svh;           /* fill the fixed height; aspect ratio determines width */
  object-fit: contain;
  display: block;
}

/* No-image fallback */
.carousel--hero .carousel__hero-placeholder {
  width: 100%;
  height: 100svh;
  background-color: var(--color-secondary);
}


/* ── Dark gradient overlay ─────────────────────────────────── */

.carousel__hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(26, 26, 46, 0.36) 0%,
    rgba(26, 26, 46, 0.20) 50%,
    rgba(26, 26, 46, 0.38) 100%
  );
  z-index: 2;
  pointer-events: none;
}


/* ── Text content overlay ──────────────────────────────────── */

.carousel__hero-content {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* Top padding ensures the card is never hidden behind the transparent header */
  padding-top: calc(var(--header-height-tall) + var(--space-4));
  pointer-events: none;
}

/* Frosted-glass card: [prev btn] [centered text + cta] [next btn] all on one plane */
.carousel__hero-card {
  max-width: 900px;
  width: 100%;
  margin-inline: auto;
  padding-block: var(--space-12);
  padding-inline: var(--space-6);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

/* Center column — title, tagline, CTA */
.carousel__hero-card-text {
  flex: 1;
  min-width: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.carousel__hero-cta-wrap {
  margin-top: var(--space-2);
}

.carousel__hero-title {
  font-family: var(--font-heading);
  font-size: var(--text-5xl);
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.1;
  margin-bottom: var(--space-4);
  text-shadow: 0 2px 20px rgba(0 0 0 / 0.4);
}

.carousel__hero-tagline {
  font-size: var(--text-xl);
  color: rgba(255 255 255 / 0.88);
  max-width: 560px;
  margin-inline: auto;
  line-height: var(--leading-normal);
  text-shadow: 0 1px 8px rgba(0 0 0 / 0.3);
}


/* ── Controls: inline inside .carousel__hero-card-body ────── */

.carousel--hero .carousel__btn {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  padding: 0;
  background: rgba(255 255 255 / 0.14);
  border: 1px solid rgba(255 255 255 / 0.45);
  color: var(--color-button-text);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 10px 28px rgba(0 0 0 / 0.25);
}

.carousel--hero .carousel__btn .carousel__btn-icon {
  display: flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
}

.carousel--hero .carousel__btn .carousel__btn-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.carousel--hero .carousel__btn:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-button-text-hover);
}


/* ── Responsive adjustments ────────────────────────────────── */

@media (max-width: 768px) {
  .carousel__hero-title {
    font-size: var(--text-4xl);
  }

  .carousel__hero-tagline {
    font-size: var(--text-lg);
  }

  .carousel--hero .carousel__btn {
    width: 44px;
    height: 44px;
  }

  .carousel--hero .carousel__btn .carousel__btn-icon {
    width: 19px;
    height: 19px;
  }
}

@media (max-width: 480px) {
  .carousel__hero-title {
    font-size: var(--text-3xl);
  }

  .carousel__hero-card {
    gap: var(--space-2);
    padding-inline: var(--space-4);
    padding-block: var(--space-8);
  }
}


/* ── Services grid ─────────────────────────────────────────── */
/* (Placed here as it shares the same section rhythm as the carousel) */

.services-grid {
  padding-block: var(--space-24);
}

.services-grid__heading {
  margin-bottom: var(--space-12);
}

.services-grid__list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  list-style: none;
  padding: 0;
  margin: 0;
}

.services-grid__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-8) var(--space-6);
  background-color: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.services-grid__item:hover {
  box-shadow: var(--shadow-md);
}

.services-grid__icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255 69 0 / 0.1);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
  flex-shrink: 0;
}

.services-grid__icon svg {
  width: 28px;
  height: 28px;
}

.services-grid__title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: var(--space-3);
}

.services-grid__text {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  margin: 0;
}

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

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