/**
 * Tailwind CSS Heading Component with Kinetic Per-Letter Blur-Slide-Fade Animation
 * 
 * Features:
 * - Responsive Font Sizing (clamp / Tailwind text-2xl -> text-5xl)
 * - Tight Letter Tracking (tracking-tight: -0.025em / tracking-tighter: -0.05em)
 * - Smooth Color Transitions (duration-300 ease-out on hover & theme states)
 * - Complex kinetic character reveal: opacity 0->1, translateY 22px->0, blur 12px->0
 * - Staggered letter ripple via CSS custom property --char-index
 * - Preserves nested spans (.text-cyan, .animated-gradient-text, etc.)
 * - Optimized for Hero Banners & Section Headers across the site
 */

/* --------------------------------------------------------------------------
   Tailwind CSS Utility Classes (Self-Contained for Compatibility)
   -------------------------------------------------------------------------- */
.tracking-tight {
  letter-spacing: -0.025em !important;
}

.tracking-tighter {
  letter-spacing: -0.05em !important;
}

.transition-colors {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.duration-300 {
  transition-duration: 300ms;
}

.duration-500 {
  transition-duration: 500ms;
}

.ease-out {
  transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
}

/* Responsive Sizing Scale matching Tailwind text-2xl -> sm:text-3xl -> md:text-4xl -> lg:text-5xl */
.text-responsive-h3 {
  font-size: clamp(1.4rem, 2.8vw, 2.35rem) !important;
  line-height: 1.22 !important;
}

.text-responsive-section {
  font-size: clamp(1.65rem, 3.4vw, 2.65rem) !important;
  line-height: 1.2 !important;
}

/* --------------------------------------------------------------------------
   Heading Component Base Styles
   -------------------------------------------------------------------------- */
h1.kinetic-blur-heading,
h2.kinetic-blur-heading,
h3.kinetic-blur-heading,
h4.kinetic-blur-heading,
.kinetic-blur-heading:not(span) {
  font-family: var(--font-heading, 'Plus Jakarta Sans', -apple-system, sans-serif);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: #ffffff;
  display: block !important;
  width: 100% !important;
  clear: both !important;
  cursor: default;
  transition: color 300ms ease-out, text-shadow 300ms ease-out;
  position: relative;
  overflow: visible;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

span.kinetic-blur-heading {
  font-family: var(--font-heading, 'Plus Jakarta Sans', -apple-system, sans-serif);
  font-weight: 800;
  letter-spacing: -0.035em;
  display: inline-block;
  cursor: default;
  transition: color 300ms ease-out, text-shadow 300ms ease-out;
  position: relative;
  overflow: visible;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Hover color transitions */
h1.kinetic-blur-heading:hover,
h2.kinetic-blur-heading:hover,
h3.kinetic-blur-heading:hover,
.kinetic-blur-heading:hover {
  color: #00f0ff;
  text-shadow: 0 0 25px rgba(0, 240, 255, 0.4), 0 0 50px rgba(0, 240, 255, 0.15);
}

/* Preserve nested child colors when parent is hovered */
h1.kinetic-blur-heading:hover .text-pink .char,
h2.kinetic-blur-heading:hover .text-pink .char,
h3.kinetic-blur-heading:hover .text-pink .char {
  color: #f472b6 !important;
}

/* Gradient Variant */
.kinetic-blur-heading.heading-gradient {
  background: linear-gradient(135deg, #ffffff 0%, #00f0ff 45%, #d946ef 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: filter 300ms ease-out;
}

.kinetic-blur-heading.heading-gradient:hover {
  filter: drop-shadow(0 0 16px rgba(0, 240, 255, 0.45));
}

/* --------------------------------------------------------------------------
   Kinetic Per-Letter Blur + Slide Up + Fade In Animation Engine
   -------------------------------------------------------------------------- */
.kinetic-blur-heading .word-wrap {
  display: inline-block;
  white-space: nowrap;
  vertical-align: baseline;
}

.kinetic-blur-heading .word-space {
  display: inline-block;
  vertical-align: baseline;
}

.kinetic-blur-heading .char {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 14px, 0) scale(0.96);
  filter: blur(4px);
  transition:
    opacity 0.48s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.48s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.48s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.25s ease-out,
    text-shadow 0.25s ease-out;
  transition-delay: calc(var(--char-index, 0) * 0.018s);
  position: relative;
}

/* Triggered Animated State (when scrolled into view) */
.kinetic-blur-heading.is-visible .char {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  filter: none;
  will-change: auto;
}

/* Individual letter hover flourish */
.kinetic-blur-heading.is-visible .char:hover {
  transform: translateY(-2px) scale(1.08);
  color: #00f0ff;
  text-shadow: 0 0 14px rgba(0, 240, 255, 0.8);
  transition-delay: 0s !important;
}

/* Nested highlighted word support */
.text-cyan .char {
  color: #00f0ff !important;
}

.text-pink .char {
  color: #d946ef !important;
}

.text-purple .char {
  color: #a855f7 !important;
}

.text-amber .char,
.text-warning .char {
  color: #fbbf24 !important;
}

.text-green .char,
.text-success .char {
  color: #4ade80 !important;
}

/* Gradient text inside heading */
.animated-gradient-text .char,
.text-gradient .char {
  background: inherit;
  background-size: inherit;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent !important;
}

/* --------------------------------------------------------------------------
   Reduced Motion Accessibility
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .kinetic-blur-heading .char {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
}
