/* ============================================
   SVG LETTERING ANIMATION
   Baunfire-style hero lettering with hover reveal
   ============================================ */

/* Container */
.lettering-bg {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
}

/* Words wrapper */
.lettering-bg .words {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  max-width: 100%;
  overflow: hidden;
}

/* Individual letter SVGs */
.lettering-bg .lettering {
  display: flex;
  align-items: center;
  gap: 0;
}

.lettering-bg .lettering svg {
  display: block;
  height: clamp(50px, 10vw, 140px);
  width: auto;
  flex-shrink: 0;
}

/* Hidden layer — white letters (initial state) */
.lettering-bg .lettering.hidden {
  position: relative;
  z-index: 2;
}

.lettering-bg .lettering.hidden svg {
  fill: #f9f9f9;
  transition: opacity 0.6s ease;
}

/* Reveal layer — dark letters (hidden initially) */
.lettering-bg .lettering.reveal {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.lettering-bg .lettering.reveal svg {
  fill: #272628;
}

/* Hover states */
.lettering-bg .words.hover .lettering.hidden {
  opacity: 0;
}

.lettering-bg .words.hover .lettering.reveal {
  opacity: 1;
}

/* Vertical layout variant (used in hero-right) */
.lettering-split {
  display: flex;
  gap: 24px;
  align-items: center;
}

.lettering-vertical .lettering-bg {
  justify-content: center;
}

.lettering-vertical .words {
  flex-direction: column;
  height: 100%;
}

.lettering-vertical .lettering {
  flex-direction: column;
}

.lettering-vertical .lettering.reveal {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Swipe-to-appear clip animation — top to bottom */
.lettering-bg .swipe-to-appear-down {
  clip-path: inset(0 0 100% 0);
  animation: swipeRevealDown 6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.lettering-bg .words.hover .swipe-to-appear-down {
  clip-path: inset(0 0 0 0);
  animation: swipeHideUp 4s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes swipeRevealDown {
  0% { clip-path: inset(0 0 100% 0); }
  100% { clip-path: inset(0 0 0 0); }
}

@keyframes swipeHideUp {
  0% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(100% 0 0 0); }
}

/* Swipe-to-appear clip animation — bottom to top */
.lettering-bg .swipe-to-appear-up {
  clip-path: inset(100% 0 0 0);
  animation: swipeRevealUp 6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.lettering-bg .words.hover .swipe-to-appear-up {
  clip-path: inset(0 0 0 0);
  animation: swipeHideDown 4s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes swipeRevealUp {
  0% { clip-path: inset(100% 0 0 0); }
  100% { clip-path: inset(0 0 0 0); }
}

@keyframes swipeHideDown {
  0% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 100% 0); }
}

/* Entry animation — load (stagger top to bottom) */
.lettering-bg .animate-load .lettering.hidden {
  animation: letterLoadDown 5s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes letterLoadDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Entry animation — load (stagger bottom to top) */
.lettering-up .animate-load .lettering.hidden {
  animation: letterLoadUp 5s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes letterLoadUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger each letter — top to bottom */
.lettering-down .lettering.hidden svg:nth-child(1) { animation-delay: 0.0s; }
.lettering-down .lettering.hidden svg:nth-child(2) { animation-delay: 0.25s; }
.lettering-down .lettering.hidden svg:nth-child(3) { animation-delay: 0.5s; }
.lettering-down .lettering.hidden svg:nth-child(4) { animation-delay: 0.75s; }

/* Stagger each letter — bottom to top (reversed) */
.lettering-up .lettering.hidden svg:nth-child(1) { animation-delay: 0.75s; }
.lettering-up .lettering.hidden svg:nth-child(2) { animation-delay: 0.5s; }
.lettering-up .lettering.hidden svg:nth-child(3) { animation-delay: 0.25s; }
.lettering-up .lettering.hidden svg:nth-child(4) { animation-delay: 0.0s; }

/* Spark canvases */
.lettering-bg .spark {
  position: absolute;
  pointer-events: none;
  z-index: 3;
}

.lettering-bg .spark1 {
  top: 10%;
  left: 15%;
}

.lettering-bg .spark2 {
  bottom: 10%;
  right: 15%;
}

.lettering-bg .spark canvas {
  width: 200px;
  height: 200px;
  touch-action: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lettering-bg .swipe-to-appear-down,
  .lettering-bg .swipe-to-appear-up {
    animation: none;
    clip-path: inset(0 0 0 0);
  }
  .lettering-bg .animate-load .lettering.hidden {
    animation: none;
  }
  .lettering-bg .lettering.hidden,
  .lettering-bg .lettering.reveal {
    transition: none;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .lettering-bg .lettering svg {
    height: clamp(32px, 8vw, 80px);
  }
  .lettering-bg .spark {
    display: none;
  }
}
