/**
 * style/app.css
 *
 * Map application styles (BUILD-SPEC §4). Builds on the design tokens in
 * style/base.css (loaded first in app.html); no new color tokens are
 * introduced outside base.css's :root variables so light/dark stay in sync.
 */

/* ---------------------------------------------------------------------- */
/* Search + filter pill bar                                               */
/* ---------------------------------------------------------------------- */

#search-mount {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  width: min(22rem, calc(100vw - 2rem));
}

.search-input {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-body);
  background: transparent;
  color: var(--color-text);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
}

.search-results:empty {
  display: none;
}

.search-result {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
  cursor: pointer;
}

.search-result.is-active,
.search-result:hover {
  background: var(--color-surface);
}

.search-result-badge {
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0 var(--space-1);
}

.search-empty {
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.filter-pill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-pill {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-small);
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.filter-pill[aria-pressed="true"] {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.filter-loading {
  color: var(--color-text-muted);
  font-style: italic;
}

.type-checkboxes {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2);
  flex-direction: column;
  gap: var(--space-1);
  white-space: nowrap;
  z-index: 3;
}

.filter-pill[data-filter="type"]:focus-within .type-checkboxes,
.filter-pill[data-filter="type"]:hover .type-checkboxes {
  display: flex;
}

.price-histogram {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  gap: 1px;
  align-items: flex-end;
  height: 3rem;
  width: 14rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-1);
  z-index: 3;
}

.filter-pill[data-filter="price"]:focus-within .price-histogram,
.filter-pill[data-filter="price"]:hover .price-histogram {
  display: flex;
}

.histogram-bin {
  flex: 1;
  background: var(--color-accent);
  min-height: 1px;
}

/* ---------------------------------------------------------------------- */
/* Listing cards                                                          */
/* ---------------------------------------------------------------------- */

.card-list {
  display: grid;
  gap: var(--space-3);
}

.card-list-empty {
  color: var(--color-text-muted);
}

.listing-card {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-bg);
}

.card-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--color-surface);
}

.card-watch-heart,
.detail-watch-heart {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  border: none;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.card-body {
  padding: var(--space-2) var(--space-3);
  display: grid;
  gap: var(--space-1);
}

.card-address {
  margin: 0;
  font-weight: 600;
}

.card-price {
  margin: 0;
  font-size: var(--font-size-h3);
}

.card-specs,
.card-listed {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* ---------------------------------------------------------------------- */
/* Sidebar (area view)                                                    */
/* ---------------------------------------------------------------------- */

#sidebar-mount {
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  padding: 0;
  transition: width 0.2s ease;
  overflow-y: auto;
  z-index: 4;
}

#sidebar-mount.is-open {
  width: min(24rem, 90vw);
  padding: var(--space-4);
}

.sidebar-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  float: right;
}

.sidebar-area-name {
  margin-top: 0;
}

.sidebar-area-stats {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}

.area-stats-basis {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.trend-up {
  color: var(--color-trend-up);
}
.trend-down {
  color: var(--color-trend-down);
}
.trend-flat {
  color: var(--color-trend-flat);
}

.watch-milestone-note {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* ---------------------------------------------------------------------- */
/* Listing detail + parcel overlay                                       */
/* ---------------------------------------------------------------------- */

#detail-mount,
#parcel-mount {
  position: absolute;
  inset: 0;
  background: var(--color-bg);
  overflow-y: auto;
  display: none;
  z-index: 5;
  padding: var(--space-4);
}

#detail-mount.is-open,
#parcel-mount.is-open {
  display: block;
}

.detail-back {
  border: none;
  background: transparent;
  font-size: var(--font-size-body);
  cursor: pointer;
  padding: var(--space-2) 0;
}

.carousel {
  position: relative;
  margin: var(--space-2) 0;
}

.carousel-slides {
  aspect-ratio: 16 / 10;
  background: var(--color-surface);
  overflow: hidden;
}

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

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
}

.carousel-arrow--prev {
  left: var(--space-2);
}
.carousel-arrow--next {
  right: var(--space-2);
}

.carousel-thumbs {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-2);
  overflow-x: auto;
}

.carousel-thumb {
  border: 2px solid transparent;
  padding: 0;
  background: none;
  cursor: pointer;
  flex: none;
}

