.property-media-hero {
  padding: 126px 24px 48px;
  background: #fff;
}

.property-media-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.property-media-title {
  margin: 0 0 24px;
  color: #0e0f11;
  font-size: clamp(2rem, 3vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.property-media-grid {
  position: relative;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
  height: min(600px, 42vw);
  min-height: 420px;
  overflow: hidden;
  border-radius: 22px;
  background: #e9e9e9;
}

.property-media-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #dedede;
  cursor: pointer;
}

.property-media-tile:first-child {
  grid-row: 1 / 3;
}

.property-media-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 180ms ease;
}

.property-media-tile:hover img,
.property-media-tile:focus-visible img {
  filter: brightness(.88);
}

.property-media-tile:focus-visible,
.property-photo-viewer-close:focus-visible,
.property-show-all:focus-visible {
  outline: 3px solid #194d80;
  outline-offset: -3px;
}

.property-show-all {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid #0e0f11;
  border-radius: 12px;
  background: #fff;
  color: #0e0f11;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .14);
}

.property-show-all svg {
  width: 18px;
  height: 18px;
}

.property-photo-viewer[hidden] {
  display: none;
}

.property-photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 100000;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  color: #0e0f11;
}

.property-photo-viewer-header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 80px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid rgba(14, 15, 17, .1);
  backdrop-filter: blur(12px);
}

.property-photo-viewer-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  text-align: center;
}

.property-photo-viewer-close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: currentColor;
  cursor: pointer;
}

.property-photo-viewer-close:hover {
  background: #f2f2f2;
}

.property-photo-viewer-close svg {
  width: 22px;
  height: 22px;
}

.property-photo-viewer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(1120px, calc(100% - 48px));
  margin: 64px auto 96px;
}

.property-photo-viewer-item {
  min-width: 0;
  margin: 0;
  background: #f1f1f1;
}

.property-photo-viewer-item:first-child,
.property-photo-viewer-item:nth-child(5n + 1) {
  grid-column: 1 / -1;
}

.property-photo-viewer-item img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
  max-height: 760px;
  object-fit: cover;
}

body.property-photo-viewer-open {
  overflow: hidden;
}

@media (min-width: 768px) {
  .property-media-grid.has-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
  }

  .property-media-grid.has-2 .property-media-tile:first-child,
  .property-media-grid.has-2 .property-media-tile:nth-child(2) {
    grid-column: auto;
    grid-row: 1;
  }

  .property-media-grid.has-3 {
    grid-template-columns: 2fr 1fr;
  }

  .property-media-grid.has-4 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }

  .property-media-grid.has-4 .property-media-tile:first-child {
    grid-row: 1 / 4;
  }
}

@media (max-width: 991px) {
  .property-media-hero {
    padding: 110px 20px 40px;
  }

  .property-media-grid {
    grid-template-columns: 2fr 1fr;
    height: min(560px, 58vw);
    min-height: 400px;
  }

  .property-media-tile:nth-of-type(4),
  .property-media-tile:nth-of-type(5) {
    display: none;
  }
}

@media (max-width: 767px) {
  .property-media-hero {
    padding: 94px 10px 32px;
  }

  .property-media-title {
    margin: 0 10px 18px;
    font-size: clamp(1.9rem, 9vw, 2.75rem);
  }

  .property-media-grid {
    display: block;
    height: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
  }

  .property-media-tile {
    display: none;
    width: 100%;
    height: 100%;
  }

  .property-media-tile:first-child {
    display: block;
  }

  .property-show-all {
    right: 14px;
    bottom: 14px;
    min-height: 44px;
    padding: 0 14px;
    font-size: 14px;
  }

  .property-photo-viewer-header {
    min-height: 64px;
    padding: 8px 10px;
  }

  .property-photo-viewer-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    margin: 8px 0 48px;
  }

  .property-photo-viewer-item,
  .property-photo-viewer-item:first-child,
  .property-photo-viewer-item:nth-child(5n + 1) {
    grid-column: 1;
  }

  .property-photo-viewer-item img {
    min-height: 0;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .property-media-tile img {
    transition: none;
  }
}
