/* ============================================
   Lodi Marine — Auto Repair Website Styles
   Palette: Emerald Green (#065f46) + Cream (#faf8f5)
   Fonts: Playfair Display + Inter
============================================ */

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

:root {
  --emerald-900: #065f46;
  --emerald-700: #047857;
  --emerald-500: #059669;
  --emerald-400: #34d399;
  --emerald-100: #d1fae5;
  --cream: #faf8f5;
  --cream-dark: #f0ebe3;
  --cream-mid: #e8e0d4;
  --neutral-900: #1a1a1a;
  --neutral-700: #374151;
  --neutral-500: #6b7280;
  --neutral-300: #d1d5db;
  --neutral-100: #f3f4f6;
  --white: #ffffff;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  color: var(--neutral-700);
  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: var(--emerald-700);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--emerald-500);
}

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

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--emerald-900);
  color: var(--white);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 600;
}

.skip-link:focus {
  top: 16px;
}

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

.section-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--emerald-500);
  margin-bottom: 12px;
}

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

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

.section-sub {
  font-size: 1.1rem;
  color: var(--neutral-500);
  max-width: 600px;
  line-height: 1.7;
}

.section-sub.light {
  color: rgba(255,255,255,0.8);
}

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

.section-header.light {
  margin-bottom: 56px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 3px solid var(--emerald-400);
  outline-offset: 2px;
}

.btn-emerald {
  background: var(--emerald-900);
  color: var(--white);
  border-color: var(--emerald-900);
}

.btn-emerald:hover {
  background: var(--emerald-700);
  border-color: var(--emerald-700);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  color: var(--emerald-900);
  border-color: var(--emerald-900);
}

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

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

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

.btn-cream {
  background: var(--cream);
  color: var(--emerald-900);
  border-color: var(--cream);
}

.btn-cream:hover {
  background: var(--white);
  border-color: var(--white);
  color: var(--emerald-900);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--cream-dark);
  transition: box-shadow var(--transition);
}

.site-header.scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--neutral-900);
}

.logo:hover {
  color: var(--neutral-900);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.logo-text .accent {
  color: var(--emerald-500);
}

.logo-text .accent-light {
  color: var(--emerald-400);
}

/* ---------- Navigation ---------- */
.nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-list a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--neutral-700);
  position: relative;
  padding: 4px 0;
}

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

.nav-list a:hover::after,
.nav-list a:focus::after {
  width: 100%;
}

.nav-list a:hover {
  color: var(--emerald-700);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 110;
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--neutral-900);
  border-radius: 2px;
  transition: all var(--transition);
}

.nav-toggle[aria-expanded="true"] .hamburger:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle[aria-expanded="true"] .hamburger:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .hamburger:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ---------- Hero ---------- */
.hero {
  padding: 120px 0 80px;
  position: relative;
  overflow: hidden;
  background: var(--cream);
}

.hero-bg-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(6,95,70,0.05) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(52,211,153,0.08) 0%, transparent 50%);
  pointer-events: none;
  aria-hidden: true;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
  position: relative;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--emerald-500);
  background: var(--emerald-100);
  padding: 6px 16px;
  border-radius: 50px;
  margin-bottom: 24px;
}

.hero-headline {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  color: var(--neutral-900);
  margin-bottom: 24px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--neutral-500);
  line-height: 1.8;
  margin-bottom: 36px;
  max-width: 520px;
}

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

.hero-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.trust-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--neutral-700);
}

.hero-image {
  position: relative;
}

.hero-img-wrapper {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.hero-badge {
  position: absolute;
  bottom: -20px;
  left: -20px;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--neutral-900);
}

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

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

.service-card {
  background: var(--cream);
  border-radius: var(--radius-md);
  padding: 36px 28px;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.service-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--emerald-100);
  background: var(--white);
}

.service-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--emerald-100);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  transition: all var(--transition);
}

.service-card:hover .service-icon {
  background: var(--emerald-900);
}

.service-card:hover .service-icon svg {
  stroke: var(--white);
}

.service-card h3 {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--neutral-900);
}

.service-card p {
  font-size: 0.95rem;
  color: var(--neutral-500);
  line-height: 1.7;
}

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

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

.about-images {
  position: relative;
}

