/* ========================================
   Responsive CSS - Global Overrides & System
   Alhelali Real Estate
   ======================================== */

/* ----------------------------------------
   1. Global Variables & Typography Scaling
   ---------------------------------------- */
:root {
    /* Fluid Typography: min (mobile) -> max (desktop) */
    --fs-h1: clamp(2.5rem, 5vw, 4.5rem);
    --fs-h2: clamp(2rem, 4vw, 3rem);
    --fs-h3: clamp(1.5rem, 3vw, 2.25rem);
    --fs-body: clamp(1rem, 2vw, 1.125rem);

    /* Spacing */
    --container-padding: 1rem;
}

@media (min-width: 768px) {
    :root {
        --container-padding: 2rem;
    }
}

@media (min-width: 1280px) {
    :root {
        --container-padding: 4rem;
        /* More breathing room on large screens */
    }
}

/* ----------------------------------------
   2. Global Layout & Container
   ---------------------------------------- */

/* Force consistently centered container with fluid padding */
.container-custom {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
    /* Safe max-widths to prevent stretching on 4k screens */
    max-width: 1440px;
}

/* Prevent horizontal scroll globally */
html,
body {
    overflow-x: hidden;
    width: 100%;
}

img {
    max-width: 100%;
    height: auto;
}

/* ----------------------------------------
   3. Typography Overrides
   ---------------------------------------- */
h1 {
    font-size: var(--fs-h1) !important;
}

h2 {
    font-size: var(--fs-h2) !important;
}

h3 {
    font-size: var(--fs-h3) !important;
}

/* Fix long words breaking layout */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ----------------------------------------
   4. Mobile (max-width: 768px)
   ---------------------------------------- */
@media (max-width: 768px) {

    /* Stack all flex containers that should be rows on desktop */
    .flex.md\:flex-row {
        flex-direction: column !important;
    }

    /* Ensure reverse layouts do not break flow on mobile */
    .flex.md\:flex-row-reverse,
    .flex.lg\:flex-row-reverse {
        flex-direction: column !important;
    }

    /* Certificates Grid - Mobile Fix */
    .certificates-grid {
        display: -ms-grid;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        /* 3 cols on mobile is better for small icons */
        gap: 0.5rem;
    }

    .certificate-card {
        width: 100%;
        height: auto;
        aspect-ratio: 3/2;
    }

    /* Footer adjustments */
    footer .grid {
        gap: 2rem;
    }

    /* Navigation Touch Targets */
    .nav-item,
    #mobile-menu a {
        padding-top: 12px;
        padding-bottom: 12px;
        display: block;
    }

    /* Mobile Menu Logic */
    .mobile-menu {
        max-height: 0;
        overflow: hidden;
        transition: all 0.3s ease-in-out;
        opacity: 0;
        background-color: white;
        /* Ensure readability */
    }

    .mobile-menu.open {
        max-height: 500px;
        /* Arbitrary large height */
        opacity: 1;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    /* Property Card Height Fix */
    .property-card {
        height: 18rem !important;
        /* h-72 equivalent */
    }
}

/* ----------------------------------------
   7. Forms & Inputs
   ---------------------------------------- */
input,
textarea,
select {
    max-width: 100%;
}

/* Fix for date inputs on mobile */
input[type="date"],
input[type="time"] {
    min-height: 48px;
    /* Touch target */
}

/* ----------------------------------------
   5. Tablet (768px - 1024px)
   ---------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) {

    /* Collapse 4-col grids to 2-col */
    .grid-cols-4,
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cols-3,
    .md\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
        /* 2 cols is safer than 3 on tablet */
    }
}

/* ----------------------------------------
   6. Utilities & Helpers
   ---------------------------------------- */
/* Utility to hide elements visually but keep accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Fix Hero Text Widths */
@media (max-width: 768px) {

    .container-custom .max-w-2xl,
    .container-custom .max-w-4xl {
        max-width: 100% !important;
    }
}