/* Loading animation */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1F2937;
    /* これを追加し直す */
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
    overflow: hidden;
}

/* 背景画像用のレイヤー */
.loader::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 100vh;
    transform: translate(-50%, -50%) scale(1);
    background-image: url('../images/hero/hero-background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(20px);
    z-index: 1;
    animation: slowZoom 10s ease-out forwards;
}

/* 背景の暗いオーバーレイ */
.loader::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(31, 41, 55, 0.5);
    z-index: 2;
}

/* ゆっくりとズームイン */
@keyframes slowZoom {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.025);
    }
}

/* ローダーの内部コンテナ */
.loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    position: relative;
    z-index: 3;
    /* 1から3に変更 */
}

.loader.hide {
    opacity: 0;
    pointer-events: none;
}

/* Three.js用のコンテナスタイル */
#loader-3d-container {
    width: 300px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* フォールバック用のキューブアニメーション */
.loader-cube {
    width: 60px;
    height: 60px;
    position: relative;
    transform-style: preserve-3d;
    animation: rotate 2s linear infinite;
    margin: 0 auto;
}

.loader-face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* CNP Landローディングバー */
.cnp-loading-container {
    text-align: center;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cnp-loading-text {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: textGlow 2s ease-in-out infinite;
}

@keyframes textGlow {

    0%,
    100% {
        opacity: 0.8;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    50% {
        opacity: 1;
        text-shadow: 0 2px 8px rgba(127, 191, 127, 0.5);
    }
}

.cnp-loading-bar {
    width: 300px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(127, 191, 127, 0.3);
    border-radius: 50px;
    padding: 3px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.3);
}

.cnp-loading-fill {
    height: 100%;
    /* ベースカラー */
    background: linear-gradient(90deg, #4A7C4E 0%, #7FBF7F 100%);
    border-radius: 50px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* 複数のレイヤーでエフェクト */
.cnp-loading-fill::before,
.cnp-loading-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50px;
}

.cnp-loading-fill::before {
    /* オーバーレイグラデーション */
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(249, 234, 31, 0.3) 20%,
            rgba(228, 160, 67, 0.5) 50%,
            rgba(249, 234, 31, 0.3) 80%,
            transparent 100%);
    animation: shimmer 3s ease-in-out infinite;
}

.cnp-loading-fill::after {
    /* キラキラエフェクト */
    background-image: radial-gradient(circle at 20% 50%,
            rgba(255, 255, 255, 0.8) 0%,
            transparent 2%);
    background-size: 50px 100%;
    animation: sparkleRun 2s linear infinite;
}

@keyframes shimmer {

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

    50% {
        opacity: 1;
        transform: translateX(100%);
    }
}

@keyframes sparkleRun {
    0% {
        background-position: -50px 0;
    }

    100% {
        background-position: calc(100% + 50px) 0;
    }
}



@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 200% 50%;
    }
}

/* キラキラエフェクト */
.cnp-loading-sparkles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: sparkleMove 3s linear infinite;
}

.sparkle:nth-child(1) {
    animation-delay: 0s;
    top: 30%;
}

.sparkle:nth-child(2) {
    animation-delay: 1s;
    top: 50%;
}

.sparkle:nth-child(3) {
    animation-delay: 2s;
    top: 70%;
}

@keyframes sparkleMove {
    0% {
        left: 0%;
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }

    10% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }

    90% {
        opacity: 1;
        transform: scale(1) rotate(360deg);
    }

    100% {
        left: 100%;
        opacity: 0;
        transform: scale(0) rotate(540deg);
    }
}

.cnp-loading-percentage {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    margin-top: 10px;
    opacity: 0.8;
}

/* 葉っぱのパーティクル（オプション） */
.leaf-particle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #4A7C4E 0%, #7FBF7F 100%);
    border-radius: 0 100% 0 100%;
    opacity: 0.6;
    animation: leafFall 8s linear infinite;
}

@keyframes leafFall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* パーティクルコンテナにoverflow hiddenを追加 */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* これを追加 */
    pointer-events: none;
}

/* パーティクルの初期位置を画面外に設定 */
.particle {
    position: absolute;
    border-radius: 50%;
    animation: particleFloat 8s linear infinite;
    box-shadow:
        0 0 10px currentColor,
        0 0 20px currentColor;
}

/* 複数の開始位置パターン */
.particle:nth-child(3n) {
    bottom: -40px;
}

.particle:nth-child(3n+1) {
    bottom: -60px;
}

.particle:nth-child(3n+2) {
    bottom: -80px;
}

/* アニメーションを調整 */
@keyframes particleFloat {
    0% {
        transform: translateY(0) translateX(0) scale(0.5);
        opacity: 0;
    }

    5% {
        opacity: 0.3;
    }

    10% {
        transform: translateY(-20px) translateX(5px) scale(1);
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-110vh) translateX(30px) scale(0.8);
        opacity: 0;
    }
}

/* 異なる動きのパーティクルを追加 */
.particle:nth-child(odd) {
    animation: particleFloatAlt 6s linear infinite;
}

@keyframes particleFloatAlt {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg) scale(0);
        opacity: 0;
    }

    2% {
        transform: translateY(-10px) translateX(0) rotate(45deg) scale(1);
        opacity: 1;
    }

    50% {
        transform: translateY(-50vh) translateX(-40px) rotate(180deg) scale(1.5);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-110vh) translateX(-60px) rotate(360deg) scale(0.5);
        opacity: 0;
    }
}

/* キラキラ効果を強化 */
.particle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle,
            rgba(255, 255, 255, 1) 0%,
            transparent 70%);
    animation: twinkle 1s ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.5;
    }
}

.firefly-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #fff200;
    border-radius: 50%;
    box-shadow:
        0 0 10px #fff200,
        0 0 20px #fff200,
        0 0 30px #fff200;
    animation: fireflyMove 10s ease-in-out infinite;
}

@keyframes fireflyMove {

    0%,
    100% {
        transform: translate(0, 0);
        opacity: 0;
    }

    20%,
    80% {
        opacity: 1;
    }

    25% {
        transform: translate(100px, -100px);
    }

    50% {
        transform: translate(-50px, -200px);
    }

    75% {
        transform: translate(50px, -150px);
    }
}