@use '../globals';
@use '../variables' as *;
@use '../mixins' as *;

// Hero-specific button extensions
%hero-button-base {
  @extend %button-base;
  padding: $spacing-sm $spacing-xl;
  font-size: $spacing-md;
  line-height: 1.5;
  border-radius: $border-radius-sm;
  gap: $spacing-xs;
  box-sizing: border-box;

  &:focus {
    box-shadow: 0 0 0 3px var(--box-shadow-hover);
  }
}

@keyframes hero-fade-up {
  from {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes hero-bubble-before {
  0%   { transform: scale(0.6) translate3d(0, 16px, 0); opacity: 0; }
  40%  { transform: scale(1.1) translate3d(0, -5px, 0); opacity: 1; }
  65%  { transform: scale(0.96) translate3d(0, 3px, 0); }
  82%  { transform: scale(1.03) translate3d(0, -1px, 0); }
  100% { transform: scale(1) translate3d(0, 0, 0); opacity: 1; }
}

@keyframes hero-bubble-after {
  0%   { transform: scale(0.5) translate3d(0, -12px, 0); opacity: 0; }
  45%  { transform: scale(1.14) translate3d(0, 4px, 0); opacity: 1; }
  68%  { transform: scale(0.94) translate3d(0, -2px, 0); }
  84%  { transform: scale(1.04) translate3d(0, 1px, 0); }
  100% { transform: scale(1) translate3d(0, 0, 0); opacity: 1; }
}

.hero-section {
  @include flex-center;
  min-height: 100vh;
  background: var(--hero-background);
  position: relative;

  // Mid-Century geometric circle decoration
  &::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -80px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 2px solid rgba(12, 68, 124, 0.15);
    pointer-events: none;
    will-change: transform, opacity;
  }

  &::after {
    content: '';
    position: absolute;
    bottom: 40px;
    left: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(239, 159, 39, 0.08);
    pointer-events: none;
    will-change: transform, opacity;
  }

  [data-theme='dark'] & {
    &::before {
      border-color: rgba(230, 241, 251, 0.1);
    }

    &::after {
      background: rgba(239, 159, 39, 0.05);
    }
  }

  &__container {
    max-width: 900px;
    width: 100%;
    text-align: center;
    @include flex-center;
    flex-direction: column;
    gap: $spacing-xl;
    position: relative;
    z-index: 1;
  }

  &__title {
    font-size: clamp(2.5rem, 7vw, 5rem);
    font-weight: 900;
    margin: 0;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: $color-heading;
    will-change: transform, opacity;
  }

  &__description {
    font-size: 1.25rem;
    line-height: 1.65;
    color: var(--color-text-muted);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    will-change: transform, opacity;
  }

  &__buttons {
    @include flex-center;
    gap: $spacing-lg;
    flex-wrap: wrap;
    will-change: transform, opacity;
  }

  &__button {
    @extend %hero-button-base;

    &--primary,
    &--tertiary {
      background: var(--color-primary);
      color: var(--color-text-on-dark);
      font-family: var(--font-headline);
      font-weight: 600;
      border-radius: 8px;

      &:hover {
        background: var(--color-secondary);
        box-shadow: none;
        filter: none;
        transform: translateY(-1px);
      }
    }

    &--secondary {
      background: transparent;
      color: var(--color-primary);
      border: 2px solid var(--color-primary);
      padding: calc(#{$spacing-sm} - 2px) $spacing-xl;

      &:hover {
        background: var(--color-primary);
        color: var(--color-text-on-dark);
        transform: translateY(-1px);
        box-shadow: none;
      }
    }
  }

  &__button-icon {
    width: $spacing-md;
    height: $spacing-md;
    flex-shrink: 0;
  }

  &__stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: $spacing-xl;
    margin-top: $spacing-3xl;

    @include globals.desktop-only {
      grid-template-columns: repeat(4, 1fr);
    }
  }

  &__stat-item {
    text-align: center;
    padding: $spacing-md;
    border-radius: $border-radius-md;
    will-change: transform, opacity;

    &--1 {
      background: var(--stat-primary-bg);

      .hero-section__stat-value {
        color: var(--stat-primary-value);
      }
      .hero-section__stat-label {
        color: var(--stat-primary-label);
      }
    }

    &--2 {
      background: var(--stat-secondary-bg);

      .hero-section__stat-value {
        color: var(--stat-secondary-value);
      }
      .hero-section__stat-label {
        color: var(--stat-secondary-label);
      }
    }

    &--3 {
      background: var(--stat-tertiary-bg);

      .hero-section__stat-value {
        color: var(--stat-tertiary-value);
      }
      .hero-section__stat-label {
        color: var(--stat-tertiary-label);
      }
    }

    &--4 {
      background: var(--stat-quaternary-bg);

      .hero-section__stat-value {
        color: var(--stat-quaternary-value);
      }
      .hero-section__stat-label {
        color: var(--stat-quaternary-label);
      }
    }
  }

  &__stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
    display: block;
  }

  &__stat-label {
    font-size: 0.875rem;
    line-height: 1.4;
    font-weight: 400;
  }
}

// Mobile responsiveness
@include globals.mobile-only {
  .hero-section {
    &__title {
      font-size: 2.5rem;
    }

    &__description {
      font-size: 1.1rem;
    }

    &__buttons {
      flex-direction: column;
      gap: $spacing-md;
    }

    &__button {
      width: 100%;
      max-width: 300px;
    }
  }
}

// Animations fire only after the page has fully loaded (--loaded class added via JS)
@media (prefers-reduced-motion: no-preference) {
  .hero-section--loaded {
    &::before {
      animation: hero-bubble-before 4s cubic-bezier(0.34, 1.2, 0.64, 1) both 0.2s;
    }

    &::after {
      animation: hero-bubble-after 4s cubic-bezier(0.34, 1.2, 0.64, 1) both 0.7s;
    }

    .hero-section__title {
      animation: hero-fade-up 0.6s ease-out both 0.2s;
    }

    .hero-section__description {
      animation: hero-fade-up 0.6s ease-out both 0.35s;
    }

    .hero-section__buttons {
      animation: hero-fade-up 0.6s ease-out both 0.5s;
    }

    .hero-section__stat-item {
      animation: hero-fade-up 0.7s ease-out both;

      &--1 { animation-delay: 0.7s; }
      &--2 { animation-delay: 0.85s; }
      &--3 { animation-delay: 1s; }
      &--4 { animation-delay: 1.15s; }
    }
  }
}
