/* ===== Makhluot Magic - Premium VFX & UI Polish ===== */

/* ============ GLOBAL SMOOTHNESS ============ */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Smooth scrollbar (desktop) */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }
    ::-webkit-scrollbar-track {
        background: rgba(108,92,231,0.05);
    }
    ::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #6c5ce7, #a855f7);
        border-radius: 10px;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(180deg, #a855f7, #6c5ce7);
    }
}

/* ============ POST CARDS - PREMIUM VFX ============ */
.post-card {
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
                box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    will-change: transform;
}

.post-card:hover {
    transform: translateY(-6px) scale(1.015) !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), 0 0 30px rgba(108,92,231,0.15) !important;
}

.post-card img {
    transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    will-change: transform;
}

.post-card:hover img {
    transform: scale(1.08);
}

/* Shimmer overlay on hover */
.post-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 35%, rgba(108,92,231,0.08) 50%, transparent 65%);
    transform: translateX(-100%);
    transition: transform 0.7s ease;
    pointer-events: none;
    z-index: 3;
}

.post-card:hover::after {
    transform: translateX(100%);
}

/* ============ HERO SECTION ============ */
.hero-main {
    position: relative;
    overflow: hidden;
}

.hero-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(108,92,231,0.0) 0%, rgba(108,92,231,0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s;
    z-index: 2;
    pointer-events: none;
}

.hero-main:hover::before {
    opacity: 1;
}

/* ============ BUTTONS - GLOSSY EFFECT ============ */
.btn, button, .btn-primary, .read-more-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn::before, .read-more-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn:hover::before, .read-more-btn:hover::before {
    left: 100%;
}

/* ============ SCROLL REVEAL ANIMATION ============ */
.mmg-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.mmg-reveal.mmg-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger delays */
.mmg-reveal:nth-child(1) { transition-delay: 0s; }
.mmg-reveal:nth-child(2) { transition-delay: 0.08s; }
.mmg-reveal:nth-child(3) { transition-delay: 0.16s; }
.mmg-reveal:nth-child(4) { transition-delay: 0.24s; }
.mmg-reveal:nth-child(5) { transition-delay: 0.32s; }
.mmg-reveal:nth-child(6) { transition-delay: 0.4s; }

/* ============ HEADER POLISH ============ */
.site-header {
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    transition: all 0.3s ease;
}

.site-header.scrolled {
    background: rgba(10, 10, 18, 0.85);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ============ BACK TO TOP - FLOATING ============ */
.back-to-top {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #6c5ce7, #a855f7) !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.4) !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1);
}

.back-to-top:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 12px 32px rgba(108, 92, 231, 0.6) !important;
}

[dir="rtl"] .back-to-top {
    right: auto !important;
    left: 24px !important;
}

/* ============ RELATED POSTS STRIP ============ */
.mmg-related-strip {
    margin: 40px 0 20px;
    padding: 24px 0;
    border-top: 1px solid var(--border-color, #2a2a3e);
}

.mmg-related-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 18px;
    color: var(--text-primary, #fff);
}

.mmg-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.mmg-related-card {
    display: block;
    background: var(--bg-card, #1e1e2e);
    border: 1px solid var(--border-color, #2a2a3e);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.mmg-related-card:hover {
    transform: translateY(-4px);
    border-color: var(--c-primary, #6c5ce7);
    box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}

.mmg-related-card img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.mmg-related-card:hover img {
    transform: scale(1.08);
}

.mmg-related-name {
    display: block;
    padding: 10px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ============ MOBILE TOUCH FEEDBACK ============ */
@media (hover: none) and (pointer: coarse) {
    a:active, button:active, .post-card:active {
        opacity: 0.7;
        transition: opacity 0.1s;
    }
    
    /* Disable hover transforms on touch devices for smoothness */
    .post-card:hover {
        transform: none !important;
    }
    .post-card:active {
        transform: scale(0.98) !important;
        transition: transform 0.15s !important;
    }
}

/* ============ MOBILE OPTIMIZATIONS ============ */
@media (max-width: 768px) {
    /* Smoother momentum scrolling on iOS */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Reduce shadows on mobile for performance */
    .post-card {
        will-change: auto;
    }
    
    /* Smaller back-to-top */
    .back-to-top {
        width: 42px !important;
        height: 42px !important;
        bottom: 16px !important;
        right: 16px !important;
    }
    [dir="rtl"] .back-to-top {
        left: 16px !important;
    }
}

/* ============ LINK HOVER UNDERLINE ANIMATION ============ */
.entry-content a:not(.btn):not(.mdg-btn):not(.mmg-related-card):not(.read-more-btn) {
    background-image: linear-gradient(90deg, var(--c-primary, #6c5ce7), var(--c-primary, #6c5ce7));
    background-size: 0 2px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.3s ease;
    text-decoration: none;
}

.entry-content a:not(.btn):not(.mdg-btn):hover {
    background-size: 100% 2px;
}

/* ============ FOCUS RINGS (a11y) ============ */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--c-primary, #6c5ce7);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============ SELECTION COLOR ============ */
::selection {
    background: rgba(108, 92, 231, 0.4);
    color: #fff;
}

/* ============ PAGE TRANSITIONS ============ */
@media (prefers-reduced-motion: no-preference) {
    body {
        animation: mmgFadeIn 0.4s ease-out;
    }
    
    @keyframes mmgFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* ============ RESPECT REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
