/* ============================================
   ReconcileIQ Splash Screen - Professional Power-Up Sequence
   Navy/Baby Blue/Royal Blue theme
   ============================================ */

/* Import professional sans-serif for UI elements */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================
   CSS Custom Properties - ReconcileIQ Palette
   ============================================ */

:root {
    /* Brand Colors - ReconcileIQ Cyan/Blue */
    --riq-cyan: #00d4ff;
    --riq-baby-blue: #5dddff;
    --riq-royal-blue: #0066ff;
    --riq-deep-blue: #0047ab;

    /* Neutral Background - Deep Navy */
    --splash-bg-deepest: #001a33;
    --splash-bg-deep: #002040;
    --splash-bg-mid: #00264d;

    /* Functional Colors */
    --splash-white: #ffffff;
    --splash-text-subtle: rgba(255, 255, 255, 0.7);
    --splash-glow-cyan: rgba(0, 212, 255, 0.6);
    --splash-glow-royal: rgba(0, 102, 255, 0.6);
}

/* ============================================
   Main Splash Container - Full Viewport
   ============================================ */

.reconcileiq-splash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    /* Use dynamic viewport height for mobile (fallback to vh) */
    height: 100dvh;
    min-height: -webkit-fill-available;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg,
        var(--splash-bg-deepest) 0%,
        var(--splash-bg-deep) 40%,
        var(--splash-bg-mid) 70%,
        var(--splash-bg-deep) 100%
    );
    z-index: 99999;
    overflow: hidden;
    /* Override global zoom.css (85%) to ensure full screen coverage */
    /* Counter 85% zoom by scaling up: 1 / 0.85 = 1.176 - use ONLY zoom, not transform */
    zoom: 1.176 !important;
    /* Box sizing to prevent any overflow */
    box-sizing: border-box;
}

/* Subtle radial gradient for depth */
.reconcileiq-splash::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 50% at 50% 40%,
        var(--splash-glow-cyan),
        transparent 70%
    );
    opacity: 0.2;
    pointer-events: none;
}

/* ============================================
   Background Animation: Gradient Mesh
   Morphing blobs with animated border-radius - defined organic shapes
   ============================================ */

.reconcileiq-splash .mesh-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.reconcileiq-splash .mesh-blob {
    position: absolute;
    filter: blur(40px);
    opacity: 0.7;
}

/* Cyan blob - top left, morphs and floats */
.reconcileiq-splash .mesh-blob:nth-child(1) {
    width: 50vmax;
    height: 50vmax;
    top: -15%;
    left: -10%;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.8) 0%, rgba(0, 150, 200, 0.4) 100%);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation: meshMorph1 15s ease-in-out infinite, meshMove1 20s ease-in-out infinite;
}

/* Royal blue blob - right side */
.reconcileiq-splash .mesh-blob:nth-child(2) {
    width: 45vmax;
    height: 45vmax;
    top: 30%;
    right: -15%;
    background: linear-gradient(225deg, rgba(0, 102, 255, 0.75) 0%, rgba(0, 71, 171, 0.4) 100%);
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    animation: meshMorph2 18s ease-in-out infinite, meshMove2 25s ease-in-out infinite;
}

/* Baby blue blob - bottom */
.reconcileiq-splash .mesh-blob:nth-child(3) {
    width: 55vmax;
    height: 55vmax;
    bottom: -20%;
    left: 15%;
    background: linear-gradient(45deg, rgba(93, 221, 255, 0.7) 0%, rgba(0, 180, 220, 0.35) 100%);
    border-radius: 50% 50% 40% 60% / 40% 60% 40% 60%;
    animation: meshMorph3 20s ease-in-out infinite, meshMove3 22s ease-in-out infinite;
}

/* Deep blue blob - center accent */
.reconcileiq-splash .mesh-blob:nth-child(4) {
    width: 35vmax;
    height: 35vmax;
    top: 15%;
    left: 30%;
    background: linear-gradient(180deg, rgba(0, 150, 255, 0.6) 0%, rgba(0, 100, 200, 0.3) 100%);
    border-radius: 70% 30% 50% 50% / 30% 50% 50% 70%;
    animation: meshMorph4 12s ease-in-out infinite, meshMove4 18s ease-in-out infinite;
}

/* Morphing animations - change blob shapes */
@keyframes meshMorph1 {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
    50% {
        border-radius: 50% 60% 30% 60% / 30% 40% 70% 50%;
    }
    75% {
        border-radius: 40% 30% 60% 50% / 60% 50% 40% 30%;
    }
}

@keyframes meshMorph2 {
    0%, 100% {
        border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    }
    25% {
        border-radius: 70% 30% 40% 60% / 60% 40% 50% 40%;
    }
    50% {
        border-radius: 50% 40% 60% 50% / 50% 70% 30% 60%;
    }
    75% {
        border-radius: 30% 70% 50% 40% / 40% 30% 60% 70%;
    }
}

