/* Critical CSS Variables */
:root {
  --primary-color: #4f67a5;
  --secondary-color: #299679;
  --nav-offset: 0px;
  --font-primary: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --transition-base: 0.3s ease;
  --shadow-light: 0 2px 8px rgba(79, 103, 165, 0.1);
  --shadow-medium: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Critical Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 1.6;
  background-color: #f8f9fa;
  color: #333;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Critical Navigation Styles */
.sticky {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  background-color: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-light);
  will-change: transform;
  transform: translateZ(0);
}

/* Accessibility and Performance Optimizations */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip Link for Screen Readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: white !important;
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  font-weight: 600;
  transition: top var(--transition-base);
}

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

/* Performance Optimizations */
.lazy-background {
  background-color: #f0f0f0;
  background-size: cover;
  background-position: center;
}

.service-item,
.gallery-item,
.testimonial-item {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

.card,
.about-image,
.contact-info {
  contain: content;
}

/* Respect User Preferences for Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-delay: -1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    background-attachment: initial !important;
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000080;
    --secondary-color: #006400;
  }
}

/* Critical Font Loading */
@font-face {
  font-family: "Work Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("Work Sans Regular"),
       url(https://fonts.gstatic.com/s/worksans/v19/QGYsz_wNahGAdqQ43Rh_fKDp.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Work Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local("Work Sans SemiBold"),
       url(https://fonts.gstatic.com/s/worksans/v19/QGYsz_wNahGAdqQ43Rh_fKDp.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Work Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local("Work Sans Bold"),
       url(https://fonts.gstatic.com/s/worksans/v19/QGYsz_wNahGAdqQ43Rh_fKDp.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Hero Section Styles */
.hero {
  position: relative;
  min-height: 70vh;
  min-height: max(70vh, calc(100vh - var(--nav-offset, 0px)));
  min-height: max(70vh, calc(100dvh - var(--nav-offset, 0px)));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  contain: layout style paint;
  content-visibility: auto;
  isolation: isolate;
  padding-top: var(--nav-offset, 0px);
}

.hero picture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  pointer-events: none;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  will-change: transform;
  transform: translateZ(0);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.2) 100%
  );
  z-index: 2;
}

.hero-content {
  position: relative;
  color: #ffffff;
  max-width: 700px;
  padding: 0 20px;
  text-align: center;
  z-index: 3;
}

.hero-content h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 1.2rem;
  line-height: 1.1;
  color: #ffffff;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
}

.hero-content p {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin: 0 0 2.5rem;
  max-width: 65ch;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
  color: #ffffff !important;
  line-height: 1.4;
}

.hero-content .h6 {
  font-size: 66px;
  color: #ffffff;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
  margin-bottom: 1rem;
  font-weight: 600;
}

/* CTA Button Styles */
.fd-cta-button,
.fd-cta-button:link,
.fd-cta-button:visited,
.fd-cta-button:hover,
.fd-cta-button:active,
.fd-cta-button:focus,
a.fd-cta-button,
a.fd-cta-button:link,
a.fd-cta-button:visited,
a.fd-cta-button:hover,
a.fd-cta-button:active,
a.fd-cta-button:focus {
  color: #ffffff !important;
  text-decoration: none !important;
}

.fd-cta-button .fd-arrow,
.fd-cta-button:hover .fd-arrow {
  color: #ffffff !important;
}

/* Enhanced Navigation Styles */
#top-bar {
  transform: translateY(0);
  opacity: 1;
  will-change: transform, opacity;
}

#main-nav {
  will-change: transform;
}

/* Tablet & Mobile Hero Styles */
@media (max-width: 1024px) {
  .hero {
    min-height: 65vh;
    height: 500px;
    max-height: 650px;
  }
}

@media (max-width: 768px) {
  .hero {
    min-height: 60vh;
    height: 450px;
    max-height: 550px;
  }
  .hero-content {
    padding: 0 15px;
  }
  .hero-content .h6 {
    font-size: 48px;
  }
  .hero-content h1 {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .hero {
    min-height: 55vh;
    height: 400px;
    max-height: 500px;
  }
  .hero-content {
    padding: 0 10px;
  }
  .hero-content .h6 {
    font-size: 36px;
  }
  .hero-content h1 {
    font-size: 18px;
    margin-bottom: 0.8rem;
  }
  .hero-content p {
    margin-bottom: 1.5rem;
  }
}

/* Image Optimization */
img:not([loading]) {
  content-visibility: auto;
}

img[loading="lazy"] {
  content-visibility: auto;
}

/* Performance Enhancement */
* {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}