.carousel-thumb img {
  width: 3.5rem;
  height: 2.5rem;
  object-fit: cover;
  display: block;
}

.carousel-thumb.is-active {
  border-color: var(--color-accent);
}

.detail-address {
  margin-bottom: 0;
}

.detail-price {
  font-size: var(--font-size-h2);
  margin-top: 0;
}

.price-change {
  color: var(--color-trend-down);
  font-weight: 600;
}

.facts-panel {
  margin: var(--space-3) 0;
}

.remarks-paragraph {
  max-width: 40rem;
}

.parcel-overlay--loading .skeleton,
.detail-loading {
  background: var(--color-surface);
  border-radius: var(--radius);
}

.skeleton {
  height: 1.25rem;
  margin-bottom: var(--space-2);
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-header {
  height: 2rem;
  width: 60%;
}

.skeleton-block {
  height: 6rem;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.parcel-sale-muted {
  color: var(--color-text-muted);
}

.parcel-sale-muted-label {
  font-size: var(--font-size-small);
}

.claim-cta {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin: var(--space-3) 0;
  background: var(--color-surface);
}

.claim-cta-button {
  display: inline-block;
  margin-top: var(--space-2);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
}

.parcel-fact-tile {
  display: inline-block;
  min-width: 5rem;
  margin: 0 var(--space-3) var(--space-3) 0;
}

.parcel-fact-tile dt {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.parcel-fact-tile dd {
  margin: 0;
  font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* Responsive layout                                                      */
/*                                                                        */
/* Everything above is the small-screen layout and stays the default:     */
/* one column, overlays that take the full viewport. That was the ONLY    */
/* layout until 2026-08-09, so on a desktop the map app rendered as a     */
/* phone UI stretched wide -- opening a listing hid the entire map behind */
/* a full-bleed panel, and the sidebar did the same.                      */
/*                                                                        */
/* Breakpoints are in rem so they track the user's font size rather than  */
/* device pixels: 48rem (~768px) is where a docked panel beside the map   */
/* starts to beat a full-bleed overlay; 90rem (~1440px) is where there is */
/* room for the panel to grow without the map becoming a sliver.          */
/* ---------------------------------------------------------------------- */

@media (min-width: 48rem) {
  /* Detail and parcel views become a docked panel: the map stays visible
     and interactive beside them, which is the whole point of a map app on
     a large screen. `inset: 0 auto 0 0` pins top/bottom/left and frees the
     right edge so `width` governs. */
  #detail-mount,
  #parcel-mount {
    inset: 0 auto 0 0;
    width: clamp(24rem, 34vw, 32rem);
    border-right: 1px solid var(--color-border);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.14);
  }

  /* Match the sidebar to the same rail so the two never disagree by a few
     pixels when one replaces the other. */
  #sidebar-mount.is-open {
    width: clamp(22rem, 30vw, 28rem);
  }

  /* Cards flow into as many columns as the panel can hold. Inside a ~26rem
     panel that is still one column; it becomes two only if the panel or
     viewport grows, so this needs no separate breakpoint. */
  .card-list {
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  }

  #search-mount {
    width: clamp(22rem, 26vw, 28rem);
  }

  /* Keep the filter bar clear of the docked panel rather than centred on
     the viewport (where a panel would cover it). */
  #filters-mount {
    left: auto;
    right: var(--space-3);
    transform: none;
  }

  /* Reclaim vertical space for the map: the four compliance lines are
     required, but on a wide screen they fit on far fewer rows. */
  .app-shell .site-footer {
    margin-top: 0;
  }

  .app-shell .site-footer__inner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: var(--space-4);
    row-gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
  }
}

@media (min-width: 90rem) {
  #detail-mount,
  #parcel-mount {
    width: clamp(30rem, 28vw, 38rem);
  }

  .carousel-thumb img {
    width: 4.5rem;
    height: 3.25rem;
  }
}

/* Short viewports (laptops, split screens): the chrome must not squeeze the
   map into a strip. Below this height the footer's compliance text scrolls
   with the page instead of permanently occupying the viewport. */
@media (max-height: 34rem) {
  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .app-shell main#main-content {
    min-height: 26rem;
  }
}
