/**
 * Modern scroll & UI animations
 * Use with scroll-animations.js for scroll-triggered effects
 */

/* পপআপ খোলা/বন্ধে স্ক্রলবারের জায়গা রাখা — ফ্লিকার রোধ (প্যাডিং লাগে না) */
html {
    scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {
    .scroll-animate,
    .scroll-animate * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Keyframes ---- */
@keyframes animFadeInUp {
    from {
        opacity: 0;
        transform: translateY(28px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes animFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes animFadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes animScaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes animBlurIn {
    from {
        opacity: 0;
        filter: blur(8px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* ---- Base: elements wait in viewport before animating ---- */
.scroll-animate {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.scroll-animate.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Initial state for keyframe variants (avoids jump when animation starts) */
.scroll-animate[data-animate="fadeUp"] { transform: translateY(28px); }
.scroll-animate[data-animate="fadeDown"] { transform: translateY(-20px); }
.scroll-animate[data-animate="fadeLeft"] { transform: translateX(-24px); }
.scroll-animate[data-animate="fadeRight"] { transform: translateX(24px); }
.scroll-animate[data-animate="scale"] { transform: scale(0.92); }

/* ---- Variants: use data-animate="fadeUp" | "fadeLeft" | "fadeRight" | "scale" | "blur" ---- */
.scroll-animate[data-animate="fadeUp"].animated {
    animation: animFadeInUp 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.scroll-animate[data-animate="fadeDown"].animated {
    animation: animFadeInDown 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.scroll-animate[data-animate="fadeLeft"].animated {
    animation: animFadeInLeft 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.scroll-animate[data-animate="fadeRight"].animated {
    animation: animFadeInRight 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.scroll-animate[data-animate="scale"].animated {
    animation: animScaleIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.scroll-animate[data-animate="blur"].animated {
    animation: animBlurIn 0.7s ease-out forwards;
}

/* Stagger delay: data-delay="1" … "5" (in 100ms steps) */
.scroll-animate[data-delay="1"].animated { animation-delay: 0.1s; }
.scroll-animate[data-delay="2"].animated { animation-delay: 0.2s; }
.scroll-animate[data-delay="3"].animated { animation-delay: 0.3s; }
.scroll-animate[data-delay="4"].animated { animation-delay: 0.4s; }
.scroll-animate[data-delay="5"].animated { animation-delay: 0.5s; }

/* Transition-based (no keyframe) delay */
.scroll-animate[data-delay="1"] { transition-delay: 0.1s; }
.scroll-animate[data-delay="2"] { transition-delay: 0.2s; }
.scroll-animate[data-delay="3"] { transition-delay: 0.3s; }
.scroll-animate[data-delay="4"] { transition-delay: 0.4s; }
.scroll-animate[data-delay="5"] { transition-delay: 0.5s; }

/* ---- Mobile drawer (modern UI): only affects mobile, desktop header unchanged ---- */
#mobile-drawer-backdrop {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
body.mobile-drawer-open #mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}
#mobile-drawer {
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
body.mobile-drawer-open #mobile-drawer {
    transform: translateX(0);
}
@media (min-width: 1024px) {
    #mobile-drawer-backdrop,
    #mobile-drawer {
        display: none !important;
    }
}

/* ---- Desktop nav: simple & unique, সব পেজে একই অ্যালাইনমেন্ট ---- */
.navbar-center,
.navbar-end {
    align-items: center;
    display: flex;
}
.nav-link-pill,
.nav-dropdown-trigger,
.nav-profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem;
    font-weight: 500;
    font-size: 0.9375rem;
    line-height: 1.25;
    color: rgba(255, 255, 255, 0.9);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 4px;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.nav-link-pill i,
.nav-dropdown-trigger i,
.nav-profile-btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    flex-shrink: 0;
    font-size: 1em;
}
.nav-link-pill:hover,
.nav-dropdown-trigger:hover {
    color: #F7DF1E;
    border-bottom-color: #F7DF1E;
    background: rgba(255, 255, 255, 0.05);
}
.nav-link-pill.active,
.nav-dropdown-trigger.active {
    color: #F7DF1E;
    border-bottom-color: #F7DF1E;
}
.nav-dropdown-trigger { cursor: pointer; }

/* Home dropdown: only on index, show on hover */
.nav-home-dropdown { position: relative; }
.nav-home-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 2px;
    padding-top: 6px;
    min-width: 200px;
    padding: 6px 0;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    list-style: none;
    z-index: 60;
}
.nav-home-dropdown:hover .nav-home-dropdown-menu { display: block; }
.nav-anchor-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
    border-radius: 4px;
}
.nav-anchor-item:hover {
    background: rgba(247, 223, 30, 0.15);
    color: #F7DF1E;
}

.nav-profile-btn {
    border: 1px solid #F7DF1E;
    border-bottom: 1px solid #F7DF1E;
    font-weight: 600;
    color: #F7DF1E;
}
.nav-profile-btn:hover {
    background: #F7DF1E;
    color: #323330;
}

/* ---- Optimizer: floating widget and reload next to title ---- */
.optimizer-floating-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    color: white;
    padding: 14px 16px;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
    border: 1px solid rgba(71, 85, 105, 0.5);
    width: 220px;
    font-family: system-ui, -apple-system, sans-serif;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.optimizer-floating-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(247, 223, 30, 0.15);
}
.optimizer-widget-title {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid rgba(71, 85, 105, 0.6);
    padding-bottom: 8px;
    color: #F7DF1E;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    letter-spacing: 0.02em;
}
.optimizer-widget-rescan {
    background: rgba(71, 85, 105, 0.4);
    border: 1px solid rgba(100, 116, 139, 0.5);
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.optimizer-widget-rescan:hover {
    background: rgba(247, 223, 30, 0.2);
    color: #F7DF1E;
    border-color: rgba(247, 223, 30, 0.4);
}

/* ---- Clock: neon digital panel (time + date) ---- */
.optimizer-clock-wrap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    font-family: 'Fira Code', 'SF Mono', monospace;
    user-select: none;
}
.optimizer-clock-ring {
    width: 152px;
    height: 82px;
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background:
        radial-gradient(circle at 0% 0%, rgba(15, 23, 42, 0.9), #020617 55%),
        radial-gradient(circle at 100% 100%, rgba(15, 23, 42, 0.9), #020617 55%);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.35),
        0 0 14px rgba(15, 23, 42, 0.5);
}
/* Animated gradient overlay for modern vibe */
.optimizer-clock-ring::before {
    content: "";
    position: absolute;
    inset: -50%;
    border-radius: 50%;
    background: conic-gradient(from 0deg at 50% 50%, rgba(247, 223, 30, 0.18), rgba(15, 23, 42, 0.05) 25%, rgba(247, 223, 30, 0.12) 50%, rgba(15, 23, 42, 0.05) 75%, rgba(247, 223, 30, 0.18) 100%);
    animation: clock-gradient-spin 8s linear infinite;
    pointer-events: none;
    z-index: 0;
}
@keyframes clock-gradient-spin {
    to { transform: rotate(360deg); }
}
.optimizer-clock-ring::after {
    z-index: 2;
    content: "";
    position: absolute;
    left: 50%;
    bottom: 10px;
    width: 32px;
    height: 4px;
    margin-left: -16px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(247, 223, 30, 0.2), #F7DF1E, rgba(247, 223, 30, 0.2));
    box-shadow:
        0 0 8px rgba(247, 223, 30, 0.8),
        0 0 14px rgba(15, 23, 42, 1);
}
.optimizer-clock-inner {
    position: absolute;
    inset: 12px 10px 14px 10px;
    border-radius: 10px;
    background: transparent;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 1;
}
.optimizer-clock-date {
    font-size: 11px;
    color: #F7DF1E;
    letter-spacing: 0.3em;
    margin-bottom: 4px;
    text-align: center;
    line-height: 1.2;
    font-weight: 500;
    text-transform: uppercase;
    text-shadow:
        0 0 5px rgba(247, 223, 30, 0.8),
        0 0 12px rgba(15, 23, 42, 1);
}
.optimizer-clock-time {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.06em;
    color: #F7DF1E;
    text-align: center;
    white-space: nowrap;
    text-shadow:
        0 0 8px rgba(247, 223, 30, 0.9),
        0 0 16px rgba(15, 23, 42, 1);
}
/* ---- Mobile: hide widget & clock; show two rounded buttons; clock opens on tap ---- */
.optimizer-mobile-buttons {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.optimizer-mobile-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #0f172a;
    color: #F7DF1E;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border: 2px solid #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: transform 0.2s, background 0.2s;
}
.optimizer-mobile-btn:hover {
    background: #1e293b;
    transform: scale(1.08);
}
.optimizer-mobile-btn:active {
    transform: scale(0.98);
}
@media (max-width: 767px) {
    .optimizer-floating-widget,
    .optimizer-clock-wrap {
        display: none !important;
    }
    .optimizer-mobile-buttons {
        display: flex;
    }
    .optimizer-clock-wrap.optimizer-clock-mobile-open {
        display: flex !important;
        flex-direction: column;
        align-items: flex-end;
        bottom: 90px;
        right: 20px;
    }
}
