<!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;
    }

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

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

    .cust-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) {
      .cust-slide img {
        width: 100%;
        height: auto;
      }
    }

    .nav-button:focus { outline: 2px solid #fff; }
  </style>
</head>
<body>
<section class="slide-msg-mobile">
<div class="slider-container" aria-roledescription="carousel">
  <div class="slider-wrapper" id="sliderWrapper">

    <div class="cust-slide">
      <a href="chairperson" target="_blank" rel="noopener">
        <img src="assets/img/4.png" alt="University of Bedfordshire">
      </a>
    </div>

    <div class="cust-slide">
      <a href="patron_in_chief" target="_blank" rel="noopener">
        <img src="assets/img/1.png" alt="Bournemouth University">
      </a>
    </div>

    <div class="cust-slide">
      <a href="patron_director" target="_blank" rel="noopener">
        <img src="assets/img/3.png" alt="Admissions">
      </a>
    </div>
    
     <div class="cust-slide">
      <a href="secretary" target="_blank" rel="noopener">
        <img src="assets/img/2.png" 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>
</section>
<script>
document.addEventListener("DOMContentLoaded", function () {

  const sliderWrapper = document.getElementById('sliderWrapper');
  const slides = Array.from(document.querySelectorAll('.cust-slide'));
  const totalSlides = slides.length;
  let currentSlide = 0;
  let intervalId = null;

  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 startAutoSlide() {
    stopAutoSlide();
    intervalId = setInterval(nextSlide, 9000);
  }

  function stopAutoSlide() {
    clearInterval(intervalId);
  }

  startAutoSlide();

});
</script>

</body>
</html>
