horizontal-carousel {
  display: flex;
  position: relative;
  overflow-x: auto;
  width: 100%;
  height: auto;
  min-height: 15rem;
  max-height: 80vh;
  object-fit: contain;
  cursor: pointer;
  border-radius: 10px;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;

  &[show-controls] {
    counter-increment: carousel-counter;
    /* anchor-name: --carousel; SET VIA JS as it must be unique*/
    anchor-name: var(--anchor-name, --carousel);
    scroll-marker-group: after;
    scrollbar-width: none;

    &::scroll-button(left) {
      content: "◄" / "Imagen anterior";
      left: calc(anchor(left) - 2.2rem);
    }

    &::scroll-button(right) {
      content: "►" / "Imagen siguiente";
      right: calc(anchor(right) - 2.2rem);
    }

    &::scroll-button(*) {
      /* position-anchor: --carousel;  SET VIA JS , as it must be unique*/
      position-anchor: var(--anchor-name, --carousel);
      position: absolute;
      align-self: anchor-center;
      background: none;
      border: none;
      padding: 1rem;
      cursor: pointer;
      height: 15rem;
      line-height: 1;
    }

    &::scroll-button(*):focus-visible {
      outline-offset: 0.5rem;
    }

    &::scroll-marker-group {
      display: flex;
      justify-content: center;
      margin-block-start: -0.5rem;
      margin-block-end: 1rem;
      width: min-content;
      margin-inline: auto;
    }

    img {
      &::scroll-marker {
        content: "●";
        height: 1em;
        width: 1em;
        text-decoration: none;
        color: var(--color-green);
        padding: 0.3rem;
      }

      &::scroll-marker:target-current {
        color: var(--color-yellow);
      }
    }
  }

  img {
    scroll-snap-align: center;
    scroll-snap-stop: always;
    object-fit: contain;
    max-width: 100%;
    flex-shrink: 0;
    margin-inline: auto;
    scroll-margin-top: 5rem; /* Ensure event card top is visible */
  }
}

/* The two repeated sections below fail when combined */
carousel-dots {
  display: flex;
  justify-content: center;
  margin-block-start: -0.5rem;
  width: min-content;
  margin-inline: auto;
  font-size: 0.5rem; /* Reduce size to match ::scroll-marker-group */
  z-index: 1;
  max-width: 80vw; /* Prevent overflow on small screens */
  overflow: hidden;

  > * {
    padding: 0.5rem;
    background: none;
    appearance: none;
    display: grid;
    place-content: center;
    text-decoration: none;
  }
}
