/**
 * home-eggs-base.css - Core Easter Egg UI Elements
 *
 * Portal overlay, sleep overlay, draw indicator, achievement toasts,
 * secret messages, speech bubbles, rainbow fart transition,
 * and their associated @keyframes.
 */

/* ========================================
   KEYFRAME ANIMATIONS — Base UI
   ======================================== */

@keyframes trailFade {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes flyAcross {
    0% { left: -100px; top: 20%; transform: scaleX(1); }
    45% { left: 110%; top: 30%; transform: scaleX(1); }
    50% { left: 110%; top: 30%; transform: scaleX(-1); }
    95% { left: -100px; top: 25%; transform: scaleX(-1); }
    100% { left: -100px; top: 20%; transform: scaleX(1); }
}

@keyframes sleepFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    0% { transform: scale(0); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes spinAway {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(2) rotate(720deg); opacity: 0; }
}

@keyframes zzzFloat {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes drawIndicatorPulse {
    0%, 100% { border-color: rgba(131, 56, 236, 0.6); }
    50% { border-color: rgba(255, 0, 110, 0.8); }
}

@keyframes toastSlide {
    0% { transform: translateX(-50%) translateY(100px); opacity: 0; }
    15% { transform: translateX(-50%) translateY(0); opacity: 1; }
    85% { transform: translateX(-50%) translateY(0); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-20px); opacity: 0; }
}

@keyframes portalSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes portalGrow {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
        transform: rotate(0deg);
    }
    50% {
        width: 300px;
        height: 300px;
        opacity: 1;
        transform: rotate(180deg);
    }
    80% {
        width: 280px;
        height: 280px;
        transform: rotate(360deg);
    }
    100% {
        width: 2000px;
        height: 2000px;
        opacity: 1;
        transform: rotate(720deg);
    }
}

@keyframes portalBgFade {
    0% { background: rgba(0, 0, 0, 0); }
    50% { background: rgba(0, 0, 0, 0.7); }
    100% { background: rgba(0, 0, 0, 1); }
}

@keyframes portalTextFade {
    0%, 30% { opacity: 0; }
    50% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes tinyFade {
    to { opacity: 0; transform: scale(0); }
}

@keyframes explosionPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

@keyframes scrambleShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* ========================================
   CORE ELEMENTS
   ======================================== */

/* Rainbow trail particle */
.trail {
    position: fixed;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    pointer-events: none;
    animation: trailFade 0.8s forwards;
    z-index: var(--z-modal);
}

/* Flying unicorn */
.unicorn {
    position: fixed;
    font-size: 4rem;
    z-index: var(--z-floating);
    animation: flyAcross 12s linear infinite;
    cursor: pointer;
    transition: filter 0.1s;
}

.unicorn:hover {
    filter: drop-shadow(0 0 10px gold);
}

/* Sleep mode overlay */
.sleep-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 20, 0.85);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    animation: sleepFadeIn 2s ease;
}

/* Floating Zzz emojis */
.sleep-overlay .zzz {
    font-size: 4rem;
    color: white;
    animation: zzzFloat 2s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.sleep-overlay .zzz:nth-child(2) {
    animation-delay: 0.5s;
    font-size: 3rem;
    opacity: 0.7;
}

.sleep-overlay .zzz:nth-child(3) {
    animation-delay: 1s;
    font-size: 2rem;
    opacity: 0.5;
}

/* Tap to wake message */
.sleep-overlay .wake-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
    margin-top: 30px;
    animation: pulse 2s ease infinite;
}

/* Speech bubble for animals */
.speech-bubble {
    position: fixed;
    background: white;
    padding: 10px 15px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-popover);
    animation: popIn 0.3s ease;
    max-width: 200px;
    text-align: center;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-top-color: white;
}

/* Clickable emoji spin state (teleport) */
.clickable-emoji.spin {
    animation: spinAway 0.5s ease forwards;
}

/* Portal overlay */
.portal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: var(--z-modal);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    animation: portalBgFade 2s ease forwards;
}

/* The swirling portal */
.portal {
    width: 0;
    height: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        #ff006e, #8338ec, #3a86ff, #06ffa5, #ffbe0b, #ff006e
    );
    animation: portalGrow 2s ease forwards;
    position: relative;
    box-shadow:
        0 0 60px #8338ec,
        0 0 100px #3a86ff,
        inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.portal::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: radial-gradient(circle, #000 0%, #1a0a2e 50%, transparent 70%);
    opacity: 0;
    animation: sleepFadeIn 1s ease 0.5s forwards;
}

.portal::after {
    content: '\1F300';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    animation: portalTextFade 2s ease forwards;
    opacity: 0;
}

/* Portal text */
.portal-text {
    position: absolute;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 0 20px #8338ec;
    animation: portalTextFade 2s ease forwards;
    top: calc(50% + 180px);
}

/* Circle drawing indicator */
.draw-indicator {
    position: fixed;
    border-radius: 50%;
    border: 3px dashed rgba(131, 56, 236, 0.6);
    pointer-events: none;
    z-index: var(--z-modal);
    animation: drawIndicatorPulse 0.5s ease infinite;
}

/* Achievement toast */
.achievement-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    padding: 15px 25px;
    border-radius: var(--radius-lg);
    text-align: center;
    z-index: var(--z-modal);
    animation: toastSlide 3s ease forwards;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}

.achievement-toast .title {
    font-size: var(--font-size-base);
    color: #7b2d00;
    font-weight: bold;
}

.achievement-toast .emoji {
    font-size: 1.5rem;
    margin-right: var(--space-2);
}

/* Secret message popup */
.secret-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: var(--space-6) var(--space-8);
    border-radius: var(--radius-lg);
    font-size: 1.5rem;
    text-align: center;
    z-index: var(--z-modal);
    animation: popIn 0.5s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.secret-message button {
    margin-top: var(--space-4);
    padding: var(--space-2) var(--space-5);
    border: none;
    background: white;
    color: #764ba2;
    border-radius: var(--radius-lg);
    font-weight: bold;
    cursor: pointer;
}

/* Name scrambler shake effect */
.scramble-name.scrambling {
    animation: textGradient 3s ease infinite, scrambleShake 0.08s ease infinite;
}

/* Bored button explosion pieces */
.tiny-button {
    position: fixed;
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    color: white;
    padding: 4px 8px;
    font-size: 0.4rem;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    z-index: var(--z-modal);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
    white-space: nowrap;
}

.tiny-button:hover {
    transform: scale(1.3);
}

.tiny-button:active {
    transform: scale(0.8);
}

.tiny-button.fading {
    animation: tinyFade 1s ease forwards;
}

/* Bored button explosion center */
.bored-explosion {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    z-index: var(--z-modal);
    animation: explosionPop 0.5s ease forwards;
    pointer-events: none;
}

/* ========================================
   MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 480px) {
    .unicorn {
        font-size: 3rem;
    }

    .sleep-overlay .zzz {
        font-size: 3rem;
    }

    .portal-text {
        font-size: 1rem;
    }
}