.about-img-main {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.about-img-secondary {
  position: absolute;
  bottom: -32px;
  right: -32px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 4px solid var(--cream);
}

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

.about-stat {
  position: absolute;
  top: -24px;
  right: 40px;
  background: var(--emerald-900);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 20px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.about-stat .stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
}

.about-stat .stat-label {
  font-size: 0.8rem;
  opacity: 0.8;
  line-height: 1.4;
}

.about-content .section-title {
  margin-bottom: 24px;
}

.about-content > p {
  color: var(--neutral-500);
  margin-bottom: 16px;
  font-size: 1rem;
  line-height: 1.8;
}

.about-list {
  list-style: none;
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

.about-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--neutral-700);
}

.about-list svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---------- Why Us ---------- */
.why-us {
  padding: 100px 0;
  background: var(--emerald-900);
  position: relative;
  overflow: hidden;
}

.why-us::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 10% 90%, rgba(52,211,153,0.15) 0%, transparent 50%),
                    radial-gradient(circle at 90% 10%, rgba(52,211,153,0.1) 0%, transparent 50%);
  pointer-events: none;
}

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

.why-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  padding: 40px 32px;
  transition: all var(--transition);
}

.why-card:hover {
  background: rgba(255,255,255,0.1);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.why-number {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--emerald-400);
  line-height: 1;
  margin-bottom: 16px;
}

.why-card h3 {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 10px;
}

.why-card p {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.7;
}

/* ---------- CTA Banner ---------- */
.cta-banner {
  padding: 80px 0;
  background: var(--cream-dark);
  border-top: 1px solid var(--cream-mid);
  border-bottom: 1px solid var(--cream-mid);
}

.cta-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  flex-wrap: wrap;
}

.cta-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 8px;
}

.cta-text {
  font-size: 1.05rem;
  color: var(--neutral-500);
}

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

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

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

.contact-desc {
  color: var(--neutral-500);
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: 32px;
}

.contact-details {
  list-style: none;
  display: grid;
  gap: 20px;
  margin-bottom: 32px;
}

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

.contact-item dt {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--emerald-100);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.contact-item dd {
  margin: 0;
}

.contact-item a {
  font-size: 1rem;
  font-weight: 500;
  color: var(--neutral-700);
}

.contact-item a:hover {
  color: var(--emerald-700);
  text-decoration: underline;
}

.contact-map {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* ---------- Contact Form ---------- */
.contact-form-wrapper {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 40px;
  border: 1px solid var(--cream-dark);
}

.form-title {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.form-desc {
  font-size: 0.95rem;
  color: var(--neutral-500);
  margin-bottom: 28px;
}

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

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--neutral-900);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--neutral-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(5,150,105,0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--neutral-500);
}

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

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-success {
  text-align: center;
  padding: 40px 20px;
}

.form-success h4 {
  font-size: 1.4rem;
  color: var(--emerald-900);
  margin: 16px 0 8px;
}

.form-success p {
  color: var(--neutral-500);
  font-size: 0.95rem;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--neutral-900);
  color: rgba(255,255,255,0.7);
  padding: 72px 0 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 48px;
  padding-bottom: 56px;
}

.footer-brand p {
  margin-top: 16px;
  font-size: 0.9rem;
  line-height: 1.7;
  max-width: 280px;
}

.footer-links h4,
.footer-contact h4 {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--white);
  margin-bottom: 20px;
}

.footer-links ul {
  list-style: none;
  display: grid;
  gap: 10px;
}

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

.footer-links a:hover,
.footer-contact a:hover {
  color: var(--emerald-400);
  text-decoration: none;
}

.footer-contact p {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 24px 0;
}

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

