/* ============================================================
   Housing Direct — portal responsive overrides
   Loaded LAST on every portal page, mirroring hdp-responsive.css on the
   platform side. Holds the @media rules that were scattered inline plus the
   mobile navigation layer.
   ============================================================ */

/* ---------- @media(max-width:900px) ---------- */
@media(max-width:900px){
  .inbox{grid-template-columns:1fr}
  :where(body.p-la-search) .slay{grid-template-columns:1fr}
  :where(body.p-la-search) .fpanel{position:static!important;max-height:none!important}
  .bd-grid{grid-template-columns:1fr}
  .setup-grid{grid-template-columns:1fr}
}

/* ---------- @media(max-width:860px) ---------- */
@media(max-width:860px){
  :where(body.p-la-dashboard) .pipe{grid-template-columns:1fr auto}
  :where(body.p-la-rates-leasing) .bands{grid-template-columns:repeat(2,1fr)}
  :where(body.p-la-rates-leasing) .inc-row{grid-template-columns:1fr auto}
  :where(body.p-la-shortlist) .slrow{grid-template-columns:90px 1fr;grid-auto-rows:auto}
  :where(body.p-la-shortlist) .sl-actions{grid-column:1/-1}
  .login{grid-template-columns:1fr}
  .login-aside{display:none}
}

/* ---------- @media(max-width:800px) ---------- */
@media(max-width:800px){
  :where(body.p-la-property) .spec-bar{grid-template-columns:repeat(2,1fr)}
  :where(body.p-la-team) .trow{grid-template-columns:auto 1fr auto}
  :where(body.p-la-team) .trow .email{display:none}
}

/* ---------- @media(max-width:760px) ---------- */
@media(max-width:760px){
  .c-list-row{grid-template-columns:auto 1fr auto}
  .c-cert,.c-exp{display:none}
  .t-row{grid-template-columns:auto 1fr auto}
  .t-role,.t-active{display:none}
}

/* ---------- @media(max-width:700px) ---------- */
@media(max-width:700px){
  :where(body.p-la-booking) .gallery{grid-template-columns:1fr;height:auto}
  /* variant: la/property.html */
  :where(body.p-la-property) .gallery{grid-template-columns:1fr}
  :where(body.p-la-booking,body.p-la-property) .gallery .g-side{display:none}
  :where(body.p-la-booking) .gallery img:first-child{height:220px}
  :where(body.p-la-household) .of-grid{grid-template-columns:1fr}
  .term-grid{grid-template-columns:repeat(2,1fr)}
  :where(body.p-la-property) .spec-grid{grid-template-columns:repeat(2,1fr)}
  :where(body.p-la-property) .featg{grid-template-columns:repeat(2,1fr)}
  :where(body.p-ll-visibility) .v-list-row{grid-template-columns:auto 1fr auto}
  :where(body.p-ll-visibility) .v-list-row .pill{display:none}
}

/* ---------- @media(max-width:640px) ---------- */
@media(max-width:640px){
  :where(body.p-la-household-edit) .srow3{grid-template-columns:1fr}
  :where(body.p-la-household-edit) .ckgrid{grid-template-columns:1fr}
  .three{grid-template-columns:1fr}
}

/* ---------- @media(max-width:560px) ---------- */
@media(max-width:560px){
  .kgrid{grid-template-columns:1fr}
  .kgrid .kv:nth-child(2){border-top:1px solid var(--line-2)}
}

/* ---------- @media(max-width:520px) ---------- */
@media(max-width:520px){
  .addr-grid{grid-template-columns:1fr}
  .two{grid-template-columns:1fr}
  .photo-grid{grid-template-columns:repeat(2,1fr)}
}

/* ============================================================
   MOBILE NAVIGATION
   portal.css hides .nav below 960px and there was no fallback,
   so the portal had no navigation at all on a phone or tablet.
   portal-mobile-nav.js injects the button and drawer; these are
   its styles. Breakpoint matches .nav's own 960px.
   ============================================================ */