@keyframes meshMorph3 {
    0%, 100% {
        border-radius: 50% 50% 40% 60% / 40% 60% 40% 60%;
    }
    25% {
        border-radius: 40% 60% 50% 50% / 60% 40% 60% 40%;
    }
    50% {
        border-radius: 60% 40% 60% 40% / 50% 50% 50% 50%;
    }
    75% {
        border-radius: 45% 55% 45% 55% / 55% 45% 55% 45%;
    }
}

@keyframes meshMorph4 {
    0%, 100% {
        border-radius: 70% 30% 50% 50% / 30% 50% 50% 70%;
    }
    33% {
        border-radius: 40% 60% 60% 40% / 60% 40% 60% 40%;
    }
    66% {
        border-radius: 50% 50% 30% 70% / 50% 70% 30% 50%;
    }
}

/* Movement animations - float around */
@keyframes meshMove1 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(10%, 15%) scale(1.05);
    }
    50% {
        transform: translate(5%, 25%) scale(0.95);
    }
    75% {
        transform: translate(-5%, 10%) scale(1.02);
    }
}

@keyframes meshMove2 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(-20%, 10%) scale(1.1);
    }
    50% {
        transform: translate(-15%, -15%) scale(0.9);
    }
    75% {
        transform: translate(-5%, -5%) scale(1.05);
    }
}

@keyframes meshMove3 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(15%, -10%) scale(0.95);
    }
    50% {
        transform: translate(-10%, -20%) scale(1.08);
    }
    75% {
        transform: translate(5%, -5%) scale(1);
    }
}

@keyframes meshMove4 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(20%, 15%) scale(1.15);
    }
    66% {
        transform: translate(-15%, 20%) scale(0.9);
    }
}

/* ============================================
   Content Container - Centered
   ============================================ */

.splash-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    padding: 40px;
    gap: 60px;
}

/* ============================================
   PHASE 1: Logo with Neon Thrumming (0-1.5s)
   ============================================ */

.splash-logo-mark {
    position: absolute;
    width: 200px;
    height: auto;
    opacity: 0;
    animation: logomarkSequence 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes logomarkSequence {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    20% {
        opacity: 1;
        transform: scale(1);
    }
    80% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}

.logomark-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Make it white */
}

/* Neon glow effect - cyan/royal blue */
.logomark-glow {
    position: absolute;
    inset: -30px;
    background: radial-gradient(
        circle at center,
        var(--splash-glow-cyan),
        var(--splash-glow-royal),
        transparent 70%
    );
    filter: blur(40px);
    animation: neonThrob 0.8s ease-in-out infinite;
}

@keyframes neonThrob {
    0%, 100% {
        opacity: 0.5;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* ============================================
   PHASE 2: Full Logo White Impact (1.5-3s)
   ============================================ */

.splash-logo-full {
    opacity: 0;
    transform: scale(0.85);
    animation: logoImpact 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) 1.5s forwards;
}

@keyframes logoImpact {
    0% {
        opacity: 0;
        transform: scale(0.85);
        filter: brightness(3) blur(10px);
    }
    30% {
        opacity: 1;
        transform: scale(1.05);
        filter: brightness(3) blur(0px);
    }
    50% {
        filter: brightness(2.5);
    }
    70% {
        transform: scale(1);
        filter: brightness(1.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1);
    }
}

.logo-img {
    height: 100px;
    width: auto;
    max-width: 600px;
    object-fit: contain;
    /* Remove white background artifacts from PNG */
    mix-blend-mode: screen;
    background: transparent;
}

/* ============================================
   PHASE 3: Workflow Reveal (3-5.5s)
   ============================================ */

.splash-workflow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
    opacity: 0;
    animation: workflowFadeIn 0.8s ease 3s forwards;
}

@keyframes workflowFadeIn {
    to {
        opacity: 1;
    }
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(20px);
}

.workflow-step[data-step="1"] {
    animation: stepEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 3.2s forwards;
}

.workflow-step[data-step="2"] {
    animation: stepEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 3.5s forwards;
}

.workflow-step[data-step="3"] {
    animation: stepEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 3.8s forwards;
}

@keyframes stepEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
}

.workflow-step[data-step="1"] .step-icon {
    animation: iconGlow 0.5s ease 4.2s forwards;
}

.workflow-step[data-step="2"] .step-icon {
    animation: iconGlow 0.5s ease 4.5s forwards;
}

.workflow-step[data-step="3"] .step-icon {
    animation: iconGlow 0.5s ease 4.8s forwards;
}

