/* Candles, sound button, film grain */

.candles {
  position: absolute;
  bottom: 0;
  z-index: 7;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  transform: scale(0.55);
}

#pages-scene.showing .candles {
  animation: candles-rise 1.4s ease;
}

.candles-left {
  left: 8px;
  transform-origin: bottom left;
}

.candles-right {
  right: 8px;
  transform-origin: bottom right;
}

@media (min-width: 700px) {
  .candles {
    transform: scale(1);
  }
}

.candle {
  position: relative;
  background: linear-gradient(90deg, #2a0006, #8e0b26 40%, #5e000f 70%, #2a0006);
  border-radius: 5px 5px 2px 2px;
}

/* wick */
.candle::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  width: 2px;
  height: 8px;
  background-color: #111;
}

.flame {
  position: absolute;
  top: -32px;
  left: 50%;
  width: 14px;
  height: 26px;
  margin-left: -6px;
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse at 50% 75%, #fff, #ffeaa8 20%, #ffb347 45%, rgba(255, 90, 20, 0.8) 70%, transparent);
  box-shadow: 0 0 25px 10px rgba(255, 160, 70, 0.4);
  transform-origin: bottom center;
  animation: glow 3s infinite;
}

.flicker .flame {
  animation-name: flicker;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.wax-drip {
  position: absolute;
  top: 2px;
  left: 22%;
  width: 28%;
  height: 30%;
  background-color: #a3102f;
  border-radius: 0 0 5px 5px;
}

@keyframes flicker {
  0%   { transform: scale(1, 1) rotate(-2deg); opacity: 1; }
  25%  { transform: scale(0.9, 1.1) rotate(3deg); }
  50%  { transform: scale(1.06, 0.88) rotate(-4deg); opacity: 0.8; }
  75%  { transform: scale(0.94, 1.14) rotate(2deg); }
  100% { transform: scale(1.02, 0.95) rotate(-1deg); opacity: 0.95; }
}

@keyframes glow {
  50% { transform: scale(1.03, 1.06); }
}

@keyframes candles-rise {
  from { opacity: 0; bottom: -40px; }
  to   { opacity: 1; bottom: 0; }
}


#sound-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 9;
  padding: 5px 12px;
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--silver);
  background-color: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(230, 230, 234, 0.4);
  border-radius: 20px;
  cursor: pointer;
}



#grain {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: 60;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  animation: grain 0.6s steps(4) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3%, 2%); }
  50%  { transform: translate(2%, -3%); }
  75%  { transform: translate(-2%, -1%); }
  100% { transform: translate(1%, 3%); }
}

@media (prefers-reduced-motion: reduce) {
  #grain {
    animation: none;
  }
}