.mobile-menu-btn{display:grid;place-items:center;width:40px;height:40px;border-radius:13px;border:1px solid var(--line);background:#fff;color:var(--ink);cursor:pointer;flex-shrink:0}
.mobile-menu-btn:hover{background:var(--tint-stone)}
@media(min-width:960px){.mobile-menu-btn{display:none}}
.mobile-nav{display:none;flex-direction:column;gap:2px;padding:8px 32px 14px;border-top:1px solid var(--line-2)}
.mobile-nav.open{display:flex}
@media(min-width:960px){.mobile-nav{display:none!important}}
.mobile-nav a{display:flex;align-items:center;min-height:44px;padding:10px 14px;border-radius:12px;font-size:15px;font-weight:500;color:var(--ink-2)}
.mobile-nav a:hover{background:var(--tint-stone);color:var(--ink)}
.mobile-nav a.active{background:var(--tint-stone);color:var(--ink);font-weight:600}
@media(max-width:640px){.mobile-nav{padding:8px 18px 14px}}

/* ============================================================
   NARROW VIEWPORTS
   The layouts that break first: two-pane lists, the wizard's
   side-by-side fields, wide tables and the search filter rail.
   ============================================================ */
@media(max-width:900px){
  /* message inbox, booking detail, occupant/property detail sidebars */
  .inbox,.bd-grid{grid-template-columns:1fr}
  /* search: filter rail above results */
  .slay{grid-template-columns:1fr}
  .fpanel{position:static;max-height:none}
}
@media(max-width:760px){
  h1{font-size:30px}
  .page-header{flex-direction:column;align-items:stretch;gap:14px}
  .page-actions{flex-wrap:wrap}
  /* wizard: stack paired fields and shrink the photo grid */
  .two,.addr-grid{grid-template-columns:1fr}
  .photo-grid{grid-template-columns:repeat(3,1fr)}
  .wfooter{gap:10px}
  .wfooter .btn{flex:1}
  /* galleries are fixed-height grids on desktop */
  .gallery{grid-template-columns:1fr!important;height:auto!important}
  .gallery .g-side{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .gallery .g-main{height:220px!important}
  .kgrid{grid-template-columns:1fr}
}
@media(max-width:560px){
  h1{font-size:26px}
  .photo-grid{grid-template-columns:repeat(2,1fr)}
  .stepbar{gap:4px}
  .tile-grid{grid-template-columns:1fr!important}
}
/* wide tables scroll inside their card rather than pushing the page */
@media(max-width:900px){
  .card:has(.ctable),.card:has(.htable),.card:has(.ltable){overflow-x:auto}
  .ctable,.htable,.ltable{min-width:620px}
}

/* ============================================================
   SITE FOOTER — spacing only; hd-footer.css owns the styling
   ============================================================ */
@media(max-width:640px){
  .site-foot-in{flex-direction:column;align-items:flex-start;gap:14px}
}

/* ============================================================
   NARROW VIEWPORTS — second pass
   Found by measuring documentElement.scrollWidth on all 93 pages
   at 375px. These layouts set grid columns inline, so the
   overrides need !important to win against the style attribute.
   ============================================================ */
@media(max-width:900px){
  /* detail pages: the sticky summary rail sits under the content */
  div:has(>.sticky-col){grid-template-columns:1fr!important}
  .sticky-col{position:static!important;top:auto!important}
  /* search: filter rail full width, results column allowed to shrink */
  .slay>*{min-width:0}
  .sgrid{min-width:0}
}
@media(max-width:760px){
  /* inline 2-up grids (needs profile, address blocks, summary pairs) */
  [style*="grid-template-columns:1fr 1fr"],[style*="grid-template-columns: 1fr 1fr"]{grid-template-columns:1fr!important}
  [style*="grid-template-columns:repeat(3"],[style*="grid-template-columns: repeat(3"]{grid-template-columns:1fr 1fr!important}
  [style*="grid-template-columns:repeat(4"],[style*="grid-template-columns: repeat(4"]{grid-template-columns:1fr 1fr!important}
  .stat-grid{grid-template-columns:1fr 1fr!important}
  /* auth: the marketing panel drops away, the form takes the screen */
  .login{grid-template-columns:1fr!important;min-height:0}
  .login-aside{display:none}
  .login-main{padding:32px 18px}
}
@media(max-width:560px){
  [style*="grid-template-columns:repeat(3"],[style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns:repeat(4"],[style*="grid-template-columns: repeat(4"]{grid-template-columns:1fr!important}
  .stat-grid{grid-template-columns:1fr!important}
}

/* grid items default to min-width:auto, which keeps a column at its
   content's min-content width — that is what pushed the detail pages
   past the viewport at 375px. Letting the items shrink fixes it. */
@media(max-width:900px){
  .grid-detail,.grid-2,.grid-2b,.slay,.inbox,.bd-grid,.kgrid{min-width:0}
  .grid-detail>*,.grid-2>*,.grid-2b>*,.slay>*,.inbox>*,.bd-grid>*,.sticky-col>*{min-width:0}
  .card,.card-hd,.form-card,.fpanel,.sec-card{min-width:0}
  .card-hd{flex-wrap:wrap}
}

@media(max-width:760px){
  /* auth card: let the form column shrink with the viewport */
  .login,.login-main{min-width:0}
  .login-main>*{min-width:0;width:100%;max-width:420px}
}
@media(max-width:640px){
  /* search results header: count and view switch on separate lines */
  .results-head{flex-wrap:wrap;gap:10px}
  .results-head>*{min-width:0}
}
