/* Catalog navigation and listing rhythm */
:root {
  --market-gutter: clamp(17px, 5.4vw, 24px);
  --control-tint: #e7f0e9;
  --catalog-nav-bottom: max(10px, env(safe-area-inset-bottom));
}
html { scrollbar-gutter: stable both-edges; }
html.catalog-dialog-open {
  overflow: hidden;
  overscroll-behavior: none;
}
dialog { overscroll-behavior: contain; }
dialog::backdrop { touch-action: none; }
.desktop-search { display: none; }

.brand { text-align: start; }
.brand strong {
  font-size: clamp(1.05rem, 5.05vw, 1.55rem);
  letter-spacing: -.045em;
}
.brand small {
  margin-top: 2px;
  color: #5e6962;
  text-align: start;
  font-size: .6rem;
}
.header-controls { gap: 0; }
.header-controls .icon, .header-controls .language {
  background: transparent;
  border: 0;
  border-radius: 22px;
  box-shadow: none;
}
.header-controls .language .current {
  background: #edf2ee;
  box-shadow: none;
}
@media (hover: hover) and (pointer: fine) {
  .header-controls .icon:hover { color: var(--green); }
}

.discovery-controls {
  background: #fff;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 0;
  padding: 8px var(--market-gutter) 8px;
  box-shadow: 0 10px 18px -20px #18322590;
}
.discovery-controls .town-button {
  min-height: 44px;
  padding: 3px 10px 3px 6px;
  background: #f6f8f5;
  border: 0;
  box-shadow: none;
}
.town-button > span:first-child { width: 25px; height: 25px; }
.town-button > span:first-child svg { width: 16px; height: 16px; }
.town-button .town-label {
  display: flex;
  align-items: baseline;
  gap: 9px;
  white-space: nowrap;
  overflow: hidden;
}
.town-label b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.town-label small { flex: 0 0 auto; margin: 0; font-size: .72rem; }

