/* ============================================
   Kim Leighton, Realtor — Scottsdale Real Estate
   Classic & Elegant · Burgundy + Blush
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --burgundy: #6B1D3A;
    --burgundy-dark: #4E1529;
    --burgundy-light: #8B2E52;
    --blush: #F5E6E0;
    --blush-light: #FBF5F2;
    --blush-dark: #E8CFC4;
    --cream: #FDF9F7;
    --charcoal: #2C2426;
    --warm-gray: #6B5E60;
    --soft-gray: #A89898;
    --white: #FFFFFF;
    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-sans: 'Lato', 'Helvetica Neue', Arial, sans-serif;
    --transition: 0.3s ease;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    color: var(--charcoal);
    background-color: var(--cream);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    list-style: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
    font-family: var(--font-serif);
    font-weight: 700;
    line-height: 1.2;
    color: var(--charcoal);
}

.section-eyebrow {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--burgundy);
    margin-bottom: 12px;
}

.section-eyebrow--light {
    color: var(--blush);
}

.section-title {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 20px;
    color: var(--charcoal);
}

.section-title--light {
    color: var(--white);
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--warm-gray);
    max-width: 600px;
    line-height: 1.8;
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.section-header .section-subtitle {
    margin: 0 auto;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
}

.btn-primary {
    background-color: var(--burgundy);
    color: var(--white);
    border-color: var(--burgundy);
}

.btn-primary:hover {
    background-color: var(--burgundy-dark);
    border-color: var(--burgundy-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(107, 29, 58, 0.3);
}

.btn-outline-light {
    background-color: transparent;
    color: var(--white);
    border-color: var(--white);
}

.btn-outline-light:hover {
    background-color: var(--white);
    color: var(--burgundy);
    transform: translateY(-2px);
}

.btn-full {
    width: 100%;
}

/* ---------- Navigation ---------- */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(253, 249, 247, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--blush-dark);
    transition: all var(--transition);
}

.nav.scrolled {
    box-shadow: 0 2px 20px rgba(107, 29, 58, 0.08);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-logo-mark {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--burgundy);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--burgundy);
    border-radius: 4px;
}

.nav-logo-text {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--charcoal);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-links a {
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-gray);
    transition: color var(--transition);
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--burgundy);
    transition: width var(--transition);
}

.nav-links a:hover {
    color: var(--burgundy);
}

.nav-links a::after:hover {
    width: 100%;
}

.nav-cta {
    background: var(--burgundy);
    color: var(--white) !important;
    padding: 10px 24px;
    border-radius: 4px;
    transition: all var(--transition) !important;
}

.nav-cta::after {
    display: none;
}

.nav-cta:hover {
    background: var(--burgundy-dark) !important;
    color: var(--white) !important;
    transform: translateY(-1px);
}

/* Mobile Toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle-bar {
    width: 24px;
    height: 2px;
    background: var(--charcoal);
    transition: all var(--transition);
    display: block;
}

.nav-toggle.active .nav-toggle-bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active .nav-toggle-bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 72px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--cream);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.mobile-menu.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.mobile-menu-link {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--charcoal);
    transition: color var(--transition);
}

.mobile-menu-link:hover {
    color: var(--burgundy);
}

.mobile-menu-cta {
    margin-top: 16px;
    background: var(--burgundy);
    color: var(--white) !important;
    padding: 12px 32px;
    border-radius: 4px;
}

/* ---------- Hero ---------- */
.hero {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    background: var(--burgundy-dark);
}

.hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(78, 21, 41, 0.88) 0%, rgba(107, 29, 58, 0.72) 50%, rgba(44, 36, 38, 0.6) 100%);
}

.hero-inner {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 24px 80px;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 60px;
    align-items: center;
    width: 100%;
}

.hero-content {
    color: var(--white);
}

.hero-eyebrow {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--blush);
    margin-bottom: 16px;
}

