.property-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.property-modal.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}

html:not(.modals-ready) .property-modal:target,
html:not(.modals-ready) .legacy-modal-anchor:target + .property-modal { display: flex; }
html:not(.modals-ready) .property-modal:target .modal-container,
html:not(.modals-ready) .legacy-modal-anchor:target + .property-modal .modal-container { transform: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-container {
  position: relative;
  width: 92%;
  max-width: 960px;
  max-height: 90vh;
  background: var(--color-bg);
  overflow: hidden;
  z-index: 1;
  transform: translateY(30px) scale(0.97);
  transition: transform 0.4s ease;
}

.property-modal.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-scroll {
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-close {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  z-index: 10;
  transition: background var(--transition-base);
}

.modal-close:hover {
  background: rgba(0,0,0,0.7);
}

.modal-close svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

/* Modal Hero */
.modal-hero {
  position: relative;
  height: 360px;
  overflow: hidden;
}

.modal-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.7) 0%,
    rgba(0,0,0,0.15) 60%,
    rgba(0,0,0,0.05) 100%
  );
}

.modal-hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px;
  z-index: 2;
}

.modal-badge {
  display: inline-block;
  padding: 5px 14px;
  background: var(--color-burgundy);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.modal-hero-content h2 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  color: #fff;
  line-height: 1.2;
  margin-bottom: 8px;
}

.modal-hero-location {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: rgba(255,255,255,0.8);
}

.modal-hero-location svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-burgundy);
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

/* Modal Body */
.modal-body {
  padding: 0 40px 40px;
}

/* Specs Bar */
.modal-specs-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0 -40px;
  padding: 0;
  border-bottom: 1px solid var(--color-border);
}

.modal-spec {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px;
  border-inline-end: 1px solid var(--color-border);
}

.modal-spec:last-child {
  border-inline-end: none;
}

.modal-spec-value {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.4rem;
  color: var(--color-text);
  margin-bottom: 4px;
}

.modal-spec-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Content Grid */
.modal-content-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 48px;
  margin-top: 40px;
}

.modal-main h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.3rem;
  color: var(--color-text);
  margin-bottom: 16px;
  margin-top: 32px;
}

.modal-main h3:first-child {
  margin-top: 0;
}

.modal-main p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  line-height: 1.8;
  margin-bottom: 16px;
}

/* Highlights */
.modal-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.modal-highlights span {
  padding: 8px 16px;
  background: var(--color-limestone);
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: 0.3px;
}

/* Sidebar */
.modal-sidebar h4 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-burgundy);
  margin-bottom: 12px;
  margin-top: 28px;
}

.modal-sidebar h4:first-child {
  margin-top: 0;
}

.modal-features {
  list-style: none;
  padding: 0;
}

.modal-features li {
  position: relative;
  padding-inline-start: 18px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  line-height: 2;
}

.modal-features li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-burgundy);
}

/* Location text in sidebar */
.modal-location-text {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
}

/* CTA Section */
.modal-cta-section {
  margin-top: 48px;
  padding: 40px;
  background: var(--color-bg-warm);
  border: 1px solid var(--color-border);
  text-align: center;
}

.modal-cta-section h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.5rem;
  color: var(--color-text);
  margin-bottom: 12px;
}

.modal-cta-section p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.modal-cta-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-btn {
  display: inline-block;
  padding: 14px 32px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-base);
}

.modal-btn-primary {
  background: var(--color-burgundy);
  color: #fff;
  border: 1px solid var(--color-burgundy);
}

.modal-btn-primary:hover {
  background: var(--color-burgundy);
  border-color: var(--color-burgundy);
}

.modal-btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.modal-btn-secondary:hover {
  border-color: var(--color-burgundy);
  color: var(--color-burgundy);
}

/* Modal Responsive */
@media (max-width: 768px) {
  .modal-container {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
  }

  .modal-scroll {
    max-height: 100vh;
  }

  .modal-hero {
    height: 260px;
  }

  .modal-hero-content {
    padding: 24px;
  }

  .modal-body {
    padding: 0 24px 24px;
  }

  .modal-specs-bar {
    grid-template-columns: repeat(2, 1fr);
    margin: 0 -24px;
  }

  .modal-spec {
    padding: 20px 12px;
  }

  .modal-spec:nth-child(2) {
    border-inline-end: none;
  }

  .modal-spec:nth-child(1),
  .modal-spec:nth-child(2) {
    border-bottom: 1px solid var(--color-border);
  }

  .modal-content-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .modal-cta-section {
    padding: 28px 20px;
  }

  .modal-cta-buttons {
    flex-direction: column;
  }

  .modal-btn {
    text-align: center;
  }
}

.modal-gallery {
  position: relative;
  background: #111;
}

.gallery-main {
  position: relative;
  height: 420px;
  overflow: hidden;
}

.gallery-slides {
  position: relative;
  width: 100%;
  height: 100%;
}

.gallery-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 0;
}

.gallery-slide.active {
  opacity: 1;
  z-index: 1;
}

.gallery-prev,
.gallery-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 5;
  transition: all var(--transition-base);
  line-height: 1;
}

.gallery-prev { left: 16px; }
.gallery-next { right: 16px; }

.gallery-prev:hover,
.gallery-next:hover {
  background: rgba(0,0,0,0.7);
  border-color: rgba(255,255,255,0.3);
}

.gallery-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 1px;
  z-index: 5;
}

.gallery-thumbs {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: #111;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-burgundy) #222;
}

.gallery-thumbs::-webkit-scrollbar {
  height: 4px;
}

.gallery-thumbs::-webkit-scrollbar-track {
  background: #222;
}

.gallery-thumbs::-webkit-scrollbar-thumb {
  background: var(--color-burgundy);
  border-radius: 2px;
}

.gallery-thumb {
  flex: 0 0 72px;
  height: 52px;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity var(--transition-base);
  border: 2px solid transparent;
  border-radius: 2px;
}

.gallery-thumb:hover {
  opacity: 0.8;
}

.gallery-thumb.active {
  opacity: 1;
  border-color: var(--color-burgundy);
}

/* Gallery replaces modal hero — position hero overlay/content */
.modal-gallery .modal-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.7) 0%,
    rgba(0,0,0,0.0) 40%
  );
  z-index: 2;
  pointer-events: none;
}

.modal-gallery .modal-hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px;
  z-index: 3;
}

/* Gallery responsive */
@media (max-width: 768px) {
  .gallery-main {
    height: 280px;
  }

  .gallery-prev,
  .gallery-next {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .gallery-prev { left: 10px; }
  .gallery-next { right: 10px; }

  .gallery-thumb {
    flex: 0 0 56px;
    height: 40px;
  }

  .modal-gallery .modal-hero-content {
    padding: 20px;
  }

}


/* Logical placement and keyboard-accessible thumbnails. */
.modal-container { transform: none; }
.gallery-thumb { padding: 0; display: block; background: transparent; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.modal-gallery .modal-hero-content { bottom: 76px; pointer-events: none; }
[dir='rtl'] .gallery-prev { left: auto; right: 16px; }
[dir='rtl'] .gallery-next { right: auto; left: 16px; }
[dir='rtl'] .gallery-prev, [dir='rtl'] .gallery-next { transform: translateY(-50%) scaleX(-1); }
@media (max-width: 768px) {
  .modal-container, .modal-scroll { max-height: 100svh; }
  .modal-container { height: 100svh; }
  .modal-gallery .modal-hero-content { bottom: 56px; }
  [dir='rtl'] .gallery-prev { right: 10px; }
  [dir='rtl'] .gallery-next { left: 10px; }
}
