@layer reset, theme, base, layout, components, utilities;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  html {
    scroll-behavior: smooth;
    text-size-adjust: 100%;
  }
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
  }
  input, button, textarea, select {
    font: inherit;
    color: inherit;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
  ul, ol {
    list-style: none;
  }
}

@layer theme {
  :root {
    color-scheme: light dark;

    /* Colors */
    --accent-color: light-dark(oklch(0.65 0.2 160), oklch(0.7 0.2 160));
    --accent-gradient: linear-gradient(135deg, oklch(0.75 0.15 160), oklch(0.65 0.2 220));
    
    --bg-page: light-dark(oklch(0.98 0.01 240), oklch(0.18 0.02 240));
    --text-main: light-dark(oklch(0.2 0.02 240), oklch(0.95 0.01 240));
    --text-muted: light-dark(oklch(0.4 0.02 240), oklch(0.7 0.01 240));

    --glass-bg: light-dark(rgba(255, 255, 255, 0.6), rgba(20, 25, 35, 0.6));
    --glass-border: light-dark(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.08));
    --glass-shadow: light-dark(
      0 8px 32px rgba(0, 0, 0, 0.05),
      0 8px 32px rgba(0, 0, 0, 0.4)
    );

    /* Typography */
    --font-heading: 'Outfit', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
    --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --text-3xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
    --text-4xl: clamp(2.5rem, 1.8rem + 3.5vw, 4rem);
    --text-5xl: clamp(3rem, 2rem + 5vw, 5.5rem);

    /* Spacing */
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 4rem;
    --space-2xl: 8rem;
  }
}

@layer base {
  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-main);
    background-color: var(--bg-page);
    line-height: 1.6;
    overflow-x: hidden;
  }
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.2;
    text-wrap: balance;
    margin-bottom: var(--space-md);
    font-weight: 600;
  }
  h1 { font-size: var(--text-5xl); font-weight: 800; letter-spacing: -0.02em; }
  h2 { font-size: var(--text-3xl); letter-spacing: -0.01em; }
  h3 { font-size: var(--text-xl); }
  p {
    margin-bottom: var(--space-md);
    text-wrap: pretty;
  }
  .lead, .subtitle {
    font-size: var(--text-lg);
    color: var(--text-muted);
  }
  
  /* Shared text gradient */
  .text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
  }
}

@layer layout {
  .container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: var(--space-md);
  }
  .section {
    padding-block: var(--space-2xl);
  }
  .section-header {
    text-align: center;
    margin-bottom: var(--space-xl);
  }
}

