/* =========================================
   Global Styles & Base
   ========================================= */
:root {
    --primary-color: #1B9C85;
    --text-dark: #0F172A;
    --text-light: #f8fafc;
    --background-light: #EDF6EE;
    --background-white: #FFFFFF;
    --border-color: #e2e8f0;
    --error-color: #dc2626;
    
    /* Overlay colors for text readability */
    --overlay-dark: rgba(15, 23, 42, 0.7);
    --overlay-medium: rgba(15, 23, 42, 0.5);
    --overlay-light: rgba(15, 23, 42, 0.3);
}
body {
    font-family: 'Open Sans', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    margin: 0;
    background-color: var(--background-white);
}
body.menu-open {
    overflow: hidden;
}
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}
h1, h2, h3 {
    font-family: 'Merriweather', serif;
    color: var(--primary-color);
}
h2 {
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: 2rem;
}
a {
    color: var(--primary-color);
    text-decoration: none;
}
a:hover {
    color: #167a68;
}
section {
    padding: 50px 0;
}
img {
    max-width: 100%;
    height: auto;
}
.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--text-light) !important;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    border: none;
    cursor: pointer;
}
.btn:hover {
    background-color: #167a68;
}

/* =========================================
   Header & Navigation
   ========================================= */
/* (Header styles are correct, no changes needed, but included for completeness) */
header { background-color: var(--background-white); box-shadow: 0 2px 4px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; }
header .container { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 20px; }
.logo img { max-height: 70px; }
.header-contact-info, .hamburger-btn, .close-btn { display: none; }
@media (min-width: 993px) {
    .header-contact-info { display: flex; gap: 1rem; }
    .header-contact-info a { font-weight: 600; }
    .main-nav ul { margin: 0; padding: 0; list-style: none; display: flex; gap: 1.5rem; }
    .main-nav a { color: var(--text-dark); font-weight: 600; }
}
@media (max-width: 992px) {
    .header-contact-info { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; line-height: 1.2; }
    .header-contact-info a { font-size: 0.8rem; font-weight: 600; }
    .main-nav { position: fixed; top: 0; right: 0; width: 85%; max-width: 320px; height: 100%; background: var(--background-white); box-shadow: -3px 0 10px rgba(0,0,0,0.15); z-index: 2000; transform: translateX(100%); transition: transform 0.3s ease-in-out; padding: 1.5rem; }
    .main-nav.is-open { transform: translateX(0); }
    .main-nav ul { list-style: none; padding: 0; margin: 0; flex-direction: column; gap: 1rem; margin-top: 3rem; }
    .main-nav a { display: block; padding: 0.75rem 1rem; font-size: 1.2rem; border-radius: 5px; color: var(--text-dark); }
    .main-nav a:hover, .main-nav a:active { background-color: var(--background-light); }
    .hamburger-btn { display: flex; flex-direction: column; justify-content: space-around; width: 30px; height: 25px; background: transparent; border: none; cursor: pointer; padding: 0; z-index: 1010; }
    .hamburger-btn span { width: 30px; height: 3px; background-color: var(--text-dark); border-radius: 3px; }
    .close-btn { display: block; position: absolute; top: 0.5rem; right: 1.5rem; font-size: 2.5rem; color: #555; background: none; border: none; cursor: pointer; }
}

/* =========================================
   Navigation Menu Animations
   ========================================= */
.main-nav a {
    position: relative;
    text-decoration: none;
    transition: color 0.3s ease-in-out;
    padding-bottom: 8px; /* Space for the underline */
}

.main-nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

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

.main-nav a:hover::after,
.main-nav a:focus::after,
.main-nav a.active::after {
    transform: scaleX(1);
}

/* Override mobile-specific hover effects to use the underline */
@media (max-width: 992px) {
    .main-nav a {
        padding: 0.75rem 1rem; /* Restore padding */
        padding-bottom: 8px;
    }

    .main-nav a:hover, .main-nav a:active {
        background-color: transparent; /* Remove background color change */
    }
}

/* =========================================
   Contact Section & Form - FIXED STYLES
   ========================================= */
#contact .section-title p {
    max-width: 700px;
    margin: 0 auto 3rem auto;
}
.contact-content {
    display: flex;
    gap: 3rem;
    flex-wrap: wrap;
}
.contact-info, .contact-form {
    flex: 1;
    min-width: 300px;
}
.contact-info h3, .contact-form h3 {
    text-align: left;
    margin-top: 0;
    margin-bottom: 1.5rem;
}
.contact-info p {
    margin-bottom: 1rem;
    line-height: 1.8;
}
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.required {
    color: var(--error-color);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    font-family: 'Open Sans', sans-serif;
    box-sizing: border-box; /* Important for padding and border */
}
.form-group input.is-invalid,
.form-group textarea.is-invalid {
    border-color: var(--error-color);
}
.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1em; /* Prevents layout shift */
}
.honeypot {
    display: none;
}
#form-status {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 5px;
    text-align: center;
}
#form-status.status-success {
    background-color: #d1fae5;
    color: #065f46;
}
#form-status.status-error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* =========================================
   Other Sections (About, Affiliations, etc.)
   ========================================= */
