/* ==========================================================
   Marlene Burling — page loader (butterfly) (drop-in, self-contained)
   Shows on first load and on every page-to-page navigation.
   Add to <head>:  <link rel="stylesheet" href="css/loader.css">
                   <script src="js/loader.js"></script>
   Colors/fonts are defined here so it works without main.css.
   ========================================================== */
.mb-loader {
  --mbl-forest: #112a1b;
  --mbl-forest2: #1a3b27;
  --mbl-teal: #305b6c;
  --mbl-green: #29663a;
  --mbl-gold: #e2a052;
  --mbl-ivory: #f7f2e6;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  z-index: 9999;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  overflow: hidden;
  box-sizing: border-box;
  color: var(--mbl-ivory);
  background:
    radial-gradient(
      60% 50% at 82% 14%,
      rgba(226, 160, 82, 0.4),
      transparent 70%
    ),
    radial-gradient(90% 70% at 12% 100%, var(--mbl-green), transparent 65%),
    linear-gradient(
      180deg,
      var(--mbl-teal) 0%,
      var(--mbl-forest2) 55%,
      var(--mbl-forest) 100%
    );
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.1s cubic-bezier(0.76, 0, 0.24, 1);
}
html.mb-loading,
html.mb-loading body {
  overflow: hidden;
}
.mb-loader.is-done {
  clip-path: inset(0 0 100% 0);
} /* curtain lifts upward */
.mb-loader.is-start {
  clip-path: inset(0 0 100% 0);
} /* page to page: the curtain starts lifted, then drops down over the page */
.mb-loader.is-nav:not(.is-done) {
  transition: clip-path 0.65s cubic-bezier(0.76, 0, 0.24, 1);
} /* quicker drop, so the old page is covered before the next one loads */
.mb-loader.is-done .mb-center {
  opacity: 0;
  transform: translateY(-24px);
  transition:
    opacity 0.5s,
    transform 0.8s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.mb-sun {
  position: absolute;
  right: -12%;
  top: -22%;
  width: 70vmax;
  height: 70vmax;
  max-width: 900px;
  max-height: 900px;
  border-radius: 50%;
  background: radial-gradient(
    closest-side,
    rgba(226, 160, 82, 0.45),
    transparent
  );
  animation: mb-sun 6s ease-in-out infinite;
}
.mb-mist {
  position: absolute;
  left: -25%;
  right: -25%;
  bottom: -8%;
  height: 50%;
  filter: blur(28px);
  background:
    radial-gradient(
      40% 55% at 30% 60%,
      rgba(247, 242, 230, 0.18),
      transparent 70%
    ),
    radial-gradient(
      35% 50% at 72% 45%,
      rgba(247, 242, 230, 0.12),
      transparent 70%
    );
  animation: mb-drift 14s ease-in-out infinite alternate;
}
.mb-motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.mb-motes i {
  position: absolute;
  bottom: -10px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 225, 160, 0.9);
  box-shadow: 0 0 12px 3px rgba(255, 205, 120, 0.5);
  opacity: 0;
  animation: mb-rise 7s linear infinite;
}

.mb-center {
  grid-area: 1/1;
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1.1rem;
  padding: 2rem;
  text-align: center;
  width: min(92vw, 460px);
  margin: auto;
}
.mb-butterfly {
  width: clamp(110px, 24vw, 160px);
  height: auto;
  overflow: visible;
  animation: mb-float 4s ease-in-out infinite;
}
.mb-butterfly path {
  fill: var(--mbl-ivory);
  fill-opacity: 0;
  stroke: var(--mbl-gold);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation:
    mb-draw 1.8s cubic-bezier(0.65, 0, 0.35, 1) forwards,
    mb-fill 1s ease 1.4s forwards;
}
.mb-butterfly .mb-upper {
  animation-delay: 0s, 1.4s;
}
.mb-butterfly .mb-lower {
  animation-delay: 0.25s, 1.65s;
}
.mb-butterfly .mb-body {
  fill: var(--mbl-gold);
  animation-delay: 0.5s, 1.9s;
}
.mb-butterfly .mb-feeler {
  fill: none;
  animation: mb-draw 1.2s ease 0.9s forwards;
}
/* Wings: each side scales in/out from the body's centre line */
.mb-butterfly .mb-wing {
  transform-box: view-box;
  transform-origin: 50px 50px;
  animation: mb-flap 0.75s ease-in-out 1.2s infinite alternate;
}
.mb-name {
  margin: 0;
  font:
    600 clamp(1.7rem, 6.4vw, 2.6rem)/1.15 "Cormorant Garamond",
    "Playfair Display",
    Georgia,
    serif;
  letter-spacing: 0.03em;
  animation: mb-up 0.9s 0.5s cubic-bezier(0.22, 0.8, 0.24, 1) both;
}
.mb-tag {
  margin: 0;
  font:
    italic 500 clamp(1.05rem, 3.6vw, 1.3rem)/1.3 "Cormorant Garamond",
    "Playfair Display",
    Georgia,
    serif;
  letter-spacing: 0.14em;
  color: var(--mbl-gold);
  animation: mb-up 0.9s 0.8s cubic-bezier(0.22, 0.8, 0.24, 1) both;
}
.mb-bar {
  width: min(240px, 64vw);
  height: 2px;
  background: rgba(247, 242, 230, 0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.6rem;
  animation: mb-up 0.8s 1s both;
}
.mb-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--mbl-gold), #f3c98a);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
}
.mb-num {
  font:
    500 0.75rem/1 "DM Sans",
    system-ui,
    sans-serif;
  letter-spacing: 0.18em;
  color: rgba(247, 242, 230, 0.7);
  font-variant-numeric: tabular-nums;
  animation: mb-up 0.8s 1.1s both;
}

@media (max-height: 480px) {
  .mb-center {
    gap: 0.5rem;
    padding: 1rem;
  }
  .mb-butterfly {
    width: 72px;
  }
  .mb-bar {
    margin-top: 0.2rem;
  }
}

@keyframes mb-draw {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes mb-fill {
  to {
    fill-opacity: 0.9;
  }
}
@keyframes mb-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes mb-float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}
@keyframes mb-flap {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0.18);
  }
}
@keyframes mb-sun {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}
@keyframes mb-drift {
  from {
    transform: translateX(-6%);
  }
  to {
    transform: translateX(8%);
  }
}
@keyframes mb-rise {
  0% {
    opacity: 0;
    transform: translateY(0);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-100vh);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mb-loader,
  .mb-loader * {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }
  .mb-butterfly path {
    stroke-dashoffset: 0;
    fill-opacity: 0.9;
  }
  .mb-butterfly .mb-feeler {
    fill-opacity: 0;
  }
  .mb-butterfly .mb-wing {
    animation: none;
  }
  .mb-loader {
    transition:
      opacity 0.3s,
      clip-path 0s;
  }
  .mb-loader.is-done {
    clip-path: none;
    opacity: 0;
  }
  .mb-loader.is-start {
    clip-path: none;
    opacity: 0;
  }
  .mb-loader.is-nav:not(.is-done) {
    transition: opacity 0.3s;
  }
}

.mb-name .logo {
  width: 320px;
  max-width: 80vw;
  height: auto;
}
