:root {
  --midnight: #0f1a24;
  --ember: #b8561b;
  --flame: #e8912d;
  --candle: #f4e9d0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  color: var(--candle);
  background: var(--midnight);
}

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(
    ellipse 90% 62% at 76% 112%,
    var(--flame) 0%,
    var(--ember) 22%,
    var(--midnight) 62%
  );
  animation: candle-room 7.4s ease-in-out infinite;
}

.glow-core,
.glow-halo {
  position: absolute;
  inset: 0;
  transform-origin: 76% 100%;
}

.glow-core {
  background: radial-gradient(
    ellipse 42% 34% at 74% 108%,
    var(--flame) 0%,
    var(--ember) 32%,
    transparent 58%
  );
  animation: candle-flicker 2.6s ease-in-out infinite;
}

.glow-halo {
  background: radial-gradient(
    ellipse 70% 48% at 78% 114%,
    rgb(232 145 45 / 0.55) 0%,
    rgb(184 86 27 / 0.28) 36%,
    transparent 64%
  );
  animation: candle-halo 4.15s ease-in-out infinite;
}

@keyframes candle-room {
  0%,
  100% {
    filter: brightness(0.92);
  }
  18% {
    filter: brightness(1.04);
  }
  36% {
    filter: brightness(0.88);
  }
  54% {
    filter: brightness(1.08);
  }
  73% {
    filter: brightness(0.94);
  }
  86% {
    filter: brightness(1.02);
  }
}

@keyframes candle-flicker {
  0%,
  100% {
    opacity: 0.42;
    transform: scale(0.96) translate(0, 0);
  }
  8% {
    opacity: 0.78;
    transform: scale(1.06) translate(-1.2%, -0.6%);
  }
  14% {
    opacity: 0.3;
    transform: scale(0.9) translate(0.8%, 0.4%);
  }
  23% {
    opacity: 0.88;
    transform: scale(1.1) translate(-0.4%, -1.1%);
  }
  37% {
    opacity: 0.5;
    transform: scale(0.98) translate(0.7%, 0.2%);
  }
  49% {
    opacity: 0.22;
    transform: scale(0.86) translate(-0.9%, 0.7%);
  }
  61% {
    opacity: 0.82;
    transform: scale(1.08) translate(0.3%, -0.9%);
  }
  74% {
    opacity: 0.46;
    transform: scale(0.94) translate(-0.2%, 0.3%);
  }
  87% {
    opacity: 0.7;
    transform: scale(1.03) translate(0.6%, -0.4%);
  }
}

@keyframes candle-halo {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1) translate(0, 0);
  }
  21% {
    opacity: 0.85;
    transform: scale(1.07) translate(-0.8%, -0.5%);
  }
  44% {
    opacity: 0.4;
    transform: scale(0.93) translate(0.6%, 0.4%);
  }
  68% {
    opacity: 0.75;
    transform: scale(1.05) translate(0.3%, -0.7%);
  }
  83% {
    opacity: 0.5;
    transform: scale(0.97) translate(-0.4%, 0.2%);
  }
}

.embers {
  position: absolute;
  inset: 0;
}

.embers i {
  position: absolute;
  bottom: 4%;
  left: 74%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--flame);
  box-shadow: 0 0 7px 2px rgb(232 145 45 / 0.55);
  opacity: 0;
  animation: ember-rise 7s linear infinite;
}

.embers i:nth-child(2) {
  left: 68%;
  width: 3px;
  height: 3px;
  background: var(--ember);
  box-shadow: 0 0 6px 2px rgb(184 86 27 / 0.5);
  animation-duration: 8.4s;
  animation-delay: -1.6s;
}

.embers i:nth-child(3) {
  left: 80%;
  width: 5px;
  height: 5px;
  animation-duration: 6.2s;
  animation-delay: -3.1s;
}

.embers i:nth-child(4) {
  left: 71%;
  width: 2px;
  height: 2px;
  background: var(--candle);
  box-shadow: 0 0 5px 1px rgb(244 233 208 / 0.35);
  animation-duration: 9.1s;
  animation-delay: -4.4s;
}

.embers i:nth-child(5) {
  left: 77%;
  width: 3px;
  height: 3px;
  animation-duration: 7.8s;
  animation-delay: -0.8s;
}

.embers i:nth-child(6) {
  left: 63%;
  width: 4px;
  height: 4px;
  background: var(--ember);
  box-shadow: 0 0 8px 2px rgb(184 86 27 / 0.45);
  animation-duration: 10.2s;
  animation-delay: -5.5s;
}

.embers i:nth-child(7) {
  left: 84%;
  width: 2px;
  height: 2px;
  animation-duration: 6.8s;
  animation-delay: -2.2s;
}

.embers i:nth-child(8) {
  left: 73%;
  width: 3px;
  height: 3px;
  background: var(--candle);
  box-shadow: 0 0 6px 2px rgb(232 145 45 / 0.4);
  animation-duration: 8.8s;
  animation-delay: -6.3s;
}

.embers i:nth-child(9) {
  left: 69%;
  width: 5px;
  height: 5px;
  animation-duration: 5.9s;
  animation-delay: -1.1s;
}

.embers i:nth-child(10) {
  left: 81%;
  width: 3px;
  height: 3px;
  background: var(--ember);
  box-shadow: 0 0 6px 2px rgb(184 86 27 / 0.5);
  animation-duration: 9.6s;
  animation-delay: -3.8s;
}

.embers i:nth-child(11) {
  left: 76%;
  width: 2px;
  height: 2px;
  animation-duration: 7.1s;
  animation-delay: -4.9s;
}

.embers i:nth-child(12) {
  left: 66%;
  width: 4px;
  height: 4px;
  animation-duration: 8.1s;
  animation-delay: -2.7s;
}

@keyframes ember-rise {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.5);
  }
  10% {
    opacity: 0.95;
  }
  55% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift, 18px), -46vh) scale(0.15);
  }
}

.embers i:nth-child(odd) {
  --drift: -22px;
}

.embers i:nth-child(3n) {
  --drift: 28px;
}

.embers i:nth-child(4n) {
  --drift: -8px;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1.5rem;
}

.page h1 {
  margin: 0;
  animation: rise 0.7s ease both;
}

.wordmark {
  display: block;
  width: min(22rem, 78vw);
  height: auto;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.7rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .glow,
  .glow-core,
  .glow-halo,
  .page h1 {
    animation: none;
  }

  .glow-core,
  .glow-halo {
    opacity: 0.45;
  }

  .embers {
    display: none;
  }
}

@media (min-width: 720px) {
  .wordmark {
    width: 24rem;
  }
}