/* (Styles are correct, but included for completeness) */
#about .about-content { display: flex; align-items: center; gap: 3rem; }
#about .about-image { flex: 1; min-width: 300px; }
#about .about-image img { border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
#about .about-text { flex: 1.5; }
@media (max-width: 768px) { #about .about-content { flex-direction: column; } }

#affiliations { background-color: var(--background-light); }
.affiliation-logos { display: flex; justify-content: center; align-items: center; gap: 4rem; flex-wrap: wrap; }
.affiliation-logos img { height: 60px; width: auto; filter: grayscale(100%); opacity: 0.7; transition: all 0.3s ease; }
.affiliation-logos img:hover { filter: grayscale(0%); opacity: 1; transform: scale(1.1); }
#affiliations p { text-align: center; margin-top: 2rem; color: #555; }

.practice-areas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem; }
.practice-area-card { border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: transform 0.3s ease, box-shadow 0.3s ease; }
.practice-area-card:hover { transform: translateY(-5px); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.practice-area-card img { width: 100%; height: 200px; object-fit: cover; }
.practice-area-card-content { padding: 1.5rem; }
.practice-area-card-content h3 { margin-top: 0; color: var(--text-dark); }
#practice-areas .section-title p { max-width: 600px; margin: 0 auto 2rem auto; }
#practice-areas .btn { display: table; margin: 2rem auto 0 auto; }

/* =========================================
   Hero Section with Background Image
   ========================================= */
#hero {
    position: relative;
    min-height: 80vh;
    display: flex;
    align-items: center;
    background-color: #333; /* Fallback color */
    background-image: linear-gradient(var(--overlay-dark), var(--overlay-dark)), url('/images/backgrounds/hero-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-light);
    text-align: center;
    padding: 120px 0 80px;
}

@supports (background-image: url('/images/backgrounds/hero-bg.webp')) {
    #hero {
        background-image: linear-gradient(var(--overlay-dark), var(--overlay-dark)), url('/images/backgrounds/hero-bg.webp');
    }
}

/* Disable parallax on mobile for better performance */
@media (max-width: 768px) {
    #hero {
        background-attachment: scroll;
        min-height: 60vh;
        padding: 100px 0 60px;
    }
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-light);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.hero-content p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    color: var(--text-light);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.6;
}

/* Responsive hero text */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 2.5rem;
    }
    
    .hero-content p {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
}

/* =========================================
   Page-Specific Backgrounds
   ========================================= */

/* Practice Areas Page Background */
#practice-areas-page {
    position: relative;
    background-color: #f0f0f0; /* Fallback color */
    background-image: linear-gradient(var(--overlay-light), var(--overlay-light)), url('/images/backgrounds/practice-areas-bg-2.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-dark);
}

