/* Homes page: builds on site.css + market.css (v3 tokens) */
.hm-ico { width: 48px; height: 48px; flex: none; display: grid; place-items: center; font-size: 26px;
  background: var(--surface-2); border-radius: var(--radius-sm); }
.hm-card.mine { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), var(--hi); }
.hm-card.st-owned .mk-price, .hm-card.st-rented .mk-price { color: var(--fg-muted); }

/* status badges: one tint per status, text kept at 4.5:1 */
.mk-badge.hm-free { background: color-mix(in oklch, var(--accent) 16%, transparent); color: var(--accent); }
.mk-badge.hm-sale { background: color-mix(in oklch, var(--reward) 16%, transparent); color: var(--reward); }
.mk-badge.hm-owned { background: color-mix(in oklch, var(--magic) 16%, transparent); color: var(--magic); }
.mk-badge.hm-rented { background: color-mix(in oklch, var(--link) 16%, transparent); color: var(--link); }
.mk-badge.hm-overdue { background: color-mix(in oklch, var(--danger) 18%, transparent); color: var(--danger); }

.hm-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.hm-actions .btn { min-height: var(--tap); }
/* "Buy" spends coins, so it wears gold; renting/paying stays emerald (.btn.go) */
.btn.buy { background: var(--reward); border-color: transparent; color: var(--on-reward); }
.btn.buy:hover { background: color-mix(in oklch, var(--reward) 88%, white); }
.btn.warn { background: color-mix(in oklch, var(--danger) 14%, var(--surface-2)); border-color: color-mix(in oklch, var(--danger) 40%, transparent); color: var(--fg); }
.btn.warn:hover { background: color-mix(in oklch, var(--danger) 24%, var(--surface-2)); }
.hm-sell { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; width: 100%; }
.hm-sell input { width: 8.5em; min-height: var(--tap); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg);
  color: var(--fg); padding: 0 var(--sp-3); font: inherit; font-size: 16px; }
.hm-sell input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
@media (max-width: 520px) { .hm-actions .btn { flex: 1 1 100%; } }

/* filter row: tabs, town picker, search */
.hm-town select { min-height: var(--tap); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--fg);
  padding: 0 var(--sp-3); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.mk-tools { justify-content: flex-start; }
.mk-tools .mk-search { margin-left: auto; }
@media (max-width: 600px) {
  .mk-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); }
  .mk-tools .seg { grid-column: 1 / -1; flex-wrap: nowrap; }
  .mk-tools .seg button { flex: 1 1 auto; padding: 0 var(--sp-2); font-size: 15px; white-space: nowrap; }
  .hm-town, .hm-town select, .mk-tools .mk-search, .mk-search input { width: 100%; min-width: 0; }
  .mk-tools .mk-search { margin-left: 0; }
  /* keep the filters in reach while scrolling a long town (only when the screen is tall enough) */
  @media (min-height: 640px) {
    .mk-tools { position: sticky; top: var(--header-h); z-index: 20; margin-inline: -16px; padding: var(--sp-2) 16px;
      background: color-mix(in oklch, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
      border-bottom: 1px solid var(--border); }
  }
}

/* "How renting works" fold-out */
.hm-how { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--hi); }
.hm-how > summary { min-height: var(--tap); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-4); cursor: pointer;
  font-weight: 750; color: var(--fg); list-style: none; }
.hm-how > summary::-webkit-details-marker { display: none; }
.hm-how > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  rotate: 45deg; translate: 0 -2px; transition: rotate var(--dur-2) var(--ease); }
.hm-how[open] > summary::after { rotate: 225deg; translate: 0 2px; }
.hm-how .mk-help { margin: 0; padding: 0 var(--sp-4) var(--sp-4); }

/* one fold-out section per town */
#homes { gap: var(--sp-3); }
.hm-town-group { grid-column: 1 / -1; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--hi); }
.hm-town-group[open] { background: transparent; border-color: transparent; box-shadow: none; }
.hm-sum { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); min-height: 56px; padding: var(--sp-2) 44px var(--sp-2) var(--sp-4);
  position: relative; cursor: pointer; list-style: none; border-radius: var(--radius); }
.hm-sum::-webkit-details-marker { display: none; }
.hm-sum::after { content: ""; position: absolute; right: 20px; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--fg-muted); border-bottom: 2px solid var(--fg-muted);
  rotate: 45deg; translate: 0 -70%; transition: rotate var(--dur-2) var(--ease); }
.hm-town-group[open] > .hm-sum::after { rotate: 225deg; translate: 0 -20%; }
.hm-sum:hover { background: var(--surface-2); }
.hm-town-group[open] > .hm-sum { position: sticky; top: var(--header-h); z-index: 5; background: var(--bg); padding-left: 0; border-radius: 0; }
.hm-group { margin: 0; font-size: var(--step-1); font-weight: 800; }
.hm-group small { font-weight: 650; color: var(--fg-muted); font-size: var(--step--1); margin-left: var(--sp-2); }
.hm-from { font-size: var(--step--1); font-weight: 700; color: var(--fg-muted); margin-left: auto; }
@media (max-width: 600px) { .hm-from { flex-basis: 100%; margin-left: 0; } }
.hm-list { padding-bottom: var(--sp-2); }
.hm-more { width: 100%; margin: var(--sp-1) 0 var(--sp-3); }
/* while the filter row is sticky on phones, the open town title tucks in under it instead of fighting for the same spot */
@media (max-width: 600px) and (min-height: 640px) { .hm-town-group[open] > .hm-sum { position: relative; top: auto; } }

/* phones: tighter cards so more fit on screen (nothing hidden) */
@media (max-width: 600px) {
  .hm-card { padding: var(--sp-3); gap: var(--sp-2); }
  .hm-card .hm-ico { width: 40px; height: 40px; font-size: 22px; }
  .hm-card .hm-actions { padding-top: var(--sp-2); }
}
