/**
 * UI Enhancements Styles
 * Modern animations and interactions
 */

/* ========================================
   SCROLL REVEAL ANIMATIONS
   ======================================== */

.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger effect for cards */
.book-card.scroll-reveal {
    animation: fadeInUp 0.6s ease-out forwards;
    animation-play-state: paused;
}

.book-card.scroll-reveal.revealed {
    animation-play-state: running;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   3D CARD TILT EFFECT
   ======================================== */

.book-card {
    transform-style: preserve-3d;
    will-change: transform;
}

.book-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(
        135deg,
        rgba(168, 85, 247, 0.15),
        rgba(236, 72, 153, 0.15)
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

.book-card:hover::before {
    opacity: 1;
}

/* Inner elements maintain their position */
.book-card > * {
    position: relative;
    z-index: 2;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

/* ========================================
   MAGNETIC BUTTON EFFECT
   ======================================== */

.primary-btn,
.hero-btn,
.action-btn {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease;
    will-change: transform;
}

/* ========================================
   RIPPLE EFFECT
   ======================================== */

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.6;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ========================================
   STATS COUNTER ANIMATION
   ======================================== */

.stat-number {
    transition: color 0.3s ease;
}

.stat-number.counted {
    color: var(--accent-purple);
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

/* ========================================
   ENHANCED FILTER CHIPS
   ======================================== */

.category-btn {
    position: relative;
    overflow: hidden;
}

.category-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.category-btn:hover::after {
    width: 200%;
    height: 200%;
}

.category-btn.active::after {
    width: 100%;
    height: 100%;
    background: rgba(168, 85, 247, 0.2);
}

/* Count badge */
.category-btn {
    gap: 6px;
}

/* ========================================
   LOADING SKELETON
   ======================================== */

.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 8px;
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 8px 0;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* ========================================
   HOVER GLOW ENHANCEMENT
   ======================================== */

.book-card {
    position: relative;
    transition: box-shadow 0.3s ease;
}

.book-card:hover {
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2),
                0 0 30px rgba(168, 85, 247, 0.1);
}


/* ========================================
   SMOOTH TRANSITIONS
   ======================================== */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.book-card,
.opensea-card,
.category-btn,
.primary-btn {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    /* Disable 3D effects on mobile for performance */
    .book-card {
        transform-style: flat !important;
    }

    .book-card > * {
        transform: none !important;
    }

    /* Adjust toast position */
    .toast-container {
        right: 10px;
        left: 10px;
        top: 70px;
    }

    .toast {
        max-width: 100% !important;
    }

    /* Quick View Modal - Mobile */
    .quick-view-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: 2.5vh auto;
    }

    .quick-view-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }

    .quick-view-nav {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .quick-view-prev {
        left: 10px;
    }

    .quick-view-next {
        right: 10px;
    }

    .quick-view-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    /* Disable magnetic buttons on touch devices */
    @media (hover: none) {
        .primary-btn:hover,
        .hero-btn:hover,
        .action-btn:hover {
            transform: none !important;
        }
    }
}

/* ========================================
   REDUCED MOTION SUPPORT
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .scroll-reveal,
    .book-card,
    .category-btn,
    .toast {
        animation: none !important;
        transition: none !important;
    }

    .book-card:hover {
        transform: none !important;
    }
}

/* ========================================
   QUICK VIEW MODAL
   ======================================== */

.quick-view-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.quick-view-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.quick-view-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.quick-view-content {
    position: relative;
    max-width: 1200px;
    max-height: 90vh;
    margin: 5vh auto;
    background: linear-gradient(145deg, #1a1a1a, #0a0a0a);
    border-radius: 20px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quick-view-modal.active .quick-view-content {
    transform: scale(1);
}

.quick-view-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
}

.quick-view-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    transform: rotate(90deg);
}

.quick-view-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 50%;
    color: white;
    font-size: 32px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-view-prev {
    left: 20px;
}

.quick-view-next {
    right: 20px;
}

.quick-view-nav:hover {
    background: rgba(168, 85, 247, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.quick-view-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
}

.quick-view-image {
    position: relative;
}

.quick-view-image img {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.quick-view-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
}

.quick-view-badge.legendary {
    background: rgba(255, 215, 0, 0.3);
    border: 2px solid var(--rarity-legendary);
    color: var(--rarity-legendary);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.quick-view-badge.epic {
    background: rgba(156, 39, 176, 0.3);
    border: 2px solid var(--rarity-epic);
    color: var(--rarity-epic);
}

.quick-view-badge.rare {
    background: rgba(33, 150, 243, 0.3);
    border: 2px solid var(--rarity-rare);
    color: var(--rarity-rare);
}

.quick-view-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 10px 0;
    color: white;
}

.quick-view-author {
    font-size: 18px;
    color: var(--accent-purple);
    margin: 0 0 20px 0;
}

.quick-view-character {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
}

.quick-view-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.meta-item {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.quick-view-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 30px;
}

.quick-view-rarities {
    margin: 30px 0;
}

.quick-view-rarities h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: white;
}

.rarity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.rarity-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.rarity-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(168, 85, 247, 0.3);
}

.rarity-tier-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
}

.rarity-price {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-purple);
    margin-bottom: 5px;
}

.rarity-token-id {
    font-size: 12px;
    color: var(--text-muted);
}

.quick-view-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.qv-btn {
    flex: 1;
    padding: 14px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.qv-btn.primary {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: white;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.qv-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

.qv-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.qv-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* ========================================
   COPY LINK BUTTON
   ======================================== */

.copy-link-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-card:hover .copy-link-btn {
    opacity: 1;
    transform: scale(1);
}

.copy-link-btn:hover {
    background: rgba(168, 85, 247, 0.3);
    border-color: var(--accent-purple);
    transform: scale(1.1);
}

.copy-link-btn:active {
    transform: scale(0.95);
}

/* ========================================
   RARITY SPARKLE EFFECTS
   ======================================== */

.sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
    z-index: 1;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    animation: sparkleFloat 3s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

@keyframes sparkleFloat {
    0%, 100% {
        opacity: 0;
        transform: translateY(0) scale(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-20px) scale(1);
    }
}

/* ========================================
   ENHANCED SCRAMBLE ANIMATION
   ======================================== */

@keyframes cardFlip {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(90deg);
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg);
    }
}

.slot-scrambling {
    position: relative;
}

.slot-scrambling::before {
    content: 'SCRAMBLING...';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 900;
    color: var(--accent-purple);
    text-shadow: 0 0 20px rgba(168, 85, 247, 0.8);
    z-index: 1000;
    animation: pulse 0.5s ease-in-out infinite;
    pointer-events: none;
}

.scramble-complete .book-card {
    animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   RESPONSIVE QUICK VIEW
   ======================================== */

@media (max-width: 768px) {
    .quick-view-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }

    .quick-view-nav {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .quick-view-title {
        font-size: 24px;
    }

    .quick-view-actions {
        flex-direction: column;
    }

    .copy-link-btn {
        opacity: 1;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

.book-card,
.category-btn,
.primary-btn {
    contain: layout style paint;
}

/* GPU acceleration */
.book-card:hover,
.category-btn:hover,
.primary-btn:hover {
    will-change: transform;
}

.book-card:not(:hover),
.category-btn:not(:hover),
.primary-btn:not(:hover) {
    will-change: auto;
}
