/* ═══════════════════════════════════════════════════════════════════════════
   apachat — Splash Screen  ·  Premium Cinematic Animation
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #060010;
  transition: opacity 0.9s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Deep space background ────────────────────────────────────────────────── */
#splash-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Large morphing orbs */
.splash-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orb-drift ease-in-out infinite;
  will-change: transform, opacity;
}

.splash-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(225,48,108,0.55) 0%, transparent 70%);
  top: -120px; left: -100px;
  animation-duration: 7s;
  animation-delay: 0s;
}
.splash-orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(131,58,180,0.5) 0%, transparent 70%);
  bottom: -100px; right: -80px;
  animation-duration: 9s;
  animation-delay: -3s;
}
.splash-orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(247,119,55,0.4) 0%, transparent 70%);
  top: 40%; left: 60%;
  animation-duration: 6s;
  animation-delay: -1.5s;
}
.splash-orb-4 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(99,102,241,0.35) 0%, transparent 70%);
  top: 20%; right: 20%;
  animation-duration: 8s;
  animation-delay: -4s;
}

@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -40px) scale(1.08); }
  66%       { transform: translate(-20px, 25px) scale(0.94); }
}

/* Noise grain overlay for depth */
#splash-noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
}

/* ── Center stage ─────────────────────────────────────────────────────────── */
#splash-inner {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ── Logo ─────────────────────────────────────────────────────────────────── */
#splash-logo-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 28px;
}

/* Glow halo behind logo */
#splash-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225,48,108,0.5) 0%, rgba(131,58,180,0.3) 40%, transparent 70%);
  animation: halo-pulse 2.5s ease-in-out 1s infinite;
  filter: blur(12px);
}

@keyframes halo-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.7; }
  50%       { transform: scale(1.25); opacity: 1;   }
}

#splash-logo {
  width: 100px;
  height: 100px;
  border-radius: 28px;
  background: linear-gradient(135deg, #E1306C 0%, #833AB4 55%, #F77737 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12) inset,
    0 24px 64px rgba(225,48,108,0.5),
    0 8px 24px rgba(131,58,180,0.4);
  animation: logo-flip 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
  transform-style: preserve-3d;
}

#splash-logo svg {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,0.4));
}

@keyframes logo-flip {
  0%   { opacity: 0; transform: perspective(600px) rotateY(-90deg) scale(0.6); }
  60%  { transform: perspective(600px) rotateY(12deg) scale(1.05); }
  80%  { transform: perspective(600px) rotateY(-5deg) scale(0.98); }
  100% { opacity: 1; transform: perspective(600px) rotateY(0deg) scale(1); }
}

/* Subtle continuous float */
#splash-logo {
  animation:
    logo-flip 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both,
    logo-float 3.5s ease-in-out 1.5s infinite;
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

/* ── Brand name ───────────────────────────────────────────────────────────── */
#splash-name {
  display: flex;
  align-items: baseline;
  gap: 1px;
  position: relative;
}

/* Shimmer sweep line */
#splash-name::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -100%;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.18) 40%,
    rgba(255,255,255,0.35) 50%,
    rgba(255,255,255,0.18) 60%,
    transparent 100%
  );
  animation: shimmer-sweep 2.2s ease 2s forwards;
  pointer-events: none;
  z-index: 5;
}

@keyframes shimmer-sweep {
  0%   { left: -100%; opacity: 0; }
  10%  { opacity: 1; }
  100% { left: 160%;  opacity: 0; }
}

#splash-name span {
  display: inline-block;
  font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
  font-size: clamp(2.8rem, 8vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  opacity: 0;
  transform: translateY(40px) scale(0.7) rotateX(40deg);
  animation: letter-rise 0.55s cubic-bezier(0.34, 1.5, 0.64, 1) forwards;
  transform-origin: bottom center;
  perspective: 400px;
  position: relative;
  z-index: 2;
}

/* Per-letter delays & colors */
#splash-name span:nth-child(1) { animation-delay: 0.7s;  color: #ff3d7f; }
#splash-name span:nth-child(2) { animation-delay: 0.82s; color: #ff6fa3; }
#splash-name span:nth-child(3) { animation-delay: 0.94s; color: #e040fb; }
#splash-name span:nth-child(4) { animation-delay: 1.06s; color: #b44fff; }
#splash-name span:nth-child(5) { animation-delay: 1.18s; color: #c084fc; }
#splash-name span:nth-child(6) { animation-delay: 1.30s; color: #f97316; }
#splash-name span:nth-child(7) { animation-delay: 1.42s; color: #fb923c; }

