<?php
$page_title = 'Home - SOL Christian Academy';
$current_page = 'index.php';
require_once 'includes/db.php';
require_once 'includes/functions.php';

$news = [];
if ($pdo) {
    $stmt = $pdo->query("SELECT id, title, slug, excerpt, image, created_at FROM news WHERE status='published' ORDER BY created_at DESC LIMIT 3");
    $news = $stmt->fetchAll();
}

$gallery = [];
if ($pdo) {
    $stmt = $pdo->query("SELECT id, title, image, alt_text FROM gallery ORDER BY sort_order ASC LIMIT 7");
    $gallery = $stmt->fetchAll();
}

$testimonials = [];
if ($pdo) {
    $stmt = $pdo->query("SELECT id, name, role, content, rating FROM testimonials WHERE is_active=1 ORDER BY created_at DESC");
    $testimonials = $stmt->fetchAll();
}

require_once 'includes/header.php';
?>

<!-- Hero Slider — Fade -->
<section class="hero-slider" id="heroSlider">
  <div class="slide active" style="background-image:url('assets/images/WORK-IN-IT.jpg');">
    <div class="slide-overlay"></div>
    <div class="slide-content">
      <span class="eyebrow">SOL Christian Academy</span>
      <h1 class="display-1">Growing in Knowledge.<br>Following in Faith.<br>Serving In Unity.</h1>
      <p class="slide-desc">An independent, fee-paying, faith school in Greater Manchester. Nurturing academic excellence and Christian values from Nursery through Sixth Form since 1970.</p>
      <div class="slide-actions">
        <a href="admissions.php" class="btn-shell">
          <span class="btn-core">
            Apply Now
            <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
          </span>
        </a>
        <a href="contact.php" class="btn-ghost">
          Book a Visit <i class="ri-arrow-right-up-line"></i>
        </a>
      </div>
    </div>
  </div>

  <div class="slide" style="background-image:url('assets/images/PHOTO-2023-07-18-17-51-07-3.jpg');">
    <div class="slide-overlay"></div>
    <div class="slide-content">
      <span class="eyebrow">Early Years</span>
      <h1 class="display-1">Where Little Minds<br>Begin to Flourish</h1>
      <p class="slide-desc">Our Nursery provides a warm, nurturing environment where children aged 2&ndash;5 develop through play-based learning, early literacy, and Christian values.</p>
      <div class="slide-actions">
        <a href="academics.php" class="btn-shell">
          <span class="btn-core">
            Explore Nursery
            <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
          </span>
        </a>
        <a href="admissions.php" class="btn-ghost">
          Apply Now <i class="ri-arrow-right-up-line"></i>
        </a>
      </div>
    </div>
  </div>

  <div class="slide" style="background-image:url('assets/images/libARY-PHOTO-1.jpg');">
    <div class="slide-overlay"></div>
    <div class="slide-content">
      <span class="eyebrow">Primary School</span>
      <h1 class="display-1">Building Strong Foundations<br>for a Lifetime of Learning</h1>
      <p class="slide-desc">Ages 5&ndash;11. Our primary programme combines the ACE curriculum with character development, creative arts, and a love for discovery in every subject.</p>
      <div class="slide-actions">
        <a href="academics.php" class="btn-shell">
          <span class="btn-core">
            Learn More
            <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
          </span>
        </a>
        <a href="admissions.php" class="btn-ghost">
          Apply Now <i class="ri-arrow-right-up-line"></i>
        </a>
      </div>
    </div>
  </div>

  <div class="slide" style="background-image:url('assets/images/MicrosoftTeams-image-17-1.jpg');">
    <div class="slide-overlay"></div>
    <div class="slide-content">
      <span class="eyebrow">Secondary School</span>
      <h1 class="display-1">Preparing Students<br>for GCSE Success &amp; Beyond</h1>
      <p class="slide-desc">Ages 11&ndash;16. A challenging academic programme with individualised learning pathways, enrichment activities, and strong pastoral care.</p>
      <div class="slide-actions">
        <a href="academics.php" class="btn-shell">
          <span class="btn-core">
            Explore Secondary
            <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
          </span>
        </a>
        <a href="admissions.php" class="btn-ghost">
          Apply Now <i class="ri-arrow-right-up-line"></i>
        </a>
      </div>
    </div>
  </div>

  <div class="slide" style="background-image:url('assets/images/PHOTO-2023-07-18-17-51-14.jpg');">
    <div class="slide-overlay"></div>
    <div class="slide-content">
      <span class="eyebrow">Faith &amp; Values</span>
      <h1 class="display-1">Christ-Centred Education<br>That Shapes Character</h1>
      <p class="slide-desc">At the heart of everything we do is a commitment to Christian values &mdash; building integrity, compassion, and moral responsibility in every student.</p>
      <div class="slide-actions">
        <a href="about.php" class="btn-shell">
          <span class="btn-core">
            Our Mission
            <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
          </span>
        </a>
        <a href="contact.php" class="btn-ghost">
          Visit Us <i class="ri-arrow-right-up-line"></i>
        </a>
      </div>
    </div>
  </div>

  <div class="slide" style="background-image:url('assets/images/ON-COMPUTER.jpg');">
    <div class="slide-overlay"></div>
    <div class="slide-content">
      <span class="eyebrow">Admissions</span>
      <h1 class="display-1">Begin Your Child's<br>Journey With Us Today</h1>
      <p class="slide-desc">Discover the SOL Christian Academy difference. We welcome families who share our vision for academic excellence grounded in faith.</p>
      <div class="slide-actions">
        <a href="admissions.php" class="btn-shell">
          <span class="btn-core">
            Apply Now
            <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
          </span>
        </a>
        <a href="contact.php" class="btn-ghost">
          Book a Visit <i class="ri-arrow-right-up-line"></i>
        </a>
      </div>
    </div>
  </div>

  <button class="slider-arrow prev" aria-label="Previous"><i class="ri-arrow-left-s-line"></i></button>
  <button class="slider-arrow next" aria-label="Next"><i class="ri-arrow-right-s-line"></i></button>
  <div class="slider-dots"></div>
