<?php
// Database connection
$host = "localhost";
$db   = "u843479158_Blogs";
$user = "u843479158_DeveloperX";
$pass = "DeveloperX@334$";

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Fetch all blogs
$sql = "SELECT * FROM blogs ORDER BY publish_date DESC";
$result = $conn->query($sql);

$blogs = [];
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $blogs[] = $row;
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DeveloperX Blogs | AI, Robotics & Tech Insights</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Explore DeveloperX blogs for AI, robotics, software development, digital transformation, and tech innovations in Pakistan.">
<meta name="keywords" content="DeveloperX blogs, Developer X, Developer.X, AI blogs, robotics articles, software development, tech insights Pakistan">
<meta name="author" content="DeveloperX">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://developerx.org/blogs.php">

<!-- Open Graph -->
<meta property="og:title" content="DeveloperX Blogs | AI & Robotics Insights">
<meta property="og:description" content="Read the latest DeveloperX blogs covering AI, robotics, software development, and technology trends.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://developerx.org/blogs.php">
<meta property="og:image" content="https://developerx.org/assets/og-blogs.jpg">

<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="DeveloperX Blogs | AI & Robotics Insights">
<meta name="twitter:description" content="DeveloperX shares expert insights and articles on AI, robotics, and emerging tech.">
<meta name="twitter:image" content="https://developerx.org/assets/og-blogs.jpg">

<!-- Fonts & Icons -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&family=Inter:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<link rel="icon" type="image/png" href="Favicon.jpeg">
<!-- CSS -->
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="footer.css">
<link rel="stylesheet" href="blog.css">

<style>

  :root {
  --primary: #0EA5E9;
  --secondary: #F8FAFC;
  --accent: #0F172A;
  --hero-overlay: rgba(15,23,42,0.85);

  /* FONT SYSTEM */
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--secondary);
  color: var(--accent);
}

.blog-hero {
  position: relative;
  padding: 6rem 2rem;
  color: #fff;
  text-align: center;

  /* Background Image */
  background: linear-gradient(var(--hero-overlay), var(--hero-overlay)),
    url("services\ bg.png");
  background-size: cover;
  background-position: center;
 
  /* Overlay using pseudo-element */
  overflow: hidden;
}

.blog-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--hero-overlay); /* your overlay color */
  z-index: 1;
}

.blog-hero h1,
.blog-hero p {
  position: relative; /* ensure text is above overlay */
  z-index: 2;
  font-family: var(--font-heading);
}

.blog-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.blog-hero p {
  font-family: var(--font-body);
  font-size: 1.1rem;
  max-width: 700px;
  margin: auto;
}


