/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS - Game Boy Inspired
   ═══════════════════════════════════════════════════════════════ */

/* ─── LOADING SCREEN ─── */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gb-darkest);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: var(--z-loader);
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-gameboy {
    width: 120px;
    height: 180px;
    background: var(--gb-shell);
    border-radius: 8px 8px 40px 40px;
    position: relative;
    box-shadow:
        inset 0 -4px 0 var(--gb-shell-dark),
        0 8px 24px rgba(0, 0, 0, 0.3);
}

.loader-screen {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 72px;
    background: var(--gb-screen);
    border: 4px solid var(--gb-purple-dim);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.loader-content {
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--gb-lightest);
    text-align: center;
    animation: screenFlicker 0.1s infinite;
}

.loader-progress {
    width: 60px;
    height: 8px;
    background: var(--gb-dark);
    margin-top: 4px;
    border: 1px solid var(--gb-purple-dim);
    position: relative;
    overflow: hidden;
}

.loader-progress-bar {
    height: 100%;
    background: var(--gb-light);
    animation: loading 2s ease-in-out forwards;
}

.loader-dpad {
    position: absolute;
    bottom: 50px;
    left: 20px;
    width: 40px;
    height: 40px;
}

.loader-dpad::before,
.loader-dpad::after {
    content: '';
    position: absolute;
    background: var(--gb-shell-dark);
}

.loader-dpad::before {
    width: 14px;
    height: 40px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 2px;
}

.loader-dpad::after {
    width: 40px;
    height: 14px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 2px;
}

.loader-buttons {
    position: absolute;
    bottom: 55px;
    right: 15px;
    display: flex;
    gap: 8px;
    transform: rotate(-25deg);
}

.loader-btn {
    width: 16px;
    height: 16px;
    background: #9b1b30;
    border-radius: 50%;
    box-shadow: inset 0 -2px 0 #6b1020;
}

.loader-text {
    margin-top: var(--space-5);
    font-family: var(--font-pixel);
    font-size: var(--text-xs);
    color: var(--gb-light);
    animation: blink 1s step-end infinite;
}

/* ─── RETRO MENU STYLE START BUTTON ─── */
.loader-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.loader-menu-arrow {
    font-family: var(--font-pixel);
    font-size: var(--text-base);
    color: var(--gb-glow);
    animation: menuArrowBlink 0.5s step-end infinite;
}

@keyframes menuArrowBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.loader-start-btn {
    font-family: var(--font-pixel);
    font-size: var(--text-sm);
    color: var(--gb-lightest);
    background: transparent;
    border: none;
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    position: relative;
    text-shadow: 2px 2px 0 var(--gb-darkest);
    transition: all 0.1s ease;
}

.loader-start-btn .start-text {
    position: relative;
    z-index: 1;
}

/* Retro selection box */
.loader-start-btn::before {
    content: '';
    position: absolute;
    inset: -4px -8px;
    border: 3px solid transparent;
    transition: border-color 0.1s ease;
}

.loader-start-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gb-light);
    opacity: 0;
    transition: opacity 0.1s ease;
    z-index: 0;
}

/* Hover = Selected state */
.loader-start-btn:hover {
    color: var(--gb-darkest);
}

.loader-start-btn:hover::before {
    border-color: var(--gb-glow);
    box-shadow:
        0 0 10px var(--gb-glow),
        inset 0 0 10px rgba(224, 170, 255, 0.2);
}

.loader-start-btn:hover::after {
    opacity: 1;
}

.loader-start-btn:active {
    transform: scale(0.95);
}

/* Pulsing glow animation */
.loader-menu {
    animation: menuPulse 1.5s ease-in-out infinite;
}

@keyframes menuPulse {

    0%,
    100% {
        filter: drop-shadow(0 0 5px var(--gb-purple-dim));
    }

    50% {
        filter: drop-shadow(0 0 15px var(--gb-glow));
    }
}

.loader-hint {
    margin-top: var(--space-4);
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--gb-purple-dim);
    letter-spacing: 1px;
    animation: hintFade 2s ease-in-out infinite;
}