</section>

<!-- Why Choose Us — Asymmetric Bento -->
<section class="section">
  <div class="container">
    <div class="section-header reveal">
      <span class="eyebrow">Why Choose Us</span>
      <h2 class="display-2">A Foundation for Life</h2>
      <p>We provide a nurturing environment where every child can flourish academically, socially, and spiritually through individualised learning and strong Christian values.</p>
    </div>
    <div class="bento">
      <div class="bento-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <div class="icon-ring"><i class="ri-book-open-line"></i></div>
            <h3>Academic Excellence</h3>
            <p>Individualised ACE curriculum with consistently high GCSE pass rates and excellent progression to sixth form and university.</p>
          </div>
        </div>
      </div>
      <div class="bento-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <div class="icon-ring"><i class="ri-heart-line"></i></div>
            <h3>Moral Values</h3>
            <p>Christ-centred education that builds character, integrity, and moral responsibility in every student.</p>
          </div>
        </div>
      </div>
      <div class="bento-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <div class="icon-ring"><i class="ri-building-line"></i></div>
            <h3>Modern Facilities</h3>
            <p>Well-equipped classrooms, science labs, ICT suites, sports facilities, and dedicated creative arts spaces.</p>
          </div>
        </div>
      </div>
      <div class="bento-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <div class="icon-ring"><i class="ri-team-line"></i></div>
            <h3>Experienced Teachers</h3>
            <p>Dedicated, qualified educators who provide personalised attention and support for every child's unique learning journey.</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- School Levels — Editorial Split -->
<section class="section">
  <div class="container">
    <div class="section-header reveal">
      <span class="eyebrow">Our School</span>
      <h2 class="display-2">A Complete Educational Journey</h2>
      <p>From age 2 through to Sixth Form, every stage of learning is thoughtfully designed to nurture curiosity, confidence, and character.</p>
    </div>
    <div class="stages-grid">
      <div class="stage-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <span class="age-badge">Ages 2–5</span>
            <h3>Nursery</h3>
            <p>A warm, stimulating environment where our youngest learners begin their educational journey through play-based learning and early Christian values.</p>
            <a href="academics.php" class="read-more">Learn More <i class="ri-arrow-right-up-line"></i></a>
          </div>
        </div>
      </div>
      <div class="stage-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <span class="age-badge">Ages 5–11</span>
            <h3>Primary School</h3>
            <p>Building strong foundations through the ACE curriculum with a focus on literacy, numeracy, character development, and a love for learning.</p>
            <a href="academics.php" class="read-more">Learn More <i class="ri-arrow-right-up-line"></i></a>
          </div>
        </div>
      </div>
      <div class="stage-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner">
            <span class="age-badge">Ages 11–16</span>
            <h3>Secondary School</h3>
            <p>A challenging academic programme preparing students for GCSEs with individualised learning, enrichment activities, and strong pastoral care.</p>
            <a href="academics.php" class="read-more">Learn More <i class="ri-arrow-right-up-line"></i></a>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- Facilities Gallery -->
