/* =========================================================
   Page Loading
   ========================================================= */

.page-loading {
    --green: #22C55E;
    --green-dark: #16A34A;
    --green-pale: rgba(34, 197, 94, 0.18);
    --ink: #F3FBF6;
    --paper: rgba(0, 0, 0, 0.65);

    box-sizing: border-box;

    position: fixed;
    inset: 0;
    z-index: 99999;

    display: none;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    overflow: hidden;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Pretendard",
        "Apple SD Gothic Neo",
        "Malgun Gothic",
        sans-serif;

    color: var(--ink);

    background: var(--paper);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.page-loading *,
.page-loading *::before,
.page-loading *::after {
    box-sizing: border-box;
}


/* 로딩 표시 ------------------------------------------------------- */

.page-loading.is-active {
    display: flex;
}


/* 배경 효과 ------------------------------------------------------- */

.page-loading::before {
    content: "";

    position: absolute;
    inset: 0;

    background:
        radial-gradient(
            560px 420px at 78% 18%,
            var(--green-pale),
            transparent 60%
        ),
        radial-gradient(
            420px 320px at 12% 88%,
            rgba(255, 255, 255, 0.05),
            transparent 65%
        );

    z-index: 0;
    pointer-events: none;
}


/* 전체 영역 ------------------------------------------------------- */

.page-loading__stage {
    position: relative;
    z-index: 1;

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 28px;

    padding: 0 24px;
}


/* 캐릭터 ---------------------------------------------------------- */

.page-loading__char-wrap {
    position: relative;

    width: 250px;
    height: 250px;

    display: flex;
    align-items: center;
    justify-content: center;
}

.page-loading__char-shadow {
    position: absolute;
    bottom: 2px;

    width: 86px;
    height: 16px;

    border-radius: 50%;

    background: rgba(0, 0, 0, 0.35);

    filter: blur(2px);

    animation:
        pageLoadingShadowPulse
        1.8s
        ease-in-out
        infinite;
}

.page-loading__char {
    position: relative;

    width: 200px;
    height: auto;

    transform-origin: bottom center;

    animation:
        pageLoadingBob
        1.8s
        ease-in-out
        infinite;
}


@keyframes pageLoadingBob {

    0%,
    100% {
        transform:
            translateY(0)
            rotate(0deg);
    }

    50% {
        transform:
            translateY(-10px)
            rotate(-1.5deg);
    }
}


@keyframes pageLoadingShadowPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.55;
    }

    50% {
        transform: scale(0.78);
        opacity: 0.3;
    }
}


/* 로딩 문구 ------------------------------------------------------- */

.page-loading__label-row {
    display: flex;
    align-items: baseline;
    justify-content: center;

    gap: 2px;

    width: 100%;

    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;

    letter-spacing: -0.01em;

    color: var(--ink);
    text-align: center;

    white-space: nowrap;
}

#page-loading-text {
    transition: opacity 0.3s ease;
}


/* 점 애니메이션 --------------------------------------------------- */

.page-loading__dots {
    display: inline-flex;

    width: 20px;

    flex-shrink: 0;
}

.page-loading__dots span {
    opacity: 0;

    animation:
        pageLoadingDotFade
        1.4s
        infinite;
}

.page-loading__dots span:nth-child(1) {
    animation-delay: 0s;
}

.page-loading__dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.page-loading__dots span:nth-child(3) {
    animation-delay: 0.4s;
}


@keyframes pageLoadingDotFade {

    0%,
    20% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}


/* 로딩 게이지 ----------------------------------------------------- */

.page-loading__track {
    position: relative;

    width: 220px;
    height: 5px;

    border-radius: 999px;

    background: rgba(255, 255, 255, 0.18);

    overflow: hidden;
}

.page-loading__fill {
    width: 36%;
    height: 100%;

    border-radius: 999px;

    background:
        linear-gradient(
            90deg,
            var(--green-dark),
            var(--green)
        );

    animation:
        pageLoadingSlide
        1.6s
        ease-in-out
        infinite;
}


@keyframes pageLoadingSlide {

    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(340%);
    }
}


/* 모션 최소화 설정 ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {

    .page-loading__char,
    .page-loading__fill,
    .page-loading__char-shadow,
    .page-loading__dots span {
        animation: none !important;
    }
}