/* ============================================================
   Preloader — only on the winter main page
   Built 1:1 from the Figma frame 1440×880 (node 7895:26946)
   ============================================================ */

.pl {
  position: fixed;
  inset: 0;
  z-index: 100000;
  overflow: hidden;
  background: transparent;
}

html.pl-lock,
html.pl-lock body {
  overflow: hidden;
}

/* 4 background columns that slide away on reveal */
.pl__cols {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.pl__col {
  background: linear-gradient(180deg, #42583c 0%, #3b4e36 100%);
  will-change: transform;
  transform: translateY(0);
}

.pl--reveal .pl__col {
  /* linear so that a 25% time offset equals a quarter of the height */
  animation: pl-col-up .72s linear forwards;
}

.pl--reveal .pl__col:nth-child(1) {
  animation-delay: 0s;
}

.pl--reveal .pl__col:nth-child(2) {
  animation-delay: .18s;
}

.pl--reveal .pl__col:nth-child(3) {
  animation-delay: .36s;
}

.pl--reveal .pl__col:nth-child(4) {
  animation-delay: .54s;
}

@keyframes pl-col-up {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-101%);
  }
}

/* Scene: background decorations are pinned to the real screen edges, the
   central composition is a 1440×880 stage scaled by viewport height so the
   logo / map / garland never get cropped or distorted on wide screens. */
.pl__scene {
  --s: calc(100vh / 880);
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: opacity .55s ease;
}

.pl--done .pl__scene {
  opacity: 0;
}

.pl__scene img {
  position: absolute;
  height: auto;
  max-width: none;
  pointer-events: none;
  user-select: none;
}

/* Snowflake patterns (top corners) */
.pl__pattern {
  top: 0;
}

.pl__pattern--l {
  left: 0;
  width: calc(557 * var(--s));
}

.pl__pattern--r {
  right: 0;
  width: calc(557 * var(--s));
}

/* Fir branches */
.pl__spruce--tr {
  right: 0;
  top: calc(-88 * var(--s));
  width: calc(320 * var(--s));
}

.pl__spruce--bl {
  left: 0;
  bottom: calc(-100 * var(--s));
  width: calc(320 * var(--s));
}

/* Snowdrifts */
.pl__drift--l {
  left: 0;
  bottom: 0;
  width: calc(481 * var(--s));
}

.pl__drift--r {
  right: 0;
  bottom: 0;
  width: calc(660 * var(--s));
}

/* Santa */
.pl__santa {
  left: calc(-91 * var(--s));
  top: calc(31 * var(--s));
  width: calc(454 * var(--s));
}

/* Central 1440×880 stage, centred and scaled by height */
.pl__center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(1440 * var(--s));
  height: calc(880 * var(--s));
  transform: translate(-50%, -50%);
}

.pl__center img,
.pl__center .pl__garland {
  position: absolute;
  height: auto;
  max-width: none;
  pointer-events: none;
  user-select: none;
}

/* Garland (cable + bulbs exported as one Figma group, so the thread is
   continuous), with the lit bulbs revealed as loading progresses */
.pl__center .pl__garland {
  left: calc(-187.5 * var(--s));
  top: calc(119 * var(--s));
  width: calc(1834 * var(--s));
  height: calc(661.2 * var(--s));
  background: url('../img/winter/preloader/garland-base.png') center / 100% 100% no-repeat;
}

.pl__garland-on {
  position: absolute;
  inset: 0;
  background: url('../img/winter/preloader/garland-lit.png') center / 100% 100% no-repeat;
  -webkit-clip-path: inset(0 calc(100% - (29.9% + var(--pl-lit, 0%) * .393)) 0 29.9%);
  clip-path: inset(0 calc(100% - (29.9% + var(--pl-lit, 0%) * .393)) 0 29.9%);
  transition: clip-path .18s linear;
}

/* Loading percentage */
.pl__percent {
  position: absolute;
  left: calc(720 * var(--s));
  top: calc(727 * var(--s));
  z-index: 3;
  transform: translateX(-50%);
  font-family: 'Lack', Arial, sans-serif;
  font-size: calc(32 * var(--s));
  line-height: 1.25;
  font-weight: 400;
  letter-spacing: -.04em;
  color: #fff;
  opacity: .48;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Map (with the star and light rays baked into the asset) */
.pl__map {
  left: calc(240.6 * var(--s));
  top: calc(31.9 * var(--s));
  width: calc(959.5 * var(--s));
}

.pl__glow {
  left: calc(540 * var(--s));
  top: calc(4 * var(--s));
  width: calc(360 * var(--s));
}

.pl__logo {
  left: calc(596.4 * var(--s));
  top: calc(57 * var(--s));
  width: calc(247.8 * var(--s));
}

/* Fallback / reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pl__scene {
    transition: none;
  }

  .pl--reveal .pl__col {
    animation-duration: .01ms;
  }
}

/* Mobile / tablet */
@media (max-width: 1023.98px) {
  .pl__scene {
    --s: 1px;
  }

  .pl__center {
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    transform: none;
  }

  .pl__pattern {
    width: 70vw;
  }

  .pl__pattern--l {
    left: -12vw;
  }

  .pl__pattern--r {
    right: -12vw;
  }

  .pl__spruce--tr {
    left: auto;
    right: -10vw;
    top: -3%;
    width: 48vw;
  }

  .pl__spruce--bl {
    left: -18vw;
    top: auto;
    bottom: -3%;
    width: 56vw;
  }

  .pl__drift--l {
    left: -6vw;
    top: auto;
    bottom: 0;
    width: 70vw;
  }

  .pl__drift--r {
    left: auto;
    right: -8vw;
    top: auto;
    bottom: 0;
    width: 78vw;
  }

  .pl__center .pl__garland {
    left: 50%;
    top: calc(min(30% + 54.02vw + 6vh, 72%) - 65.9vw);
    width: 224vw;
    height: 80.6vw;
    transform: translateX(-50%);
  }

  .pl__percent {
    left: 50%;
    top: 80%;
    font-size: clamp(22px, 3.4vw, 34px);
  }

  .pl__map {
    left: 2vw;
    top: 30%;
    width: 96vw;
  }

  .pl__glow {
    left: 30vw;
    top: 0;
    width: 40vw;
  }

  .pl__logo {
    left: 50%;
    top: 4%;
    width: 48vw;
    transform: translateX(-50%);
  }

  .pl__santa {
    left: -12vw;
    top: 6%;
    width: 48vw;
  }
}

/* Portrait tablets: keep the map compact so the full-width cable does not
   cross the map artwork */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .pl__map {
    left: 50%;
    top: 22%;
    width: 76vw;
    transform: translateX(-50%);
  }

  .pl__glow {
    left: 37vw;
    top: 4%;
    width: 26vw;
  }

  .pl__logo {
    width: 42vw;
  }
}