.footer-bottom p {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.4);
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .hero-grid {
    gap: 48px;
  }
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
  }
}

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

  .nav-list {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--cream);
    flex-direction: column;
    align-items: flex-start;
    padding: 96px 32px 32px;
    gap: 20px;
    box-shadow: var(--shadow-lg);
    transition: right var(--transition);
    z-index: 100;
  }

  .nav-list.open {
    right: 0;
  }

  .nav-list a {
    font-size: 1.05rem;
    padding: 8px 0;
  }

  .nav-list .btn {
    margin-top: 8px;
  }

  .hero {
    padding: 100px 0 60px;
  }

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

  .hero-image {
    order: -1;
  }

  .hero-badge {
    position: relative;
    bottom: auto;
    left: auto;
    margin-top: 16px;
    display: inline-flex;
  }

  .services {
    padding: 72px 0;
  }

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

  .about {
    padding: 72px 0;
  }

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

  .about-img-secondary {
    right: 0;
    bottom: -24px;
  }

  .about-stat {
    top: -16px;
    right: 16px;
  }

  .why-us {
    padding: 72px 0;
  }

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

  .cta-banner {
    padding: 56px 0;
  }

  .cta-grid {
    flex-direction: column;
    text-align: center;
  }

  .cta-actions {
    justify-content: center;
  }

  .contact {
    padding: 72px 0;
  }

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

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

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

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

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

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .hero-actions {
    flex-direction: column;
  }

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

  .hero-trust {
    flex-direction: column;
    gap: 12px;
  }

  .cta-actions {
    flex-direction: column;
    width: 100%;
  }

  .cta-actions .btn {
    width: 100%;
  }
}

/* ---------- Mobile nav overlay ---------- */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.nav-overlay.active {
  opacity: 1;
  pointer-events: all;
}
</style>

<sm-file path="script.js">
(function () {
  'use strict';

  // ---------- Header scroll effect ----------
  const header = document.querySelector('.site-header');
  let lastScroll = 0;

  function handleScroll() {
    const currentScroll = window.pageYOffset;
    if (currentScroll > 10) {
      header.classList.add('scrolled');
    } else {
      header.classList.remove('scrolled');
    }
    lastScroll = currentScroll;
  }

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

  // ---------- Mobile navigation ----------
  const navToggle = document.querySelector('.nav-toggle');
  const navList = document.querySelector('.nav-list');
  const navOverlay = document.createElement('div');
  navOverlay.className = 'nav-overlay';
  document.body.appendChild(navOverlay);

  function toggleNav() {
    const isOpen = navToggle.getAttribute('aria-expanded') === 'true';
    navToggle.setAttribute('aria-expanded', String(!isOpen));
    navList.classList.toggle('open');
    navOverlay.classList.toggle('active');
    document.body.style.overflow = !isOpen ? 'hidden' : '';
  }

  function closeNav() {
    navToggle.setAttribute('aria-expanded', 'false');
    navList.classList.remove('open');
    navOverlay.classList.remove('active');
    document.body.style.overflow = '';
  }

  navToggle.addEventListener('click', toggleNav);
  navOverlay.addEventListener('click', closeNav);

  // Close nav on link click
  navList.querySelectorAll('a').forEach(function (link) {
    link.addEventListener('click', closeNav);
  });

  // Close nav on Escape key
  document.addEventListener('keydown', function (e) {
    if (e.key === 'Escape' && navList.classList.contains('open')) {
      closeNav();
      navToggle.focus();
    }
  });

  // ---------- Contact form ----------
  const form = document.getElementById('contact-form');
  const successMsg = document.getElementById('form-success');

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

      // Basic validation
      const name = document.getElementById('name');
      const email = document.getElementById('email');
      const message = document.getElementById('message');
      let valid = true;

      [name, email, message].forEach(function (field) {
        field.style.borderColor = '';
        if (!field.value.trim()) {
          field.style.borderColor = '#ef4444';
          valid = false;
        }
      });

      if (email.value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.value)) {
        email.style.borderColor = '#ef4444';
        valid = false;
      }

      if (!valid) return;

      // Show success
      form.style.display = 'none';
      successMsg.removeAttribute('hidden');
    });
  }

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

  // ---------- Intersection Observer for fade-in animations ----------
  const observerOptions = {
    root: null,
    rootMargin: '0px 0px -60px 0px',
    threshold: 0.1
  };

  const fadeObserver = new IntersectionObserver(function (entries) {
    entries.forEach(function (entry) {
      if (entry.isIntersecting) {
        entry.target.style.opacity = '1';
        entry.target.style.transform = 'translateY(0)';
        fadeObserver.unobserve(entry.target);
      }
    });
  }, observerOptions);

  document.querySelectorAll('.service-card, .why-card, .about-content, .about-images, .contact-info, .contact-form-wrapper').forEach(function (el) {
    el.style.opacity = '0';
    el.style.transform = 'translateY(24px)';
    el.style.transition = 'opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1)';
    fadeObserver.observe(el);
  });
})();
