/* ============================================================
   LEVAL — live map page (استكشف المواقع)
   Light ivory/sage/sand theme, matching the rest of the site.
   Tiles are proxied through /api/map/tiles.
   ============================================================ */

.map-page {
  background: var(--ivory);
}

.ic {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* icons drawn from the brand sprite already carry their own strokes */
.ic use {
  pointer-events: none;
}

/* ---------- Intro ---------- */

.map-intro {
  padding-block: clamp(3rem, 8vh, 5rem) clamp(1.75rem, 4vh, 2.5rem);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

.map-intro__head {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.map-intro--center .map-intro__head {
  align-items: center;
  text-align: center;
}

.map-title {
  margin: 0;
  font-size: clamp(2.2rem, 4.6vw, 3.6rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--sage-deep);
}

.map-subtitle {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1rem;
  line-height: 2;
}

/* ---------- Map board ---------- */

.map-section {
  padding-block: clamp(2rem, 5vh, 3rem);
}

.mapboard {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--paper);
  box-shadow: 0 24px 60px -40px rgba(25, 40, 33, 0.45);
}

.mapboard__map {
  width: 100%;
  height: clamp(420px, 62vh, 620px);
  background: var(--sand-light);
}

.mapboard__loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--paper);
  transition: opacity 0.3s ease;
}

.mapboard.is-ready .mapboard__loading {
  opacity: 0;
  pointer-events: none;
}

/* Leaflet keeps its zoom control on the physical left, so this sits opposite */
.map-list-btn {
  position: absolute;
  z-index: 500;
  inset-inline-start: 1rem;
  top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--hairline-strong);
  background: var(--paper);
  color: var(--sage-deep);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 6px 18px -10px rgba(25, 40, 33, 0.5);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.map-list-btn:hover {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--ivory);
}

/* ---------- Markers ---------- */

.pin-wrap {
  background: none !important;
  border: 0 !important;
}

.pin {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  transform: translate(-50%, -100%);
  animation: pin-drop 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}

html[dir="rtl"] .pin {
  transform: translate(50%, -100%);
}

@keyframes pin-drop {
  from { opacity: 0; transform: translate(-50%, -160%); }
}

html[dir="rtl"] .pin {
  animation-name: pin-drop-rtl;
}

@keyframes pin-drop-rtl {
  from { opacity: 0; transform: translate(50%, -160%); }
  to   { opacity: 1; transform: translate(50%, -100%); }
}

.pin__marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50% 50% 50% 4px;
  background: var(--sage);
  color: var(--ivory);
  box-shadow: 0 8px 20px -6px rgba(25, 40, 33, 0.55);
  transform: rotate(-45deg);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.pin__marker > * {
  transform: rotate(45deg);
}

.pin__marker--full {
  background: var(--sand);
  color: var(--sage-deep);
}

.pin:hover .pin__marker,
.pin.is-active .pin__marker {
  background: var(--sage-deep);
  color: var(--sand);
  transform: rotate(-45deg) scale(1.08);
}

.pin__count {
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.pin__count .ic {
  width: 18px;
  height: 18px;
}

.pin__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--hairline);
  background: var(--paper);
  box-shadow: 0 8px 22px -12px rgba(25, 40, 33, 0.55);
  white-space: nowrap;
  transition: border-color 0.2s ease;
}

.pin:hover .pin__label,
.pin.is-active .pin__label {
  border-color: var(--sand);
}

.pin__name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sage-deep);
}

.pin__meta {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------- Location cards ---------- */

.loc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.75rem;
}

.loc-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--hairline);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.loc-card:hover {
  border-color: var(--sand);
  transform: translateY(-4px);
  box-shadow: 0 22px 45px -30px rgba(25, 40, 33, 0.5);
}

.loc-card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--sand-light);
}

.loc-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.loc-card:hover .loc-card__media img {
  transform: scale(1.05);
}

.loc-card__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(64, 88, 76, 0.3);
}

.loc-card__ph .ic {
  width: 2.4rem;
  height: 2.4rem;
}

.loc-card__count {
  position: absolute;
  inset-inline-start: 0.85rem;
  top: 0.85rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sand);
}

