/* ─────────────────────────────────────────────────────────
   SPLASH.CSS — One-time intro overlay
   Appears on page load, plays once, disappears.
   CSS animations handle the entrance (stroke draw + greeting fade).
   CSS transitions handle colour shifts (ivory → ink darken phase).
   GSAP handles all website animations. Kept completely separate.
   ───────────────────────────────────────────────────────── */

/* ── Overlay ──────────────────────────────────────────── */
#splash-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;               /* Modern shorthand; above is fallback */
  width: 100vw;
  height: 100vh;
  z-index: 9999;

  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  gap: 28px;

  background: #F5F0E8;    /* Ivory */
  pointer-events: all;    /* Catch all input during splash */

  /* Declare both transitions upfront.
     Each only fires when its property actually changes. */
  -webkit-transition: background 1.2s ease-in-out, opacity 0.5s ease-out;
          transition: background 1.2s ease-in-out, opacity 0.5s ease-out;

  will-change: background, opacity;
}

/* ── Ivory → Ink (added at t=1800ms) ─────────────────── */
#splash-overlay.splash-darken {
  background: #0A0A0A;    /* Ink */
}

/* ── Final fade-out (added at t=3400ms) ──────────────── */
#splash-overlay.splash-fade-out {
  opacity: 0;
  pointer-events: none;
}

/* ── CE Logo SVG ──────────────────────────────────────── */
.splash-logo {
  width: 100px;
  height: 100px;
  display: block;
  -ms-flex-negative: 0;
      flex-shrink: 0;
  overflow: visible;
}

/* ── C element — draws in first, 0.6s ────────────────── */
/* Uses pathLength="1" on the SVG element so dasharray/offset
   values are normalised: 1 = full path, 0 = hidden.          */
.splash-logo-c {
  fill: none;
  stroke: #0A0A0A;        /* Ink */
  stroke-width: 9;
  stroke-linecap: round;

  stroke-dasharray: 1;    /* One full dash = entire path */
  stroke-dashoffset: 1;   /* Offset by full length = hidden */

  /* Entrance: stroke draws in over 0.6s, no delay */
  -webkit-animation: splash-draw-c 0.6s ease-in-out forwards;
          animation: splash-draw-c 0.6s ease-in-out forwards;

  /* Colour transition for darken phase (ink → white at t=1800ms) */
  -webkit-transition: stroke 1.2s ease-in-out;
          transition: stroke 1.2s ease-in-out;
}

#splash-overlay.splash-darken .splash-logo-c {
  stroke: #FFFFFF;
}

/* ── E element — draws in second, 0.5s, 0.2s overlap ─── */
.splash-logo-e {
  fill: none;
  stroke: #D4A843;        /* Turmeric Gold — never changes */
  stroke-width: 7;
  stroke-linecap: round;

  stroke-dasharray: 1;
  stroke-dashoffset: 1;

  /* Entrance: begins 0.4s in (0.2s before C finishes at 0.6s) */
  -webkit-animation: splash-draw-e 0.5s ease-in-out 0.4s forwards;
          animation: splash-draw-e 0.5s ease-in-out 0.4s forwards;
}

/* ── Greeting text ────────────────────────────────────── */
.splash-greeting {
  font-family: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #0A0A0A;         /* Ink */
  text-align: center;
  white-space: nowrap;

  /* Start hidden and slightly low */
  opacity: 0;
  -webkit-transform: translateY(8px);
          transform: translateY(8px);

  /* Entrance: fades up after logo completes (logo done at 0.9s) */
  -webkit-animation: splash-greeting-in 0.4s ease-out 0.9s forwards;
          animation: splash-greeting-in 0.4s ease-out 0.9s forwards;

  /* Colour transition for darken phase (ink → ivory at t=1800ms) */
  -webkit-transition: color 1.2s ease-in-out;
          transition: color 1.2s ease-in-out;
}

/* Greeting shifts from Ink to Ivory as background darkens */
#splash-overlay.splash-darken .splash-greeting {
  color: #F5F0E8;         /* Ivory */
}

/* ── Entrance keyframes ───────────────────────────────── */

/* C arc draws in: dashoffset 1 → 0 */
@-webkit-keyframes splash-draw-c {
  to { stroke-dashoffset: 0; }
}
@keyframes splash-draw-c {
  to { stroke-dashoffset: 0; }
}

/* E mark draws in: dashoffset 1 → 0 */
@-webkit-keyframes splash-draw-e {
  to { stroke-dashoffset: 0; }
}
@keyframes splash-draw-e {
  to { stroke-dashoffset: 0; }
}

/* Greeting fades up from translateY(8px) */
@-webkit-keyframes splash-greeting-in {
  to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}
@keyframes splash-greeting-in {
  to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}

/* ── Reduced motion: instant, no animations ──────────── */
@media (prefers-reduced-motion: reduce) {
  #splash-overlay,
  .splash-logo-c,
  .splash-greeting {
    -webkit-transition-duration: 0s !important;
            transition-duration: 0s !important;
    -webkit-transition-delay: 0s !important;
            transition-delay: 0s !important;
  }

  .splash-logo-c,
  .splash-logo-e {
    -webkit-animation: none !important;
            animation: none !important;
    stroke-dashoffset: 0;   /* Immediately show strokes */
  }

  .splash-greeting {
    -webkit-animation: none !important;
            animation: none !important;
    opacity: 1;
    -webkit-transform: none;
            transform: none;
  }
}

/* ── Safe area: iOS notch support ────────────────────── */
@supports (padding: env(safe-area-inset-top)) {
  #splash-overlay {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}