<?php if (!empty($gallery)): ?>
<section class="section">
  <div class="container">
    <div class="section-header reveal">
      <span class="eyebrow">Facilities</span>
      <h2 class="display-2">Our Learning Spaces</h2>
      <p>Take a visual tour of our school facilities, classrooms, and environments designed to inspire learning.</p>
    </div>
    <div class="gallery-grid">
      <?php foreach ($gallery as $i => $item): ?>
      <div class="gallery-item reveal" data-index="<?php echo $i; ?>" data-full="<?php e($item['image']); ?>" data-title="<?php e($item['title']); ?>">
        <img src="<?php e($item['image']); ?>" alt="<?php e($item['alt_text'] ?: $item['title']); ?>" loading="lazy">
        <div class="overlay"><?php e($item['title']); ?></div>
      </div>
      <?php endforeach; ?>
    </div>
    <div style="text-align:center;margin-top:2.5rem;" class="reveal">
      <a href="gallery.php" class="btn-ghost">
        View Full Gallery <i class="ri-arrow-right-up-line"></i>
      </a>
    </div>
  </div>
</section>
<?php endif; ?>

<!-- Testimonials -->
<?php if (!empty($testimonials)): ?>
<section class="section">
  <div class="container">
    <div class="section-header reveal">
      <span class="eyebrow">Testimonials</span>
      <h2 class="display-2">What Our Community Says</h2>
      <p>Hear from parents and families about their experience at SOL Christian Academy.</p>
    </div>
    <div class="testimonials-grid">
      <?php foreach ($testimonials as $t): ?>
      <div class="reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner testimonial-card">
            <div class="stars"><?php echo str_repeat('&#9733;', (int)($t['rating'] ?? 5)); ?></div>
            <blockquote>"<?php e($t['content']); ?>"</blockquote>
            <cite>
              <strong><?php e($t['name']); ?></strong>
              <span><?php e($t['role']); ?></span>
            </cite>
          </div>
        </div>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>
<?php endif; ?>

<!-- Latest News -->
<?php if (!empty($news)): ?>
<section class="section">
  <div class="container">
    <div class="section-header reveal">
      <span class="eyebrow">News &amp; Events</span>
      <h2 class="display-2">Latest Updates</h2>
      <p>Stay informed with the latest happenings at SOL Christian Academy.</p>
    </div>
    <div class="news-grid">
      <?php foreach ($news as $item): ?>
      <div class="news-card reveal">
        <div class="bezel" style="height:100%;">
          <div class="bezel-inner" style="padding:0;">
            <?php if ($item['image']): ?>
            <img src="<?php e($item['image']); ?>" alt="<?php e($item['title']); ?>" loading="lazy">
            <?php endif; ?>
            <div class="news-card-body">
              <div class="date"><?php echo date('j M Y', strtotime($item['created_at'])); ?></div>
              <h3><?php e($item['title']); ?></h3>
              <p><?php e(truncate($item['excerpt'] ?: '', 100)); ?></p>
              <a href="news-detail.php?slug=<?php e($item['slug']); ?>" class="read-more">
                Read More <i class="ri-arrow-right-up-line"></i>
              </a>
            </div>
          </div>
        </div>
      </div>
      <?php endforeach; ?>
    </div>
    <div style="text-align:center;margin-top:2.5rem;" class="reveal">
      <a href="news.php" class="btn-ghost">
        View All News <i class="ri-arrow-right-up-line"></i>
      </a>
    </div>
  </div>
</section>
<?php endif; ?>

<!-- CTA — Double-Bezel -->
<section style="padding:clamp(3rem,5vw,5rem) 0;margin:0;">
  <div class="container">
    <div class="cta reveal">
      <div class="bezel" style="background:rgba(255,255,255,0.08);border-color:rgba(255,255,255,0.1);">
        <div class="bezel-inner" style="background:var(--near-black);">
          <span class="eyebrow" style="background:rgba(255,255,255,0.08);color:rgba(255,255,255,0.6);">Admissions</span>
          <h2 class="display-2" style="color:var(--white);">Begin Your Child's Journey With Us</h2>
          <p>Discover how SOL Christian Academy can provide an exceptional education grounded in Christian values.</p>
          <div style="display:flex;flex-wrap:wrap;justify-content:center;gap:0.75rem;">
            <a href="admissions.php" class="btn-shell">
              <span class="btn-core">
                Apply Now
                <span class="icon-ring"><i class="ri-arrow-right-up-line"></i></span>
              </span>
            </a>
            <a href="contact.php" class="btn-ghost">
              Contact Us <i class="ri-arrow-right-up-line"></i>
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- Lightbox Modal -->
<div class="modal-overlay" id="galleryModal">
  <div class="modal-content">
    <div class="modal-header">
      <h5 class="modal-title"></h5>
      <button class="modal-close" aria-label="Close"><i class="ri-close-line"></i></button>
    </div>
    <img src="" alt="">
  </div>
</div>

<?php require_once 'includes/footer.php'; ?>