@keyframes letter-rise {
  0%   { opacity: 0; transform: translateY(40px) scale(0.7) rotateX(40deg); }
  60%  { opacity: 1; transform: translateY(-6px) scale(1.08) rotateX(-5deg); }
  80%  { transform: translateY(3px) scale(0.97) rotateX(2deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateX(0deg); }
}

/* After all letters land — apply gradient shimmer continuously */
#splash-name span:nth-child(1) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 0.7s forwards, letter-glow 3s ease-in-out 2.2s infinite; }
#splash-name span:nth-child(2) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 0.82s forwards, letter-glow 3s ease-in-out 2.3s infinite; }
#splash-name span:nth-child(3) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 0.94s forwards, letter-glow 3s ease-in-out 2.4s infinite; }
#splash-name span:nth-child(4) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 1.06s forwards, letter-glow 3s ease-in-out 2.5s infinite; }
#splash-name span:nth-child(5) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 1.18s forwards, letter-glow 3s ease-in-out 2.6s infinite; }
#splash-name span:nth-child(6) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 1.30s forwards, letter-glow 3s ease-in-out 2.7s infinite; }
#splash-name span:nth-child(7) { animation: letter-rise 0.55s cubic-bezier(0.34,1.5,0.64,1) 1.42s forwards, letter-glow 3s ease-in-out 2.8s infinite; }

@keyframes letter-glow {
  0%, 100% { text-shadow: none; filter: brightness(1); }
  50%       { text-shadow: 0 0 20px currentColor, 0 0 40px currentColor; filter: brightness(1.3); }
}

/* ── Tagline ──────────────────────────────────────────────────────────────── */
#splash-tagline {
  margin-top: 14px;
  font-family: -apple-system, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255,255,255,0);
  background: linear-gradient(90deg, #E1306C, #833AB4, #F77737, #E1306C);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  opacity: 0;
  animation:
    tagline-in 0.7s ease 2s forwards,
    gradient-flow 3s linear 2.5s infinite;
}

@keyframes tagline-in {
  from { opacity: 0; transform: translateY(10px) scaleX(0.8); letter-spacing: 0.6em; }
  to   { opacity: 1; transform: translateY(0) scaleX(1);      letter-spacing: 0.35em; }
}

@keyframes gradient-flow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ── Progress dots ────────────────────────────────────────────────────────── */
#splash-dots {
  display: flex;
  gap: 7px;
  margin-top: 40px;
  opacity: 0;
  animation: dots-appear 0.4s ease 2.2s forwards;
}

.splash-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  animation: dot-pulse 1.4s ease-in-out infinite;
}
.splash-dot:nth-child(1) { animation-delay: 2.3s; background: #E1306C; }
.splash-dot:nth-child(2) { animation-delay: 2.5s; background: #833AB4; }
.splash-dot:nth-child(3) { animation-delay: 2.7s; background: #F77737; }

@keyframes dots-appear {
  to { opacity: 1; }
}

@keyframes dot-pulse {
  0%, 100% { transform: scale(1);   opacity: 0.4; }
  50%       { transform: scale(1.6); opacity: 1;   }
}

/* ── Floating particles ───────────────────────────────────────────────────── */
.splash-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: particle-rise linear infinite;
  opacity: 0;
}

@keyframes particle-rise {
  0%   { transform: translateY(0)     scale(1);   opacity: 0;   }
  8%   { opacity: 0.9; }
  85%  { opacity: 0.5; }
  100% { transform: translateY(-160px) scale(0.2); opacity: 0; }
}

/* ── Scan line (subtle CRT effect) ───────────────────────────────────────── */
#splash-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 1;
  opacity: 0.6;
}

/* ── Vignette ─────────────────────────────────────────────────────────────── */
#splash-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 40%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 1;
}

/* ── Hide / exit transition ───────────────────────────────────────────────── */
#splash.hide {
  opacity: 0;
  transform: scale(1.08);
  pointer-events: none;
}

/* ── AdSense Ad Banners ───────────────────────────────────────────────────── */
.apa-ad-wrap {
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.07);
  overflow: hidden;
}

/* Sticky bottom banner (autorelaxed) */
.apa-ad-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 100%;
  z-index: 1000;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  padding: 4px 0;
}

/* In-article fluid ad */
.apa-ad-inline {
  border-radius: 12px;
  margin: 12px auto;
  border: 1px solid rgba(0,0,0,0.06);
}

/* Fluid layout-key ad */
.apa-ad-fluid {
  border-radius: 12px;
  margin: 12px auto;
  border: 1px solid rgba(0,0,0,0.06);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .apa-ad-wrap {
    background: #1a1a2e;
    border-color: rgba(255,255,255,0.06);
  }
  .apa-ad-bottom {
    box-shadow: 0 -2px 12px rgba(0,0,0,0.4);
  }
}

/* Mobile: full-width, no border-radius on sticky */
@media (max-width: 600px) {
  .apa-ad-bottom { padding: 2px 0; }
  .apa-ad-inline,
  .apa-ad-fluid  { border-radius: 8px; margin: 8px 8px; }
}