@layer components {
  /* Glass Card */
  .glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
  }

  /* Button */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8em 1.5em;
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 600;
    border-radius: 999px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    cursor: pointer;
    border: none;
    outline: none;
  }
  .btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 4px;
  }
  .btn-primary {
    background: var(--text-main);
    color: var(--bg-page);
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
  }
  @media (prefers-color-scheme: dark) {
    .btn-primary {
      background: var(--accent-gradient);
      color: #fff;
    }
  }
  .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  }
  .btn-block {
    width: 100%;
  }

  /* Navbar */
  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding-block: var(--space-md);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    transition: padding 0.3s ease;
  }
  /* Animation for sticky header when using scroll driven */
  @supports (animation-timeline: scroll()) {
    .navbar {
      animation: nav-shrink linear both;
      animation-timeline: scroll();
      animation-range: 0 100px;
    }
    @keyframes nav-shrink {
      to {
        padding-block: var(--space-sm);
        box-shadow: 0 4px 24px rgba(0,0,0,0.05);
      }
    }
  }

  .navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .logo-img {
    height: 40px;
    transition: transform 0.3s;
  }
  .logo:hover .logo-img {
    transform: scale(1.05);
  }
  
  .nav-list {
    display: flex;
    gap: var(--space-lg);
  }
  .nav-list a {
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 600;
    position: relative;
    padding-block: 0.5em;
  }
  .nav-list a::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-color);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease;
  }
  .nav-list a:hover::after {
    transform: scaleX(1);
    transform-origin: left;
  }

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

  /* Hero */
  .hero {
    position: relative;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
    overflow: hidden;
  }
  .hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: -2;
    transform: scale(1.05);
  }
  @supports (animation-timeline: scroll()) {
    .hero-bg {
      animation: parallax linear both;
      animation-timeline: scroll();
      animation-range: 0 100vh;
    }
    @keyframes parallax {
      to { transform: translateY(20%) scale(1.1); }
    }
  }

  .hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, 
      light-dark(rgba(255,255,255,0.7), rgba(15,18,25,0.8)),
      var(--bg-page)
    );
    z-index: -1;
  }
  .hero-content {
    text-align: center;
    max-width: 800px;
  }

  /* About */
  .about-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
  }
  .about-text {
    padding: var(--space-xl);
    text-align: center;
    font-size: var(--text-lg);
  }
  .features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);
  }
  .feature-card {
    padding: var(--space-lg);
    text-align: center;
    transition: transform 0.3s ease, background 0.3s ease;
  }
  .feature-card:hover {
    transform: translateY(-8px);
    background: light-dark(rgba(255, 255, 255, 0.9), rgba(20, 25, 35, 0.9));
  }
  .feature-icon {
    width: 64px;
    height: 64px;
    margin-inline: auto;
    margin-bottom: var(--space-md);
    background: var(--accent-gradient);
    border-radius: 16px;
    display: grid;
    place-items: center;
    padding: 12px;
  }
  /* In dark mode we don't invert because icons are on a gradient bg, 
     wait, the gradient is dark? Let's just use CSS filter to make them white */
  .feature-icon img {
    filter: brightness(0) invert(1);
  }

  /* Services */
  .service-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
  }
  .service-card {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  }
  .service-card:hover {
    transform: translateY(-12px) scale(1.02);
  }
  .card-img {
    height: 240px;
    overflow: hidden;
  }
  .card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
  }
  .service-card:hover .card-img img {
    transform: scale(1.1);
  }
  .card-content {
    padding: var(--space-lg);
    flex: 1;
  }

  /* BESS Section */
  .bess-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: center;
  }
  @media (max-width: 900px) {
    .bess-layout { grid-template-columns: 1fr; }
  }
  .bess-types {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
  }
  .type-badge {
    padding: 0.5em 1em;
    border-radius: 999px;
    border: 1px solid var(--accent-color);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent-color);
    background: transparent;
  }
  
  .bess-image-container {
    position: relative;
    padding: var(--space-sm);
  }
  .bess-img {
    border-radius: 16px;
    position: relative;
    z-index: 2;
  }
  .bess-glow {
    position: absolute;
    inset: -20px;
    background: var(--accent-gradient);
    filter: blur(40px);
    opacity: 0.2;
    z-index: 1;
    border-radius: 50%;
  }

  /* Gallery */
  .gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-auto-rows: 250px;
    gap: var(--space-md);
  }
  .gallery-item {
    border-radius: 24px;
    overflow: hidden;
    position: relative;
  }
  .gallery-item.tall {
    grid-row: span 2;
  }
  @media (max-width: 600px) {
    .gallery-item.tall { grid-row: span 1; }
  }
  .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease, filter 0.5s ease;
    filter: grayscale(20%);
  }
  .gallery-item:hover img {
    transform: scale(1.05);
    filter: grayscale(0%);
  }

  /* Contact */
  .contact-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    overflow: hidden;
  }
  @media (max-width: 800px) {
    .contact-box { grid-template-columns: 1fr; }
  }
  .contact-info {
    padding: var(--space-xl);
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  }
  .contact-list {
    margin-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }
  .contact-list li {
    display: flex;
    gap: var(--space-md);
    align-items: center;
  }
  .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--glass-border);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
  }
  
  .contact-form-wrapper {
    padding: var(--space-xl);
  }
  .modern-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }
  .input-group {
    position: relative;
  }
  .input-group input,
  .input-group textarea {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--text-muted);
    padding: 0.8rem 0;
    color: var(--text-main);
    transition: border-color 0.3s;
  }
  .input-group input:focus-visible,
  .input-group textarea:focus-visible {
    outline: none;
    border-color: var(--accent-color);
  }
  .input-group label {
    position: absolute;
    left: 0;
    top: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s, font-size 0.3s;
    pointer-events: none;
  }
  
  /* Floating label */
  .input-group input:focus-visible ~ label,
  .input-group input:not(:placeholder-shown) ~ label,
  .input-group textarea:focus-visible ~ label,
  .input-group textarea:not(:placeholder-shown) ~ label {
    transform: translateY(-1.5rem);
    font-size: var(--text-xs);
    color: var(--accent-color);
  }

  /* Footer */
  .footer {
    padding-block: var(--space-xl);
    text-align: center;
    border-top: 1px solid var(--glass-border);
    margin-top: var(--space-2xl);
  }
  .footer-logo {
    margin-bottom: var(--space-md);
    display: flex;
    justify-content: center;
  }
  .footer-logo img {
    /* If dark mode, and logo is dark text, invert. We don't know the exact logo but let's assume it adapts or is a light text logo */
  }
}

@layer utilities {
  /* Scroll-driven animations fallback for non-supporting browsers */
  /* If animation-timeline is supported, we apply the animations */
  @supports (animation-timeline: view()) {
    .fade-in {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 30%;
    }
    .slide-up {
      animation: slide-up-anim linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 30%;
    }
    
    @keyframes reveal {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    @keyframes slide-up-anim {
      from { 
        opacity: 0; 
        transform: translateY(40px); 
      }
      to { 
        opacity: 1; 
        transform: translateY(0); 
      }
    }
    
    /* Hero animations use standard time-based animations because they are always in view on load */
    .hero .slide-up {
      animation: hero-slide-up-anim 1s cubic-bezier(0.2, 1, 0.3, 1) both;
      animation-timeline: auto; /* override view() */
    }
    @keyframes hero-slide-up-anim {
      from { opacity: 0; transform: translateY(40px); }
      to { opacity: 1; transform: translateY(0); }
    }
  }
}