@keyframes hintFade {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ─── BOOT SEQUENCE ANIMATION ─── */
.boot-sequence {
    position: absolute;
    inset: 0;
    background: var(--gb-darkest);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    z-index: 100;
}

.boot-sequence.active {
    opacity: 1;
    visibility: visible;
    animation: bootFlash 0.15s ease-out;
}

@keyframes bootFlash {
    0% {
        background: var(--gb-lightest);
    }

    100% {
        background: var(--gb-darkest);
    }
}

.boot-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.3) 2px,
            rgba(0, 0, 0, 0.3) 4px);
    animation: scanlineMove 0.1s linear infinite;
    pointer-events: none;
}

@keyframes scanlineMove {
    0% {
        transform: translateY(0);
    }

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

.boot-content {
    text-align: center;
    animation: bootContentDrop 0.5s ease-out 0.15s both;
}

@keyframes bootContentDrop {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }

    60% {
        transform: translateY(5px);
    }

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

.boot-logo {
    font-family: var(--font-pixel);
    font-size: var(--text-4xl);
    color: var(--gb-glow);
    margin-bottom: var(--space-4);
    text-shadow:
        0 0 10px var(--gb-glow),
        0 0 20px var(--gb-light),
        0 0 40px var(--gb-purple-dim);
    animation: bootLogoGlow 0.3s ease-in-out 0.6s 3;
}

@keyframes bootLogoGlow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.boot-text {
    font-family: var(--font-pixel);
    font-size: var(--text-xs);
    color: var(--gb-light);
    margin-bottom: var(--space-3);
    animation: blink 0.3s step-end infinite;
}

.boot-bar {
    width: 200px;
    height: 12px;
    background: var(--gb-dark);
    border: 2px solid var(--gb-light);
    margin: 0 auto;
    overflow: hidden;
}

.boot-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--gb-light), var(--gb-glow));
    animation: bootBarFill 1s ease-out 0.3s forwards;
}

@keyframes bootBarFill {
    0% {
        width: 0;
    }

    100% {
        width: 100%;
    }
}

@keyframes loading {
    0% {
        width: 0;
    }

    100% {
        width: 100%;
    }
}

@keyframes screenFlicker {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.98;
    }
}

/* ─── FADE IN ANIMATIONS ─── */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.fade-in-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.fade-in-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Staggered delays */
.delay-1 {
    transition-delay: 0.1s;
}

.delay-2 {
    transition-delay: 0.2s;
}

.delay-3 {
    transition-delay: 0.3s;
}

.delay-4 {
    transition-delay: 0.4s;
}

.delay-5 {
    transition-delay: 0.5s;
}

/* ─── PIXEL GLITCH EFFECT ─── */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.glitch:hover::before {
    animation: glitch-1 0.3s linear;
    color: var(--gb-light);
    left: 2px;
    opacity: 0.8;
}

.glitch:hover::after {
    animation: glitch-2 0.3s linear;
    color: var(--gb-dark);
    left: -2px;
    opacity: 0.8;
}

@keyframes glitch-1 {

    0%,
    100% {
        clip-path: inset(0 0 90% 0);
    }

    20% {
        clip-path: inset(30% 0 50% 0);
    }

    40% {
        clip-path: inset(60% 0 20% 0);
    }

    60% {
        clip-path: inset(10% 0 70% 0);
    }

    80% {
        clip-path: inset(80% 0 5% 0);
    }
}

@keyframes glitch-2 {

    0%,
    100% {
        clip-path: inset(90% 0 0 0);
    }

    20% {
        clip-path: inset(50% 0 30% 0);
    }

    40% {
        clip-path: inset(20% 0 60% 0);
    }

    60% {
        clip-path: inset(70% 0 10% 0);
    }

    80% {
        clip-path: inset(5% 0 80% 0);
    }
}

/* ─── TYPING EFFECT ─── */
.typing {
    overflow: hidden;
    border-right: 3px solid var(--gb-light);
    white-space: nowrap;
    animation:
        typing 3s steps(30, end),
        cursor-blink 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes cursor-blink {

    0%,
    100% {
        border-color: var(--gb-light);
    }

    50% {
        border-color: transparent;
    }
}

/* ─── PULSE ANIMATION ─── */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(157, 78, 221, 0.4);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px 10px rgba(157, 78, 221, 0);
    }
}

