/* ==========================================================================
   RR Homes - Modern Luxury Interactive Header
   ========================================================================== */

/* Variables */
:root {
    --primary-gold: #C8A96A;
    --primary-gold-hover: #b49658;
    --charcoal-dark: #1E1A22;
    /* Deep charcoal / purple tint */
    --text-dark: #333333;
    --text-light: #ffffff;
    --border-light: #eaeaea;
    --bg-glass: rgba(255, 255, 255, 0.98);

    --font-primary: 'Poppins', sans-serif;
    --font-heading: 'Playfair Display', serif;

    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
.top-bar *,
.header *,
.mobile-nav * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   TOP BAR
   ========================================================================== */
.top-bar {
    background: var(--charcoal-dark);
    color: var(--text-light);
    font-family: var(--font-primary);
    font-size: 12px;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1001;
    transition: var(--transition-smooth);
}

.top-bar-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar .divider {
    color: var(--primary-gold);
    margin: 0 10px;
    opacity: 0.7;
}

.top-bar a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s ease;
}

.top-bar a:hover {
    color: var(--primary-gold);
}

/* Hide Top Bar on Scroll */
.top-bar.scrolled {
    margin-top: -40px;
    /* Slides it up smoothly out of view */
}

/* ==========================================================================
   MAIN HEADER
   ========================================================================== */
.header {
    position: sticky;
    /* Or absolute/fixed depending on layout, usually sticky is fine */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: #ffffff;
    font-family: var(--font-primary);
    transition: var(--transition-smooth);
    border-bottom: 1px solid transparent;
}

/* Initially absolute to overlap properly if sticky is used */
.header {
    position: fixed;
    top: 38px;
    /* Height of top bar approx */
}

/* Animated Flowing/Blinking Border */
.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-gold), #ffffff, var(--primary-gold), transparent);
    background-size: 200% 100%;
    animation: movingGlow 2.5s linear infinite;
    z-index: 10;
}

@keyframes movingGlow {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.header.scrolled {
    top: 0;
    /* Snaps to top when top-bar slides away */
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 40px;
    position: relative;
    height: 120px;
    display: flex;
    align-items: center;
    transition: var(--transition-smooth);
}

/* LOGO */
.logo-container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    transition: var(--transition-smooth);
    z-index: 10;
}

.logo-container img {
    width: 100%;
    height: auto;
    display: block;
    transition: var(--transition-smooth);
}

/* NAVIGATION MENU */
.main-nav {
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: flex-start;
    transition: var(--transition-smooth);
    z-index: 5;
}

.nav-left-items,
.nav-right-items {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 35px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-left-items {
    justify-content: flex-start;
}

.nav-right-items {
    justify-content: flex-start;
}

.nav-gap {
    width: 220px;
    /* Space for logo */
    flex: 0 0 auto;
    transition: var(--transition-smooth);
}

.main-nav a {
    text-decoration: none;
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    position: relative;
    padding: 8px 0;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.main-nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-gold);
    transition: width 0.3s ease;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--primary-gold);
}

.main-nav a:hover::after,
.main-nav a.active::after {
    width: 100%;
}

/* DROPDOWN MENU */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown > a::after {
    display: none;
}

.dropdown-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--bg-glass);
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1);
    z-index: 1000;
    border-top: 2px solid var(--primary-gold);
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.nav-dropdown:hover .dropdown-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-content a {
    color: var(--text-dark);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 13px;
    text-transform: capitalize;
    border-bottom: 1px solid var(--border-light);
}

.dropdown-content a::after {
    display: none;
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: #f8f9fa;
    color: var(--primary-gold);
    padding-left: 20px;
}

/* MOBILE DROPDOWN */
.mobile-dropdown-content {
    display: none;
    list-style: none;
    padding-left: 20px;
    margin-top: 10px;
}

.mobile-dropdown-trigger.active .mobile-dropdown-content {
    display: block;
}

.mobile-dropdown-trigger.active > a i {
    transform: rotate(180deg);
}

.mobile-dropdown-content a {
    font-size: 14px;
    color: #666;
    padding: 8px 0;
    display: block;
}

/* HEADER MODAL */
.header-modal {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.header-modal.show {
    visibility: visible;
    opacity: 1;
}

.header-modal-content {
    background-color: #fff;
    padding: 40px;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}

.header-modal.show .header-modal-content {
    transform: translateY(0);
}

.header-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #999;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.header-modal-close:hover {
    color: var(--primary-gold);
}

.modal-title {
    font-family: var(--font-heading);
    color: var(--charcoal-dark);
    font-size: 28px;
    margin-bottom: 5px;
}

.modal-subtitle {
    color: #666;
    font-size: 14px;
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 15px;
}

.header-form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-family: var(--font-primary);
    font-size: 14px;
    transition: border-color 0.3s;
}

.header-form-control:focus {
    outline: none;
    border-color: var(--primary-gold);
}

