/* Locasello 2 — Dot boundary map + listings panel */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #f8f5f0;
  color: #3a3a3a;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* ── Side Panel (desktop) ── */
.panel {
  width: 360px;
  min-width: 360px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e0dcd6;
  z-index: 10;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e8e4de;
}

.panel-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2c2c2c;
  letter-spacing: -0.02em;
}

.panel-header .tagline {
  font-size: 0.75rem;
  color: #999;
  margin-top: 2px;
}

.search-bar {
  padding: 12px 20px;
  border-bottom: 1px solid #e8e4de;
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d4d0ca;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: #2c3e6b;
}

.search-bar button {
  padding: 8px 16px;
  background: #2c3e6b;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.search-bar button:hover { background: #1e2d4d; }

.listings-count {
  padding: 8px 20px;
  font-size: 0.72rem;
  color: #999;
  border-bottom: 1px solid #f0ece6;
}

.listings {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.listing-card {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #f0ece6;
  cursor: pointer;
  transition: background 0.1s;
}

.listing-card:hover { background: #faf8f5; }
.listing-card.active { background: #f0ece6; }

.listing-thumb {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.listing-info {
  flex: 1;
  min-width: 0;
}

.listing-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #2c2c2c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.listing-desc {
  font-size: 0.75rem;
  color: #888;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.listing-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  align-items: center;
}

.listing-price {
  font-size: 0.88rem;
  font-weight: 700;
  color: #2c3e6b;
}

.listing-distance {
  font-size: 0.7rem;
  color: #aaa;
}

/* ── Map Area ── */
.map-area {
  flex: 1;
  position: relative;
  height: 100vh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

canvas:active { cursor: grabbing; }

.map-status {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 0.6rem;
  color: #999;
  background: rgba(255,255,255,0.8);
  padding: 2px 8px;
  border-radius: 3px;
  pointer-events: none;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-controls button {
  width: 32px;
  height: 32px;
  background: #fff;
  border: 1px solid #d4d0ca;
  border-radius: 4px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  transition: all 0.1s;
}

.map-controls button:hover {
  background: #f0ece6;
  border-color: #aaa;
}

/* ── Popup (desktop) ── */
.popup {
  position: absolute;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 14px;
  width: 260px;
  z-index: 20;
  pointer-events: auto;
  display: none;
}

.popup .popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #999;
}

.popup img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}

.popup .popup-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.popup .popup-desc {
  font-size: 0.75rem;
  color: #888;
  margin: 4px 0;
}

.popup .popup-price {
  font-size: 1rem;
  font-weight: 700;
  color: #2c3e6b;
}

.popup .popup-directions {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.75rem;
  color: #2c3e6b;
  text-decoration: none;
}

.popup .popup-directions:hover { text-decoration: underline; }

/* ── Loading overlay ── */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  color: #999;
  pointer-events: none;
  display: none;
}

.loading.active { display: block; }

/* ── Mobile header (hidden on desktop) ── */
.mobile-header {
  display: none;
}

/* ── Mobile search overlay (hidden on desktop) ── */
.mobile-search {
  display: none;
}

/* ── Bottom sheet (hidden on desktop) ── */
.bottom-sheet {
  display: none;
}

/* ══════════════════════════════════════
   RESPONSIVE / MOBILE (≤768px)
   ══════════════════════════════════════ */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  /* Hide desktop panel */
  .panel {
    display: none;
  }

  /* Map takes full screen */
  .map-area {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height for mobile browsers */
  }

  /* Hide desktop popup on mobile */
  .popup {
    display: none !important;
  }

  /* ── Mobile header bar ── */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    padding: 12px 16px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
  }

  .mobile-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c2c2c;
    letter-spacing: -0.02em;
  }

  .mobile-search-toggle {
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #d4d0ca;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: all 0.15s;
  }

  .mobile-search-toggle:active {
    background: #f0ece6;
    transform: scale(0.92);
  }

  /* ── Mobile search overlay ── */
  .mobile-search {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    padding: 10px 12px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }

  .mobile-search.open {
    display: block;
  }

  .mobile-search-inner {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .mobile-search-inner input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d4d0ca;
    border-radius: 20px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    background: #fff;
  }

  .mobile-search-inner input:focus {
    border-color: #2c3e6b;
  }

  #mobile-search-btn {
    padding: 10px 18px;
    background: #2c3e6b;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-search-cancel {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Move map controls below mobile header */
  .map-controls {
    top: 64px;
  }

  /* ── Bottom sheet ── */
  .bottom-sheet {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 35;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    max-height: 70vh;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
  }

  .bottom-sheet.open {
    transform: translateY(0);
  }

  .bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: #d4d0ca;
    border-radius: 2px;
    margin: 10px auto 0;
  }

  .bottom-sheet-close {
    position: absolute;
    top: 8px;
    right: 14px;
    width: 32px;
    height: 32px;
    background: #f0ece6;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.1s;
  }

  .bottom-sheet-close:active {
    background: #e0dcd6;
  }

  .bottom-sheet-content {
    padding: 14px 16px 24px;
    overflow-y: auto;
    max-height: calc(70vh - 30px);
    -webkit-overflow-scrolling: touch;
  }

  /* ── Sheet: detail view ── */
  .sheet-detail-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 14px;
  }

  .sheet-detail-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0;
  }

  .sheet-detail-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e6b;
    margin: 6px 0;
  }

  .sheet-detail-desc {
    font-size: 0.88rem;
    color: #666;
    line-height: 1.45;
    margin: 8px 0;
  }

  .sheet-detail-meta {
    font-size: 0.78rem;
    color: #aaa;
    margin: 8px 0;
  }

  .sheet-detail-directions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 20px;
    background: #2c3e6b;
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s;
  }

  .sheet-detail-directions:active {
    background: #1e2d4d;
  }

  /* ── Sheet: search results list ── */
  .sheet-results-header {
    font-size: 0.78rem;
    color: #999;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0ece6;
  }

  .sheet-listing-card {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0ece6;
    cursor: pointer;
  }

  .sheet-listing-card:active {
    background: #faf8f5;
  }

  .sheet-listing-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
  }

  .sheet-listing-info {
    flex: 1;
    min-width: 0;
  }

  .sheet-listing-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c2c2c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sheet-listing-desc {
    font-size: 0.78rem;
    color: #888;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sheet-listing-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    align-items: center;
  }

  .sheet-listing-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: #2c3e6b;
  }

  .sheet-listing-distance {
    font-size: 0.72rem;
    color: #aaa;
  }

  .sheet-empty {
    text-align: center;
    padding: 32px 0;
    color: #aaa;
    font-size: 0.9rem;
  }
}
