/* ==========================================================
   MIZU NOVA — water droplet preloader
   ========================================================== */

html.is-loading,
html.is-loading body {
  overflow: hidden;
}

#preloader {
  --pl-bg-inner: #13306e;
  --pl-bg-outer: #0d1f4d;
  --pl-level: 0; /* 0 → 1, set by JS */

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy, #021D43);
  color: #fff;
  overflow: visible;
  will-change: transform;
  /* Failsafe: if JS never runs, hide the overlay after 8s */
  animation: pl-failsafe 0.4s ease 8s forwards;
}

/* wavy bottom edge, revealed while the overlay wipes upward */
#preloader::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 48px;
  margin-top: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 48' preserveAspectRatio='none'%3E%3Cpath fill='%230d1f4d' d='M0 0H1200V18C1100 42 1000 42 900 18S700 -6 600 18 400 42 300 18 100 -6 0 18Z'/%3E%3C/svg%3E") repeat-x;
  background-size: 600px 48px;
  pointer-events: none;
}

.pl-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 16px;
}

/* ---------- droplet ---------- */
.pl-drop-wrap {
  position: relative;
  width: clamp(110px, 34vw, 140px);
  margin-bottom: 40px;
}

.pl-drop {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 10px 24px rgba(45, 127, 224, 0.35));
  transform-origin: 50% 70%;
  animation: pl-bob 3s ease-in-out infinite;
}

.pl-water {
  /* level 0 → wave crest sits below the drop (y≈184); level 1 → above the tip (y≈-14) */
  transform: translateY(calc(184px - var(--pl-level) * 198px));
}

.pl-wave {
  transform-box: view-box;
}
.pl-wave--back {
  animation: pl-wave 2.6s linear infinite;
}
.pl-wave--front {
  animation: pl-wave 1.8s linear infinite reverse;
}

.pl-bubble {
  fill: #dff0ff;
  fill-opacity: 0.75;
  opacity: 0;
  transform-box: fill-box;
  animation: pl-bubble 2.4s ease-in infinite;
}
.pl-bubble--2 { animation-delay: 0.7s; animation-duration: 2s; }
.pl-bubble--3 { animation-delay: 1.3s; animation-duration: 2.8s; }
.pl-bubble--4 { animation-delay: 1.9s; animation-duration: 2.2s; }

/* ---------- ripples ---------- */
.pl-ripples {
  position: absolute;
  left: 50%;
  bottom: -18px;
  width: 120px;
  height: 26px;
  transform: translateX(-50%);
  pointer-events: none;
}
.pl-ripples span {
  position: absolute;
  inset: 0;
  border: 1.5px solid rgba(143, 184, 255, 0.6);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.2);
  animation: pl-ripple 2.4s ease-out infinite;
}
.pl-ripples span:nth-child(2) { animation-delay: 0.8s; }
.pl-ripples span:nth-child(3) { animation-delay: 1.6s; }

/* ---------- text ---------- */
.pl-brand {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: clamp(34px, 10vw, 52px);
  line-height: 1;
  letter-spacing: 0.22em;
  margin-right: -0.22em; /* optically re-center letter-spaced text */
  color: #fff;
}

.pl-tagline {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(14px, 3.6vw, 15px);
  letter-spacing: 0.08em;
  color: #8fb8ff;
  margin-top: 8px;
}

.pl-percent {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 18px;
  min-width: 4.5ch;
}

/* ---------- exit ---------- */
#preloader.is-exiting {
  animation: pl-wipe 0.7s cubic-bezier(0.7, 0, 0.3, 1) 0.18s forwards;
  pointer-events: none;
}
#preloader.is-exiting .pl-drop {
  animation: pl-splash 0.38s ease-out forwards;
}
#preloader.is-exiting .pl-ripples span {
  animation: pl-ripple 0.5s ease-out forwards;
}
#preloader.is-exiting .pl-brand,
#preloader.is-exiting .pl-tagline,
#preloader.is-exiting .pl-percent {
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: translateY(-10px);
}

/* ---------- keyframes ---------- */
@keyframes pl-wave {
  from { transform: translateX(0); }
  to   { transform: translateX(140px); }
}
@keyframes pl-bubble {
  0%   { transform: translateY(0) scale(0.6); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 0.9; }
  100% { transform: translateY(-150px) scale(1.1); opacity: 0; }
}
@keyframes pl-ripple {
  0%   { transform: scale(0.2); opacity: 0.9; }
  100% { transform: scale(1.4); opacity: 0; }
}
@keyframes pl-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes pl-splash {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(0.92, 1.06); }
  100% { transform: scale(1.6);  opacity: 0; }
}
@keyframes pl-wipe {
  from { transform: translateY(0); }
  to   { transform: translateY(calc(-100% - 60px)); }
}
@keyframes pl-fade {
  to { opacity: 0; }
}
@keyframes pl-failsafe {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #preloader .pl-drop,
  #preloader .pl-wave,
  #preloader .pl-bubble,
  #preloader .pl-ripples span {
    animation: none !important;
  }
  #preloader .pl-bubble,
  #preloader .pl-ripples span {
    display: none;
  }
  #preloader::after {
    display: none;
  }
  #preloader.is-exiting {
    animation: pl-fade 0.3s ease forwards;
  }
}

/* Skip preloader after first view in this session */
