/* ==========================================================
   Responsive + performance layer (Windows / desktop + mobile)
   Loaded AFTER style.css. Layout only, no colors or logic.
   ========================================================== */

/* ---------- Base: all devices ---------- */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-padding-top:90px}
body{min-height:100vh;min-height:100dvh;overflow-x:hidden;-webkit-tap-highlight-color:transparent;text-rendering:optimizeLegibility}
img,svg,video{max-width:100%}
img{height:auto}
button,a,input,select,textarea,summary{touch-action:manipulation}
:focus-visible{outline:2px solid var(--g);outline-offset:2px}
.ltr{direction:ltr;text-align:left}
table{display:block;max-width:100%;overflow-x:auto}
.property-modal-photos,.price-range,.tabs{-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
.property-modal{overscroll-behavior:contain}
#menu{overscroll-behavior:contain}

/* Skip layout/paint work for off-screen property cards */
#flist .property-card{content-visibility:auto;contain-intrinsic-size:auto 420px}

/* ---------- Notch / safe areas (iPhone, Android gesture bars) ---------- */
header,.dash header{padding-top:max(12px,env(safe-area-inset-top))}
.dash main,.login main{padding-bottom:max(48px,calc(24px + env(safe-area-inset-bottom)))}
.dash #menu{padding-top:max(14px,env(safe-area-inset-top));height:100vh;height:100dvh;bottom:auto}
.dash #st{bottom:max(20px,env(safe-area-inset-bottom))}
.property-modal-backdrop{padding-bottom:max(8px,env(safe-area-inset-bottom))}
@supports(padding:max(0px)){
  header{padding-inline-start:max(16px,env(safe-area-inset-left,0px));padding-inline-end:max(16px,env(safe-area-inset-right,0px))}
}

/* ---------- Phones & small tablets ---------- */
@media(max-width:820px){
  /* 16px inputs stop iOS Safari from zooming on focus */
  input,select,textarea{font-size:16px;min-height:46px}
  textarea{min-height:90px}
  /* comfortable touch targets */
  button,.btn,.tabs button,.chips button,#menu #mtabs button,#menu .out{min-height:44px}
  .burger,.notification-trigger,.theme-toggle{min-width:44px;min-height:44px}
  .row{flex-wrap:wrap}
  .row>button,.row>.btn{flex:1 1 130px}
  .property-modal-actions button{min-height:46px}
  .dash #menu{width:min(86vw,330px)}
}
@media(max-width:520px){
  .card,.profile-panel{margin-bottom:12px}
  .cats{grid-template-columns:repeat(2,minmax(0,1fr))}
  h1{font-size:1.05rem}
  .login main.narrow{padding-top:8px}
}
/* landscape phones: keep the drawer scrollable and compact */
@media(max-height:480px) and (orientation:landscape){
  .dash #menu #mtabs button,.dash #menu .out{min-height:40px;padding:8px 12px}
  .dash header{padding-top:6px;padding-bottom:6px}
  .header-date,.header-gold{height:auto;min-height:64px}
}

/* ---------- Tablets ---------- */
@media(min-width:821px) and (max-width:1023px){
  main{max-width:900px}
  #flist{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;align-items:start}
  #flist .card{margin-bottom:0}
  #flist .empty{grid-column:1/-1}
}

/* ---------- Windows / laptop / desktop ---------- */
@media(min-width:1024px){
  :root{--side-w:272px}

  /* permanent right-hand sidebar (RTL) instead of the drawer */
  body.dash{padding-inline-start:var(--side-w)}
  .dash .burger,.dash #mc,.dash #ov{display:none!important}
  .dash #menu{
    transform:none!important;visibility:visible!important;
    width:var(--side-w);top:0;bottom:0;height:100vh;height:100dvh;
    padding:18px 14px 16px;gap:8px;z-index:20;
    border-inline-start:1px solid var(--ln);
    box-shadow:-6px 0 28px rgba(20,45,45,.07);
    scrollbar-width:thin;
  }
  .dash #menu .mhead{padding-bottom:14px;margin-bottom:8px}
  .dash #menu #mtabs button{min-height:46px;cursor:pointer}
  .dash #menu #mtabs button:hover{transform:none}
  .menu-open{overflow:auto}

  /* header + content use the remaining width */
  .dash header{padding:14px 28px;position:sticky;top:0;z-index:15}
  .dash .header-brand{flex:0 0 auto}
  .dash main{max-width:1240px;padding:26px 28px 60px}
  .dash .header-market{max-width:720px}
  .header-date,.header-gold{height:92px;min-height:92px}

  /* dashboard breathes on wide screens */
  .dashboard-grid{grid-template-columns:minmax(0,1.05fr) minmax(0,1.45fr) minmax(260px,.9fr);gap:18px}
  .dashboard-stats{gap:16px}

  /* property files: responsive multi-column grid */
  #flist{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:16px;align-items:start}
  #flist .card{margin-bottom:0;height:100%}
  #flist .empty{grid-column:1/-1}

  /* forms: use 3 columns when there is room */
  form.grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:0 16px}
  form.grid .full,form.grid>h2,form.grid>h3{grid-column:1/-1}

  .story-layout{grid-template-columns:minmax(260px,380px) minmax(320px,1fr)}
  .property-modal{max-width:860px}
  .notification-panel{max-width:520px}

  /* desktop polish: custom scrollbars + hover */
  *{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--g) 45%,transparent) transparent}
  ::-webkit-scrollbar{width:10px;height:10px}
  ::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--g) 40%,transparent);border-radius:8px;border:2px solid transparent;background-clip:content-box}
  button,.btn,a{cursor:pointer}
}

/* very wide monitors */
@media(min-width:1600px){
  .dash main{max-width:1400px}
  #flist{grid-template-columns:repeat(auto-fill,minmax(380px,1fr))}
}

/* Login page: centered card on big screens */
@media(min-width:821px){
  .login main.narrow{margin-top:5vh}
}

/* Print: clean property sheets from Windows */
@media print{
  header,#menu,#ov,.burger,.theme-toggle,.notification-trigger,#st{display:none!important}
  body.dash{padding:0}
  body{background:#fff;color:#000}
  .card{box-shadow:none;break-inside:avoid}
}
