/* Shared card styles. Load on the front end AND in the block editor. */
.lma-card-carousel {
  --lma-carousel-accent: var(--wp--preset--color--accent-1, #c5143d);
  --lma-carousel-surface: var(--wp--preset--color--base, #fff);
  --lma-carousel-text: var(--wp--preset--color--alter-font, #50524e);
  --lma-carousel-border: #e7e8eb;
  --lma-carousel-gap: 14px;
  --lma-carousel-control-top: 100px;
  position: relative;
  min-width: 0;
  max-width: 100%;
  color: var(--lma-carousel-text);
  font-family: var(--wp--preset--font-family--helvetica-neue-lt-pro, "Helvetica Neue LT Pro", sans-serif);
  font-size: 1rem;
  line-height: 1.35;
  text-align: start;
}

.lma-card-carousel *,
.lma-card-carousel *::before,
.lma-card-carousel *::after {
  box-sizing: border-box;
}

.lma-card-carousel .lma-card-carousel__viewport {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0 0 4px;
  overflow-x: auto; /* Usable fallback when JS or Swiper is unavailable. */
  scrollbar-color: var(--lma-carousel-accent) #dedede;
  scrollbar-width: thin;
}

.lma-card-carousel .lma-card-carousel__track {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: var(--lma-carousel-gap);
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  counter-reset: lma-carousel-card;
}

.lma-card-carousel .lma-card-carousel__card {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-self: stretch;
  width: clamp(200px, calc((100% - 56px) / 5.25), 280px);
  min-width: 0;
  max-width: none;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--lma-carousel-border);
  border-radius: 12px;
  background: var(--lma-carousel-surface);
  counter-increment: lma-carousel-card;
}

.lma-card-carousel .lma-card-carousel__media {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 2.1 / 1;
  margin: 0;
  background: #eef0f2;
}

.lma-card-carousel .lma-card-carousel__media::after {
  content: counter(lma-carousel-card);
  position: absolute;
  z-index: 1;
  inset-inline-start: 12px;
  inset-block-end: -17px;
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding-inline: 5px;
  border: 2px solid var(--lma-carousel-surface);
  border-radius: 999px;
  background: var(--lma-carousel-accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

.lma-card-carousel .lma-card-carousel__image,
.lma-card-carousel .lma-card-carousel__image img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
}

.lma-card-carousel .lma-card-carousel__image img {
  aspect-ratio: 2.1 / 1;
  object-fit: cover;
  border-radius: 0;
}

.lma-card-carousel .lma-card-carousel__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 23px 14px 16px;
}

.lma-card-carousel .lma-card-carousel__title {
  min-height: 2.4em;
  margin: 0;
  padding: 0;
  color: var(--lma-carousel-accent);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.lma-card-carousel .lma-card-carousel__description {
  flex: 1 1 auto;
  margin: 10px 0 14px;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.3;
}

.lma-card-carousel .lma-card-carousel__resources {
  min-height: 7.25rem;
  margin: auto 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--lma-carousel-border);
}

.lma-card-carousel .lma-card-carousel__resources-label {
  margin: 0 0 5px;
  font-size: 0.875rem;
  font-weight: 700;
}

.lma-card-carousel .lma-card-carousel__links {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.3;
}

.lma-card-carousel .lma-card-carousel__links > li {
  position: relative;
  margin: 0;
  padding: 0 0 5px 15px;
  list-style: none;
}

.lma-card-carousel .lma-card-carousel__links > li::before {
  content: "›";
  position: absolute;
  inset-inline-start: 1px;
  inset-block-start: -1px;
  color: var(--lma-carousel-accent);
  font-size: 1.15em;
  font-weight: 700;
}

.lma-card-carousel .lma-card-carousel__links a {
  color: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
  text-decoration: none;
}

/* The theme justifies group text globally; card text follows the mockup. */
.lma-card-carousel :is(.lma-card-carousel__title, .lma-card-carousel__description, .lma-card-carousel__resources-label, .lma-card-carousel__links, .lma-card-carousel__links > li) {
  text-align: start;
}

.lma-card-carousel .lma-card-carousel__links a:hover {
  color: var(--lma-carousel-accent);
  text-decoration: underline;
}

.lma-card-carousel :is(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--lma-carousel-accent);
  outline-offset: 2px;
}

/* JS enhancement: no native scrollbar or flex gap on the transformed track. */
.lma-card-carousel.is-enhanced .lma-card-carousel__viewport {
  overflow: hidden;
  touch-action: pan-y;
}

.lma-card-carousel.is-enhanced .lma-card-carousel__track {
  gap: 0;
  transition-property: transform;
  transition-timing-function: ease-out;
  will-change: transform;
}

.lma-card-carousel.is-enhanced:not(.is-at-end):not(.is-static)::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset-block-start: 0;
  inset-block-end: 24px;
  inset-inline-end: 0;
  width: 36px;
  background: linear-gradient(to right, transparent, var(--lma-carousel-surface));
  pointer-events: none;
}

.lma-card-carousel .lma-card-carousel__button {
  position: absolute;
  z-index: 3;
  inset-block-start: var(--lma-carousel-control-top);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid var(--lma-carousel-border);
  border-radius: 50%;
  background: var(--lma-carousel-surface);
  color: var(--lma-carousel-accent);
  box-shadow: 0 2px 6px #00000024;
  cursor: pointer;
  appearance: none;
}

.lma-card-carousel .lma-card-carousel__button::before {
  content: "";
  width: 10px;
  height: 10px;
  border-block-start: 3px solid currentColor;
  border-inline-end: 3px solid currentColor;
  transform: rotate(45deg) translate(-2px, 2px);
}

.lma-card-carousel .lma-card-carousel__button--next {
  inset-inline-end: 6px;
}

.lma-card-carousel .lma-card-carousel__button--prev {
  inset-inline-start: 6px;
}

.lma-card-carousel .lma-card-carousel__button--prev::before {
  transform: rotate(-135deg) translate(-2px, 2px);
}

.lma-card-carousel .lma-card-carousel__button[hidden],
.lma-card-carousel.is-static .lma-card-carousel__scrollbar {
  display: none;
}

.lma-card-carousel .lma-card-carousel__scrollbar {
  position: relative;
  width: calc(100% - 12px);
  height: 8px;
  margin: 8px 6px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #dedede;
  touch-action: none;
}

.lma-card-carousel .lma-card-carousel__scrollbar .swiper-scrollbar-drag {
  height: 100%;
  border-radius: inherit;
  background: var(--lma-carousel-accent);
  cursor: grab;
}

.lma-card-carousel .lma-card-carousel__scrollbar .swiper-scrollbar-drag:active {
  cursor: grabbing;
}

@media (max-width: 600px) {
  .lma-card-carousel .lma-card-carousel__card {
    width: min(82%, 280px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lma-card-carousel .lma-card-carousel__track {
    transition-duration: 0ms !important;
  }
}
