/* ==========================================================================
   CSS CUSTOM PROPERTIES & CONFIGURATION
   ========================================================================== */

:root {
  /* Color configuration */
  --glow-hue: 35deg;

  /* Spring animation easing curve for natural motion */
  --spring-easing: linear(
    0,
    0.002,
    0.01 0.9%,
    0.038 1.8%,
    0.156,
    0.312 5.8%,
    0.789 11.1%,
    1.015 14.2%,
    1.096,
    1.157,
    1.199,
    1.224 20.3%,
    1.231,
    1.231,
    1.226,
    1.214 24.6%,
    1.176 26.9%,
    1.057 32.6%,
    1.007 35.5%,
    0.984,
    0.968,
    0.956,
    0.949 42%,
    0.946 44.1%,
    0.95 46.5%,
    0.998 57.2%,
    1.007,
    1.011 63.3%,
    1.012 68.3%,
    0.998 84%,
    1
  );

  /* Animation duration */
  --spring-duration: 1.33s;
}

/* Custom property for shimmer animation angle */
@property --shimmer {
  syntax: '<angle>';
  inherits: false;
  initial-value: 33deg;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

/* Rotating shimmer effect */
@keyframes shimmer {
  0% {
    --shimmer: 0deg;
  }
  100% {
    --shimmer: 360deg;
  }
}

/* Pulsing shine effect for hover states */
@keyframes shine {
  0% {
    opacity: 0;
  }
  15%,
  55% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Text gradient sweep animation */
@keyframes text {
  0% {
    background-position: 100% center;
  }
  100% {
    background-position: -100% center;
  }
}

/* ==========================================================================
   MAIN BUTTON STYLES
   ========================================================================== */

.glow-button {
  /* Layout & positioning */
  --inset: 40px;
  position: relative;
  isolation: isolate;

  /* Typography */
  color: var(--bg-color);
  font-family: 'Lora', serif;
  font-size: 18px;
  font-weight: 700;
  text-wrap: balance;
  text-align: center;

  /* Spacing & dimensions */
  padding: 18px;
  border-radius: 18px;
  scale: 1;

  /* Visual styling */
  background-image: linear-gradient(
    315deg,
    #f4d03f -10%,
    #eea238 50%,
    #d4ac0d 110%
  );

  /* Layered shadow effects for depth */
  box-shadow:
    0 4px 8px 2px hsl(var(--glow-hue) 80% 30% / 22%),
    0 2px 4px 1px hsl(var(--glow-hue) 80% 30% / 28%),
    inset 0 1px 0 hsl(var(--glow-hue) 80% 90% / 40%),
    inset 0 -1px 0 hsl(var(--glow-hue) 80% 30% / 28%);

  /* Smooth spring-based transitions */
  transition: all var(--spring-duration) var(--spring-easing);
}

/* ==========================================================================
   BUTTON INTERACTION STATES
   ========================================================================== */

/* Hover and active states - elevated appearance */
.glow-button:hover:not(:active),
.glow-button.active {
  transition-duration: calc(var(--spring-duration) * 0.5);
  transform: translateY(-2px);

  /* Enhanced shadow for lifted effect */
  box-shadow:
    0 6px 12px 3px hsl(var(--glow-hue) 80% 30% / 26%),
    0 3px 6px 2px hsl(var(--glow-hue) 80% 30% / 32%),
    inset 0 1px 0 hsl(var(--glow-hue) 80% 95% / 45%),
    inset 0 -1px 0 hsl(var(--glow-hue) 80% 30% / 33%);
}

/* Pressed state - depressed appearance */
.glow-button:active {
  transition-duration: calc(var(--spring-duration) * 0.5);
  transform: translateY(1px);

  /* Reduced shadow for pressed effect */
  box-shadow:
    0 2px 4px 1px hsl(var(--glow-hue) 80% 30% / 28%),
    0 1px 2px 0px hsl(var(--glow-hue) 80% 30% / 33%),
    inset 0 1px 0 hsl(var(--glow-hue) 80% 80% / 33%),
    inset 0 -1px 0 hsl(var(--glow-hue) 80% 30% / 38%);
}

/* ==========================================================================
   SHIMMER EFFECT STYLES
   ========================================================================== */

/* Main shimmer container with rotating conic gradient mask */
.shimmer {
  position: absolute;
  inset: calc(var(--inset) * -1);
  border-radius: inherit;
  pointer-events: none;

  /* Conic gradient mask creates the shimmer sweep effect */
  mask-image: conic-gradient(
    from var(--shimmer, 0deg),
    transparent 0%,
    transparent 20%,
    black 36%,
    black 45%,
    transparent 50%,
    transparent 70%,
    black 85%,
    black 95%,
    transparent 100%
  );
  mask-size: cover;
  mix-blend-mode: plus-lighter;
  animation: shimmer 1s linear infinite both;
}

/* Shimmer pseudo-elements for layered glow effects */
.shimmer::before,
.shimmer::after {
  content: '';
  position: absolute;
  inset: var(--inset);
  border-radius: inherit;
  pointer-events: none;
  mix-blend-mode: color;
  transition: all 0.5s ease;
  opacity: 0;
}

/* Background glow layer */
.shimmer::before {
  box-shadow:
    0 0 calc(var(--inset) * 0.1) 2px hsl(var(--glow-hue) 80% 95% / 55%),
    0 0 calc(var(--inset) * 0.18) 4px hsl(var(--glow-hue) 80% 80% / 42%),
    0 0 calc(var(--inset) * 0.33) 4px hsl(var(--glow-hue) 80% 70% / 35%),
    0 0 calc(var(--inset) * 0.66) 5px hsl(var(--glow-hue) 80% 70% / 28%);
  z-index: -1;
}

/* Foreground glow layer */
.shimmer::after {
  z-index: 2;
}

/* Activate shimmer effects on hover and active states */
.glow-button:hover .shimmer::before,
.glow-button:hover .shimmer::after,
.glow-button.active .shimmer::before,
.glow-button.active .shimmer::after {
  opacity: 1 !important;
  animation: shine 1.2s ease-in 2 forwards !important;
  animation-delay: 0s !important;
}

/* ==========================================================================
   TEXT ANIMATION STYLES
   ========================================================================== */

/* Text element with gradient background for sweep effect */
.glow-button .text {
  color: var(--bg-color);
  background-color: var(--bg-color);

  /* Gradient that creates the text sweep animation */
  background-image: linear-gradient(
    120deg,
    transparent,
    hsla(var(--glow-hue), 100%, 80%, 0.66) 40%,
    hsla(var(--glow-hue), 100%, 90%, 0.9) 50%,
    transparent 52%
  );
  background-clip: text;
  background-repeat: no-repeat;
  background-size: 300% 300%;
  background-position: center 200%;
}

/* Activate text sweep animation on hover and active states */
.glow-button:hover .text,
.glow-button.active .text {
  animation: text 0.66s ease-in 2 both !important;
  animation-delay: 0s !important;
}
