/* path: wp-content/themes/bedrebyttede/assets/css/components/carousel.css */
@layer components {

  /* ============ CAROUSEL ============ */
  .bb-carousel {
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    /* Focus outline managed manually */
  }

  .bb-carousel:focus-visible {
    box-shadow: 0 0 0 2px var(--brand);
    border-radius: var(--radius-2);
  }

  .bb-carousel__track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* IE/Edge */
    height: 100%;
    -webkit-overflow-scrolling: touch;
    /* Safari swipe */
  }

  .bb-carousel__track::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
  }

  /* Grab cursor only in create/edit listing context */
  .bb-stepform .bb-carousel__track {
    cursor: grab;
  }

  .bb-stepform .bb-carousel__track:active {
    cursor: grabbing;
  }

  /* Carousel Item */
  .bb-carousel__item {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    /* Fallback bg if image lacks coverage */
  }

  /* Core image rules — fill the hero while collapsed, centered */
  .bb-carousel__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
  }

  /* Letterbox contain only in expanded state — collapsed always covers */
  .bb-hero--letterbox.is-expanded .bb-carousel__item img {
    object-fit: contain;
  }

  /* --- Dots --- */
  .bb-carousel__dots {
    position: absolute;
    bottom: var(--space-3);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: color-mix(in oklab, black, transparent 50%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-round);
    z-index: 5;
    pointer-events: auto;
    /* Clickable */
    transition: opacity var(--dur-2);
    max-width: 80%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .bb-carousel__dots::-webkit-scrollbar {
    display: none;
  }

  .bb-carousel__dot {
    display: block;
    /* Ensure flex rendering */
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: var(--radius-round);
    background: color-mix(in oklab, white, transparent 55%);
    transition: all 200ms var(--ease-out, ease-out);
    cursor: pointer;
    border: none;
    padding: 0;
    box-sizing: content-box;
    outline: 4px solid transparent;
    /* Larger hit area */
    flex-shrink: 0;
  }

  .bb-carousel__dot:hover {
    background: color-mix(in oklab, white, transparent 20%);
    transform: scale(1.3);
  }

  .bb-carousel__dot.is-active {
    background: #fff;
    width: 20px;
    /* Pill */
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
  }

  .bb-carousel__dot.is-active:hover {
    transform: none;
    /* No scale on active */
  }

  /* --- Desktop Arrows --- */
  .bb-carousel__arrow {
    display: flex;
    /* Exist in DOM for layout */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 200ms ease;
    opacity: 0;
    /* Hidden by default */
    pointer-events: none;
    /* Ignore phantom clicks */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  /* JS logic hide */
  .bb-carousel__arrow.is-hidden {
    display: none !important;
  }

  /* Show arrows when hovering anywhere on the carousel */
  .bb-carousel:hover .bb-carousel__arrow:not(.is-hidden) {
    opacity: 1;
    pointer-events: auto;
  }

  .bb-carousel__arrow:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translateY(-50%) scale(1.1);
  }

  .bb-carousel__arrow:active {
    transform: translateY(-50%) scale(0.92);
  }

  .bb-carousel__arrow:focus-visible {
    opacity: 1 !important;
    pointer-events: auto !important;
    outline: 2px solid #fff;
    outline-offset: 2px;
  }

  .bb-carousel__arrow--prev {
    left: var(--space-3);
  }

  .bb-carousel__arrow--next {
    right: var(--space-3);
  }

  /* --- Fallback --- */
  .bb-carousel__fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--surface-2);
    color: var(--muted);
    gap: var(--space-3);
  }

  .bb-carousel__fallback i {
    font-size: 4rem;
    opacity: 0.4;
  }
}
