/**
 * Mutola blogi — gorizontal karousel (::scroll-* + scroll-snap).
 */
@layer mutola-carousel-base, mutola-carousel-demo;

@layer mutola-carousel-demo {
  #mutola-blog-carousel {
    --nav-btn-size: 40px;
    --nav-btn-bg: #ff0042;
    --nav-btn-txt: #ffffff;
    --nav-marker-size: 20px;
    --nav-marker-color: #ff0042;

    width: min(calc(100% - 2rem), 720px);
    margin-inline: auto;
    list-style: none;
    padding-block: 2rem;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(250px, 280px);
    gap: 0;
    position: relative;
    anchor-name: --mutola-carousel;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
    font-family: "Manrope", system-ui, sans-serif;
    scroll-marker-group: after;
  }

  #mutola-blog-carousel::-webkit-scrollbar {
    display: none;
  }

  @supports not selector(::scroll-marker-group) {
    #mutola-blog-carousel {
      gap: 1rem;
    }
  }

  #mutola-blog-carousel::before,
  #mutola-blog-carousel::after {
    content: "";
  }

  #mutola-blog-carousel::scroll-marker-group {
    position: absolute;
    position-anchor: --mutola-carousel;
    inline-size: min(90cqi, 400px);
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    gap: 0.25rem;
    padding-block-start: 1rem;
    top: anchor(bottom);
    left: calc(anchor(left) - 10%);
    right: calc(anchor(right) - 10%);
  }

  #mutola-blog-carousel > div {
    position: relative;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    container-type: scroll-state;
    display: grid;
    grid-template-areas: "img" "title" "desc";
    text-align: center;
  }

  #mutola-blog-carousel > div.mutola-slide--video {
    grid-template-areas: "img" "badge" "title" "body" "cta";
    text-align: center;
  }

  #mutola-blog-carousel > div.scroll-start {
    scroll-initial-target: nearest;
  }

  #mutola-blog-carousel > div:not(.mutola-slide--video) > h2 {
    grid-area: title;
    margin: 1rem 0 0 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #010717;
    white-space: nowrap;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div.mutola-slide--video > h2 {
    grid-area: title;
    margin: 1rem 0 0 0;
    font-size: 0.95rem;
    line-height: 1.25;
    font-weight: 700;
    color: #010717;
    white-space: normal;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div:not(.mutola-slide--video) > p {
    grid-area: desc;
    margin: 0;
    font-size: 0.85rem;
    color: #4c4d56;
    white-space: nowrap;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div.mutola-slide--video > p.mutola-slide__badge {
    grid-area: badge;
    margin: 0.4rem 0 0 0;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ff0042;
    white-space: nowrap;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div.mutola-slide--video > p.mutola-slide__body {
    grid-area: body;
    margin: 0.35rem 0 0 0;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #4c4d56;
    white-space: normal;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div.mutola-slide--video > a.mutola-slide__btn {
    grid-area: cta;
    justify-self: center;
    margin-top: 0.45rem;
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    background-color: #ff0042;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div.mutola-slide--video > a.mutola-slide__btn:hover {
    background-color: transparent;
    color: #ff0042;
    box-shadow: inset 0 0 0 1px #ff0042;
  }

  #mutola-blog-carousel > div:not(.mutola-slide--video) > .img {
    grid-area: img;
    width: 100%;
    aspect-ratio: 3/4;
    transition: all 300ms ease-in-out;
    transform-origin: center center;
  }

  #mutola-blog-carousel > div.mutola-slide--video > .img {
    position: relative;
    overflow: hidden;
    aspect-ratio: 9/16;
    max-height: 240px;
    min-height: 140px;
    margin-inline: auto;
    width: 100%;
    max-width: 200px;
    transform-origin: center center;
    transition: all 300ms ease-in-out;
  }

  #mutola-blog-carousel > div > .img > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
  }

  #mutola-blog-carousel > div.mutola-slide--video > .img > iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 16px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
    background: #000;
  }

  @container not scroll-state(snapped: inline) {
    #mutola-blog-carousel > div:not(.mutola-slide--video) > h2 {
      scale: 0.5;
      opacity: 0.5;
      translate: 0 -100px;
    }

    #mutola-blog-carousel > div.mutola-slide--video > h2 {
      scale: 0.5;
      opacity: 0.5;
      translate: 0 -100px;
    }

    #mutola-blog-carousel > div:not(.mutola-slide--video) > p {
      scale: 0.5;
      opacity: 0;
    }

    #mutola-blog-carousel > div.mutola-slide--video > p.mutola-slide__badge {
      scale: 0.5;
      opacity: 0;
    }

    #mutola-blog-carousel > div.mutola-slide--video > p.mutola-slide__body {
      scale: 0.5;
      opacity: 0;
    }

    #mutola-blog-carousel > div.mutola-slide--video > a.mutola-slide__btn {
      scale: 0.5;
      opacity: 0;
    }

    #mutola-blog-carousel > div:not(.mutola-slide--video) > .img {
      scale: 0.5;
      opacity: 0.5;
    }

    #mutola-blog-carousel > div.mutola-slide--video > .img {
      scale: 0.5;
      opacity: 0.5;
    }
  }

  #mutola-blog-carousel > div::scroll-marker {
    content: " ";
    height: var(--nav-marker-size);
    aspect-ratio: 1;
    background-color: var(--nav-marker-color);
    border-radius: 50%;
    transition: 150ms ease-in-out;
    scale: 0.75;
    opacity: 0.25;
  }

  #mutola-blog-carousel > div::scroll-marker:target-current {
    opacity: 1;
    scale: 1;
  }

  #mutola-blog-carousel > div::scroll-marker:where(:hover, :focus-visible) {
    opacity: 1;
  }

  #mutola-blog-carousel > div::scroll-marker:focus-visible {
    outline: 1px dashed var(--nav-marker-color);
    outline-offset: 4px;
  }

  #mutola-blog-carousel::scroll-button(*) {
    position: absolute;
    position-anchor: --mutola-carousel;
    width: var(--nav-btn-size);
    aspect-ratio: 1/1;
    font: inherit;
    background-color: var(--nav-btn-bg);
    display: grid;
    place-content: center;
    color: var(--nav-btn-txt);
    border: none;
    border-radius: 50%;
    opacity: 0.85;
    cursor: pointer;
    transition: all 150ms ease-in-out;
    outline: 1px dashed transparent;
    outline-offset: 0;
  }

  #mutola-blog-carousel::scroll-button(inline-start) {
    content: "❮";
    left: calc(anchor(left) - var(--nav-btn-size));
  }

  #mutola-blog-carousel::scroll-button(inline-end) {
    content: "❯";
    right: calc(anchor(right) - var(--nav-btn-size));
  }

  #mutola-blog-carousel::scroll-button(*):not(:disabled):where(:hover, :focus-visible) {
    opacity: 1;
    scale: 1.1;
  }

  #mutola-blog-carousel::scroll-button(*):focus-visible {
    outline: 1px dashed var(--nav-btn-bg);
    outline-offset: 4px;
  }

  #mutola-blog-carousel::scroll-button(*):disabled {
    opacity: 0.25;
    cursor: unset;
  }
}

@layer mutola-carousel-base {
  .mutola-blog-carousel-wrap .msg-supports-carousel {
    font-size: 0.8rem;
    color: #4c4d56;
    text-align: center;
    margin: 0 0 0.5rem;
  }

  @supports selector(::scroll-marker-group) {
    .mutola-blog-carousel-wrap .msg-supports-carousel {
      display: none;
    }
  }
}
