/**
 * effects.css
 * 背景エフェクト、アニメーション
 */

/* パーティクルキャンバス */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* グリッド背景 (White Protocol: シンプルな単一层グリッド) */
.grid-system {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 1;
    /* bodyの上、content(z-index: 10)の下 */
    opacity: 0.8;
    /* 1.0だと少し強い可能性があるので、微調整 */
    pointer-events: none;
}

/* スキャンライン */
.scanning-line {
    position: fixed;
    width: 100%;
    height: 2px;
    background: rgba(0, 242, 255, 0.4);
    top: -10%;
    animation: scan 8s infinite linear;
    z-index: 0;
    pointer-events: none;
}

@keyframes scan {
    to {
        top: 110%;
    }
}

/* 背景オーブ */
.bg-orb {
    position: fixed;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.1;
    pointer-events: none;
}

.orb-1 {
    top: -10%;
    left: -10%;
    background: var(--primary-color);
}

.orb-2 {
    bottom: -10%;
    right: -10%;
    background: var(--secondary-color);
}

/* グリッチエフェクト */
.glitch {
    position: relative;
}

.glitch:hover {
    animation: glitch 0.3s ease-in-out;
}

@keyframes glitch {

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

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(2px, -2px);
    }

    60% {
        transform: translate(-2px, -2px);
    }

    80% {
        transform: translate(2px, 2px);
    }
}

/* セクション切り替え時の遷移演出（Scanner / Pixels） */
.glitch-overlay {
    position: fixed;
    top: 0;
    left: 70px;
    /* サイドバーの幅を避ける */
    width: calc(100% - 70px);
    height: 100vh;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* 1. Scanner エフェクト */
.shutter {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 255, 0.1) 95%, var(--primary-color) 100%);
    opacity: 0;
}

.shutter.animate {
    animation: scanMove 0.7s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes scanMove {
    0% {
        left: -100%;
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        left: 100%;
        opacity: 0;
    }
}

/* 2. Pixels エフェクト */
.pixel-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(8, 1fr);
    pointer-events: none;
}

.pixel-block {
    background: var(--primary-color);
    opacity: 0;
}

.animate-pixels .pixel-block {
    animation: pixelFade 0.5s forwards;
}

@keyframes pixelFade {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    50% {
        opacity: 0.15;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.05);
    }
}

/* 遷移時のマイルドな背景グロウ（共通） */
.glitch-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-color);
    opacity: 0;
    pointer-events: none;
}

.flash-active::after {
    animation: simpleGlow 0.5s ease-out;
}

@keyframes simpleGlow {
    0% {
        opacity: 0;
    }

    40% {
        opacity: 0.05;
    }

    100% {
        opacity: 0;
    }
}

/* フェードインアニメーション */
.fade-in {
    opacity: 0;
    --fade-y: 30px;
    transform: translateY(var(--fade-y));
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
    --fade-y: 0px;
}

/* 文字アセンブリ演出 (Explosion) */
.assembly-container {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    perspective: 1000px;
}

/* 単語の途中で改行させないためのラップ */
.assembly-word {
    display: inline-block;
    white-space: nowrap;
}

.assembly-char {
    display: inline-block;
    transition: all 0.8s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    opacity: 1;
    filter: blur(0px);
}

.assembly-char.hidden {
    opacity: 0;
    filter: blur(5px);
}

/* Explosion 状態 */
.assembly-explosion {
    transform: translate(var(--tx), var(--ty)) rotate(var(--tr)) scale(1.5);
}

/* ホバー時の微細なリアクション */
.assembly-char:hover {
    color: var(--primary-color);
    transform: translateY(-5px) scale(1.1) !important;
    text-shadow: 0 0 20px var(--primary-color);
    z-index: 10;
}

/* ============================================================ */
/* WORLD_LINE_SHIFT (Interaction Overlay)                       */
/* ============================================================ */

.world-shift-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s;
    overflow: hidden;
    pointer-events: none;
}

.world-shift-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.world-shift-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.shift-glitch {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent 0,
            transparent 2px,
            rgba(0, 242, 255, 0.05) 2px,
            rgba(0, 242, 255, 0.05) 4px);
    animation: shift-noise 0.2s steps(2) infinite;
}

@keyframes shift-noise {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(4px);
    }
}

.shift-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    color: var(--primary-color);
    letter-spacing: 4px;
    text-shadow: 0 0 10px var(--primary-color);
    animation: status-flicker 1.5s infinite;
}

@keyframes status-flicker {

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

    50% {
        opacity: 0.6;
        transform: scale(0.98);
    }

    55% {
        opacity: 1;
        transform: skewX(-10deg);
    }

    60% {
        transform: skewX(0);
    }
}
/* 他テーマの要素を非表示(Water World) */
.paper-texture,
.watercolor-bg {
    display: none !important;
}
