/**
 * @file
 * Feature slider paragraph carousel for the Save Mo Lives theme.
 *
 * DOM structure produced by paragraph--feature_slider.html.twig /
 * paragraph--feature_slide.html.twig:
 *
 *  .sml-feature-slider[data-sml-feature-slider]
 *    .sml-feature-slider__viewport
 *      .sml-feature-slider__track
 *        .sml-feature-slider__slide[data-sml-slide]  (one per paragraph)
 *          .sml-feature-slider__media   (white card, optional)
 *            img.sml-feature-slider__image
 *          .sml-feature-slider__body
 *            .sml-feature-slider__tags  (optional)
 *            h2.sml-feature-slider__title
 *            .sml-feature-slider__text  (optional, rich HTML)
 *            hr.sml-feature-slider__divider (optional, present when CTA)
 *            .sml-feature-slider__cta   (optional)
 *    .sml-feature-slider__controls  (absent for single-slide)
 *      .sml-feature-slider__nav
 *        button.sml-feature-slider__prev  (plain arrow icon)
 *        .sml-feature-slider__dots[role="tablist"]  (dots injected by JS)
 *        button.sml-feature-slider__next  (plain arrow icon)
 */

/* -------------------------------------------------------------------------
 * Outer section — light background, constrained to page shell width.
 * ------------------------------------------------------------------------- */
.sml-feature-slider {
  position: relative;
  background: var(--sml-white);
  color: var(--sml-black);
  overflow: hidden;
  padding: 0;
}

/* -------------------------------------------------------------------------
 * Viewport: clips the sliding track.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__viewport {
  overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Track: flex row that translates horizontally to change the active slide.
 * JS reads .sml-feature-slider__track and sets transform directly.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__track {
  display: flex;
  transition: transform 0.4s ease;
}

/*
 * Drupal wraps field items in .field / .field__items / .field__item divs.
 * The track itself cannot be the field wrapper, so we promote those inner
 * items into the flex context.
 */
.sml-feature-slider__track .field--name-field-slides {
  display: contents;
}

.sml-feature-slider__track .field--name-field-slides .field__item {
  flex: 0 0 100%;
  min-width: 0;
}

/* -------------------------------------------------------------------------
 * Individual slide — full width, padding creates the page-level gutter.
 * Single-column (mobile-first); two-column grid added at 56rem.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__slide {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
  max-width: var(--sml-home-max, 1416px);
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 3.5rem) var(--sml-home-pad, 1.5rem);
  box-sizing: border-box;
}

@media (min-width: 56rem) {
  .sml-feature-slider__slide {
    display: grid;
    grid-template-columns: 55fr 45fr;
    grid-template-rows: auto;
    align-items: start;
    /* Figma: ~166px gutter between the image card and the body column. */
    column-gap: clamp(2rem, 12vw, 166px);
    row-gap: clamp(2rem, 4vw, 3.5rem);
  }
}

/* -------------------------------------------------------------------------
 * Image card — white, rounded, slight shadow.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__media {
  background: var(--sml-white);
  border-radius: 5px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Figma: 683 x 480 card; cap width so the art is not upscaled/oversized. */
  max-width: 683px;
  aspect-ratio: 7 / 5;
  box-sizing: border-box;
}

.sml-feature-slider__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
}

/* -------------------------------------------------------------------------
 * Body column.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

/* -------------------------------------------------------------------------
 * Tags (optional, above title).
 * ------------------------------------------------------------------------- */
.sml-feature-slider__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  font-family: var(--sml-font-code-pro-bold);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sml-black);
}

.sml-feature-slider__tag + .sml-feature-slider__tag::before {
  content: ',\00a0';
}

/* -------------------------------------------------------------------------
 * Title — Code Pro Bold, black, large.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__title {
  margin: 0;
  font-family: var(--sml-font-code-pro-bold);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  line-height: 1.4;
  color: var(--sml-black);
}

/* -------------------------------------------------------------------------
 * Body text — Jost, black; inline links styled per Figma (purple/bold).
 * ------------------------------------------------------------------------- */
