<?php
/**
 * Plugin Name: Bilal Custom Styles
 * Description: Custom professional styling and footer for Bilal Taha's portfolio.
 */

add_action('wp_head', function() {
    echo '
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=Poppins:wght@400;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <style>
        :root {
            --primary-accent: #3b82f6;
            --secondary-accent: #10b981;
            --bg-neutral: #f8fafc;
            --text-dark: #1e293b;
            --text-light: #64748b;
            --card-bg: rgba(255, 255, 255, 0.7);
            --border-color: rgba(255, 255, 255, 0.3);
            --footer-bg: white;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        [data-theme="dark"] {
            --bg-neutral: #0f172a;
            --text-dark: #f1f5f9;
            --text-light: #94a3b8;
            --card-bg: rgba(30, 41, 59, 0.7);
            --border-color: rgba(255, 255, 255, 0.1);
            --footer-bg: #1e293b;
        }

        body {
            font-family: "Inter", sans-serif;
            background-color: var(--bg-neutral);
            color: var(--text-dark);
            line-height: 1.6;
            transition: background-color 0.3s ease, color 0.3s ease;
        }

        h1, h2, h3, h4 {
            font-family: "Poppins", sans-serif;
            font-weight: 700;
            color: var(--text-dark);
        }

        .wp-block-group {
            padding: 2rem 0;
        }

        /* Hero Section Styling */
        .hero-section h1 {
            background: linear-gradient(90deg, var(--primary-accent), var(--secondary-accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-size: 3.5rem !important;
            margin-bottom: 1rem;
        }

        /* Button Styling */
        .wp-block-button__link {
            border-radius: 12px !important;
            padding: 12px 24px !important;
            font-weight: 600 !important;
            transition: transform 0.2s ease, box-shadow 0.2s ease !important;
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1) !important;
        }

        .wp-block-button__link:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;
        }

        /* Card / Glassmorphism */
        .project-card, .skill-card {
            background: var(--card-bg);
            backdrop-filter: blur(10px);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            padding: 24px;
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
            transition: var(--transition);
        }

        .project-card:hover, .skill-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
        }

        .skill-card i {
            font-size: 2.5rem;
            margin-bottom: 1rem;
            color: var(--primary-accent);
        }

        footer.site-footer {
            margin-top: 80px;
            padding: 40px 0;
            background: var(--footer-bg);
            border-top: 1px solid var(--border-color);
            text-align: center;
            color: var(--text-light);
        }

        /* Theme Toggle */
        .theme-toggle {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 1000;
            background: var(--primary-accent);
            color: white;
            border: none;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            cursor: pointer;
            box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            transition: var(--transition);
        }

        .theme-toggle:hover {
            transform: scale(1.1);
        }

        /* Reveal Animation */
        .reveal {
            opacity: 0;
            transform: translateY(30px);
            transition: all 0.8s ease-out;
        }

        .reveal.active {
            opacity: 1;
            transform: translateY(0);
        }

        /* Back to Top Button */
        .back-to-top {
            position: fixed;
            bottom: 80px;
            right: 20px;
            z-index: 1000;
            background: var(--footer-bg);
            color: var(--primary-accent);
            border: 1px solid var(--border-color);
            border-radius: 50%;
            width: 50px;
            height: 50px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            transition: var(--transition);
            opacity: 0;
            visibility: hidden;
            box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
        }

        .back-to-top.show {
            opacity: 1;
            visibility: visible;
        }

        .back-to-top:hover {
            background: var(--primary-accent);
            color: white;
            transform: translateY(-5px);
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .hero-section h1 {
                font-size: 2.5rem !important;
            }
        }
    </style>';
});

add_action('wp_footer', function() {
    echo '
    <button class="theme-toggle" id="theme-toggle" title="Toggle Dark/Light Mode">
        <i class="fas fa-moon"></i>
    </button>
    <button class="back-to-top" id="back-to-top" title="Back to Top">
        <i class="fas fa-arrow-up"></i>
    </button>
    <footer class="site-footer">
        <div class="wp-block-group">
            <p>&copy; ' . date('Y') . ' Bilal Taha. Software Engineer | Innovator | Problem Solver.</p>
        </div>
    </footer>
    <script>
        // Dark Mode Toggle
        const toggleBtn = document.getElementById("theme-toggle");
        const backToTopBtn = document.getElementById("back-to-top");
        const body = document.body;
        const icon = toggleBtn.querySelector("i");

        const currentTheme = localStorage.getItem("theme");
        if (currentTheme) {
            document.documentElement.setAttribute("data-theme", currentTheme);
            if (currentTheme === "dark") {
                icon.classList.replace("fa-moon", "fa-sun");
            }
        }

        toggleBtn.addEventListener("click", () => {
            let theme = document.documentElement.getAttribute("data-theme");
            if (theme === "dark") {
                document.documentElement.setAttribute("data-theme", "light");
                localStorage.setItem("theme", "light");
                icon.classList.replace("fa-sun", "fa-moon");
            } else {
                document.documentElement.setAttribute("data-theme", "dark");
                localStorage.setItem("theme", "dark");
                icon.classList.replace("fa-moon", "fa-sun");
            }
        });

        // Back to Top Logic
        window.addEventListener("scroll", () => {
            if (window.scrollY > 300) {
                backToTopBtn.classList.add("show");
            } else {
                backToTopBtn.classList.remove("show");
            }
        });

        backToTopBtn.addEventListener("click", () => {
            window.scrollTo({ top: 0, behavior: "smooth" });
        });

        // Scroll Reveal
        function reveal() {
            var reveals = document.querySelectorAll(".reveal");
            for (var i = 0; i < reveals.length; i++) {
                var windowHeight = window.innerHeight;
                var elementTop = reveals[i].getBoundingClientRect().top;
                var elementVisible = 150;
                if (elementTop < windowHeight - elementVisible) {
                    reveals[i].classList.add("active");
                }
            }
        }
        window.addEventListener("scroll", reveal);
        reveal(); // Initial check
    </script>';
}, 100);
