/* ROOVI area styles: housing (homes list, home, interest, requests, the wonen nav). Owned by the housing area.
   Uses the tokens and components from css/app.css. Every selector is scoped under a class prefixed "housing-" so
   areas never collide. Mobile first (390px), no horizontal page scroll; the one horizontal track is the photo gallery
   and the similar-homes strip, both scroll-snap containers. */

/* ----- segmented nav (SPEC 17.3) ----- */
.housing-nav { margin: 0 0 var(--space-4); }
.housing-nav-list {
  display: flex; gap: 4px;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
/* each item takes the width its label needs: "Verzoeken" never breaks mid-word in Dutch at 375px */
.housing-nav-item { flex: 1 1 auto; min-width: 0; }
.housing-nav-link {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--tap);
  padding: 6px 4px;
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600; line-height: 1.2;
  color: var(--text-secondary);
  text-align: center; white-space: nowrap; overflow-wrap: normal;
  text-decoration: none;
}
.housing-nav-link:hover { color: var(--text); }
.housing-nav-link.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.housing-nav-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.housing-nav-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint); color: var(--accent-strong);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ----- shared layout ----- */
.housing-slot:empty { display: none; }
.housing-slot { margin-top: var(--space-2); }
.housing-form-error:empty { display: none; }
.housing-form-error { margin-bottom: var(--space-3); }
.housing-attribution { margin: var(--space-4) 0 var(--space-3); line-height: 1.45; }
.housing-paste-action { margin-top: var(--space-2); }
.housing-empty { padding-top: var(--space-4); }

/* ----- homes list: chips, grid ----- */
/* one row that never wraps: a long city name scrolls the row sideways instead of pushing Filters onto a second line */
/* the scroll box gets 4px of padding (and the same negative margin) so the 2px focus ring of a chip is not clipped by overflow */
.housing-chips {
  display: flex; flex-wrap: nowrap; gap: 6px;
  padding: 4px; margin: -4px -4px calc(var(--space-4) - 4px);
  overflow-x: auto;
  scrollbar-width: none;
}
.housing-chips::-webkit-scrollbar { display: none; }
.housing-chip { flex: 0 0 auto; min-height: var(--tap); padding-inline: 10px; white-space: nowrap; }
.housing-results { min-width: 0; }
.housing-grid {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin: 0; padding: 0; list-style: none;
}
.housing-grid-item { min-width: 0; }
.housing-more { margin-top: var(--space-4); }
.housing-fallback { display: flex; flex-direction: column; gap: var(--space-3); }
.housing-fallback-form { display: flex; flex-direction: column; gap: var(--space-3); }
.housing-fallback-form .field { margin-bottom: 0; }
.housing-retry { align-self: flex-start; }

@media (min-width: 640px) {
  .housing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .housing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ----- the filter sheet ----- */
.housing-filter-form { display: flex; flex-direction: column; gap: var(--space-3); }
.housing-filter-form .field { margin-bottom: 0; }
.housing-filter-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.housing-filter-pair .field { min-width: 0; }
/* two columns on a phone (a 136px cell fits "Gemeubileerd" in Dutch on one line; three cells of that width do not fit 358px) */
.housing-segmented .choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: var(--space-2); }
.housing-segmented .choice {
  justify-content: center;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
}
.housing-segmented .choice input { position: absolute; width: 1px; height: 1px; opacity: 0; margin: 0; }
.housing-segmented .choice-body { align-items: center; }

/* ----- a home card in the grid and in similar homes (the whole card is the link) ----- */
.housing-tile {
  display: flex; flex-direction: column;
  height: 100%;
  padding: 0; overflow: hidden;
  color: inherit; text-decoration: none;
}
.housing-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.housing-tile-body { display: flex; flex-direction: column; gap: 4px; padding: var(--space-3) var(--space-4) var(--space-4); min-width: 0; }
.housing-tile-price { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.housing-tile-address { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.housing-tile-meta { margin: 0; font-size: 14px; line-height: 1.4; color: var(--text-secondary); overflow-wrap: anywhere; }
.housing-tile-via { margin: var(--space-1) 0 0; font-size: 12px; color: var(--text-tertiary); }

/* ----- photos: a 4:3 box, so nothing shifts while the image loads ----- */
.housing-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-2);
}
.housing-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.housing-photo-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
}

