/*
 * VHA Memorial Foundation — first-visit splash screen ("Option A · Lavender Bloom")
 * Pair with vha-splash.js. All selectors are prefixed .vhas- to avoid collisions.
 * Fonts: Cormorant Garamond (600, italic 500) + Inter (500, 600) — already used on the site.
 *
 * Timeline (seconds from start)
 *   0.00–1.10  lavender field grows in, edges first, converging on the center
 *   0.50–1.60  logo emblem scales/fades in; warm glow rises behind it from 0.9
 *   1.05/1.30/1.55  name, "MEMORIAL FOUNDATION", tagline fade DOWN in a continuous cascade
 *   2.10–4.90  butterfly glides in on one smooth S-curve and lands above-right of the emblem
 *   2.40–7.80  petals drift up from the field (they keep going behind the fade-out)
 *   2.50–3.60  one breeze ripples left → right through the flowers
 *   6.00–6.80  whole overlay fades out, revealing the page; removed from the DOM at the end
 */

.vhas-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #FBFAFE 0%, #F1ECFB 100%);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  animation: vhasIn .25s ease-out both, vhasOut .8s ease-in 6s forwards;
}
.vhas-root.vhas-skip { animation: vhasOut .3s ease-in 0s forwards; }

/* ---------- glow ---------- */
.vhas-glow {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255,206,140,.42) 0%, rgba(255,214,160,.18) 40%, rgba(255,220,170,0) 70%);
  opacity: 0;
  animation: vhasGlow 1.8s ease-out .9s forwards;
}

/* ---------- lavender field ---------- */
.vhas-field {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.vhas-field--front { bottom: -6px; padding: 0 6px; }
.vhas-field--back  { bottom: -4px; padding: 0 0 0 22px; opacity: .6; filter: blur(1.2px); }
.vhas-sprig {
  flex: 0 0 auto;
  transform-origin: 50% 100%;
  opacity: 0;
  animation:
    vhasRise 1.1s cubic-bezier(.2,.8,.2,1) var(--rd) forwards,
    vhasBreeze 1.5s ease-in-out var(--bd) 1;
}
.vhas-sprig svg {
  display: block;
  transform-origin: 50% 100%;
  animation: vhasSway 3.5s ease-in-out infinite;
}

/* ---------- petals ---------- */
.vhas-petal {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  animation: vhasPetal 3s ease-out var(--pd) forwards;
}

/* ---------- logo + text ---------- */
.vhas-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.vhas-emblem {
  display: block;
  width: clamp(300px, 36vw, 460px);
  height: auto;
  aspect-ratio: 905 / 335;
  margin-bottom: clamp(16px, 2.5vh, 26px);
  opacity: 0;
  animation: vhasMark 1.1s cubic-bezier(.2,.8,.2,1) .5s forwards;
}
.vhas-name {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(34px, 4.1vw, 52px);
  line-height: 1.05;
  letter-spacing: .01em;
  color: #3B2A6B;
  opacity: 0;
  animation: vhasFadeDown .8s ease-out 1.05s forwards;
}
.vhas-sub {
  margin: 10px 0 0;
  font-size: clamp(11px, 1.1vw, 14px);
  font-weight: 600;
  letter-spacing: .32em;
  color: #6B4FB8;
  opacity: 0;
  animation: vhasFadeDown .8s ease-out 1.3s forwards;
}
.vhas-tagline {
  margin: clamp(18px, 3.5vh, 28px) 0 0;
  max-width: 34ch;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(19px, 1.9vw, 24px);
  line-height: 1.35;
  color: #5A5566;
  opacity: 0;
  animation: vhasFadeDown .9s ease-out 1.55s forwards;
}
@media (min-width: 700px) { .vhas-tagline { max-width: none; } }

/* ---------- butterfly ---------- */
.vhas-fly {
  position: absolute;
  left: 0; top: 0;
  width: var(--fly-size, 78px);
  height: calc(var(--fly-size, 78px) * 0.846);
  pointer-events: none;
  opacity: 0;
  offset-rotate: 0deg;
  offset-distance: 0%;
  animation: vhasFly 2.8s cubic-bezier(.42,0,.2,1) 2.1s forwards;
}
/* Tilt lives on the inner drawing: a rotate on the flying element itself would also swing its
   flight path around the screen corner, pulling the landing spot low-left on wide screens. */
.vhas-fly svg { display: block; width: 100%; height: 100%; overflow: visible; rotate: 18deg; animation: vhasTilt 2.8s ease-in-out 2.1s forwards; }
.vhas-wl, .vhas-wr {
  transform-box: fill-box;
  animation: vhasFlap .44s ease-in-out 2.1s 6, vhasRest 2s ease-in-out 4.75s infinite;
}
.vhas-wl { transform-origin: 100% 50%; }
.vhas-wr { transform-origin: 0% 50%; }

/* ---------- skip ---------- */
.vhas-skipbtn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid #CFC4EE;
  background: rgba(255,255,255,.75);
  color: #5B3FA0;
  font: 500 14px Inter, system-ui, sans-serif;
  cursor: pointer;
}
.vhas-skipbtn:hover { background: #fff; color: #3B2A6B; }
.vhas-skipbtn:focus-visible { outline: 2px solid #A18DDB; outline-offset: 2px; }

/* lock page scroll while the splash is up */
html.vhas-lock, html.vhas-lock body { overflow: hidden !important; }

/* ---------- keyframes ---------- */
@keyframes vhasIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes vhasOut { to { opacity: 0; visibility: hidden; } }
@keyframes vhasRise { from { transform: translateY(60%) scaleY(.4); opacity: 0; } to { transform: translateY(0) scaleY(1); opacity: 1; } }
@keyframes vhasBreeze { 0% { rotate: 0deg; } 35% { rotate: 7deg; } 70% { rotate: -2deg; } 100% { rotate: 0deg; } }
@keyframes vhasSway { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@keyframes vhasFadeDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes vhasMark { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes vhasGlow { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@keyframes vhasPetal {
  0%   { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  15%  { opacity: .85; }
  100% { opacity: 0; transform: translate(var(--dx), -230px) rotate(var(--rot)); }
}
@keyframes vhasFly { 0% { offset-distance: 0%; opacity: 0; } 10% { opacity: 1; } 100% { offset-distance: 100%; opacity: 1; } }
@keyframes vhasTilt { 0% { rotate: 18deg; } 35% { rotate: -4deg; } 70% { rotate: 10deg; } 100% { rotate: 6deg; } }
@keyframes vhasFlap { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.35); } }
@keyframes vhasRest { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.7); } }

/* ---------- reduced motion: a calm fade, butterfly already perched ---------- */
@media (prefers-reduced-motion: reduce) {
  .vhas-root { animation: vhasIn .3s ease-out both, vhasOut .6s ease-in 4s forwards; }
  .vhas-sprig, .vhas-emblem, .vhas-name, .vhas-sub, .vhas-tagline, .vhas-glow {
    animation: vhasIn .4s linear 0s forwards;
  }
  .vhas-sprig svg, .vhas-wl, .vhas-wr { animation: none; }
  .vhas-petal { display: none; }
  .vhas-fly { animation: none; opacity: 1; offset-distance: 100%; }
  .vhas-fly svg { animation: none; rotate: 6deg; }
}

/* Before and while the splash fades in, keep the page underneath out of sight (added by vha-splash.js) */
html.vhas-pending { background: #FBFAFE; }
html.vhas-pending body > *:not(.vhas-root) { visibility: hidden !important; }
