/* css/candle.css
   Enhanced SVG flame animation, embers and +1 float.
   Replace/append to your existing candle styles.
*/

/* wrapper and button */
.candle-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  position: relative;
}

#light-candle-btn {
  background: linear-gradient(#fffbf0, #ffe9b0);
  border: 1px solid #b87a00;
  color: #000;
  padding: 12px 20px;
  border-radius: 36px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(184,122,0,0.18);
  position: relative;
  overflow: visible;
}

#light-candle-btn.loading {
  opacity: 0.7;
  cursor: progress;
}

/* counter */
#candle-counter {
  font-size: 1rem;
  color: #333;
  background: rgba(0,0,0,0.03);
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.06);
}

#candle-counter.pulse {
  animation: candle-pulse 600ms ease;
}
@keyframes candle-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* +1 float */
.candle-plus {
  position: absolute;
  bottom: 100%;
  font-weight: 800;
  color: #ff6f3c;
  opacity: 0;
  transform: translateX(-50%) translateY(0);
  left: 50%;
  pointer-events: none;
}
.candle-plus.animate {
  animation: plus-float 900ms cubic-bezier(.22,.9,.35,1);
}
@keyframes plus-float {
  0% { transform: translateX(-50%) translateY(6px) scale(1); opacity: 1; }
  60% { transform: translateX(-50%) translateY(-26px) scale(1.06); opacity: 0.9; }
  100% { transform: translateX(-50%) translateY(-48px) scale(0.95); opacity: 0; }
}

/* SVG flame base styles */
.candle-flame-svg {
  width: 84px;
  height: 126px;
  pointer-events: none;
  display: block;
  will-change: transform, opacity;
  transform-origin: 50% 80%;
  opacity: 0.98;
}

/* initial state before animation starts */
.candle-flame-svg.start .flame-outer,
.candle-flame-svg.start .flame-core,
.candle-flame-svg.start .flame-glow {
  transform-origin: 40px 80px;
  transform: translateY(6px) scale(0.98);
  opacity: 0.92;
}

/* main animation: flicker + subtle vertical movement */
.candle-flame-svg.animate .flame-outer {
  animation: flame-flicker-outer 900ms ease-in-out both;
}
.candle-flame-svg.animate .flame-core {
  animation: flame-flicker-core 900ms ease-in-out both;
}
.candle-flame-svg.animate .flame-glow {
  animation: flame-glow 900ms ease-in-out both;
}

/* outer flicker: skew/scale subtle */
@keyframes flame-flicker-outer {
  0%   { transform: translateY(0) scaleY(1) skewX(0deg); opacity:1; }
  25%  { transform: translateY(-2px) scaleY(1.02) skewX(-2deg); opacity:0.98; }
  50%  { transform: translateY(0) scaleY(0.99) skewX(1.5deg); opacity:1; }
  75%  { transform: translateY(-1px) scaleY(1.01) skewX(-1deg); opacity:0.99; }
  100% { transform: translateY(0) scaleY(1) skewX(0deg); opacity:1; }
}

@keyframes flame-flicker-core {
  0%   { transform: translateY(0) scale(1); opacity:1; }
  30%  { transform: translateY(-1.5px) scale(1.02); opacity:0.95; }
  60%  { transform: translateY(0) scale(0.99); opacity:1; }
  100% { transform: translateY(0) scale(1); opacity:1; }
}

@keyframes flame-glow {
  0% { transform: scale(1); opacity:0.9; filter: blur(3px); }
  50% { transform: scale(1.04); opacity:0.95; filter: blur(5px); }
  100% { transform: scale(1); opacity:0.9; filter: blur(3px); }
}

/* Embers: small circles that float up and fade */
.ember {
  opacity: 1;
  transform-origin: center;
  will-change: transform, opacity;
}
.ember.ember-animate {
  animation: ember-rise 1100ms cubic-bezier(.22,.9,.35,1) forwards;
}
@keyframes ember-rise {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  40% {
    transform: translateY(-18px) scale(1.1);
    opacity: 0.9;
  }
  100% {
    transform: translateY(-62px) scale(0.6);
    opacity: 0;
  }
}

/* small accessibility: reduce-motion preference */
@media (prefers-reduced-motion: reduce) {
  .candle-flame-svg.animate .flame-outer,
  .candle-flame-svg.animate .flame-core,
  .candle-flame-svg.animate .flame-glow,
  .ember.ember-animate,
  .candle-plus.animate,
  #candle-counter.pulse {
    animation-duration: 1ms !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

/* layout: center flame/button, counter anchored right */
.candle-wrapper { width: 100%; max-width: 720px; margin: 18px auto; padding: 0 12px; }

/* shared container for both interactive and lit states */
.candle-lit-state {
  position: relative;        /* allows absolute positioning of counter */
  width: 50%;     /*trebalo bi mobile 50% a normal 25% */
  display: flex;
  justify-content: center;   /* center flame/button horizontally */
  align-items: center;
  min-height: 96px;          /* ensure enough vertical space for flame/button */
  padding: 10px 48px;        /* horizontal padding to give space for counter */
  box-sizing: border-box;
}

/* Counter anchored to the right */
.candle-lit-state #candle-counter {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.03);
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.06);
  font-weight: 600;
  color: #333;
}

/* Centered interactive button styling (unchanged) */
#light-candle-btn {
  background: linear-gradient(#fffbf0, #ffe9b0);
  border: 1px solid #b87a00;
  color: #000;
  padding: 12px 20px;
  border-radius: 36px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(184,122,0,0.18);
  position: relative;
  z-index: 1; /* ensure above inserted SVG animations */
}

/* static flame (no label) */
.static-flame {
  display: block;
  width: 56px;
  height: 84px;
  will-change: transform, opacity;
  transform-origin: 50% 80%;
  animation: static-flame-flicker 2000ms infinite ease-in-out;
}

/* keep accessibility preference in mind */
@media (prefers-reduced-motion: reduce) {
  .static-flame,
  .candle-flame-svg,
  .candle-plus,
  .ember {
    animation-duration: 1ms !important;
    transform: none !important;
    opacity: 1 !important;
  }
}