/**
 * Nexus AI — Premium Features CSS
 * Module 10: GSAP animations, grain texture, glitch, WhatsApp float, cookie bar,
 *             magnetic buttons, page-transition loader, dark/light toggle, print styles
 */

/* ============================================================
   GRAIN / NOISE TEXTURE OVERLAY
   ============================================================ */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    opacity: 0.025;
    mix-blend-mode: overlay;
}

/* ============================================================
   PAGE TRANSITION LOADER
   ============================================================ */
.page-transition {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary, #050811);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.page-transition.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.page-transition__logo {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary, linear-gradient(135deg, #6c63ff, #00d4ff));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: ptLogoBreath 1.2s ease-in-out infinite;
}

.page-transition__bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--gradient-primary, linear-gradient(90deg, #6c63ff, #00d4ff));
    box-shadow: 0 0 12px rgba(108, 99, 255, 0.8);
    transition: width 0.5s ease;
}

@keyframes ptLogoBreath {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(0.97); }
}

/* ============================================================
   GLITCH TEXT EFFECT
   ============================================================ */
.glitch {
    position: relative;
    display: inline-block;
}

.glitch::before,
.glitch::after {
    content: attr(data-glitch);
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: transparent;
    clip-path: inset(0);
}

.glitch::before {
    color: var(--color-neon-secondary, #00d4ff);
    text-shadow: -2px 0 var(--color-neon-secondary, #00d4ff);
    animation: glitch-before 3.5s infinite linear;
    left: 2px;
}

.glitch::after {
    color: var(--color-neon-accent, #ff2d78);
    text-shadow: 2px 0 var(--color-neon-accent, #ff2d78);
    animation: glitch-after 3.5s infinite linear;
    left: -2px;
}

@keyframes glitch-before {
    0%,  90%, 100% { clip-path: inset(50% 0 50% 0); transform: translateX(0); }
    91%             { clip-path: inset(10% 0 80% 0); transform: translateX(-3px); }
    92%             { clip-path: inset(60% 0 20% 0); transform: translateX(3px); }
    93%             { clip-path: inset(30% 0 55% 0); transform: translateX(-2px); }
    94%             { clip-path: inset(75% 0 10% 0); transform: translateX(2px); }
    95%             { clip-path: inset(50% 0 50% 0); transform: translateX(0); }
}

@keyframes glitch-after {
    0%,  88%, 100% { clip-path: inset(50% 0 50% 0); transform: translateX(0); }
    89%             { clip-path: inset(20% 0 70% 0); transform: translateX(3px); }
    90%             { clip-path: inset(65% 0 15% 0); transform: translateX(-3px); }
    91%             { clip-path: inset(40% 0 45% 0); transform: translateX(2px); }
    92%             { clip-path: inset(80% 0 5%  0); transform: translateX(-2px); }
    93%             { clip-path: inset(50% 0 50% 0); transform: translateX(0); }
}

/* ============================================================
   MAGNETIC BUTTON
   ============================================================ */
.btn-magnetic {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform;
}

.btn-magnetic::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: inherit;
    /* invisible hit area enlarger */
}

/* ============================================================
   FLOATING WHATSAPP BUTTON
   ============================================================ */
.whatsapp-float {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
}

.whatsapp-float__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25d366;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.45);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.whatsapp-float__icon::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(37, 211, 102, 0.4);
    animation: whatsappPulse 2s ease-out infinite;
}

.whatsapp-float__label {
    background: rgba(37, 211, 102, 0.1);
    border: 1px solid rgba(37, 211, 102, 0.3);
    backdrop-filter: blur(12px);
    color: #2bde6c;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.whatsapp-float:hover .whatsapp-float__icon {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.6);
}

.whatsapp-float:hover .whatsapp-float__label {
    opacity: 1;
    transform: translateX(0);
}

@keyframes whatsappPulse {
    0%   { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* ============================================================
   COOKIE CONSENT BAR
   ============================================================ */
.cookie-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99998;
    padding: 16px 24px;
    background: rgba(8, 13, 26, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(108, 99, 255, 0.25);
    transform: translateY(100%);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -4px 40px rgba(108, 99, 255, 0.12);
}

.cookie-bar.is-visible {
    transform: translateY(0);
}

.cookie-bar__inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-bar__icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(108, 99, 255, 0.5));
}

.cookie-bar__text {
    flex: 1;
    min-width: 220px;
    font-size: 0.875rem;
    color: var(--color-text-muted, #8892b0);
    line-height: 1.6;
}

.cookie-bar__text a {
    color: var(--color-neon-primary, #6c63ff);
    text-decoration: underline;
}

.cookie-bar__actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.cookie-bar__accept {
    padding: 9px 22px;
    border-radius: 8px;
    border: none;
    background: var(--gradient-primary, linear-gradient(135deg, #6c63ff, #00d4ff));
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-family: inherit;
}

.cookie-bar__accept:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.cookie-bar__decline {
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: var(--color-text-muted, #8892b0);
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    font-family: inherit;
}

.cookie-bar__decline:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   DARK / LIGHT MODE TOGGLE
   ============================================================ */
.theme-toggle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 9980;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-toggle__btn {
    width: 38px;
    height: 38px;
    border-radius: 8px 0 0 8px;
    background: rgba(14, 22, 44, 0.9);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-right: none;
    color: var(--color-text-muted, #8892b0);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    backdrop-filter: blur(12px);
}

.theme-toggle__btn:hover {
    color: var(--color-neon-primary, #6c63ff);
    border-color: rgba(108, 99, 255, 0.4);
    background: rgba(108, 99, 255, 0.1);
}

/* Light mode overrides */
body.light-mode {
    --color-bg-primary:    #f0f2f8;
    --color-bg-secondary:  #e4e8f0;
    --color-bg-card:       #ffffff;
    --color-text-primary:  #0a0e1a;
    --color-text-secondary:#2d3561;
    --color-text-muted:    #64748b;
    --color-border:        rgba(0, 0, 0, 0.1);
}

body.light-mode .glass-card {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .footer {
    background: #1a1f35;
}

body.light-mode header,
body.light-mode .navbar {
    background: rgba(240, 242, 248, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

/* ============================================================
   GSAP / SCROLL ANIMATION HELPERS
   ============================================================ */

/* Elements that will be animated by GSAP — initial hidden state */
[data-gsap="fade-up"] {
    opacity: 0;
    transform: translateY(40px);
}

[data-gsap="fade-left"] {
    opacity: 0;
    transform: translateX(40px);
}

[data-gsap="fade-right"] {
    opacity: 0;
    transform: translateX(-40px);
}

[data-gsap="scale-in"] {
    opacity: 0;
    transform: scale(0.9);
}

[data-gsap="stagger-children"] > * {
    opacity: 0;
    transform: translateY(30px);
}

/* Split text chars */
.split-char {
    display: inline-block;
}

/* Highlight line that sweeps under section headings */
.gsap-underline {
    position: relative;
}

.gsap-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary, linear-gradient(90deg, #6c63ff, #00d4ff));
    transform: scaleX(0);
    transform-origin: left;
    border-radius: 2px;
}

/* Scroll-triggered counter */
[data-gsap-counter] {
    display: inline-block;
}

/* Parallax wrapper */
.gsap-parallax {
    will-change: transform;
}

/* Reveal mask */
.gsap-reveal {
    clip-path: inset(0 100% 0 0);
}

/* ============================================================
   SECTION SCROLL REVEAL STATES (fallback if GSAP disabled)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    [data-gsap],
    [data-gsap] > *,
    .glitch::before,
    .glitch::after,
    .whatsapp-float__icon::before {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
        clip-path: none !important;
    }
}

/* ============================================================
   PRINT STYLESHEET
   ============================================================ */
@media print {
    /* Hide decorative & interactive elements */
    .navbar,
    .footer,
    .back-to-top,
    .custom-cursor,
    .whatsapp-float,
    .cookie-bar,
    .theme-toggle,
    .page-transition,
    .reading-progress,
    .particles-js-canvas-el,
    .hero__particles,
    .hero__orb,
    .neon-glow,
    .footer__glow,
    [data-particles],
    button:not(.print-show),
    .btn-primary,
    .btn-secondary,
    #backToTop,
    .blog-share,
    .post-navigation,
    .related-posts,
    .sidebar,
    .comment-respond,
    .wpadminbar,
    body::before,
    body::after {
        display: none !important;
    }

    /* Page setup */
    @page {
        margin: 20mm 15mm;
        size: A4;
    }

    body {
        background: #fff !important;
        color: #111 !important;
        font-size: 11pt;
        line-height: 1.6;
        font-family: 'Cairo', Arial, sans-serif;
    }

    /* Links */
    a {
        color: #111 !important;
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #555;
    }

    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: '';
    }

    /* Typography */
    h1, h2, h3, h4, h5, h6 {
        color: #111 !important;
        page-break-after: avoid;
    }

    p, blockquote, ul, ol {
        orphans: 3;
        widows: 3;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    /* Cards & glass */
    .glass-card {
        background: #f9f9f9 !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }

    /* Main content full width */
    .site-main,
    .container,
    .entry-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Blog single */
    .single-post__layout {
        display: block !important;
    }

    .author-box {
        border: 1px solid #ddd !important;
        background: #f9f9f9 !important;
    }
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS FOR NEW ELEMENTS
   ============================================================ */
@media (max-width: 768px) {
    .whatsapp-float {
        bottom: 20px;
        left: 16px;
    }

    .whatsapp-float__icon {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }

    .whatsapp-float__label {
        display: none; /* Too tight on mobile; icon alone is sufficient */
    }

    .cookie-bar__inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .cookie-bar__actions {
        width: 100%;
    }

    .cookie-bar__accept,
    .cookie-bar__decline {
        flex: 1;
        text-align: center;
    }

    .theme-toggle {
        top: auto;
        bottom: 90px;
        right: 0;
    }
}