.loc-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem 1.35rem 1.4rem;
}

.loc-card__name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--sage-deep);
}

.loc-card__district {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.loc-card__facts {
  display: flex;
  gap: 1rem;
  margin: 1.1rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--hairline);
}

.loc-card__facts li {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  flex: 1;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--muted);
}

.loc-card__facts .ic {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  color: var(--sage-soft);
}

.loc-card__facts strong {
  color: var(--sage-deep);
  font-weight: 600;
}

.loc-card__cta {
  width: 100%;
  margin-top: 1.25rem;
}

/* ---------- Perks strip ---------- */

.map-perks {
  padding-block: clamp(2rem, 5vh, 3rem);
  background: var(--paper);
  border-block: 1px solid var(--hairline);
}

.map-perks__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem 2rem;
}

.map-perks__list li {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: var(--sage-deep);
}

.map-perks__list .ic {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--sage);
}

/* ---------- Slide-in panel ---------- */

.map-scrim {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(29, 43, 37, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.map-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.map-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  z-index: 1000;
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--ivory);
  border-inline-start: 1px solid var(--hairline);
  box-shadow: -18px 0 60px -30px rgba(25, 40, 33, 0.6);
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

html[dir="rtl"] .map-panel {
  transform: translateX(-100%);
}

/* both selectors listed so this outranks the RTL rule above */
.map-panel.is-open,
html[dir="rtl"] .map-panel.is-open {
  transform: translateX(0);
}

.map-panel__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
}

.panel-back,
.panel-close {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--sage-deep);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.panel-back:hover,
.panel-close:hover {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--ivory);
}

.panel-close .ic {
  width: 1.1rem;
  height: 1.1rem;
}

.map-panel__scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem 1.25rem 2rem;
}

/* ---------- Building detail ---------- */

.bd__head {
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--hairline);
}

.bd__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--sage-soft-text);
}

.bd__eyebrow .ic {
  width: 1rem;
  height: 1rem;
}

.bd__name {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--sage-deep);
}

.bd__sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.bd__sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--sand);
}

.bd__avail {
  color: var(--sage);
  font-weight: 600;
}

.bd__list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---------- Unit card inside the panel ---------- */

.unit {
  background: var(--paper);
  border: 1px solid var(--hairline);
  animation: unit-in 0.4s ease backwards;
  animation-delay: calc(var(--row, 0) * 55ms);
}

@keyframes unit-in {
  from { opacity: 0; transform: translateY(16px); }
}

.unit--reserved {
  opacity: 0.75;
}

.unit__gallery {
  border-bottom: 1px solid var(--hairline);
}

.unit__stage {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--sand-light);
}

.unit__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.unit__ph {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: rgba(64, 88, 76, 0.3);
}

.unit__stage.is-empty .unit__ph {
  display: grid;
}

.unit__ph .ic {
  width: 2.2rem;
  height: 2.2rem;
}

.unit__tag {
  position: absolute;
  inset-inline-end: 0.7rem;
  bottom: 0.7rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--sage-deep);
  background: var(--sand);
}

.unit__badge {
  position: absolute;
  inset-inline-start: 0.7rem;
  top: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.unit__badge .ic {
  width: 0.9rem;
  height: 0.9rem;
}

.unit__badge--available {
  color: var(--ivory);
  background: var(--sage);
}

.unit__badge--reserved {
  color: var(--sage-deep);
  background: var(--sand);
}

.unit__thumbs {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem;
  overflow-x: auto;
}

.unit__thumb {
  position: relative;
  width: 62px;
  height: 46px;
  flex-shrink: 0;
  padding: 0;
  overflow: hidden;
  border: 1.5px solid var(--hairline);
  background: var(--sand-light);
  cursor: pointer;
}

.unit__thumb.is-active {
  border-color: var(--sage);
}

.unit__thumbimg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.unit__thumbimg.is-empty {
  opacity: 0;
}

.unit__thumbph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(64, 88, 76, 0.3);
}

.unit__thumbph .ic {
  width: 1.1rem;
  height: 1.1rem;
}