@keyframes iconGlow {
    to {
        background: rgba(0, 212, 255, 0.15);
        border-color: var(--riq-cyan);
        box-shadow:
            0 0 20px var(--splash-glow-cyan),
            inset 0 0 15px rgba(0, 212, 255, 0.1);
    }
}

.step-icon svg {
    width: 28px;
    height: 28px;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.4s ease;
}

.workflow-step[data-step="1"] .step-icon svg {
    animation: iconColorize 0.5s ease 4.2s forwards;
}

.workflow-step[data-step="2"] .step-icon svg {
    animation: iconColorize 0.5s ease 4.5s forwards;
}

.workflow-step[data-step="3"] .step-icon svg {
    animation: iconColorize 0.5s ease 4.8s forwards;
}

@keyframes iconColorize {
    to {
        color: var(--riq-baby-blue);
        filter: drop-shadow(0 0 6px var(--splash-glow-cyan));
    }
}

.step-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.4s ease;
}

.workflow-step[data-step="1"] .step-label {
    animation: labelActivate 0.5s ease 4.2s forwards;
}

.workflow-step[data-step="2"] .step-label {
    animation: labelActivate 0.5s ease 4.5s forwards;
}

.workflow-step[data-step="3"] .step-label {
    animation: labelActivate 0.5s ease 4.8s forwards;
}

@keyframes labelActivate {
    to {
        color: var(--riq-baby-blue);
    }
}

/* Workflow connectors */
.workflow-connector {
    width: 60px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    opacity: 0;
    animation: connectorFade 0.4s ease 4s forwards;
}

@keyframes connectorFade {
    to {
        opacity: 1;
    }
}

/* ============================================
   PHASE 4: Tagline (5.5-6.5s) + Hold (6.5-8s)
   ============================================ */

.splash-tagline {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--splash-text-subtle);
    text-align: center;
    opacity: 0;
    animation: taglineFade 0.6s ease 5.5s forwards;
    margin: 0;
}

/* Hold state for readability: 6.5s-8s = 1.5 second pause */

@keyframes taglineFade {
    to {
        opacity: 1;
    }
}

/* ============================================
   Click to Skip Hint
   ============================================ */

.reconcileiq-splash .splash-skip-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.05em;
    opacity: 0;
    animation: riqSkipHintFade 0.5s ease 2s forwards;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10;
}

.reconcileiq-splash .splash-skip-hint:hover {
    color: rgba(255, 255, 255, 0.6);
}

@keyframes riqSkipHintFade {
    to {
        opacity: 1;
    }
}

/* Make entire splash clickable */
.reconcileiq-splash {
    cursor: pointer;
}

/* ============================================
   Fade Out (8s) - Standard fade
   ============================================ */

.reconcileiq-splash.fade-out {
    animation: splashFadeOut 0.8s ease forwards;
}

@keyframes splashFadeOut {
    to {
        opacity: 0;
    }
}

/* ============================================
   Diffuse Effect - Click to Skip
   Elegant blur + fade + scale for manual skip
   ============================================ */