/* ----- gallery: scroll snap, one photo per view ----- */
.housing-gallery { margin: 0 calc(var(--space-4) * -1) var(--space-4); }
.housing-gallery-track {
  display: flex; overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.housing-gallery-track::-webkit-scrollbar { display: none; }
.housing-gallery-track:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) {
  .housing-gallery-track { scroll-behavior: auto; }
}
.housing-slide {
  flex: 0 0 100%;
  margin: 0; min-width: 0;
  scroll-snap-align: start;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
}
.housing-slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.housing-gallery-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-2) var(--space-4) 0;
}
.housing-gallery-bar[hidden] { display: none; }
.housing-gallery-count { margin: 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ----- one home ----- */
.housing-home { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.housing-home-body { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.housing-price { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.housing-address { margin: calc(var(--space-1) * -1) 0 0; font-size: 16px; color: var(--text-secondary); overflow-wrap: anywhere; }
.housing-age { margin: 0; }
.housing-facts { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.housing-fact { min-width: 0; }
.housing-description-block { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.housing-description { font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.housing-description p { margin: 0 0 var(--space-3); }
.housing-description p:last-child { margin-bottom: 0; }
.housing-description.is-clamped:not(.is-open) { max-height: 6.2em; overflow: hidden; }
.housing-more-toggle { margin-left: calc(var(--space-2) * -1); }
.housing-sources { display: flex; flex-direction: column; gap: var(--space-2); }
.housing-source { width: 100%; }
.housing-similar > .section-title { margin-bottom: var(--space-3); }
.housing-strip {
  display: flex; gap: var(--space-3);
  margin: 0; padding: 0 var(--space-4) var(--space-2);
  overflow-x: auto; list-style: none;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--space-4); /* a snapped card keeps the 16px gutter, like the padding does */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.housing-strip-item {
  flex: 0 0 72%; min-width: 0;
  max-width: 280px;
  scroll-snap-align: start;
}
.housing-strip-item .housing-tile { height: auto; }
.housing-similar { margin: 0 calc(var(--space-4) * -1); }
/* the place of the similar homes while they are not loaded: it takes no space in the column (the observer still sees it) */
.housing-similar-slot:empty { height: 0; margin-top: calc(var(--space-4) * -1); }
.housing-similar > .section-head { padding: 0 var(--space-4); }
.housing-similar .section-title { margin: 0; }

/* the call to action stays on screen while the athlete reads the home (above the tab bar on phones) */
.housing-sticky {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-3));
  z-index: 6;
  padding: var(--space-2);
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}
/* the confirmation toast sits above the sticky bar on this page */
body:has(.housing-sticky) #toast-region { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 84px); }

/* ----- the interest screen: paste first ----- */
.housing-interest-form { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.housing-link-card .field { margin-bottom: var(--space-3); }
.housing-paste { margin: 0; }
.housing-paste-input {
  min-height: 96px;
  font-size: 16px; /* 16px keeps iOS from zooming in on focus */
  overflow-wrap: anywhere;
}
.housing-paste-button { margin-top: var(--space-3); }
.housing-listing-slot:empty { display: none; }
.housing-listing-slot { margin-top: var(--space-4); }
.housing-listing-card { margin: 0; }
.housing-listing-head { margin-bottom: var(--space-2); }
.housing-listing-title { margin: 0 0 var(--space-1); overflow-wrap: anywhere; }
.housing-listing-meta { margin: 0 0 var(--space-3); }
.housing-listing-open { margin-bottom: var(--space-3); }
.housing-listing-card .banner { margin-bottom: var(--space-3); }

/* the confirmation for a live home */
.housing-listing-card .housing-photo { margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-3); width: auto; }
.housing-listing-price { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.housing-listing-address { margin: var(--space-1) 0 0; font-size: 17px; overflow-wrap: anywhere; }
.housing-listing-card > .muted { margin: var(--space-1) 0 0; }
.housing-listing-card > .banner { margin-top: var(--space-3); }
.housing-details .card-title { margin-bottom: var(--space-3); }
.housing-details-list { margin: 0; }
.housing-details-list .kv-row { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.housing-details-list .kv-row:last-child { border-bottom: 0; }
.housing-details-change { display: inline-flex; align-items: center; min-height: var(--tap); margin-top: var(--space-2); }

/* the first-request questions (SPEC 16.1, brief 5.8) */
.housing-consent-card .card-title { margin-bottom: var(--space-2); }
.housing-consent-block + .housing-consent-block {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--amber-border);
}
.housing-purpose { font-size: 15px; line-height: 1.5; }
.housing-consent-block .field { margin-bottom: var(--space-2); }
.housing-consent-block .choice-check { margin-top: var(--space-2); }
.housing-consent-block > p { margin: 0 0 var(--space-3); }
.housing-consent-block > .housing-purpose { margin: 0 0 var(--space-3); }
.housing-guidance .card-title { margin-bottom: var(--space-2); }
.housing-consent-card .card-title + p { margin: 0 0 var(--space-3); font-size: 15px; }

/* folded details (section collapsible: the chevron and the tap target come from app.css): the optional fields and what is shared */
.housing-optional { margin: 0; }
.housing-optional-card .field:last-child { margin-bottom: 0; }
.housing-optional-body { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.housing-optional-body .field { margin-bottom: 0; }
.housing-nothing-sent { margin: 0; }
.housing-share-details { margin: 0; }
.housing-share-card p { margin: 0; }
.housing-share-card p + p { margin-top: var(--space-2); }

/* the three-step strip (SPEC 16.1 item 4, trimmed by SPEC 17.0): shown on the paste flow while the field is empty */
.housing-steps { margin: 0 0 var(--space-4); }
.housing-steps-slot:empty { display: none; }
.housing-steps-list {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0; padding: 0; list-style: none;
}
.housing-step {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2);
  min-width: 0; padding: var(--space-3) var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.housing-step-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent-strong);
}
.housing-step-body { display: flex; flex-direction: column; min-width: 0; }
.housing-step-title { font-size: 14px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
@media (max-width: 639px) {
  .housing-steps-list { grid-template-columns: 1fr; }
  .housing-step { flex-direction: row; align-items: center; }
}

/* ----- requests ----- */
.housing-mine-list { min-width: 0; }
.housing-homes { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.housing-request { min-width: 0; }
.housing-home-card { min-width: 0; }
.housing-home-card .card-title { margin-bottom: 0; }
.housing-home-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
.housing-home-top .housing-photo { border-radius: var(--radius); }
.housing-home-text { min-width: 0; }
.housing-home-title { margin: 0; overflow-wrap: anywhere; }
.housing-home-price { margin: var(--space-1) 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.housing-home-where { margin: var(--space-1) 0 0; font-size: 14px; color: var(--text-secondary); overflow-wrap: anywhere; }
.housing-home-host { margin: var(--space-1) 0 0; overflow-wrap: anywhere; }
.housing-home-card .muted.small { margin: var(--space-1) 0 0; }
.housing-viewing { margin: var(--space-3) 0 0; }
.housing-timeline { margin: var(--space-4) 0 0; }
.housing-timeline .timeline-current .timeline-dot { background: var(--amber-strong); border-color: var(--amber-strong); }
.housing-timeline .timeline-current .timeline-title { font-weight: 700; }
.housing-timeline .timeline-next .timeline-title { color: var(--text-tertiary); font-weight: 500; }
.housing-timeline .timeline-danger .timeline-dot { background: var(--danger); border-color: var(--danger); }
.housing-home-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  margin-top: var(--space-4);
}

@media (min-width: 640px) {
  .housing-home-top { grid-template-columns: 180px minmax(0, 1fr); align-items: start; }
  .housing-filter-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .housing-strip-item { flex-basis: 260px; }
}