.hero-headline {
    font-family: var(--font-serif);
    font-size: clamp(2.8rem, 5.5vw, 4.5rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--white);
    margin-bottom: 24px;
}

.hero-sub {
    font-size: 1.1rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.85);
    max-width: 520px;
    margin-bottom: 36px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.hero-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 24px;
}

.hero-card-accent {
    width: 40px;
    height: 3px;
    background: var(--blush);
    border-radius: 2px;
    margin-bottom: 12px;
}

.hero-card-label {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 8px;
}

.hero-card-label--light {
    color: var(--blush);
}

.hero-card-text {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.7;
}

.hero-card-text--light {
    color: rgba(255, 255, 255, 0.7);
}

.hero-card--inverse {
    background: var(--burgundy);
    border-color: var(--burgundy-light);
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-stat {
    flex: 1;
}

.hero-stat-number {
    display: block;
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
    margin-bottom: 6px;
}

.hero-stat-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hero-stat-divider {
    width: 1px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
}

.hero-scroll {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: var(--white);
    opacity: 0.6;
    transition: opacity var(--transition);
    animation: heroScrollBounce 2s ease-in-out infinite;
}

.hero-scroll:hover {
    opacity: 1;
}

@keyframes heroScrollBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(6px); }
}

/* ---------- About ---------- */
.about {
    padding: 100px 0;
    background: var(--cream);
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.about-image-wrap {
    position: relative;
}

.about-image {
    width: 100%;
    height: 500px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(107, 29, 58, 0.12);
}

.about-image-accent {
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 200px;
    height: 200px;
    background: var(--blush);
    border-radius: 8px;
    z-index: -1;
}

.about-content {
    padding: 20px 0;
}

.about-text {
    font-size: 1.05rem;
    color: var(--warm-gray);
    line-height: 1.9;
    margin-bottom: 20px;
}

.about-values {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 32px;
}

.about-value {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--charcoal);
}

.about-value svg {
    flex-shrink: 0;
}

/* ---------- Services ---------- */
.services {
    padding: 100px 0;
    background: var(--blush-light);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
}

.service-card {
    background: var(--white);
    border-radius: 8px;
    padding: 40px 36px;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.service-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(107, 29, 58, 0.1);
    border-color: var(--blush-dark);
}

.service-card-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blush);
    border-radius: 8px;
    margin-bottom: 20px;
    color: var(--burgundy);
    transition: all var(--transition);
}

.service-card:hover .service-card-icon {
    background: var(--burgundy);
    color: var(--white);
}

.service-card-title {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: var(--charcoal);
}

.service-card-text {
    font-size: 0.95rem;
    color: var(--warm-gray);
    line-height: 1.8;
}

/* ---------- Areas ---------- */
.areas {
    padding: 100px 0;
    background: var(--cream);
}

.areas-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.area-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 4/3;
}

.area-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.area-item:hover .area-img {
    transform: scale(1.05);
}

.area-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(44, 36, 38, 0.85) 0%, rgba(44, 36, 38, 0.2) 60%, transparent 100%);
    transition: background var(--transition);
}

.area-item:hover .area-overlay {
    background: linear-gradient(to top, rgba(107, 29, 58, 0.9) 0%, rgba(107, 29, 58, 0.3) 60%, transparent 100%);
}

.area-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 28px;
    color: var(--white);
}

.area-name {
    font-size: 1.4rem;
    color: var(--white);
    margin-bottom: 8px;
}

.area-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.7;
}

/* ---------- Testimonials ---------- */
.testimonials {
    padding: 100px 0;
    background: var(--blush-light);
}

.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

.testimonial-card {
    background: var(--white);
    border-radius: 8px;
    padding: 36px 32px;
    position: relative;
    transition: all var(--transition);
    border: 1px solid var(--blush);
}

.testimonial-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(107, 29, 58, 0.08);
}

.testimonial-quote {
    position: absolute;
    top: 20px;
    right: 24px;
}

