/* Shared location gallery - detail pages + market cards */

.location-gallery {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  outline: none;
  touch-action: pan-y pinch-zoom;
}

.location-gallery[hidden] {
  display: none;
}

.location-gallery-detail {
  border: 1px solid rgba(17, 24, 61, 0.12);
  border-radius: 16px;
  background: var(--white, #fff);
  box-shadow: 0 18px 44px rgba(7, 12, 36, 0.13);
}

.location-gallery-viewport {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: rgba(17, 24, 61, 0.04);
}

.location-gallery-detail .location-gallery-viewport {
  aspect-ratio: auto;
  height: var(--office-gallery-height, clamp(240px, 20vw, 340px));
}

.location-gallery-card .location-gallery-viewport {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
}

.location-gallery-slide {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--duration-gallery, 420ms) var(--ease-premium, ease),
    transform var(--duration-gallery, 420ms) var(--ease-premium, ease);
  background: rgba(247, 241, 232, 0.55);
  transform: scale(1.02);
}

.location-gallery-slide.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.location-gallery-slide.is-landscape .location-gallery-photo {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  object-fit: cover;
  object-position: center center;
}

.location-gallery-slide.is-portrait {
  display: grid;
  place-items: center;
  justify-items: center;
  align-items: center;
  overflow: hidden;
}

.location-gallery-slide.is-portrait .location-gallery-bg {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: blur(12px) saturate(1.05);
  transform: scale(1.12);
  transform-origin: center center;
  opacity: 0.58;
  pointer-events: none;
}

.location-gallery-slide.is-portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(247, 241, 232, 0.36), rgba(247, 241, 232, 0.2) 48%, rgba(17, 24, 61, 0.1));
}

.location-gallery-slide.is-portrait .location-gallery-fg {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  box-sizing: border-box;
  width: auto;
  height: 100%;
  max-width: 92%;
  max-height: 100%;
  margin: auto;
  padding: 0;
  object-fit: contain;
  object-position: center center;
}

.location-gallery-viewport > .location-gallery-control {
  position: absolute;
  z-index: 3;
  top: 50%;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--navy, #11183d);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 20px rgba(7, 12, 36, 0.18);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  touch-action: manipulation;
}

.location-gallery-viewport > .location-gallery-control.prev {
  left: 10px;
  right: auto;
}

.location-gallery-viewport > .location-gallery-control.next {
  right: 10px;
  left: auto;
}

.location-gallery-viewport > .location-gallery-control:hover,
.location-gallery-viewport > .location-gallery-control:focus-visible {
  background: var(--cream, #f7f1e8);
}

.location-gallery-viewport > .location-gallery-control:focus-visible {
  outline: 3px solid rgba(17, 24, 61, 0.28);
  outline-offset: 2px;
}

.location-gallery-dots {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 10px;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 7px;
  pointer-events: none;
}

.location-gallery-slide img,
.location-gallery-lightbox-image {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.location-gallery-dot {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  cursor: pointer;
  position: relative;
}

.location-gallery-dot::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(7, 12, 36, 0.28);
  transform: translate(-50%, -50%);
}

.location-gallery-dot.is-active::before {
  background: var(--cream, #f7f1e8);
  width: 10px;
  height: 10px;
}

.location-gallery-card .location-gallery-dot.is-active::before {
  background: #11183d;
}

.location-gallery-dot:focus-visible {
  outline: 2px solid var(--navy, #11183d);
  outline-offset: 2px;
}

/* Detail carousels no longer render a caption/footer strip. */

.location-gallery-open {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.location-gallery-viewport > .location-gallery-control,
.location-gallery-dots {
  z-index: 5;
  pointer-events: auto;
}

.location-gallery-lightbox {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
}

.location-gallery-lightbox[hidden] {
  display: none;
}

.location-gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 36, 0.9);
}

.location-gallery-lightbox-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: min(1120px, calc(100vw - 112px));
  height: min(
    860px,
    calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
  );
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  pointer-events: none;
}

.location-gallery-lightbox-dialog > * {
  pointer-events: auto;
}

.location-gallery-lightbox-image {
  display: block;
  box-sizing: border-box;
  width: auto;
  height: auto;
  /* Prefer viewport units - percentage max-height fails on replaced
     grid items because min-height:auto locks to intrinsic image size. */
  max-width: min(1120px, calc(100vw - 112px));
  max-height: min(
    84dvh,
    calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
  );
  min-width: 0;
  min-height: 0;
  margin: 0;
  object-fit: contain;
  object-position: center center;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 24px 70px rgba(2, 8, 32, 0.42);
}

/* Controls live on the lightbox viewport (not inside the dialog grid).
   Higher specificity beats .button-sheen { position: relative }. */
.location-gallery-lightbox > .location-gallery-lightbox-close,
.location-gallery-lightbox > .location-gallery-lightbox-close.button-sheen {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  left: auto;
  bottom: auto;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--navy, #11183d);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(2, 8, 32, 0.28);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  overflow: visible;
  isolation: auto;
  transform: none;
}

.location-gallery-lightbox > .location-gallery-lightbox-control,
.location-gallery-lightbox > .location-gallery-lightbox-control.button-sheen {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--navy, #11183d);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(2, 8, 32, 0.28);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  overflow: visible;
  isolation: auto;
  transform: translateY(-50%);
}

.location-gallery-lightbox > .location-gallery-lightbox-control.prev,
.location-gallery-lightbox > .location-gallery-lightbox-control.prev.button-sheen {
  left: max(12px, env(safe-area-inset-left, 0px));
  right: auto;
}

.location-gallery-lightbox > .location-gallery-lightbox-control.next,
.location-gallery-lightbox > .location-gallery-lightbox-control.next.button-sheen {
  right: max(12px, env(safe-area-inset-right, 0px));
  left: auto;
}

.location-gallery-lightbox-control[hidden] {
  display: none;
}

.location-gallery-lightbox-close:focus-visible,
.location-gallery-lightbox-control:focus-visible {
  outline: 3px solid rgba(247, 241, 232, 0.9);
  outline-offset: 3px;
}

.location-gallery-lightbox-open {
  overflow: hidden;
}

/* Card variant chrome only - do NOT force width/height here.
   Market cards use negative-margin full-bleed sizing from styles.css;
   a width:100% rule here previously overrode that and left-shifted media. */
.location-gallery-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.location-gallery-card .location-gallery-open {
  display: none;
}

@media (max-width: 860px) {
  .location-gallery-viewport > .location-gallery-control {
    width: 48px;
    height: 48px;
    font-size: 1.55rem;
  }

  .location-gallery-lightbox-dialog {
    width: calc(100vw - 24px);
    height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .location-gallery-lightbox > .location-gallery-lightbox-control,
  .location-gallery-lightbox > .location-gallery-lightbox-control.button-sheen {
    width: 48px;
    height: 48px;
  }

  .location-gallery-lightbox > .location-gallery-lightbox-control.prev,
  .location-gallery-lightbox > .location-gallery-lightbox-control.prev.button-sheen {
    left: max(6px, env(safe-area-inset-left, 0px));
  }

  .location-gallery-lightbox > .location-gallery-lightbox-control.next,
  .location-gallery-lightbox > .location-gallery-lightbox-control.next.button-sheen {
    right: max(6px, env(safe-area-inset-right, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .location-gallery-slide {
    transition: none;
    transform: none;
  }

  .location-gallery-slide.is-active {
    transform: none;
  }
}
