<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Image Slider</title>
  <style>
    .slider-container {
      position: relative;
      width: 100%;
      max-width: 977px;
      margin: auto;
      overflow: hidden;
      border-radius: 10px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
      background: #000; /* background visible if image smaller */
    }

    .slider-wrapper {
      display: flex;
      transition: transform 0.6s ease-in-out;
      will-change: transform;
    }

    .slide {
      flex: 0 0 100%;
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .slide a {
      display: block;
      width: 100%;
    }

    .slide img {
      display: block;
      width: 100%;
      height: auto; /* ✅ makes height adjust automatically */
      object-fit: contain; /* shows full image, no cutting */
    }

    .nav-button {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      background: rgba(0, 0, 0, 0.6);
      color: white;
      border: none;
      padding: 12px;
      cursor: pointer;
      font-size: 18px;
      z-index: 10;
      border-radius: 50%;
      line-height: 1;
    }

    .prev { left: 10px; }
    .next { right: 10px; }

    @media (max-width: 768px) {
      .slide img {
        width: 100%;
        height: auto;
      }
    }

    .nav-button:focus { outline: 2px solid #fff; }
  </style>
</head>
<body>

<div class="slider-container" aria-roledescription="carousel">
  <div class="slider-wrapper" id="sliderWrapper">

    <div class="slide">
      <a href="https://fui.edu.pk/university-bedfordshire" target="_blank" rel="noopener">
        <img src="1.jpeg" alt="University of Bedfordshire">
      </a>
    </div>

    <div class="slide">
      <a href="https://fui.edu.pk/bournemouth-university" target="_blank" rel="noopener">
        <img src="2.jpeg" alt="Bournemouth University">
      </a>
    </div>

    <div class="slide">
      <a href="https://fui.edu.pk/admissions" target="_blank" rel="noopener">
        <img src="3.jpeg" alt="Admissions">
      </a>
    </div>
    
     <div class="slide">
      <a href="https://fui.edu.pk/admissions" target="_blank" rel="noopener">
        <img src="4.jpeg" alt="Admissions">
      </a>
    </div>
    
     <div class="slide">
      <a href="https://fui.edu.pk/admissions" target="_blank" rel="noopener">
        <img src="5.jpeg" alt="Admissions">
      </a>
    </div>
    
     <div class="slide">
      <a href="https://fui.edu.pk/admissions" target="_blank" rel="noopener">
        <img src="6.jpeg" alt="Admissions">
      </a>
    </div>
    
  </div>

  <button class="nav-button prev" aria-label="Previous slide" onclick="prevSlide()">❮</button>
  <button class="nav-button next" aria-label="Next slide" onclick="nextSlide()">❯</button>
</div>

<script>
  <script>
document.addEventListener('DOMContentLoaded', function () {

  const sliderWrapper = document.getElementById('sliderWrapper');
  const slides = document.querySelectorAll('.slide');
  const totalSlides = slides.length;

  let currentSlide = 0;
  let intervalId;

  function updateSlider() {
    sliderWrapper.style.transform = `translateX(-${currentSlide * 100}%)`;
  }

  window.nextSlide = function () {
    currentSlide = (currentSlide + 1) % totalSlides;
    updateSlider();
  }

  window.prevSlide = function () {
    currentSlide = (currentSlide - 1 + totalSlides) % totalSlides;
    updateSlider();
  }

  function startAuto() {
    intervalId = setInterval(window.nextSlide, 5000);
  }

  function stopAuto() {
    clearInterval(intervalId);
  }

  startAuto();

  const container = document.querySelector('.slider-container');

  if (container) {
    container.addEventListener('mouseenter', stopAuto);
    container.addEventListener('mouseleave', startAuto);
  }

});
</script>
</script>

</body>
</html>