.testimonial-text {
    font-size: 1rem;
    line-height: 1.85;
    color: var(--warm-gray);
    margin-bottom: 24px;
    font-style: italic;
}

.testimonial-author {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--charcoal);
}

/* ---------- CTA ---------- */
.cta {
    position: relative;
    padding: 100px 0;
    overflow: hidden;
}

.cta-bg {
    position: absolute;
    inset: 0;
}

.cta-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cta-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(78, 21, 41, 0.92) 0%, rgba(44, 36, 38, 0.85) 100%);
}

.cta-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
}

.cta-text {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.8;
    margin-bottom: 36px;
}

.cta-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

/* ---------- Contact ---------- */
.contact {
    padding: 100px 0;
    background: var(--cream);
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: start;
}

.contact-text {
    font-size: 1.05rem;
    color: var(--warm-gray);
    line-height: 1.8;
    margin-bottom: 36px;
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.contact-detail {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.contact-detail svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.contact-detail-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--soft-gray);
    margin-bottom: 4px;
}

.contact-detail-value {
    font-size: 1rem;
    color: var(--charcoal);
    line-height: 1.7;
    transition: color var(--transition);
}

.contact-detail-value:hover {
    color: var(--burgundy);
}

.contact-form-wrap {
    background: var(--white);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(107, 29, 58, 0.06);
    border: 1px solid var(--blush);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--warm-gray);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--charcoal);
    background: var(--blush-light);
    border: 1px solid var(--blush-dark);
    border-radius: 4px;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--burgundy);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(107, 29, 58, 0.08);
}

.form-input::placeholder {
    color: var(--soft-gray);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B5E60' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-success {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 14px 18px;
    background: #E8F5E9;
    color: #2E7D32;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-success svg {
    flex-shrink: 0;
}

/* ---------- Map ---------- */
.map-section {
    height: 380px;
    background: var(--blush);
}

.map-section iframe {
    filter: grayscale(30%) contrast(1.05);
}

/* ---------- Footer ---------- */
.footer {
    background: var(--charcoal);
    color: rgba(255, 255, 255, 0.7);
    padding: 64px 0 0;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr;
    gap: 48px;
    padding-bottom: 48px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.footer-logo-mark {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.footer-logo-text {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
}

.footer-tagline {
    font-size: 0.9rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.5);
    max-width: 280px;
}

.footer-heading {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 20px;
}

.footer-links ul,
.footer-contact ul {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-links a,
.footer-contact a {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    transition: color var(--transition);
}

.footer-links a:hover,
.footer-contact a:hover {
    color: var(--blush);
}

.footer-contact span {
    font-size: 0.9rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.5);
}

.footer-bottom {
    padding: 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-bottom p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.35);
}

.footer-disclaimer {
    font-size: 0.75rem !important;
    max-width: 400px;
    text-align: right;
}