.sml-feature-slider__text {
  font-family: var(--sml-font-jost);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--sml-black);
  display: -webkit-box;
  overflow: hidden;
  height: calc(1.5em * 4);
  min-height: calc(1.5em * 4);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.sml-feature-slider__text .text-content {
  display: -webkit-box;
  overflow: hidden;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.sml-feature-slider__text p {
  margin: 0 0 0.75rem;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.sml-feature-slider__text p:last-child {
  margin-bottom: 0;
}

.sml-feature-slider__text a {
  color: var(--sml-purple);
  font-weight: 700;
  text-decoration: underline;
}

.sml-feature-slider__text a:hover,
.sml-feature-slider__text a:focus {
  color: var(--sml-purple);
}

/* -------------------------------------------------------------------------
 * Divider rule — shown when there is a CTA.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__divider {
  border: 0;
  border-top: 2px solid var(--sml-black);
  margin: 0.5rem 0;
}

/* -------------------------------------------------------------------------
 * CTA — relies on global .sml-arrow-link (dark text, orange on hover).
 * No overrides needed for the light background variant.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__cta {
  margin-top: 0.25rem;
}

/* -------------------------------------------------------------------------
 * Controls outer wrapper: follows the viewport so it stays in one fixed
 * position regardless of the active slide's content height.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--sml-home-max, 1416px);
  margin: -0.5rem auto 0;
  padding: 0 var(--sml-home-pad, 1.5rem) 1.75rem;
  background: transparent;
}

@media (min-width: 56rem) {
  .sml-feature-slider > .sml-feature-slider__controls {
    display: grid;
    /* Matches the column layout from .sml-feature-slider__slide. */
    grid-template-columns: 55fr 45fr;
    justify-content: unset;
    column-gap: clamp(2rem, 12vw, 166px);
  }

  .sml-feature-slider > .sml-feature-slider__controls
    .sml-feature-slider__nav {
    grid-column: 2;
  }
}

/* -------------------------------------------------------------------------
 * Nav row: prev arrow | dots | next arrow.
 * It grows with the number of dots and maintains a consistent arrow gap.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  width: 100%;
}

/* -------------------------------------------------------------------------
 * Prev / next arrow buttons — plain icon, no box or border.
 * Icon is a thin line arrow on a 24×24 viewBox.
 * ------------------------------------------------------------------------- */
.sml-feature-slider__arrow {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
  color: var(--sml-black);
  border: 0;
  background: transparent;
}

.sml-feature-slider__arrow svg {
  width: 2.5rem;
  height: 2.5rem;
}

.sml-feature-slider__arrow:hover,
.sml-feature-slider__arrow:focus-visible {
  color: var(--sml-purple);
  outline: none;
}

.sml-feature-slider__arrow:focus-visible {
  outline: 2px solid var(--sml-purple);
  outline-offset: 2px;
}

.sml-feature-slider__arrow:disabled {
  cursor: default;
  opacity: 0.3;
}

/* Dots container. */
.sml-feature-slider__dots {
  display: flex;
  flex: 1 1 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 0.5rem;
}

/*
 * Individual dot button (injected by JS).
 * Inactive: dark outline, transparent fill.
 * Active:   filled orange.
 * Figma size: 16px (1rem).
 */
.sml-feature-slider__dot {
  width: 1rem;
  height: 1rem;
  padding: 0;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
  border: 1.5px solid var(--sml-black);
  border-radius: 50%;
  background: transparent;
}

.sml-feature-slider__dot.is-active {
  border-color: var(--sml-orange);
  background: var(--sml-orange);
}

.sml-feature-slider__dot:focus-visible {
  outline: 2px solid var(--sml-orange);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Text-first layout modifier.
 * Applied when field_image_first is explicitly set to false on the
 * feature_slider paragraph. On mobile the single-column stack is
 * unchanged; on desktop the body column moves left and the image moves
 * right by reversing grid order on both the slide and the controls row.
 * ------------------------------------------------------------------------- */
@media (min-width: 56rem) {
  .sml-feature-slider--text-first .sml-feature-slider__slide {
    grid-template-columns: 45fr 55fr;
  }

  .sml-feature-slider--text-first .sml-feature-slider__media {
    order: 2;
  }

  .sml-feature-slider--text-first > .sml-feature-slider__controls {
    grid-template-columns: 45fr 55fr;
  }

  .sml-feature-slider--text-first
    > .sml-feature-slider__controls
    .sml-feature-slider__nav {
    grid-column: 1;
  }
}

/* -------------------------------------------------------------------------
 * Block wrapper: section heading + carousel.
 * The .sml-section__title inside mirrors the Figma "Current Campaigns" H2
 * (Code Pro Black LC, 40px, centered). Padding only on top so the slider
 * can handle its own internal spacing.
 * ------------------------------------------------------------------------- */
.sml-campaigns,
.sml-featured-program {
  background: var(--sml-white);
  color: var(--sml-black);
}

.sml-campaigns .sml-section__inner,
.sml-featured-program .sml-section__inner {
  padding-top: clamp(2.5rem, 5vw, 4.5rem);
  padding-bottom: 0;
}
