/* Page widths and layout (y4 layout review, approved Nov 25, 2026). Loaded on every app page after app.css.
   One width system: full width (map search, photo viewer), 1440px (photo grid), 1180px (listing, city, market,
   account; lines up with each site's header), 720px / about 72 characters for reading text.
   Shared break points: 1680, 1280, 1024, 760. Colors come from each site's theme file, so NWRS, PVH and TDH keep
   their own look. Map search widths live in search-ux.css (loaded by the map search only). */

/* ---------- Listing page ---------- */
/* Columns: main + 360px tour card from 1280px, main + 320px from 1024px, one column below 1024px */
@media (min-width: 1280px) { .page-listing .listing-grid { grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; } }
@media (min-width: 1024px) and (max-width: 1279px) { .page-listing .listing-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; } }
@media (max-width: 1023px) { .page-listing .listing-grid { grid-template-columns: minmax(0, 1fr); } .page-listing .side-card { position: static; } }

/* The tour card never scrolls inside itself (two scrollbars side by side felt broken). It stays in view while the page
   scrolls (layout-ux.js adds .lay-fits and sets the top so a tall card pins by its bottom edge). */
.page-listing .side-card { max-height: none; overflow: visible; position: static; }
@media (min-width: 1024px) { .page-listing .side-card.lay-fits { position: sticky; top: calc(var(--header-h, 0px) + 16px); } }

/* Photos: big enough to sell the home, short enough that the price shows on a laptop's first screen */
@media (min-width: 1024px) { .page-listing .gallery2 { height: clamp(300px, 34vw, 520px); } }

/* Reading text in the main column stays about 72 characters a line */
.page-listing .remarks, .page-listing .listing-grid > div > .section > p { max-width: 72ch; }

/* Tablets and phones: "Request a tour" and "Ask a question" stay one tap away in a bar at the bottom of the screen
   (the tour card is the last block on the page there). The bar steps aside while the tour card is on screen. */
.lay-bar { display: none; }
@media (max-width: 1023px) {
  .lay-bar { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--surface, #fff); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 14px rgba(0,0,0,.08); transition: transform .18s ease; }
  .lay-bar.off { transform: translateY(110%); }
  .lay-bar .btn { min-height: 46px; font-weight: 700; padding: 8px 10px; margin: 0; }
  body.page-listing { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
}
@media (min-width: 761px) and (max-width: 1023px) { .lay-bar { grid-template-columns: minmax(0, 260px) minmax(0, 320px); justify-content: center; } }

/* Photo viewer: dark and full screen, the photo as big as the screen allows (was a white box capped at 1100px).
   One at a time and Grid modes, arrows, keys and the wheel all keep working. */
.page-listing .photo-viewer { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding: 14px 16px;
  background: #111; color: #F2F4F7; }
.page-listing .photo-viewer[open] { display: flex; flex-direction: column; }
.page-listing .photo-viewer::backdrop { background: #111; }
.page-listing .photo-viewer .modal-close { color: #fff; font-size: 34px; }
.page-listing .photo-viewer .modal-close-form { right: 16px; top: 10px; z-index: 2; }
.page-listing .photo-viewer .pv-bar { background: rgba(255,255,255,.12); align-self: flex-start; }
.page-listing .photo-viewer .pv-mode { color: #C9D1DC; }
.page-listing .photo-viewer .pv-mode[aria-pressed="true"] { background: #fff; color: #111; }
.page-listing .photo-viewer .pv-one { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-listing .photo-viewer .pv-one[hidden] { display: none; }
.page-listing .photo-viewer .pv-img { flex: 1; min-height: 0; max-height: none; height: 100%; }
.page-listing .photo-viewer .pv-nav .btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; min-width: 120px; }
.page-listing .photo-viewer .pv-hint, .page-listing .photo-viewer .pv-fig figcaption { color: #9AA4B2; }
.page-listing .photo-viewer .pv-all { max-height: none; flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-content: start;
  width: 100%; max-width: 1280px; margin: 0 auto; }
.page-listing .photo-viewer .pv-all[hidden] { display: none; }
.page-listing .photo-viewer .pv-fig { margin: 0; }
.page-listing .photo-viewer .pv-fig:first-child { grid-column: 1 / -1; }
@media (max-width: 1023px) { .page-listing .photo-viewer .pv-all { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .page-listing .photo-viewer { padding: 10px 8px; }
  .page-listing .photo-viewer .pv-nav .btn { min-width: 0; }
}
@media print { .lay-bar { display: none !important; } }

/* ---------- Market reports and guide stat tiles: always full rows ---------- */
/* A fixed count of tiles gets a fixed column count (8 = 4 + 4, 6 = 3 + 3); an odd count lets the last tile fill the row.
   The market hub's 2 x 2 snapshot (.mr-snap) keeps its own look. */
.guide .wrap > .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide .wrap > .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .guide .wrap > .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .guide .wrap > .stats > .stat:last-child:nth-child(odd) { grid-column: auto; }
  .guide .wrap > .stats:has(> .stat:nth-child(3):last-child),
  .guide .wrap > .stats:has(> .stat:nth-child(5):last-child),
  .guide .wrap > .stats:has(> .stat:nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .guide .wrap > .stats > .stat:nth-child(5):last-child { grid-column: span 2; }
  .guide .wrap > .stats > .stat:nth-child(7):last-child { grid-column: span 2; }
}

/* ---------- City and ZIP pages (/homes/city): reading text about 72 characters a line ---------- */
.page-area main.listing > p:not(.crumbs), .page-area .section p, .page-area .section h2 { max-width: 72ch; }

/* ---------- My Home Search: lines up with the header (1180px), text about 72 characters a line ---------- */
.page-account .account { max-width: 1180px; }
.page-account .account p { max-width: 72ch; }

/* Listing tour card on computers: short to start (agent, day, time, one button); the contact boxes open when the visitor starts */
@media (min-width: 1024px) {
  #tour-form.lay-compact .tour-contact, #tour-form.lay-compact .sms-consent, #tour-form.lay-compact label:has(> select[name="time2"]) { display: none; }
}