/* ---------- Scroll Reveal (progressive enhancement) ---------- */
@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(24px);
        transition: opacity 0.7s ease, transform 0.7s ease;
    }

    .reveal.revealed {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .hero-inner {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .hero-card {
        flex: 1;
        min-width: 200px;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .about-image {
        height: 400px;
    }

    .contact-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 36px;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }

    .nav-toggle {
        display: flex;
    }

    .hero {
        min-height: auto;
        padding: 100px 0 60px;
    }

    .hero-inner {
        padding: 0 24px 60px;
    }

    .hero-headline {
        font-size: clamp(2.2rem, 8vw, 3rem);
    }

    .hero-stats {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .hero-stat-divider {
        width: 48px;
        height: 1px;
    }

    .hero-scroll {
        display: none;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .areas-grid {
        grid-template-columns: 1fr;
    }

    .testimonials-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .contact-form-wrap {
        padding: 28px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }

    .footer-disclaimer {
        text-align: center;
    }

    .about-image-accent {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
        text-align: center;
    }

    .cta-actions {
        flex-direction: column;
        align-items: center;
    }

    .cta-actions .btn {
        width: 100%;
        max-width: 280px;
    }
}
</style>
<sm-file path="script.js">
(function () {
    'use strict';

    // ---- Navigation scroll effect ----
    const nav = document.getElementById('nav');
    let lastScroll = 0;

    function handleNavScroll() {
        const currentScroll = window.pageYOffset;
        if (currentScroll > 50) {
            nav.classList.add('scrolled');
        } else {
            nav.classList.remove('scrolled');
        }
        lastScroll = currentScroll;
    }

    window.addEventListener('scroll', handleNavScroll, { passive: true });

    // ---- Mobile menu ----
    const navToggle = document.getElementById('navToggle');
    const mobileMenu = document.getElementById('mobileMenu');
    const mobileLinks = mobileMenu.querySelectorAll('a');

    function toggleMobileMenu() {
        const isOpen = mobileMenu.classList.contains('active');
        navToggle.classList.toggle('active');
        mobileMenu.classList.toggle('active');
        navToggle.setAttribute('aria-expanded', !isOpen);
        document.body.style.overflow = isOpen ? '' : 'hidden';
    }

    navToggle.addEventListener('click', toggleMobileMenu);

    mobileLinks.forEach(function (link) {
        link.addEventListener('click', function () {
            navToggle.classList.remove('active');
            mobileMenu.classList.remove('active');
            navToggle.setAttribute('aria-expanded', 'false');
            document.body.style.overflow = '';
        });
    });

    // ---- Smooth scroll for anchor links ----
    document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
        anchor.addEventListener('click', function (e) {
            const targetId = anchor.getAttribute('href');
            if (targetId === '#') return;
            const target = document.querySelector(targetId);
            if (target) {
                e.preventDefault();
                const navHeight = nav.offsetHeight;
                const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - navHeight - 20;
                window.scrollTo({
                    top: targetPosition,
                    behavior: 'smooth'
                });
            }
        });
    });

    // ---- Scroll reveal (progressive enhancement) ----
    if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
        const revealElements = document.querySelectorAll('.reveal');

        function revealOnScroll() {
            revealElements.forEach(function (el) {
                const rect = el.getBoundingClientRect();
                const windowHeight = window.innerHeight;
                if (rect.top < windowHeight - 60) {
                    el.classList.add('revealed');
                }
            });
        }

        // Initial check
        revealOnScroll();
        window.addEventListener('scroll', revealOnScroll, { passive: true });
    }

    // ---- Contact form ----
    const contactForm = document.getElementById('contactForm');
    const formSuccess = document.getElementById('formSuccess');

    if (contactForm) {
        contactForm.addEventListener('submit', function (e) {
            e.preventDefault();

            // Basic validation
            const firstName = document.getElementById('firstName').value.trim();
            const lastName = document.getElementById('lastName').value.trim();
            const email = document.getElementById('email').value.trim();

            if (!firstName || !lastName || !email) {
                return;
            }

            // Simulate submission
            const submitBtn = contactForm.querySelector('button[type="submit"]');
            submitBtn.disabled = true;
            submitBtn.textContent = 'Sending...';

            setTimeout(function () {
                contactForm.style.display = 'none';
                formSuccess.style.display = 'flex';
            }, 800);
        });
    }

    // ---- Active nav link highlighting ----
    const sections = document.querySelectorAll('section[id]');
    const navLinks = document.querySelectorAll('.nav-links a:not(.nav-cta)');

    function highlightNav() {
        const scrollPos = window.pageYOffset + 150;

        sections.forEach(function (section) {
            const top = section.offsetTop;
            const height = section.offsetHeight;
            const id = section.getAttribute('id');

            if (scrollPos >= top && scrollPos < top + height) {
                navLinks.forEach(function (link) {
                    link.classList.remove('active');
                    if (link.getAttribute('href') === '#' + id) {
                        link.classList.add('active');
                    }
                });
            }
        });
    }

    window.addEventListener('scroll', highlightNav, { passive: true });

})();
