/* ==========================================================================
   FINOX INDUSTRIAL PRECISION SVG PRELOADER
   Sequential Blueprint Drawing Architecture:
   Phase 1: Inner F Outline Draw -> Color Fill (Center of Screen)
   Phase 2: Outer Square Frame Outline Draw -> Color Fill (Center of Screen)
   Phase 3: Icon Shift Left -> Text Outline Draw -> Text Color Fill
   Phase 4: Pristine Solidification -> Exit Fade
   ========================================================================== */

body.preloader-active {
    overflow: hidden !important;
    touch-action: none !important;
}

.preloader {
    background-color: #ffffff;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999999;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.55s cubic-bezier(0.65, 0, 0.35, 1),
                transform 0.55s cubic-bezier(0.65, 0, 0.35, 1),
                visibility 0.55s cubic-bezier(0.65, 0, 0.35, 1);
    will-change: opacity, transform;
}

.preloader.fade-out {
    opacity: 0 !important;
    transform: translateY(-16px) !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.preloader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    user-select: none;
    width: 100%;
    padding: 0 15px;
}

.preloader-logo-wrapper {
    position: relative;
    width: 85px;
    height: 85px;
    max-width: 85vw;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible !important;
}

.finox-preloader-svg {
    width: 100%;
    height: 100%;
    overflow: visible !important;
    transform-origin: center center;
}

/* Base states for blueprint outline strokes & mask fill strokes */
.draw-stroke,
.mask-stroke {
    stroke-dasharray: var(--path-length, 2500);
    stroke-dashoffset: var(--path-length, 2500);
    transition: none;
}

/* Icon group centered in SVG canvas */
.finox-icon-group {
    transform: none;
    transform-origin: center center;
    will-change: transform;
}

.finox-final-logo-group {
    opacity: 0;
    transform-origin: center center;
    will-change: opacity;
}

.finox-stroke-layer {
    transition: opacity 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}

/* ==========================================================================
   PRECISION SEQUENTIAL ANIMATION TIMELINE
   --------------------------------------------------------------------------
   Phase 1: Inner F Outline Draw -> Color Fill (0.20s - 1.85s)
   Phase 2: Outer Square Frame Outline Draw -> Color Fill (1.80s - 3.15s)
   Phase 3: Pristine Solidification & Hold (3.20s - 3.70s)
   ========================================================================== */

/* --- PHASE 1: INNER F SHAPE (Center of screen) --- */

/* 1A. Upper Blue Outline Draw (0.20s -> 0.95s) */
.preloader.animating .stroke-upper-blue {
    animation: drawPath 0.75s cubic-bezier(0.4, 0, 0.2, 1) 0.20s forwards;
}

/* 1B. Upper Blue Solid Color Fill (0.85s -> 1.45s) */
.preloader.animating .mask-upper-blue {
    animation: drawPath 0.60s cubic-bezier(0.4, 0, 0.2, 1) 0.85s forwards;
}

/* 2A. Lower Navy Outline Draw (0.60s -> 1.35s) */
.preloader.animating .stroke-lower-navy {
    animation: drawPath 0.75s cubic-bezier(0.4, 0, 0.2, 1) 0.60s forwards;
}

/* 2B. Lower Navy Solid Color Fill (1.25s -> 1.85s) */
.preloader.animating .mask-lower-navy {
    animation: drawPath 0.60s cubic-bezier(0.4, 0, 0.2, 1) 1.25s forwards;
}

/* --- PHASE 2: OUTER SQUARE FRAME (Center of screen) --- */

/* 3A. Outer Square Outline Draw (1.80s -> 2.65s) */
.preloader.animating .stroke-outer-tl,
.preloader.animating .stroke-outer-br {
    animation: drawPath 0.85s cubic-bezier(0.4, 0, 0.2, 1) 1.80s forwards;
}

/* 3B. Outer Square Solid Color Fill (2.50s -> 3.15s) */
.preloader.animating .mask-outer-tl,
.preloader.animating .mask-outer-br {
    animation: drawPath 0.65s cubic-bezier(0.4, 0, 0.2, 1) 2.50s forwards;
}

/* --- PHASE 3: FINAL PRISTINE SOLIDIFICATION & SCALE PULSE --- */

/* Step 4: Solidify crisp original vectors & fade blueprint lines (3.20s -> 3.70s) */
.preloader.animating .finox-final-logo-group {
    animation: revealFinalLogo 0.50s cubic-bezier(0.65, 0, 0.35, 1) 3.20s forwards;
}

.preloader.animating .finox-stroke-layer {
    animation: fadeStrokes 0.50s cubic-bezier(0.65, 0, 0.35, 1) 3.25s forwards;
}

.preloader.animating .finox-preloader-svg {
    animation: subtleScalePulse 0.70s cubic-bezier(0.65, 0, 0.35, 1) 3.20s forwards;
}

/* ==========================================================================
   KEYFRAME ANIMATION DEFINITIONS
   ========================================================================== */

@keyframes drawPath {
    to {
        stroke-dashoffset: 0;
    }
}

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

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

@keyframes subtleScalePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.025);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive Breakpoints for Desktop, Tablet, and Mobile */
@media (max-width: 992px) {
    .preloader-logo-wrapper {
        width: 76px;
        height: 76px;
    }
}

@media (max-width: 768px) {
    .preloader-logo-wrapper {
        width: 68px;
        height: 68px;
    }
}

@media (max-width: 576px) {
    .preloader-logo-wrapper {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 380px) {
    .preloader-logo-wrapper {
        width: 52px;
        height: 52px;
    }
}

/* Accessibility: prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .preloader {
        display: none !important;
    }

    body.preloader-active {
        overflow: auto !important;
        touch-action: auto !important;
    }
}