/* ─── BOUNCE ─── */
.bounce {
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

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

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

/* ─── SHAKE (for errors/attention) ─── */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

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

    20% {
        transform: translateX(-5px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-5px);
    }

    80% {
        transform: translateX(5px);
    }
}

/* ─── PIXEL WAVE ─── */
.wave-text span {
    display: inline-block;
    animation: wave 1.5s ease-in-out infinite;
}

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

.wave-text span:nth-child(2) {
    animation-delay: 0.1s;
}

.wave-text span:nth-child(3) {
    animation-delay: 0.2s;
}

.wave-text span:nth-child(4) {
    animation-delay: 0.3s;
}

.wave-text span:nth-child(5) {
    animation-delay: 0.4s;
}

.wave-text span:nth-child(6) {
    animation-delay: 0.5s;
}

.wave-text span:nth-child(7) {
    animation-delay: 0.6s;
}

.wave-text span:nth-child(8) {
    animation-delay: 0.7s;
}

@keyframes wave {

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

    50% {
        transform: translateY(-5px);
    }
}

/* ─── SCAN LINE SWEEP ─── */
.scanline-sweep::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to bottom,
            transparent,
            rgba(157, 78, 221, 0.3),
            transparent);
    animation: scanline 3s linear infinite;
}

@keyframes scanline {
    0% {
        top: 0;
    }

    100% {
        top: 100%;
    }
}

/* ─── SKILL BAR ANIMATION ─── */
.skill-bar-fill {
    width: 0;
    transition: width 1s ease-out;
}

.skill-bar-fill.animate {
    width: var(--skill-level);
}

/* ─── HOVER LIFT ─── */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

/* ─── SCREEN BOOT SEQUENCE ─── */
.boot-sequence {
    opacity: 0;
    animation: bootUp 0.5s ease-out forwards;
}

@keyframes bootUp {
    0% {
        opacity: 0;
        filter: brightness(2);
    }

    50% {
        opacity: 1;
        filter: brightness(1.5);
    }

    100% {
        opacity: 1;
        filter: brightness(1);
    }
}

/* ─── CRT FLICKER ─── */
.crt-flicker {
    animation: crtFlicker 0.15s infinite;
}

@keyframes crtFlicker {
    0% {
        opacity: 0.97;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.98;
    }
}

/* ═══════════════════════════════════════════════════════════════
   PAGE TRANSITION - Game Boy Loading Screen
   ═══════════════════════════════════════════════════════════════ */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gb-darkest);
    z-index: calc(var(--z-loader) - 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.page-transition.active {
    opacity: 1;
    visibility: visible;
}

.page-transition-screen {
    width: 200px;
    height: 60px;
    background: var(--gb-screen);
    border: 4px solid var(--gb-purple-dim);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.page-transition-content {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--gb-lightest);
    text-align: center;
}

.page-transition-bar {
    position: absolute;
    bottom: 8px;
    left: 10px;
    right: 10px;
    height: 6px;
    background: var(--gb-dark);
    border: 1px solid var(--gb-purple-dim);
    overflow: hidden;
}

.page-transition-progress {
    height: 100%;
    background: var(--gb-light);
    width: 0;
    animation: pageLoad 0.4s ease-out forwards;
}

@keyframes pageLoad {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

.page-transition-dots {
    margin-top: var(--space-3);
    display: flex;
    gap: 8px;
}

.page-transition-dot {
    width: 8px;
    height: 8px;
    background: var(--gb-purple-dim);
    animation: dotPulse 0.6s ease-in-out infinite;
}

.page-transition-dot:nth-child(2) {
    animation-delay: 0.1s;
}

.page-transition-dot:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes dotPulse {

    0%,
    100% {
        background: var(--gb-purple-dim);
        transform: scale(1);
    }

    50% {
        background: var(--gb-light);
        transform: scale(1.2);
    }
}