.w-100 {
    width: 100%;
    justify-content: center;
}

/* BUTTONS */
.header-buttons {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 15px;
    transition: var(--transition-smooth);
    z-index: 20;
}

.btn {
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 4px;
    /* Slightly squared for modern luxury */
    font-weight: 500;
    font-size: 14px;
    font-family: var(--font-primary);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Phone Icon Button */
.btn-outline {
    border: 1px solid var(--border-light);
    color: var(--text-dark);
    background: #ffffff;
    padding: 10px 15px;
}

.btn-outline:hover {
    border-color: var(--primary-gold);
    color: var(--primary-gold);
    box-shadow: 0 4px 15px rgba(200, 169, 106, 0.1);
}

/* Enquire Now Button */
.btn-primary {
    background: var(--charcoal-dark);
    color: #ffffff;
    border: 1px solid var(--charcoal-dark);
}

.btn-primary:hover {
    background: var(--primary-gold);
    border-color: var(--primary-gold);
    box-shadow: 0 4px 20px rgba(200, 169, 106, 0.3);
    /* Glow effect */
    transform: translateY(-2px);
}

.mobile-toggle {
    display: none;
    font-size: 24px;
    color: var(--charcoal-dark);
    cursor: pointer;
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
}


/* ==========================================================================
   SCROLLED STATE - THE MAGIC BEHAVIOR
   ========================================================================== */
.header.scrolled {
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.06);
    /* Subtle depth shadow */
}

.header.scrolled .header-container {
    height: 80px;
    /* Slimmer header */
}

/* Logo gracefully moves to left */
.header.scrolled .logo-container {
    left: 40px;
    transform: translate(0, -50%);
    width: 120px;
    /* Slightly smaller sharp logo */
}

/* Navbar aligns to right side (next to buttons) */
.header.scrolled .main-nav {
    justify-content: flex-end;
    padding-right: 320px;
    /* Increased from 210px to ensure total clearance from the absolutely positioned buttons */
}

/* Collapse the split and merge the nav items */
.header.scrolled .nav-left-items,
.header.scrolled .nav-right-items {
    flex: 0 0 auto;
}

.header.scrolled .nav-gap {
    width: 35px;
    /* Becomes a normal list gap */
}


/* ==========================================================================
   MOBILE & TABLET NAVIGATION
   ========================================================================== */
html, body {
    overflow-x: hidden;
    width: 100%;
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    transform: translateX(100%);
    width: 100%;
    max-width: 360px;
    height: 100vh;
    background: #ffffff;
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    padding: 40px;
    font-family: var(--font-primary);
}

.mobile-nav.active {
    transform: translateX(0);
}

.mobile-nav-close {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 26px;
    color: var(--text-dark);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.mobile-nav-close:hover {
    transform: rotate(90deg);
    color: var(--primary-gold);
}

.mobile-logo {
    width: 160px;
    margin-bottom: 50px;
}

.mobile-logo img {
    width: 100%;
    height: auto;
}

.mobile-menu-list {
    list-style: none;
    margin: 0 0 50px 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.mobile-menu-list a {
    text-decoration: none;
    color: var(--text-dark);
    font-size: 16px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.mobile-menu-list a:hover {
    color: var(--primary-gold);
}

.mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: auto;
}

.mobile-btn {
    text-align: center;
    justify-content: center;
    width: 100%;
}


/* ==========================================================================
   RESPONSIVE LOGIC
   ========================================================================== */
@media screen and (max-width: 1250px) {
    .nav-gap {
        width: 180px;
    }

    .main-nav a {
        font-size: 13px;
    }

    .header.scrolled .main-nav {
        padding-right: 200px;
    }

    .top-bar-container {
        padding: 8px 20px;
    }

    .header-container {
        padding: 0 20px;
    }

    .header.scrolled .logo-container {
        left: 20px;
    }

    .header-buttons {
        right: 20px;
    }

    .top-bar-left span.divider:nth-child(2),
    .top-bar-left span:nth-child(3) {
        display: none;
        /* Hide 'Luxury Living' on smaller screens */
    }
}

@media screen and (max-width: 1050px) {

    .main-nav,
    .header-buttons {
        display: none !important;
    }

    .mobile-toggle {
        display: block;
        right: 20px;
    }

    .header-container {
        height: 100px;
        justify-content: center;
    }

    .logo-container {
        left: 50%;
        transform: translate(-50%, -50%);
        width: 150px;
    }

    .header.scrolled .logo-container {
        left: 50%;
        transform: translate(-50%, -50%);
        /* Centered on mobile even when scrolled as per requirement */
    }
}

@media screen and (max-width: 768px) {
    .top-bar {
        display: none;
        /* Hide top bar completely on standard mobile */
    }

    .header {
        top: 0;
        /* Reset top since top-bar is gone */
    }

    .header-container {
        height: 80px;
    }

    .logo-container {
        width: 130px;
    }
}