.category-row {
  grid-template-columns: .9fr 1.25fr 1.05fr .85fr;
  gap: 7px;
  margin-top: 9px;
  padding-bottom: 0;
}
.category-row > button[data-category],
.category-row > button.access-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 4px;
  min-height: 44px;
  height: auto;
  padding: 0 3px;
  margin: 0;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: .75rem;
  line-height: 1.15;
  text-align: center;
  isolation: isolate;
}
.category-row > button::before {
  position: absolute;
  z-index: -1;
  inset: 6px 0;
  content: '';
  border-radius: inherit;
  background: #f5f7f4;
}
@media (hover: hover) and (pointer: fine) {
  .category-row > button:not(.active):hover::before { background: #ebf1ec; }
}
.category-row button > span:first-child { display: flex; }
.category-row button > span:last-child { min-inline-size: 0; overflow-wrap: anywhere; hyphens: none; }
.category-row button svg, .category-row .access-button svg {
  width: 13px;
  height: 13px;
  color: var(--green);
}
.category-row > button[data-category].active,
.category-row > button.access-button.active {
  color: #1f5641;
  background: transparent;
  font-weight: 650;
}
.category-row > button.active::before { background: var(--control-tint); }
.category-row > button.active svg { color: inherit; }
.category-row > button.active::after { display: none; }

.catalog-intro { display: grid; grid-template-columns: minmax(0,1fr); gap: 3px; margin: 0; }
.catalog-intro h1:not(.sr-only) { margin-bottom: 3px; }
#catalog-title.quiet-focus:focus { outline: none; }
.catalog-refinements {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  column-gap: 10px;
  margin-bottom: 2px;
}
#filter-summary {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#filter-summary::-webkit-scrollbar { display: none; }
#filter-summary button {
  display: grid;
  flex: none;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  max-width: 100%;
  padding: 0;
  background: transparent;
  color: var(--green);
  font-size: .7rem;
  font-weight: 550;
}
#filter-summary button:focus-visible { outline-offset: -2px; }
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 23px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 20px;
  background: #edf3ed;
  white-space: nowrap;
}
.filter-pill-label {
  min-width: 0;
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-pill > [aria-hidden] { flex-shrink: 0; font-size: .85rem; line-height: 1; }
#filter-summary button:hover .filter-pill { background: #e3ede3; }
#clear-filters {
  min-height: 44px;
  padding: 0 1px;
  color: var(--green);
  font-size: .75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
#clear-filters:hover { text-decoration: underline; }
.catalog-refinements .quiet-focus:focus { outline: none; }

/* A single link covers the photo and its caption. */
.property-card .property-link {
  display: block;
  height: 100%;
  border-radius: 14px;
}
.property-card .card-image { width: 100%; box-shadow: none; }
.property-card .card-image .badge { padding: 3px 7px; }
.property-card .save svg { width: 19px; }
.property-card .save:not(.saved) svg { fill: none; }
.property-card .save.saved svg { fill: #fff; }
.heart-effects { position: absolute; width: 0; height: 0; pointer-events: none; }
[data-save] .heart-depth {
  fill: #000;
  stroke: none;
  filter: url(#property-heart-depth);
}
[data-save].saved .heart-depth { display: none; }
.property-card .card-image img { display: block; }
.property-card .missing-photo { padding: 12px; text-align: center; }
.property-card .card-copy { min-width: 0; padding: 8px 2px 0; color: var(--ink); }
.property-card .card-copy h3 {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.property-card .card-copy .card-meta {
  margin-top: 3px;
  color: #4e5b54;
  line-height: 1.22;
}
.property-card .card-meta > span:first-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.property-card .property-link:focus-visible { outline-offset: 2px; }

.market-footer {
  display: grid;
  justify-items: center;
  margin-block: 36px 8px;
  padding: 24px 0 16px;
  border-top: 1px solid #e3e9e2;
  text-align: center;
}
.social-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 294px);
  padding: 0;
  margin: 0;
}
.social-links a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  color: #34463c;
  font-size: .77rem;
  overflow-wrap: anywhere;
}
.social-links a:hover { color: var(--green); text-decoration: underline; }
.social-links img { width: 15px; height: 15px; }

.bottom-nav {
  inset-inline: 0;
  bottom: var(--catalog-nav-bottom);
  width: min(310px, calc(100% - 2 * max(var(--market-gutter), env(safe-area-inset-left), env(safe-area-inset-right))));
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 4px;
  border: 1px solid #dfe6df;
  border-radius: 20px;
  background: #fff;
  box-shadow: none;
}
.bottom-nav button {
  position: relative;
  display: grid;
  grid-template-rows: 21px auto;
  place-content: center;
  place-items: center;
  justify-self: stretch;
  max-width: none;
  padding: 0 1px;
  gap: 2px;
  line-height: 1.15;
  min-height: 44px;
  border-radius: 15px;
  color: #536159;
  font-size: .75rem;
}
.bottom-nav button[aria-current="page"] {
  color: var(--green);
  background: transparent;
  font-weight: 650;
}
.bottom-nav button[aria-expanded="true"], #saved-top[aria-current="page"] { color: var(--green); }
:is(#saved-tab, #saved-top)[aria-current="page"] svg { fill: currentColor; }
.bottom-nav button > [data-i] {
  display: grid;
  place-items: center;
  width: 28px;
  height: 21px;
}
.bottom-nav button svg { width: 15px; height: 15px; }

#towns-tab:disabled, #change-location:disabled { opacity: .55; cursor: default; }

#search-dialog { padding: 16px; }
#search-dialog, #filter-dialog { background: #fff; }
#search-dialog .dialog-head { margin-bottom: 8px; }
#search-dialog .dialog-head h2 { font-size: 1.15rem; }
#search-dialog .dialog-head button, #filter-dialog .dialog-head button,
.catalog-popup .dialog-head button { width: 44px; height: 44px; }
.search-field { min-height: 44px; padding: 0 12px; }
.search-field:focus-within { box-shadow: 0 0 0 2px #49705e; }
.search-field input { min-height: 44px; outline: none; }
.catalog-popup .location-option {
  min-height: 48px;
  padding: 6px 8px;
  gap: 11px;
}
.catalog-popup .location-option > svg:first-child {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 7px;
}
#guide-dialog .guide-content { padding: 0; }
#guide-dialog .guide-content > p { font-size: .88rem; line-height: 1.45; }
#guide-dialog .guide-search { margin-top: 12px; }
#guide-dialog .guide-content h3 { margin: 14px 0 4px; }
#filter-dialog fieldset { margin-block: 12px 0; }
#filter-dialog .radio-row {
  width: 100%;
  min-height: 48px;
  padding-block: 10px;
  border-bottom: 0;
  text-align: start;
}
#filter-dialog .dialog-bottom { margin-top: 12px; padding-top: 12px; }
.access-check {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 1.5px solid #85948a;
  border-radius: 50%;
}
.radio-row[aria-pressed="true"] .access-check {
  border: 6px solid var(--green);
}

@media (max-width: 799px) {
  .home-header {
    min-height: 56px;
    padding: 6px max(var(--market-gutter), env(safe-area-inset-right)) 6px max(var(--market-gutter), env(safe-area-inset-left));
  }
  .discovery-controls { padding-inline: max(var(--market-gutter), env(safe-area-inset-left)) max(var(--market-gutter), env(safe-area-inset-right)); }
  #catalog { padding: 16px max(var(--market-gutter), env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) max(var(--market-gutter), env(safe-area-inset-left)); }
  .catalog-intro h1 { font-size: 1.12rem; line-height: 1.3; }
  .grid { gap: 22px 14px; }
  .property-card .card-copy h3 { font-size: .85rem; }
  .property-card .card-copy .card-meta { font-size: .75rem; }
  .property-card .card-image {
    aspect-ratio: 1.24;
    height: auto;
    border-radius: 15px;
  }
  #search-dialog .dialog-bottom { margin-top: 18px; padding-top: 14px; }
  .owner-invite { padding: 22px var(--market-gutter); }
}

@media (max-width: 365px) {
  .category-row button > span:first-child { display: none; }
  .brand strong { font-size: clamp(.91rem, 4.75vw, 1.08rem); }
  .town-label small { font-size: .68rem; }
}

@media (min-width: 800px) {
  .discovery-controls { padding-block: 10px 8px; }
  .grid { gap: 30px 22px; }
}
@media (min-width: 1024px) {
  #home .header-controls #open-search { display: none; }
  .discovery-controls {
    display: grid;
    grid-template-columns: minmax(205px, 1.1fr) minmax(205px, 1.1fr) minmax(408px, 1.65fr);
    align-items: center;
    gap: 12px;
    max-width: 1280px;
    margin-inline: auto;
    padding: 9px 40px 10px;
  }
  .desktop-search {
    display: flex;
    align-items: center;
    min-width: 0;
    border: 1px solid #dce6df;
    border-radius: 24px;
    background: #fff;
  }
  .desktop-search input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0 0 0 13px;
    background: transparent;
    border: 0;
    border-radius: 24px;
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
  }
  .desktop-search button {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    min-height: 44px;
    border-radius: 50%;
    color: var(--green);
  }
  .desktop-search button span { display: grid; place-items: center; }
  .desktop-search button svg { width: 17px; height: 17px; }
  .discovery-controls .category-row { margin-top: 0; }
  #home .category-row > button { font-size: .83rem; }
  .property-card .card-copy h3 { font-size: 1.0625rem; }
  .property-card .card-copy .card-meta { font-size: .875rem; }
}
@media (min-width: 800px) and (min-height: 620px) {
  .property-card .card-image {
    max-height: clamp(210px, (100svh - 23.25rem) / 2, 360px);
  }
}

/* Keep the landscape phone viewport available for browsing. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1023px) {
  .home-header { min-height: 44px; padding: 0 14px; }
  .discovery-controls {
    position: static;
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 2.1fr;
    align-items: center;
    gap: 10px;
    padding: 3px 14px;
  }
  .discovery-controls .town-button { min-height: 44px; }
  .category-row { width: 100%; margin: 0; padding: 0; }
  #catalog { padding: 6px 14px 80px; }
  .catalog-intro h1 { font-size: 1.12rem; }
  .grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px 12px; }
  .property-card .card-image { height: auto; aspect-ratio: 1.25; }
}
