<?php
/**
 * albrecht-soil-analysis.php
 *
 * Public marketing/landing page for Albrecht Soil Analysis service.
 * No authentication required.
 */

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$pageTitle   = 'Albrecht Soil Analysis';
$pageIntro   = 'Crop Monitor uses the Albrecht Method to balance your soil for maximum production.';
$pageDesc    = 'Comprehensive soil analysis reports for Australian conditions.';
$siteName    = 'Crop Monitor';

$h = fn($v) => htmlspecialchars((string) $v, ENT_QUOTES, 'UTF-8');

// Handle newsletter subscription (stub — configure MailChimp API separately)
$newsletterSuccess = false;
$newsletterError   = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['newsletter-submit'])) {
    $nEmail = filter_var(trim($_POST['email'] ?? ''), FILTER_VALIDATE_EMAIL);
    $nName  = trim($_POST['name'] ?? '');
    if ($nEmail && $nName) {
        // TODO: integrate MailChimp API or SMTP
        $newsletterSuccess = true;
    } else {
        $newsletterError = 'Please provide a valid name and email address.';
    }
}

// Handle contact form (stub — configure SMTP separately)
$contactSuccess = false;
$contactError   = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['enquiry-submit'])) {
    $cEmail = filter_var(trim($_POST['email'] ?? ''), FILTER_VALIDATE_EMAIL);
    $cName  = trim($_POST['name'] ?? '');
    $cText  = trim($_POST['text'] ?? '');
    if ($cEmail && $cName && $cText) {
        // TODO: send via PHPMailer/SMTP to enquiries@cropmonitor.info
        $contactSuccess = true;
    } else {
        $contactError = 'Please fill in all fields with a valid email address.';
    }
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="keywords" content="<?= $h($pageIntro) ?>">
    <meta name="description" content="<?= $h($pageDesc) ?>">
    <title><?= $h($pageTitle) ?> | <?= $h($siteName) ?></title>
    <link rel="icon" href="/client-assets/images/favicon.ico?v=2" type="image/x-icon">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.css" crossorigin="anonymous" rel="stylesheet">
    <link rel="stylesheet" href="/client-assets/css/greyscale.css">
    <style>
        .carousel-item {
            height: 65vh;
            min-height: 250px;
            background: no-repeat center center scroll;
            background-size: cover;
        }
        .nav-link { text-align: center; font-weight: bold; }
        .slideOne   { background-image: linear-gradient(rgba(0,0,0,.25),rgba(0,0,0,.25)), url('/client-assets/FredTemplate/images/g6.jpg'); background-size: cover; }
        .slideTwo   { background-image: linear-gradient(rgba(0,0,0,.25),rgba(0,0,0,.25)), url('/client-assets/FredTemplate/images/g7.jpg'); background-size: cover; }
        .slideThree { background-image: linear-gradient(rgba(0,0,0,.25),rgba(0,0,0,.25)), url('/client-assets/FredTemplate/images/g3.jpg'); background-size: cover; }
    </style>
</head>
<body>

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="mainNav">
    <div class="container">
        <a class="navbar-brand js-scroll-trigger" href="#">
            <img src="/client-assets/images/favicon.ico" width="30" height="30" class="d-inline-block align-top" alt="">
            Crop Monitor
        </a>

        <button class="navbar-toggler" type="button"
                data-bs-toggle="collapse" data-bs-target="#navbarResponsive"
                aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarResponsive">
            <form class="d-none d-md-block mx-auto">
                <button class="btn btn-sm btn-outline-success" type="button">
                    Try <?= $h($pageTitle) ?> Free
                </button>
            </form>
            <ul class="navbar-nav ms-auto">
                <li class="nav-item"><a class="nav-link" href="#about">About</a></li>
                <li class="nav-item"><a class="nav-link" href="#blog">Blog</a></li>
                <li class="nav-item"><a class="nav-link" href="#contact">Contact Us</a></li>
                <li class="nav-item"><a class="nav-link" href="/login/login.php">Login</a></li>
                <li class="nav-item"><a class="nav-link text-dark" href="#"><i class="fab fa-facebook-f"></i></a></li>
                <li class="nav-item"><a class="nav-link text-dark" href="#"><i class="fab fa-twitter"></i></a></li>
                <li class="nav-item"><a class="nav-link text-dark" href="#"><i class="fab fa-instagram"></i></a></li>
            </ul>
        </div>
    </div>
</nav>

<!-- Hero Carousel -->
<header>
    <div id="carouselLandingPage" class="carousel slide" data-bs-ride="carousel">
        <div class="carousel-indicators">
            <button type="button" data-bs-target="#carouselLandingPage" data-bs-slide-to="0" class="active" aria-current="true"></button>
            <button type="button" data-bs-target="#carouselLandingPage" data-bs-slide-to="1"></button>
            <button type="button" data-bs-target="#carouselLandingPage" data-bs-slide-to="2"></button>
        </div>
        <div class="carousel-inner">
            <div class="carousel-item active slideOne">
                <div class="carousel-caption text-start">
                    <div class="row">
                        <div class="col-md-9">
                            <h2 class="fw-bold"><?= $h($pageTitle) ?></h2>
                            <p class="lead col-12 col-md-6"><?= $h($pageIntro) ?></p>
                            <p class="col-12 col-md-6 fst-italic d-none d-md-block"><?= $h($pageDesc) ?></p>
                            <a href="#signup" class="btn btn-outline-success">Get a Free Soil Report now!</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="carousel-item slideTwo">
                <div class="carousel-caption text-start">
                    <div class="row">
                        <div class="col-md-8">
                            <h2 class="fw-bold">Balanced Soil, Better Yields</h2>
                            <p class="lead col-12 col-md-6">Correct cation balance improves soil chemistry and physical structure.</p>
                            <a href="#signup" class="btn btn-outline-success">Get a Free Soil Report now!</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="carousel-item slideThree">
                <div class="carousel-caption text-start">
                    <div class="row">
                        <div class="col-md-8">
                            <h2 class="fw-bold">Feed the Soil, Feed the Plant</h2>
                            <p class="lead col-12 col-md-6">Real-time monitoring for Australian conditions.</p>
                            <a href="#signup" class="btn btn-outline-success">Get a Free Soil Report now!</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <button class="carousel-control-prev" type="button" data-bs-target="#carouselLandingPage" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Previous</span>
        </button>
        <button class="carousel-control-next" type="button" data-bs-target="#carouselLandingPage" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="visually-hidden">Next</span>
        </button>
    </div>
</header>

<!-- About Section -->
<section id="about" class="py-5">
    <div class="container">
        <h2 class="text-success">Albrecht Soil Analysis</h2>
        <hr>
        <blockquote class="blockquote text-center">
            <p class="mb-0">The soil is the '<i>creative material</i>' of most of the basic needs of life. Creation starts with a handful of dust.</p>
            <footer class="blockquote-footer">Dr. William A. Albrecht. <cite>University of Missouri</cite></footer>
        </blockquote>
        <hr>
        <div class="row row-cols-1 row-cols-md-3 g-4">
            <div class="col">
                <div class="card border-success text-center h-100">
                    <div class="card-body">
                        <h2 class="card-title">Physical</h2>
                        <i class="fas fa-atom fa-3x mb-2"></i>
                        <p class="card-text">When you correct cation balance, you have addressed soil chemistry, which improves the physical structure of the soil.</p>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card border-success text-center h-100">
                    <div class="card-body">
                        <h2 class="card-title">Chemical</h2>
                        <i class="fas fa-flask fa-3x mb-2"></i>
                        <p class="card-text">The correction of cation balance and the provision of minimum levels of micronutrients takes care of the chemical part of soil productivity and health.</p>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card border-success text-center h-100">
                    <div class="card-body">
                        <h2 class="card-title">Biological</h2>
                        <i class="fas fa-bug fa-3x mb-2"></i>
                        <p class="card-text">The essential understanding involves a recognition that the purpose of cation balancing is to stimulate soil biology, and much of the beneficial response relates to firing up this workforce.</p>
                    </div>
                </div>
            </div>
        </div>
        <hr>
    </div>
</section>

<!-- Services Section -->
<section id="services" class="projects-section bg-light pt-2">
    <div class="container py-4">
        <h3 class="text-center mb-4">Our Services</h3>
        <div class="row row-cols-1 row-cols-md-3 g-4">
            <div class="col">
                <div class="card h-100 border-success">
                    <div class="card-body">
                        <h5 class="card-title">Soil Analysis</h5>
                        <p class="card-text">Comprehensive Albrecht Method soil testing with detailed nutrient balance reports.</p>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card h-100 border-success">
                    <div class="card-body">
                        <h5 class="card-title">Plant Tissue Analysis</h5>
                        <p class="card-text">Identify nutrient deficiencies in your crops with laboratory-accurate tissue testing.</p>
                    </div>
                </div>
            </div>
            <div class="col">
                <div class="card h-100 border-success">
                    <div class="card-body">
                        <h5 class="card-title">Water Quality Analysis</h5>
                        <p class="card-text">Test irrigation and drinking water for optimal farm management.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<section class="bg-dark text-light py-5" id="blog">
    <div class="container">
        <p class="lead">Dr. Albrecht saw a direct link between soil quality and food quality, drawing a direct connection between poor quality forage crops and ill health in livestock.</p>
    </div>
</section>

<section class="py-5" id="contact-info">
    <div class="container">
        <p class="lead">Feed the soil to feed the plant is a vital concept of the Albrecht Model of soil building.</p>
    </div>
</section>

<!-- Newsletter Signup Section -->
<section id="signup" class="signup-section">
    <div class="container">
        <div class="row">
            <div class="col-md-10 col-lg-8 mx-auto text-center">
                <i class="far fa-paper-plane fa-2x mb-2 text-white"></i>
                <h2 class="text-white mb-5">Subscribe to receive updates!</h2>
                <?php if ($newsletterSuccess): ?>
                    <h2 class="text-white mb-5">Thank you for subscribing!</h2>
                <?php elseif ($newsletterError): ?>
                    <div class="alert alert-warning"><?= $h($newsletterError) ?></div>
                <?php endif; ?>
                <form action="#signup" method="post" class="d-flex flex-wrap gap-2 justify-content-center">
                    <input type="hidden" name="nospam" value="">
                    <input class="form-control flex-fill" type="email" name="email" placeholder="Email Address"
                           value="<?= $h($_POST['email'] ?? '') ?>">
                    <input class="form-control flex-fill" type="text" name="name" placeholder="Full Name"
                           value="<?= $h($_POST['name'] ?? '') ?>">
                    <button type="submit" name="newsletter-submit" class="btn btn-success">Subscribe</button>
                </form>
            </div>
        </div>
    </div>
</section>

<!-- Contact Section -->
<section id="contact" class="contact-section bg-black">
    <div class="container py-5">
        <div class="row mb-4">
            <div class="col-md-4 mb-3 mb-md-0">
                <div class="card py-4 h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-map-marked-alt text-primary mb-2"></i>
                        <h4 class="text-uppercase m-0">Address</h4>
                        <hr class="my-4">
                        <div class="small text-muted">34 Coplestone Street,<br>Scottsdale, Tasmania 7260</div>
                    </div>
                </div>
            </div>
            <div class="col-md-4 mb-3 mb-md-0">
                <div class="card py-4 h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-envelope text-primary mb-2"></i>
                        <h4 class="text-uppercase m-0">Email</h4>
                        <hr class="my-4">
                        <div class="small text-muted">
                            <a href="mailto:enquiry@cropmonitor.info">enquiry@cropmonitor.info</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-4 mb-3 mb-md-0">
                <div class="card py-4 h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-mobile-alt text-primary mb-2"></i>
                        <h4 class="text-uppercase m-0">Phone</h4>
                        <hr class="my-4">
                        <div class="small text-muted">0417 728 061</div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col">
                <div class="card py-4 h-100">
                    <div class="card-body text-center">
                        <i class="fas fa-paper-plane text-primary mb-2"></i>
                        <h4 class="text-uppercase m-0">Contact Us</h4>
                        <hr class="my-4">
                        <?php if ($contactSuccess): ?>
                            <div class="alert alert-success">Thank you for contacting us, we will be in touch soon.</div>
                        <?php elseif ($contactError): ?>
                            <div class="alert alert-warning"><?= $h($contactError) ?></div>
                        <?php endif; ?>
                        <form action="#contact" method="post" class="d-flex flex-wrap gap-2 justify-content-center">
                            <input type="hidden" name="nospam" value="">
                            <input class="form-control form-control-sm flex-fill" type="email" name="email"
                                   placeholder="Email Address" value="<?= $h($_POST['email'] ?? '') ?>">
                            <input class="form-control form-control-sm flex-fill" type="text" name="name"
                                   placeholder="Full Name" value="<?= $h($_POST['name'] ?? '') ?>">
                            <textarea class="form-control form-control-sm flex-fill" name="text" rows="1"
                                      placeholder="Your enquiry is about..."><?= $h($_POST['text'] ?? '') ?></textarea>
                            <button type="submit" name="enquiry-submit" class="btn btn-sm btn-success">Submit</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- Footer -->
<footer class="footer bg-dark py-2 text-center text-white-50">
    <div class="container">
        &copy; <?= date('Y') ?> Crop Monitor. All Rights Reserved.
    </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
</body>
</html>