.blog-section { padding:3rem 2rem; }
.blog-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(300px, 1fr)); gap:2rem; }
.blog-card { background:#fff; border-radius:10px; overflow:hidden; box-shadow:0 5px 20px rgba(0,0,0,0.1); cursor:pointer; transition:0.3s; }
.blog-card:hover { transform:translateY(-5px); box-shadow:0 8px 25px rgba(0,0,0,0.15); }
.blog-card img { width:100%; height:200px; object-fit:cover; }
.blog-info { padding:1rem; }
.blog-info h3 { font-family:'Poppins', sans-serif; color:#0EA5E9; margin-bottom:0.5rem; }
.blog-info p { font-family:'Inter', sans-serif; color:#555; font-size:0.95rem; line-height:1.5; }
.blog-info .read-more { color:#0F172A; font-weight:600; margin-top:0.5rem; display:inline-block; }

.blog-modal { display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(15,23,42,0.85); justify-content:center; align-items:center; z-index:1000; }
.blog-modal .modal-box { background:#fff; border-radius:10px; max-width:800px; width:90%; padding:2rem; position:relative; max-height:90%; overflow-y:auto; }
.blog-modal .close-modal { position:absolute; top:1rem; right:1rem; font-size:1.5rem; cursor:pointer; }
.blog-modal img { width:100%; max-height:400px; object-fit:cover; margin-bottom:1rem; }
.blog-modal h2 { font-family:'Poppins', sans-serif; color:#0EA5E9; margin-bottom:0.5rem; }
.blog-modal p { font-family:'Inter', sans-serif; color:#555; line-height:1.6; }


/* ================= FOOTER ================= */
.footer {
  background: var(--accent);
  color: #CBD5E1;
  padding: 80px 0 0;
  padding-left: 10px;

}

/* GRID */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: 48px;
}

/* ================= BRAND ================= */
.footer-brand p {
  font-size: 15px;
  line-height: 1.7;
  max-width: 420px;
  padding-left: 8px;

}

/* LOGO */
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-left: 8px; /* left spacing */
}

.logo-img {
  width: 70px;
  height: 70px;
  object-fit: contain;
}


/* ================= LINKS ================= */
.footer-links h4,
.footer-contact h4 {
  font-size: 18px;
  font-family: var(--font-heading);
  margin-bottom: 18px;
  color: #ffffff;
}

.footer-links ul {
  list-style: none;
}

.footer-links li {
  margin-bottom: 10px;
  font-size: 15px;
}

.footer-links a {
  color: #CBD5E1;
  text-decoration: none;
  transition: 0.3s ease;
}

.footer-links a:hover {
  color: var(--primary);
  padding-left: 4px;
}

/* ================= CONTACT ================= */
.footer-contact p {
  font-size: 15px;
  margin-bottom: 10px;
}

.footer-contact a {
  color: #CBD5E1;
  text-decoration: none;
}

/* SOCIALS */
.footer-socials {
  margin-top: 18px;
}

.footer-socials a {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: #ffffff;
  margin-right: 10px;
  transition: 0.3s ease;
}

.footer-socials a:hover {
  background: var(--primary);
  transform: translateY(-2px);
}

/* ================= BOTTOM BAR ================= */
.footer-bottom {
  margin-top: 60px;
  padding: 18px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}

.footer-bottom p {
  font-size: 14px;
  color: #94A3B8;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
  }
}

@media (max-width: 600px) {
  .footer {
    text-align: center;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .logo {
    justify-content: center;
    padding-left: 0;
  }

  .footer-socials {
    justify-content: center;
  }
}



</style>
</head>
<body>

<!-- ===== HEADER ===== -->
<header class="header">
  <div class="nav-container">

    <!-- Logo -->
 <div class="logo">
  <a href="index.html">
    <img src="X logo.png" alt="DeveloperX Icon" class="logo-icon">
  </a>
</div>



    <!-- Hamburger -->
    <div class="menu-toggle" id="menuToggle">
      <span></span>
      <span></span>
      <span></span>
    </div>

   <nav class="nav" id="navMenu">
  <!-- Home with dropdown -->
  <div class="nav-item">
    <a href="index.html">Home</a>
    
  </div>

  <!-- About with dropdown -->
  <div class="nav-item">
    <a href="about.html">About</a>
    
  </div>

  <!-- Services with dropdown -->
  <div class="nav-item">
    <a href="services.html">Services</a>
   
  </div>

  <!-- Other links without dropdown -->
  <a href="portfolio.html">Portfolio</a>
  <a href="blogs.php">Blog</a>
  <a href="contact-us.html">Get a Quote</a>
  
</nav>
</header>


<!-- ===== BLOG HERO ===== -->
<section class="blog-hero">
  <h1>DeveloperX Blog</h1>
  <p>Latest articles and insights on AI, robotics, software development, and tech innovations in Pakistan by DeveloperX.</p>
</section>

<!-- ===== BLOG GRID ===== -->
<section class="blog-section">
  <div class="container">
    <div class="blog-grid">
      <?php foreach($blogs as $b): ?>
        <div class="blog-card" 
             data-img="<?php echo htmlspecialchars($b['image'], ENT_QUOTES); ?>" 
             data-title="<?php echo htmlspecialchars($b['title'], ENT_QUOTES); ?>" 
             data-content="<?php echo htmlspecialchars($b['content'], ENT_QUOTES); ?>">
          <img src="uploads/blogs/<?php echo $b['image']; ?>" alt="<?php echo htmlspecialchars($b['title']); ?>">
          <div class="blog-info">
            <h3><?php echo htmlspecialchars($b['title']); ?></h3>
            <p>
              <?php 
                // Show only 120 characters for excerpt in card
                echo htmlspecialchars(substr($b['content'],0,120)) . '...'; 
              ?>
            </p>
            <span class="read-more">View Details →</span>
          </div>
        </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- ===== BLOG MODAL ===== -->
<div id="modal" class="blog-modal">
  <div class="modal-box">
    <span class="close-modal" onclick="closeModal()">×</span>
    <img id="modalImg">
    <h2 id="modalTitle"></h2>
    <p id="modalContent"></p>
  </div>
</div>




<footer class="footer">
  <div class="container footer-grid">

   <div class="footer-brand">
  <div class="logo">
    <img src="logo.png" alt="DeveloperX Logo" class="logo-img">
    
  </div>

  <p>
    DeveloperX is a full-service digital agency delivering
    high-performance web, mobile, and marketing solutions
    for startups and enterprises worldwide.
  </p>
</div>


    <!-- QUICK LINKS -->
    <div class="footer-links">
      <h4>Quick Links</h4>
      <ul>
        <li><a href="about.html">About Us</a></li>
        <li><a href="services.html">Services</a></li>
        <li><a href="portfolio.html">Portfolio</a></li>
        <li><a href="career.html">Career</a></li>
        <li><a href="contact-us.html">Contact Us</a></li>
      </ul>
    </div>

    <!-- SERVICES -->
    <div class="footer-links">
      <h4>Our Services</h4>
      <ul>
        <li>Web Development</li>
        <li>Mobile App Development</li>
        <li>UI/UX & Graphic Design</li>
        <li>Digital Marketing & SEO</li>
        <li>AI Automation & Robotics</li>
      </ul>
    </div>

    <!-- CONTACT -->
    <div class="footer-contact">
      <h4>Contact</h4>
      <p>Email: <a href="mailto:contact@developerx.org">contact@developerx.org</a></p>
      <p>Phone: +92 319 541 4024</p>
      <p>Location: Islamabad Pakistan</p>

      <div class="footer-socials">
  <a href="https://www.facebook.com/share/1MQr4uUEpF/" target="_blank" aria-label="Facebook">
    <i class="fab fa-facebook-f"></i>
  </a>

  <a href="https://www.linkedin.com/company/developerxtech/" target="_blank" aria-label="LinkedIn">
    <i class="fab fa-linkedin-in"></i>
  </a>

  <a href="https://www.instagram.com/developer.x334" target="_blank" aria-label="Instagram">
    <i class="fab fa-instagram"></i>
  </a>

  <a href="https://whatsapp.com/channel/0029VbAnFbD2P59rDEQu6B17" target="_blank" aria-label="WhatsApp Channel">
    <i class="fab fa-whatsapp"></i>
  </a>
</div>

    </div>

  </div>

  <!-- COPYRIGHT -->
  <div class="footer-bottom">
    <p>© 2026 DeveloperX. All Rights Reserved.</p>
  </div>
</footer>
<div class="scroll-indicator"></div>

<script src="script.js"></script>

<!-- ===== JS ===== -->
<script>
// Get all blog cards
const blogCards = document.querySelectorAll('.blog-card');

blogCards.forEach(card => {
  card.addEventListener('click', () => {
    const img = card.getAttribute('data-img');
    const title = card.getAttribute('data-title');
    const content = card.getAttribute('data-content');

    openModal(img, title, content);
  });
});

function openModal(img, title, content){
  const modal = document.getElementById("modal");
  modal.style.display = "flex";
  document.body.style.overflow = "hidden";

  document.getElementById("modalImg").src = "uploads/blogs/" + img;
  document.getElementById("modalTitle").innerText = title;
  document.getElementById("modalContent").innerHTML = content; // full blog content
}

function closeModal(){
  const modal = document.getElementById("modal");
  modal.style.display = "none";
  document.body.style.overflow = "auto";
}

// Optional: close modal when clicking outside modal box
window.addEventListener('click', function(e){
  const modal = document.getElementById('modal');
  if(e.target === modal){
    closeModal();
  }
});
</script>

</body>
</html>