.unit__body {
  padding: 1.1rem 1.2rem 1.25rem;
}

.unit__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.unit__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--sage-deep);
}

.unit__namelink:hover {
  color: var(--sage);
  text-decoration: underline;
}

.unit__price {
  margin: 0;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: end;
}

.unit__price strong {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--sage);
}

.unit__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0.9rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--hairline);
}

.unit__meta li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--sage-deep);
}

.unit__meta .ic {
  width: 1rem;
  height: 1rem;
  color: var(--sage-soft);
}

/* ---------- Booking buttons ---------- */

.unit__more {
  display: inline-block;
  margin-top: 0.9rem;
  font-size: 0.82rem;
  color: var(--sage);
  border-bottom: 1px solid var(--sand);
  padding-bottom: 2px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.unit__more:hover {
  color: var(--sage-deep);
  border-color: var(--sage);
}

.unit__book {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--hairline);
}

.unit__booklabel {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.unit__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.book {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: 1 1 0;
  min-width: 88px;
  padding: 0.65rem 0.5rem;
  border: 1px solid var(--hairline-strong);
  background: #fff;
  color: var(--sage-deep);
  font-size: 0.82rem;
  font-weight: 500;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.book .ic {
  width: 1.05rem;
  height: 1.05rem;
}

.book:hover {
  transform: translateY(-2px);
}

.book--whatsapp {
  border-color: #25d366;
}

.book--whatsapp .ic {
  color: #25d366;
  fill: currentColor;
  stroke: none;
}

.book--whatsapp:hover {
  background: rgba(37, 211, 102, 0.1);
}

.book--booking:hover {
  background: rgba(0, 59, 149, 0.08);
  border-color: #003b95;
}

.book--airbnb .ic {
  color: #ff385c;
  fill: currentColor;
  stroke: none;
}

.book--airbnb:hover {
  background: rgba(255, 56, 92, 0.08);
  border-color: #ff385c;
}

.book--off {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Leaflet chrome ---------- */

.leaflet-container {
  font: inherit;
  background: var(--sand-light);
}

/* Google tiles already arrive in the LEVAL palette. The OpenStreetMap
   fallback does not, so warm and desaturate it to stay on brand. */
.mapboard.is-fallback .leaflet-tile-pane {
  filter: saturate(0.5) sepia(0.16) brightness(1.03) contrast(0.96);
}

.leaflet-control-zoom {
  border: 1px solid var(--hairline-strong) !important;
  box-shadow: 0 6px 18px -12px rgba(25, 40, 33, 0.6) !important;
}

.leaflet-control-zoom a {
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  background: var(--paper) !important;
  color: var(--sage-deep) !important;
  border-bottom-color: var(--hairline) !important;
  margin: 0 !important;
}

.leaflet-control-zoom a:hover {
  background: var(--sage) !important;
  color: var(--ivory) !important;
}

.leaflet-control-attribution {
  background: rgba(251, 249, 244, 0.85) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
  padding: 2px 7px !important;
}

.leaflet-control-attribution a {
  color: var(--sage) !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .loc-cards {
    grid-template-columns: 1fr;
  }

  .map-perks__list {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .mapboard__map {
    height: 60vh;
  }

  /* panel becomes a bottom sheet on phones */
  .map-panel,
  html[dir="rtl"] .map-panel {
    top: auto;
    inset-inline: 0;
    bottom: 0;
    width: 100%;
    height: 88vh;
    border-inline-start: 0;
    border-top: 1px solid var(--hairline);
    transform: translateY(100%);
  }

  .map-panel.is-open,
  html[dir="rtl"] .map-panel.is-open {
    transform: translateY(0);
  }

  .map-panel__bar {
    position: relative;
    padding-top: 1.5rem;
  }

  /* grab handle */
  .map-panel__bar::before {
    content: "";
    position: absolute;
    top: 0.5rem;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--hairline-strong);
  }

  .pin__label {
    display: none;
  }

  .unit__top {
    flex-direction: column;
    gap: 0.35rem;
  }

  .unit__price {
    text-align: start;
  }
}
