.unit-hero-gallery-block {
  position: relative;

  .m-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #f5f5f5;
    overflow: hidden;
  }

  .gallery-main-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
  }

  /* The webp <picture> wrappers must fill their box so the inner img's
     width/height:100% + object-fit:cover still work. Scoped to these three
     contexts so the lightbox modal's <picture> is left alone. */
  .m-hero > picture,
  .m-hero-mobile-slide > picture,
  .m-thumbnail > picture {
    display: block;
    width: 100%;
    height: 100%;
  }

  .m-hero-mobile {
    position: relative;
  }

  .m-hero-mobile-slide {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    cursor: pointer;
  }

  .gallery-mobile-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .unit-hero-mobile-carousel {
    .owl-nav {
      margin: 0;

      button.owl-prev,
      button.owl-next {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        margin: 0;
        padding: 0;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.35) !important;
        backdrop-filter: blur(9.65px);
        -webkit-backdrop-filter: blur(9.65px);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;
      }

      button.owl-prev {
        left: 12px;
      }

      button.owl-next {
        right: 12px;
      }

      button.owl-prev:hover,
      button.owl-next:hover {
        background: rgba(0, 0, 0, 0.5) !important;
      }

      button {
        svg {
          stroke: #fff;
        }

        &.disabled {
          opacity: 0.35;
          cursor: default;
        }
      }
    }
  }

  .gallery-expand-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
    width: 34px;
    height: 34px;
    padding: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;

    &:hover {
      background: rgba(0, 0, 0, 0.6);
    }

    svg {
      color: #fff;
      stroke: #fff;
    }
  }

  .a-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.35) 100%);
    z-index: 5;
    pointer-events: none;
  }

  .m-carousel-controls {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: stretch;
    gap: 6px;
    max-width: calc(100% - 24px);
  }

  .m-image-carousel {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 11px 15px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(9.65px);
    -webkit-backdrop-filter: blur(9.65px);
    min-width: 0;
  }

  .carousel-stepper-button {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;

    &:hover {
      background: rgba(255, 255, 255, 0.15);
    }

    svg {
      color: #fff;
      stroke: #fff;
    }
  }

  .m-thumbnails {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 77px;
    overflow-x: auto;
    scroll-behavior: auto !important;
    /* Horizontal room for the active thumbnail's transform: scale() to grow
       into at the first/last position, so it doesn't get clipped by this
       container's own overflow edge. */
    padding: 0 10px;
    margin: 0;
    min-width: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;

    &::-webkit-scrollbar {
      display: none;
    }
  }

  .m-thumbnail {
    flex: 0 0 auto;
    width: 84px;
    height: 59px;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    border: 2px solid transparent;
    box-sizing: content-box;
    /* Scale (not width/height) so the active thumbnail's box never changes
       size — the flex row's total width stays constant even if clicking
       prev/next faster than this transition retargets it mid-flight, which
       otherwise briefly desyncs the growing/shrinking thumbnails and made
       the whole centred toolbar jitter. */
    transform: scale(1);
    transform-origin: center;
    transition: transform 0.25s ease, filter 0.25s ease;
    filter: brightness(0.9);

    &:hover {
      filter: brightness(1);
    }

    &.active {
      transform: scale(1.2262, 1.2373);
      border: 2px solid #fff;
      filter: brightness(1);
      z-index: 1;
    }
  }

  .thumbnail-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .a-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 12px;
    padding: 11px;
    width: 115px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(9.65px);
    -webkit-backdrop-filter: blur(9.65px);
    border: none;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
    line-height: 1.12;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;

    &:hover {
      background: rgba(0, 0, 0, 0.5);
      color: #fff;
    }

    &--disabled {
      opacity: 0.9;
      cursor: default;

      &:hover {
        background: rgba(0, 0, 0, 0.35);
      }
    }
  }

  .o-2021-units-page & {
    .a-cta {
      background: rgba(0, 0, 0, 0.35);
      color: #fff;
      border: none;
      border-radius: 0;
      min-width: 0;

      &:hover {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
      }

      &--disabled,
      &--disabled:hover {
        background: rgba(0, 0, 0, 0.35);
      }
    }
  }

  .a-icn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;

    svg {
      width: 100%;
      height: 100%;
    }
  }

  .a-text {
    display: block;
    max-width: 94px;
    word-break: normal;
    overflow-wrap: normal;
  }

  @media (max-width: 767px) {
    .m-carousel-controls {
      gap: 4px;
      bottom: 10px;
    }

    .m-image-carousel {
      gap: 8px;
      padding: 8px 10px;
    }

    .a-cta {
      width: 92px;
      padding: 8px;
      gap: 8px;
      font-size: 11px;
    }

    .a-icn {
      width: 26px;
      height: 26px;
    }
  }

  /* 360° tour modal close button — self-contained so it stays visible
     regardless of subtheme modal styles. Mirrors the gallery modal close. */
  #unit-hero-tour-modal .a-close {
    position: absolute;
    z-index: 2;
    top: 15px;
    right: 15px;
    width: 50px;
    height: 50px;
    padding: 0;
    border: solid 2px #000;
    background-color: #000;
    transition: all 0.35s ease;

    svg path {
      fill: #fff;
    }

    &:hover {
      background-color: #fff;

      svg path {
        fill: #000;
      }
    }
  }


}
