/* ============================================================
   HBR MOBILE FIX  — Gen3
   Fixes for: header text missing, header chopped, h-scroll
   Applies to all public-facing pages
   ============================================================ */

/* ── 1. PREVENT ALL HORIZONTAL SCROLL ─────────────────────── */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw;
}

/* Every element stays inside the viewport */
*,
*::before,
*::after {
    box-sizing: border-box;
    max-width: 100%;
}

/* ── 2. HEADER / NAVBAR ────────────────────────────────────── */
header {
    width: 100% !important;
    max-width: 100vw !important;

}

.navbar {
	width: 100% !important;
	max-width: 100% !important;
	/* Stop wrapping — logo + hamburger always stay on one row */
	flex-wrap: nowrap !important;
	gap: 0 !important;
	/* Keep logo and hamburger at opposite ends */
	justify-content: space-between !important;
	align-items: center !important;
	padding-top: 0;
	padding-right: 2px;
	padding-left: 2px;
	padding-bottom: 0;
	/* No min-width that could push past viewport */
	min-width: 0 !important;
}

/* ── 3. LOGO — always visible, never overflows ─────────────── */
.logo {
    /* Allow logo to shrink if needed but never grow past available space */
    flex: 0 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    gap: 8px !important;
}

.logo img {
    flex-shrink: 0 !important;
    height: 44px !important;
    width: auto !important;
}

/* Logo text — keep it visible on all pages / all phone sizes */
.logo-text {
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

.logo-main {
    display: block !important;
    font-size: 0.78em !important;
    font-weight: bold !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
}

.logo-byline {
    display: block !important;
    font-size: 0.48em !important;
    opacity: 0.9 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
}

/* Hide byline on all portrait phones — it overflows the navbar */
@media (max-width: 480px) {
    .logo-byline {
        display: none !important;
    }
}

/* ── 4. HAMBURGER — fixed size, never shrinks ──────────────── */
.hamburger {
    flex-shrink: 0 !important;
    margin-left: 8px !important;
}

/* ── 5. LISTINGS PAGE — sidebar layout collapses to single column ── */
@media (max-width: 900px) {

    /* Collapse the two-column page wrapper to single column */
    .page-wrapper {
        grid-template-columns: 1fr !important;
        padding: 15px !important;
        gap: 20px !important;
    }

    /* Sidebar drops below content, no longer sticky/fixed */
    .sidebar {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Listings grid — don't enforce 300px minimum on small screens */
    .listings-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ── 5. PHONE PORTRAIT  (≤ 480 px) ────────────────────────── */
@media (max-width: 480px) {

    /* Slightly smaller logo image on small phones */
    .logo img {
        height: 38px !important;
    }

    /* Scale down logo text a touch more on tiny screens */
    .logo-main {
        font-size: 0.72em !important;
    }

    .logo-byline {
        font-size: 0.44em !important;
    }

    /* Single-column grids */
    .properties-grid,
    .listings-grid,
    .team-grid,
    .features-grid,
    .stats-grid,
    .quick-stats,
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    input,
    select,
    textarea {
        width: 100% !important;
        font-size: 16px !important; /* prevents iOS zoom-on-focus */
        box-sizing: border-box !important;
    }

    /* Sections & containers */
    .container,
    section,
    .section {
        padding-left: 12px !important;
        padding-right: 12px !important;
        width: 100% !important;
    }

    /* Tables — scroll horizontally inside their own box */
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-width: 100% !important;
    }

    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Modals */
    .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 15px !important;
    }
}

/* ── 6. EXTRA-SMALL PHONES  (≤ 360 px) ────────────────────── */
@media (max-width: 360px) {

    .logo img {
        height: 32px !important;
    }

    .logo-main {
        font-size: 0.65em !important;
    }

    .logo-byline {
        display: none !important; /* truly too small — drop byline only */
    }
}

/* ── 7. TABLET  (481 px – 768 px) ──────────────────────────── */
@media (min-width: 481px) and (max-width: 900px) {

    .logo img {
        height: 48px !important;
    }

    .logo-main {
        font-size: 0.9em !important;
    }

    /* Two-column grids are fine on tablets */
    .properties-grid,
    .listings-grid,
    .team-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ── 8. LANDSCAPE PHONE — scrollable menu, locked page ─────── */
@media (max-width: 900px) and (orientation: landscape) {

    /* Header is shorter in landscape */
    header {
        padding: 8px 0 !important;
    }

    .logo img {
        height: 36px !important;
    }

    /* Menu must not exceed screen height minus the header */
    .mobile-menu {
        top: 55px !important;
        max-height: calc(100dvh - 55px) !important;  /* dvh = dynamic viewport height, accounts for browser chrome */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important; /* smooth scroll on iOS */
    }

    /* Fallback for browsers that don't support dvh */
    @supports not (height: 100dvh) {
        .mobile-menu {
            max-height: calc(var(--vh, 1vh) * 100 - 55px) !important;
        }
    }
}

/* Page scroll lock is handled via JS (saves/restores scroll position) */

/* ── 9. DESKTOP TWO-ROW NAVBAR ─────────────────────────────── */
/* Top row: logo left, hamburger right (hamburger hidden on desktop) */
/* Bottom row: nav links spanning full width */
@media (min-width: 901px) {

    .navbar {
	flex-direction: column !important;
	align-items: stretch !important;
	gap: 6px !important;
	padding-top: 10px;
	padding-right: 2px;
	padding-left: 2px;
	padding-bottom: 10px;
    }

    /* Top row — logo fills the row */
    .logo {
        width: 100% !important;
        font-size: 1.8em !important;
        overflow: visible !important;
    }

    .logo img {
        height: 60px !important;
    }

    /* Show byline on desktop */
    .logo-byline {
        display: block !important;
        font-size: 0.56em !important;
    }

    /* Bottom row — nav links spread across full width */
    nav {
        display: flex !important;
        width: 100% !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
    }

    nav a {
        margin-left: 0 !important;
        margin-right: 20px !important;
        font-size: 1.05em !important;
        white-space: nowrap !important;
    }
}