.reconcileiq-splash.diffuse {
    animation: riqSplashDiffuse 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.reconcileiq-splash.diffuse .splash-content {
    animation: riqContentDiffuse 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.reconcileiq-splash.diffuse .mesh-container {
    animation: riqMeshDiffuse 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.reconcileiq-splash.diffuse .splash-skip-hint {
    animation: riqHintDiffuse 0.3s ease forwards;
}

@keyframes riqSplashDiffuse {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

@keyframes riqContentDiffuse {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }
    100% {
        opacity: 0;
        transform: scale(1.05);
        filter: blur(20px);
    }
}

@keyframes riqMeshDiffuse {
    0% {
        opacity: 1;
        filter: blur(0px);
    }
    100% {
        opacity: 0;
        filter: blur(40px);
    }
}

@keyframes riqHintDiffuse {
    to {
        opacity: 0;
    }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    /*
     * Mobile browsers typically IGNORE zoom on html, so the global 85% zoom doesn't apply.
     * Therefore, we MUST NOT counter-scale on mobile - it would make content too large.
     */
    .reconcileiq-splash {
        zoom: 1 !important;
        /* Reset all transform properties */
        transform: none !important;
        /* Ensure full viewport coverage on mobile */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        width: 100dvw !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: -webkit-fill-available;
        overflow: hidden !important;
    }

    /* Ensure content container is properly sized and visible */
    .reconcileiq-splash .splash-content {
        position: relative !important;
        z-index: 10 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        gap: 30px;
        padding: 20px;
        box-sizing: border-box;
    }

    /* Ensure ::before gradient doesn't cover content */
    .reconcileiq-splash::before {
        z-index: 0 !important;
        pointer-events: none !important;
    }

    /* Logo mark - ensure it's visible and centered */
    .reconcileiq-splash .splash-logo-mark {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 120px;
        z-index: 5 !important;
    }

    /* Override animation to include translate for mobile */
    .reconcileiq-splash .splash-logo-mark {
        animation: riqLogomarkSequenceMobile 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }

    /* Full logo - ensure visible */
    .reconcileiq-splash .splash-logo-full {
        position: relative !important;
        z-index: 10 !important;
        display: block !important;
    }

    .reconcileiq-splash .logo-img {
        height: 60px;
        max-width: 85vw;
        display: block !important;
    }

    /* Workflow - stack vertically on mobile */
    .reconcileiq-splash .splash-workflow {
        flex-direction: column;
        gap: 20px;
        margin-top: 20px;
        position: relative !important;
        z-index: 10 !important;
        display: flex !important;
    }

    .reconcileiq-splash .workflow-step {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        position: relative !important;
        z-index: 10 !important;
    }

    .reconcileiq-splash .workflow-connector {
        width: 2px;
        height: 30px;
        display: block !important;
    }

    .reconcileiq-splash .step-icon {
        width: 52px;
        height: 52px;
        display: flex !important;
    }

    .reconcileiq-splash .step-icon svg {
        width: 22px;
        height: 22px;
        display: block !important;
    }

    .reconcileiq-splash .step-label {
        font-size: 11px;
        display: block !important;
    }

    .reconcileiq-splash .splash-tagline {
        font-size: 13px;
        padding: 0 16px;
        position: relative !important;
        z-index: 10 !important;
        display: block !important;
    }

    /* Glow effect - ensure it's behind content */
    .reconcileiq-splash .logomark-glow {
        z-index: 1 !important;
    }
}

/* Mobile-specific animation that maintains centering */
@keyframes riqLogomarkSequenceMobile {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@media (max-width: 480px) {
    .reconcileiq-splash .logo-img {
        height: 50px;
        max-width: 80vw;
    }

    .reconcileiq-splash .splash-logo-mark {
        width: 100px;
    }

    .reconcileiq-splash .splash-content {
        gap: 24px;
        padding: 16px;
    }

    .reconcileiq-splash .step-icon {
        width: 44px;
        height: 44px;
    }

    .reconcileiq-splash .step-icon svg {
        width: 20px;
        height: 20px;
    }

    .reconcileiq-splash .step-label {
        font-size: 10px;
    }

    .reconcileiq-splash .splash-workflow {
        gap: 16px;
    }

    .reconcileiq-splash .workflow-connector {
        height: 24px;
    }

    .reconcileiq-splash .splash-tagline {
        font-size: 12px;
    }
}

/* ============================================
   Accessibility
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .splash-logo-mark,
    .logomark-glow,
    .splash-logo-full,
    .splash-workflow,
    .workflow-step,
    .step-icon,
    .step-icon svg,
    .step-label,
    .workflow-connector,
    .splash-tagline,
    .reconcileiq-splash.fade-out {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
    }
}

/* Performance optimization */
.reconcileiq-splash * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   BLEED-IN ANIMATION SYSTEM
   UI elements animate in after splash fades out
   ============================================ */

/* Elements start visible by default for safety */
.bleed-in {
    opacity: 1;
    transform: translateY(0);
}

/* Only hide when splash is actively showing (body has splash-active class) */
body.splash-active .bleed-in {
    opacity: 0;
    transform: translateY(15px);
}

/* When body has .bleed-active, animate elements in with stagger */
body.bleed-active .bleed-in {
    animation: bleedInReveal 0.5s ease-out forwards;
    animation-delay: var(--bleed-delay, 0ms);
}

/* The reveal animation with subtle neon glow pulse - ReconcileIQ cyan */
@keyframes bleedInReveal {
    0% {
        opacity: 0;
        transform: translateY(15px);
        filter: drop-shadow(0 0 0px var(--bleed-glow-color, rgba(0, 212, 255, 0)));
    }
    60% {
        opacity: 1;
        transform: translateY(0);
        filter: drop-shadow(0 0 15px var(--bleed-glow-color, rgba(0, 212, 255, 0.5)));
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        filter: drop-shadow(0 0 0px var(--bleed-glow-color, rgba(0, 212, 255, 0)));
    }
}

/* ReconcileIQ specific glow color - cyan/blue */
body .bleed-in {
    --bleed-glow-color: rgba(0, 212, 255, 0.5);
}

/* Stagger delays - smooth cascade */
.header.bleed-in { --bleed-delay: 0ms; }
.guide-button.bleed-in { --bleed-delay: 100ms; }
.input-section.bleed-in { --bleed-delay: 200ms; }
.file-upload-section.bleed-in { --bleed-delay: 300ms; }
.reconcile-button.bleed-in { --bleed-delay: 400ms; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .bleed-in {
        opacity: 1;
        transform: none;
    }
    body.bleed-active .bleed-in {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