@supports (background-image: url('/images/backgrounds/practice-areas-bg-2.webp')) {
    #practice-areas-page {
        background-image: linear-gradient(var(--overlay-light), var(--overlay-light)), url('/images/backgrounds/practice-areas-bg-2.webp');
    }
}

/* FAQ Page Background */
#faq-page {
    position: relative;
    background-color: #f0f0f0; /* Fallback color */
    background-image: linear-gradient(var(--overlay-light), var(--overlay-light)), url('/images/backgrounds/faq-bg-new-2.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-dark);
}

@supports (background-image: url('/images/backgrounds/faq-bg-new-2.webp')) {
    #faq-page {
        background-image: linear-gradient(var(--overlay-light), var(--overlay-light)), url('/images/backgrounds/faq-bg-new-2.webp');
    }
}

/* Contact Page Background */
#contact {
    position: relative;
    background-color: #f0f0f0; /* Fallback color */
    background-image: linear-gradient(var(--overlay-light), var(--overlay-light)), url('/images/backgrounds/contact-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-dark);
}

@supports (background-image: url('/images/backgrounds/contact-bg.webp')) {
    #contact {
        background-image: linear-gradient(var(--overlay-light), var(--overlay-light)), url('/images/backgrounds/contact-bg.webp');
    }
}

/* Disable parallax on mobile for page backgrounds */
@media (max-width: 768px) {
    #practice-areas-page,
    #faq-page,
    #contact {
        background-attachment: scroll;
    }
}

/* =========================================
   Background Content Wrapper
   ========================================= */
.background-content {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 2rem;
    margin: 2rem 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* =========================================
   Image Optimization Utilities
   ========================================= */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lazy-load.loaded {
    opacity: 1;
}

/* Responsive image container */
.responsive-image {
    width: 100%;
    height: auto;
    display: block;
}

/* =========================================
   Performance Optimizations
   ========================================= */
/* Preload critical background images */
@media (min-width: 769px) {
    #hero::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url('/images/backgrounds/hero-bg.webp');
        background-size: cover;
        background-position: center;
        opacity: 0;
        transition: opacity 0.5s ease-in-out;
        z-index: 1;
    }
    
    #hero.loaded::before {
        opacity: 1;
    }
}

/* =========================================
   Accessibility Enhancements
   ========================================= */
/* High contrast mode support */
@media (prefers-contrast: high) {
    #hero,
    #practice-areas-page,
    #faq-page,
    #contact {
        background: var(--background-light);
    }
    
    .hero-content h1,
    .hero-content p {
        color: var(--text-dark);
        text-shadow: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #hero,
    #practice-areas-page,
    #faq-page,
    #contact {
        background-attachment: scroll;
    }
    
    .hero-content h1,
    .hero-content p {
        transition: none;
    }
}

/* =========================================
   Testimonials Section
   ========================================= */
.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.testimonial-card {
    background: var(--background-white);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary-color);
}

.testimonial-card p {
    font-style: italic;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.testimonial-card footer {
    font-weight: 600;
    color: var(--primary-color);
}

/* =========================================
     Accordion Styles
   ========================================= */
.faq-category {
    color: var(--primary-color);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.faq-accordion {
    margin-bottom: 2rem;
}

.faq-item {
    background: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.faq-question {
    background: var(--background-light);
    padding: 1.5rem;
    margin: 0;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s ease;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.faq-question:hover {
    background: #d1f2eb;
}

.faq-question::after {
    content: '+';
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question::after {
    transform: translateY(-50%) rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 500px;
}

.faq-answer p {
    padding: 0 1.5rem 1.5rem;
    margin: 0;
    line-height: 1.6;
}

/* =========================================
   Footer Styles
   ========================================= */
footer {
    background-color: var(--text-dark);
    color: var(--text-light);
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}