/* ============================================
   LedgerIQ Splash Screen - Professional Power-Up Sequence
   Emerald/Green 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 - LedgerIQ Palette
   ============================================ */

:root {
    /* Brand Colors - LedgerIQ Emerald/Green */
    --liq-emerald: #10b981;
    --liq-green-light: #4ade80;
    --liq-green-brand: #16a34a;
    --liq-green-deep: #15803d;

    /* Neutral Background - Deep Forest */
    --splash-bg-deepest: #001a0d;
    --splash-bg-deep: #002211;
    --splash-bg-mid: #003318;

    /* Functional Colors */
    --splash-white: #ffffff;
    --splash-text-subtle: rgba(255, 255, 255, 0.7);
    --splash-glow-emerald: rgba(16, 185, 129, 0.6);
    --splash-glow-green: rgba(22, 163, 74, 0.6);
}

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

.ledgeriq-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 */
.ledgeriq-splash::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 50% at 50% 40%,
        var(--splash-glow-emerald),
        transparent 70%
    );
    opacity: 0.2;
    pointer-events: none;
}

/* ============================================
   Background Animation: Subtle Grid with Pulse Waves
   Ledger-like grid pattern with radiating pulses
   ============================================ */

.ledgeriq-splash::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Create subtle grid pattern */
    background-image:
        linear-gradient(rgba(16, 185, 129, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* Pulse wave element - added via JavaScript or as separate div */
.ledgeriq-splash .pulse-waves {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ledgeriq-splash .pulse-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(16, 185, 129, 0.15);
    animation: pulseExpand 4s ease-out infinite;
}

.ledgeriq-splash .pulse-wave:nth-child(1) {
    animation-delay: 0s;
}

.ledgeriq-splash .pulse-wave:nth-child(2) {
    animation-delay: 1s;
}

.ledgeriq-splash .pulse-wave:nth-child(3) {
    animation-delay: 2s;
}

.ledgeriq-splash .pulse-wave:nth-child(4) {
    animation-delay: 3s;
}

@keyframes pulseExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.6;
        border-width: 2px;
    }
    100% {
        width: 200vmax;
        height: 200vmax;
        opacity: 0;
        border-width: 1px;
    }
}

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

.ledgeriq-splash .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)
   ============================================ */

.ledgeriq-splash .splash-logo-mark {
    position: absolute;
    /* Center the logomark properly */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: auto;
    opacity: 0;
    animation: liqLogomarkSequence 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes liqLogomarkSequence {
    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);
    }
}

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

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

@keyframes liqNeonThrob {
    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)
   ============================================ */

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

@keyframes liqLogoImpact {
    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);
    }
}

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

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

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

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

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

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

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

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

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

.ledgeriq-splash .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;
}

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

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

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

@keyframes liqIconGlow {
    to {
        background: rgba(16, 185, 129, 0.15);
        border-color: var(--liq-emerald);
        box-shadow:
            0 0 20px var(--splash-glow-emerald),
            inset 0 0 15px rgba(16, 185, 129, 0.1);
    }
}

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

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

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

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

@keyframes liqIconColorize {
    to {
        color: var(--liq-green-light);
        filter: drop-shadow(0 0 6px var(--splash-glow-emerald));
    }
}

.ledgeriq-splash .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;
}

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

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

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

@keyframes liqLabelActivate {
    to {
        color: var(--liq-green-light);
    }
}

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

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

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

.ledgeriq-splash .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: liqTaglineFade 0.6s ease 5.5s forwards;
    margin: 0;
}

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

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

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

.ledgeriq-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: liqSkipHintFade 0.5s ease 2s forwards;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10;
}

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

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

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

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

.ledgeriq-splash.fade-out {
    animation: liqSplashFadeOut 0.8s ease forwards;
}

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

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

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

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

.ledgeriq-splash.diffuse .pulse-waves {
    animation: liqPulsesDiffuse 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.ledgeriq-splash.diffuse .splash-skip-hint {
    animation: liqHintDiffuse 0.3s ease forwards;
}

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

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

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

@keyframes liqHintDiffuse {
    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.
     */
    .ledgeriq-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 */
    .ledgeriq-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 */
    .ledgeriq-splash::before {
        z-index: 0 !important;
        pointer-events: none !important;
    }

    /* Logo mark - ensure it's visible and centered */
    .ledgeriq-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 */
    .ledgeriq-splash .splash-logo-mark {
        animation: liqLogomarkSequenceMobile 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }

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

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

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

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

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

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

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

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

    .ledgeriq-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 */
    .ledgeriq-splash .logomark-glow {
        z-index: 1 !important;
    }
}

/* Mobile-specific animation that maintains centering */
@keyframes liqLogomarkSequenceMobile {
    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) {
    .ledgeriq-splash .logo-img {
        height: 80px;
        max-width: 80vw;
    }

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

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

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

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

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

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

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

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

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

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

/* Performance optimization */
.ledgeriq-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 - LedgerIQ emerald */
@keyframes bleedInReveal {
    0% {
        opacity: 0;
        transform: translateY(15px);
        filter: drop-shadow(0 0 0px var(--bleed-glow-color, rgba(16, 185, 129, 0)));
    }
    60% {
        opacity: 1;
        transform: translateY(0);
        filter: drop-shadow(0 0 15px var(--bleed-glow-color, rgba(16, 185, 129, 0.5)));
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        filter: drop-shadow(0 0 0px var(--bleed-glow-color, rgba(16, 185, 129, 0)));
    }
}

/* LedgerIQ specific glow color - emerald green */
body .bleed-in {
    --bleed-glow-color: rgba(16, 185, 129, 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; }
.analyze-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;
    }
}
