/* ---------- Loader ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  /* the black is drawn by the two half-panels (::before / ::after) so they can split open */
  background: transparent;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 0 5vw;
  transition:
    opacity 0.9s ease,
    visibility 0.9s;
  animation: ld-fail 0.8s 9s forwards; /* failsafe if the script never runs */
}
#loader::before,
#loader::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 50.2%;
  background: #000;
  z-index: 1;
  will-change: transform;
}
#loader::before {
  top: 0;
}
#loader::after {
  bottom: 0;
}
.ld-in {
  position: relative;
  z-index: 2;
}
#loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
html.loading,
html.loading body {
  overflow: hidden;
}
.ld-line {
  height: 1px;
  width: 0;
  margin: 1.5rem auto 0;
  background: #b82027;
  box-shadow: 0 0 12px #b82027;
  animation: ld-line 1.2s cubic-bezier(0.65, 0, 0.35, 1) 1.2s forwards;
}
.ld-title {
  margin: 0;
  font:
    700 clamp(1.5rem, 6vw, 3.4rem)/1.1 "Playfair Display",
    Georgia,
    serif;
  letter-spacing: 0.18em;
  color: #e8d4b0;
  opacity: 0;
  text-shadow: 0 0 30px rgba(230, 164, 92, 0.6);
  animation: ld-in 1.2s ease 0.2s forwards;
}
.ld-by {
  margin: 1.5rem 0 0;
  font:
    400 0.7rem Manrope,
    sans-serif;
  letter-spacing: 0.5em;
  color: #e6a45c;
  opacity: 0;
  animation: ld-in 1s ease 1.8s forwards;
}
.ld-pct {
  margin-top: 2.5rem;
  font:
    300 0.8rem Manrope,
    sans-serif;
  letter-spacing: 0.3em;
  color: #c56b36;
  font-variant-numeric: tabular-nums;
}

/* ---------- Outro (added by loader.js) ----------
   0.0s  title lifts away and blurs, percentage + line fade
   0.35s a beam of light sweeps across the middle of the screen
   0.85s the black splits at the beam and slides up / down
   1.9s  loader is removed */
.ld-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transform: scaleX(0);
  background: linear-gradient(
    90deg,
    transparent,
    #e6a45c 20%,
    #fff 50%,
    #e6a45c 80%,
    transparent
  );
  box-shadow:
    0 0 24px 4px rgba(184, 32, 39, 0.9),
    0 0 90px 12px rgba(230, 164, 92, 0.45);
}
#loader.outro .ld-title {
  animation: ld-title-out 0.7s cubic-bezier(0.5, 0, 0.75, 0) forwards;
}
#loader.outro .ld-pct {
  animation: ld-fade-out 0.35s ease forwards;
}
#loader.outro .ld-line {
  animation: ld-line-out 0.4s ease forwards;
}
#loader.outro .ld-beam {
  animation: ld-beam 1.1s cubic-bezier(0.65, 0, 0.35, 1) 0.35s forwards;
}
#loader.outro::before {
  animation: ld-up 1s cubic-bezier(0.77, 0, 0.175, 1) 0.85s forwards;
}
#loader.outro::after {
  animation: ld-down 1s cubic-bezier(0.77, 0, 0.175, 1) 0.85s forwards;
}
#loader.outro.done {
  transition: none;
}

@keyframes ld-line {
  to {
    width: min(420px, 70vw);
  }
}
@keyframes ld-in {
  to {
    opacity: 1;
  }
}
@keyframes ld-fail {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}
@keyframes ld-title-out {
  from {
    opacity: 1;
    transform: none;
    letter-spacing: 0.18em;
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-18px) scale(1.04);
    letter-spacing: 0.32em;
    filter: blur(6px);
  }
}
@keyframes ld-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes ld-line-out {
  from {
    width: min(420px, 70vw);
    opacity: 1;
  }
  to {
    width: min(420px, 70vw);
    opacity: 0;
  }
}
@keyframes ld-beam {
  0% {
    transform: scaleX(0);
    opacity: 1;
    height: 2px;
  }
  45% {
    transform: scaleX(1);
    opacity: 1;
    height: 2px;
  }
  70% {
    transform: scaleX(1);
    opacity: 1;
    height: 3px;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
    height: 3px;
  }
}
@keyframes ld-up {
  to {
    transform: translateY(-101%);
  }
}
@keyframes ld-down {
  to {
    transform: translateY(101%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ld-line {
    animation-duration: 0.01s;
  }
  .ld-title,
  .ld-by {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }
}
