/* =========================================================
   Preloader — ink calligraphy
   Shows once per session; fades when body.site-ready is set.
   ========================================================= */

#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--cream, #f7f1e5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

/* Subtle paper texture dots */
#preloader::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(90, 58, 34, 0.04) 1px, transparent 1px),
    radial-gradient(rgba(32, 57, 44, 0.03) 1px, transparent 1px);
  background-size: 28px 28px, 40px 40px;
  background-position: 0 0, 14px 14px;
  pointer-events: none;
}

.preloader-inner {
  text-align: center;
  color: var(--gold, #c9a24a);
}

.preloader-svg {
  width: min(560px, 85vw);
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Each stroke uses a dashoffset-to-zero draw */
.preloader-svg path {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: ink-draw 2s cubic-bezier(0.65, 0.05, 0.36, 1) forwards;
}

/* Stagger words: books first, amp, cloud, underline */
.ink-books path:nth-child(1) { animation-delay: 0.1s; }
.ink-books path:nth-child(2) { animation-delay: 0.35s; }
.ink-books path:nth-child(3) { animation-delay: 0.5s; }
.ink-books path:nth-child(4) { animation-delay: 0.65s; }
.ink-books path:nth-child(5) { animation-delay: 0.8s; }
.ink-amp path               { animation-delay: 1.0s; }
.ink-cloud path:nth-child(1) { animation-delay: 1.2s; }
.ink-cloud path:nth-child(2) { animation-delay: 1.35s; }
.ink-cloud path:nth-child(3) { animation-delay: 1.5s; }
.ink-cloud path:nth-child(4) { animation-delay: 1.65s; }
.ink-underline               { animation-delay: 1.9s; animation-duration: 1.1s; }

@keyframes ink-draw {
  to { stroke-dashoffset: 0; }
}

.preloader-tag {
  margin-top: 24px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--brown, #5a3a22);
  opacity: 0;
  animation: tag-fade 0.8s ease 2.4s forwards;
}
@keyframes tag-fade {
  to { opacity: 0.7; }
}

/* Hide state */
body.site-ready #preloader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Lock scroll while loading */
body:not(.site-ready) {
  overflow: hidden;
}

/* Reduced motion — skip the drawing and just show static text */
@media (prefers-reduced-motion: reduce) {
  .preloader-svg path {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    animation: none;
  }
  .preloader-tag { animation: none; opacity: 0.7; }
}
