<?php
require_once __DIR__ . '/lib/csrf.php';

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

$contactSuccess = $_SESSION['contact_success'] ?? null;
$contactError   = $_SESSION['contact_error']   ?? null;
unset($_SESSION['contact_success'], $_SESSION['contact_error']);

$pageTitle = 'Precision Soil Science for Australian Farms';
$siteName  = 'Crop Monitor';
$siteUrl   = '/';
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title><?= htmlspecialchars($pageTitle . ' | ' . $siteName, ENT_QUOTES, 'UTF-8') ?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Centralise records for irrigation, weather and soil moisture. Real-time crop monitoring built on Albrecht Method soil science for Australian conditions.">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400&display=swap" rel="stylesheet">
  <link href="client-assets/css/home.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>

<!-- ── NAVIGATION ──────────────────────────── -->
<nav>
  <a href="/" class="nav-logo">
    <div class="nav-logo-mark">🌿</div>
    <span class="nav-logo-text">Crop Monitor</span>
  </a>
  <ul class="nav-links">
    <li><a href="#science">Science</a></li>
    <li><a href="#services">Services</a></li>
    <li><a href="#how-it-works">How It Works</a></li>
    <li><a href="#team">Team</a></li>
    <li><a href="#contact">Contact</a></li>
  </ul>
  <div class="nav-cta">
    <a href="/login/login.php" class="btn-outline">Sign In</a>
    <a href="/login/register.php" class="btn-primary">Get Started</a>
  </div>
</nav>

<!-- ── HERO ────────────────────────────────── -->
<section class="hero">
  <div class="hero-left">
    <div class="hero-eyebrow">Albrecht Method · Australian Conditions</div>
    <h1>Soil Science<br>That <em>Feeds</em><br>Your Farm</h1>
    <p class="hero-desc">Built on Dr. William Albrecht's proven base cation saturation ratios — monitor calcium, magnesium, potassium and moisture levels in real-time, with tailored recommendations for Australian broadacre, viticulture and dairy operations.</p>
    <div class="hero-actions">
      <a href="/login/register.php" class="btn-hero">Start Monitoring</a>
      <a href="#science" class="btn-hero-sec">The Science</a>
    </div>
    <div class="hero-stats">
      <div class="hero-stat">
        <div class="hero-stat-num">768</div>
        <div class="hero-stat-label">Blocks monitored</div>
      </div>
      <div class="hero-stat">
        <div class="hero-stat-num">94%</div>
        <div class="hero-stat-label">Nutrient accuracy</div>
      </div>
      <div class="hero-stat">
        <div class="hero-stat-num">24/7</div>
        <div class="hero-stat-label">Real-time alerts</div>
      </div>
    </div>
  </div>
  <div class="hero-right">
    <div class="hero-soil-diagram">
      <div style="font-family:'DM Mono',monospace;font-size:0.65rem;letter-spacing:0.12em;text-transform:uppercase;color:rgba(255,255,255,0.25);margin-bottom:1rem;padding-left:1.5rem;">Soil Profile Analysis</div>
      <div class="soil-layer">
        <div class="soil-layer-label">0–15 cm</div>
        <div class="soil-layer-name">Topsoil</div>
        <div class="soil-layer-detail">Ca 68% · Mg 14% · K 4.2%</div>
      </div>
      <div class="soil-layer">
        <div class="soil-layer-label">15–30 cm</div>
        <div class="soil-layer-name">Sub-Surface</div>
        <div class="soil-layer-detail">Ca 61% · Mg 17% · K 3.8%</div>
      </div>
      <div class="soil-layer">
        <div class="soil-layer-label">30–60 cm</div>
        <div class="soil-layer-name">B Horizon</div>
        <div class="soil-layer-detail">Ca 54% · Mg 21% · K 2.9%</div>
      </div>
      <div class="soil-layer">
        <div class="soil-layer-label">60+ cm</div>
        <div class="soil-layer-name">Parent Material</div>
        <div class="soil-layer-detail">CEC 12.4 meq/100g</div>
      </div>
    </div>
    <!-- Donut chart SVG -->
    <div class="hero-cation-ring">
      <svg viewBox="0 0 160 160" fill="none" xmlns="http://www.w3.org/2000/svg">
        <!-- Ca 65% -->
        <circle cx="80" cy="80" r="60" stroke="#4a7a42" stroke-width="16" stroke-dasharray="244 135" stroke-dashoffset="0" transform="rotate(-90 80 80)" opacity="0.85"/>
        <!-- Mg 15% -->
        <circle cx="80" cy="80" r="60" stroke="#c8853a" stroke-width="16" stroke-dasharray="56 323" stroke-dashoffset="-244" transform="rotate(-90 80 80)" opacity="0.75"/>
        <!-- K 4% -->
        <circle cx="80" cy="80" r="60" stroke="#e8c87a" stroke-width="16" stroke-dasharray="15 364" stroke-dashoffset="-300" transform="rotate(-90 80 80)" opacity="0.75"/>
        <!-- Other -->
        <circle cx="80" cy="80" r="60" stroke="rgba(255,255,255,0.1)" stroke-width="16" stroke-dasharray="64 315" stroke-dashoffset="-315" transform="rotate(-90 80 80)"/>
      </svg>
      <div class="cation-ring-label">
        <span>BCSR</span>
        <strong>65%</strong>
        <span style="font-size:0.6rem;color:rgba(255,255,255,0.3);">Ca sat.</span>
      </div>
    </div>
  </div>
</section>

<!-- ── MARQUEE ──────────────────────────────── -->
<div class="marquee-band">
  <div class="marquee-track">
    <span class="marquee-item">Albrecht BCSR Method</span>
    <span class="marquee-item">Calcium 60–70% Saturation</span>
    <span class="marquee-item">Cation Exchange Capacity</span>
    <span class="marquee-item">Real-Time Soil Monitoring</span>
    <span class="marquee-item">Fertiliser Recommendations</span>
    <span class="marquee-item">Australian Conditions</span>
    <span class="marquee-item">Plant Tissue Analysis</span>
    <span class="marquee-item">Irrigation Optimisation</span>
    <span class="marquee-item">Albrecht BCSR Method</span>
    <span class="marquee-item">Calcium 60–70% Saturation</span>
    <span class="marquee-item">Cation Exchange Capacity</span>
    <span class="marquee-item">Real-Time Soil Monitoring</span>
    <span class="marquee-item">Fertiliser Recommendations</span>
    <span class="marquee-item">Australian Conditions</span>
    <span class="marquee-item">Plant Tissue Analysis</span>
    <span class="marquee-item">Irrigation Optimisation</span>
  </div>
</div>

<!-- ── ALBRECHT SCIENCE ─────────────────────── -->
<div class="albrecht" id="science">
  <div class="albrecht-grid">
    <div class="albrecht-left fade-up">
      <div class="section-eyebrow">The Albrecht Method</div>
      <h2 class="section-title">Nutrient Balance,<br>Not Just Quantity</h2>
      <div class="albrecht-body">
        <p>Developed by Dr. William Albrecht at the University of Missouri in the 1930s and 40s, the <strong>Base Cation Saturation Ratio (BCSR)</strong> system changed how we understand soil fertility. Rather than simply applying fixed fertiliser quantities, Albrecht showed that the <em>balance</em> between calcium, magnesium and potassium is what determines soil health and plant performance.</p>
        <p>Calcium should occupy 60–70% of your soil's cation exchange sites. Magnesium 10–20%. Potassium 3–5%. When these ratios are right, soil structure improves, nutrient uptake increases, and your crops can reach their genetic potential.</p>
      </div>
      <div class="albrecht-quote">
        <p>"The soil is the basis of agriculture — and its fertility determines the health of everything that grows from it."</p>
        <cite>— Dr. William Albert Albrecht, University of Missouri</cite>
      </div>
      <div class="principle-cards">
        <div class="principle-card fade-up">
          <div class="principle-icon">⚖️</div>
          <div>
            <h4>Cation Balance Over Quantity</h4>
            <p>Optimal plant nutrition requires the right Ca:Mg:K ratio (approx. 13:2:1), not simply high levels of any single nutrient.</p>
          </div>
        </div>
        <div class="principle-card fade-up">
          <div class="principle-icon">🧱</div>
          <div>
            <h4>Calcium Builds Soil Structure</h4>
            <p>Calcium increases flocculation and pore space, improving drainage and root penetration. Excess magnesium compacts soil.</p>
          </div>
        </div>
        <div class="principle-card fade-up">
          <div class="principle-icon">🔬</div>
          <div>
            <h4>CEC-Based Amendment Strategy</h4>
            <p>Amendment rates are calculated from your soil's Cation Exchange Capacity — ensuring targeted, economical applications.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="albrecht-right fade-up">
      <div class="cation-chart">
        <div class="cation-chart-title">Target Base Saturation Ranges — Albrecht BCSR</div>

        <div class="cation-bar-row">
          <div class="cation-label">Calcium</div>
          <div class="cation-bar-track"><div class="cation-bar-fill" style="width:65%;background:linear-gradient(90deg,#4a7a42,#7dc87a);animation-delay:0.1s;"></div></div>
          <div class="cation-val">60–70%</div>
        </div>
        <div class="cation-bar-row">
          <div class="cation-label">Magnesium</div>
          <div class="cation-bar-track"><div class="cation-bar-fill" style="width:15%;background:linear-gradient(90deg,#c8853a,#e8a860);animation-delay:0.2s;"></div></div>
          <div class="cation-val">10–20%</div>
        </div>
        <div class="cation-bar-row">
          <div class="cation-label">Potassium</div>
          <div class="cation-bar-track"><div class="cation-bar-fill" style="width:4%;background:linear-gradient(90deg,#e8c87a,#f0dc9a);animation-delay:0.3s;"></div></div>
          <div class="cation-val">3–5%</div>
        </div>
        <div class="cation-bar-row">
          <div class="cation-label">Hydrogen</div>
          <div class="cation-bar-track"><div class="cation-bar-fill" style="width:10%;background:linear-gradient(90deg,rgba(255,255,255,0.3),rgba(255,255,255,0.5));animation-delay:0.4s;"></div></div>
          <div class="cation-val">10–15%</div>
        </div>
        <div class="cation-bar-row">
          <div class="cation-label">Sodium</div>
          <div class="cation-bar-track"><div class="cation-bar-fill" style="width:1.5%;background:linear-gradient(90deg,rgba(200,133,58,0.5),rgba(200,133,58,0.7));animation-delay:0.5s;"></div></div>
          <div class="cation-val">&lt;3%</div>
        </div>

        <div class="cation-note">Optimal ranges based on Albrecht's original research and modern CEC-adjusted field data. Best applied to soils with moderate CEC (10–25 meq/100g).</div>
      </div>
    </div>
  </div>
</div>

<!-- ── SERVICES ─────────────────────────────── -->
<section class="services" id="services">
  <div class="services-inner">
    <div class="services-header fade-up">
      <div class="section-eyebrow">What We Offer</div>
      <h2 class="section-title">Comprehensive Farm Analysis</h2>
      <p class="section-sub">From cation balance to irrigation scheduling — every measurement your farm needs, on one platform.</p>
    </div>
    <div class="services-grid">
      <div class="service-card fade-up">
        <div class="service-num">01</div>
        <div class="service-icon-wrap">🌱</div>
        <h3>Soil Analysis</h3>
        <p>Full BCSR analysis measuring CEC, base saturation percentages, pH, organic matter, and macro/micronutrient levels. Fertiliser recommendations tailored to your soil type and target crop.</p>
        <a href="/login/login.php" class="service-link">Get started →</a>
      </div>
      <div class="service-card fade-up">
        <div class="service-num">02</div>
        <div class="service-icon-wrap">🌿</div>
        <h3>Plant Analysis</h3>
        <p>Tissue analysis to detect nutrient deficiency or toxicity in real-time. Identifies whether problems stem from soil imbalances or in-season factors — before symptoms become visible yield losses.</p>
        <a href="/login/login.php" class="service-link">Get started →</a>
      </div>
      <div class="service-card fade-up">
        <div class="service-num">03</div>
        <div class="service-icon-wrap">💧</div>
        <h3>Water Analysis</h3>
        <p>Monitor irrigation water quality including sodium, bicarbonate, pH, and EC. Understand how your water chemistry interacts with soil cation ratios and adjust programmes accordingly.</p>
        <a href="/login/login.php" class="service-link">Get started →</a>
      </div>
    </div>
  </div>
</section>

<!-- ── SOIL HEALTH PILLARS ──────────────────── -->
<section class="science" id="health">
  <div class="science-inner">
    <div class="science-layout">
      <div class="fade-up">
        <div class="section-eyebrow">Soil Health Framework</div>
        <h2 class="section-title">Three Pillars of Healthy Soil</h2>
        <p class="section-sub" style="margin-bottom:2rem;">True soil health integrates physical, chemical, and biological components. Albrecht's cation balance work addresses the chemical foundation — which in turn improves structure and biology.</p>
        <div class="pillars">
          <div class="pillar fade-up">
            <div class="pillar-number" style="color:rgba(200,133,58,0.25);">01</div>
            <div>
              <h4>Physical</h4>
              <p>Proper Ca:Mg ratios improve soil aggregation and pore space, enhancing drainage, aeration and root penetration. Good structure reduces compaction and tillage requirements over time.</p>
            </div>
          </div>
          <div class="pillar fade-up">
            <div class="pillar-number" style="color:rgba(107,140,90,0.25);">02</div>
            <div>
              <h4>Chemical</h4>
              <p>Cation balance governs pH, nutrient availability, and plant uptake efficiency. Monitoring BCSR ratios enables targeted amendments rather than blanket fertiliser applications that can worsen imbalances.</p>
            </div>
          </div>
          <div class="pillar fade-up">
            <div class="pillar-number" style="color:rgba(122,74,42,0.2);">03</div>
            <div>
              <h4>Biological</h4>
              <p>Balanced soil chemistry creates optimal conditions for microbial populations, nutrient cycling, and nitrogen fixation. Soil biology thrives when chemistry and physics are in harmony.</p>
            </div>
          </div>
        </div>
      </div>
      <div class="fade-up">
        <div class="soil-profile-card">
          <div class="soil-profile-title">Live Nutrient Dashboard — Block A3, Riverina</div>
          <div class="nutrient-row">
            <div class="nutrient-name">Calcium</div>
            <div class="nutrient-bar-track"><div class="nutrient-bar-fill" style="width:65%;background:#7dc87a;"></div></div>
            <div class="nutrient-status status-optimal">Optimal</div>
          </div>
          <div class="nutrient-row">
            <div class="nutrient-name">Magnesium</div>
            <div class="nutrient-bar-track"><div class="nutrient-bar-fill" style="width:22%;background:#e8a860;"></div></div>
            <div class="nutrient-status status-high">High</div>
          </div>
          <div class="nutrient-row">
            <div class="nutrient-name">Potassium</div>
            <div class="nutrient-bar-track"><div class="nutrient-bar-fill" style="width:28%;background:#e8c87a;"></div></div>
            <div class="nutrient-status status-caution">Watch</div>
          </div>
          <div class="nutrient-row">
            <div class="nutrient-name">Phosphorus</div>
            <div class="nutrient-bar-track"><div class="nutrient-bar-fill" style="width:40%;background:#7dc87a;"></div></div>
            <div class="nutrient-status status-optimal">Optimal</div>
          </div>
          <div class="nutrient-row">
            <div class="nutrient-name">Sulphur</div>
            <div class="nutrient-bar-track"><div class="nutrient-bar-fill" style="width:15%;background:#e07070;"></div></div>
            <div class="nutrient-status status-low">Low</div>
          </div>
          <div class="nutrient-row">
            <div class="nutrient-name">Soil Moisture</div>
            <div class="nutrient-bar-track"><div class="nutrient-bar-fill" style="width:58%;background:#7dc87a;"></div></div>
            <div class="nutrient-status status-optimal">Optimal</div>
          </div>
          <div class="soil-profile-footer">
            <div class="soil-score">
              <span class="soil-score-label">Soil Health Score</span>
              <span class="soil-score-val">74</span>
              <span class="soil-score-sub">/ 100 · Updated 4 min ago</span>
            </div>
            <div class="soil-alert">⚠️ Apply gypsum to correct elevated Mg:Ca ratio in B horizon</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ── HOW IT WORKS ─────────────────────────── -->
<section class="process" id="how-it-works">
  <div class="process-inner">
    <div class="process-header fade-up">
      <div class="section-eyebrow">The Process</div>
      <h2 class="section-title">From Sample to Decision</h2>
      <p class="section-sub">A structured four-step process that turns raw soil data into actionable farm management recommendations.</p>
    </div>
    <div class="steps">
      <div class="step fade-up">
        <div class="step-num">1</div>
        <h4>Sample Collection</h4>
        <p>Collect soil, plant or water samples using our guided protocols — designed to capture accurate profiles at every soil depth.</p>
      </div>
      <div class="step fade-up">
        <div class="step-num">2</div>
        <h4>Lab Analysis</h4>
        <p>CEC, BCSR ratios, pH, organic matter, and full macro/micronutrient panels analysed by certified Australian laboratories.</p>
      </div>
      <div class="step fade-up">
        <div class="step-num">3</div>
        <h4>Albrecht Scoring</h4>
        <p>Results are scored against Albrecht's target ranges, adjusted for your soil type, CEC and target crop requirements.</p>
      </div>
      <div class="step fade-up">
        <div class="step-num">4</div>
        <h4>Recommendations</h4>
        <p>Receive a tailored fertiliser and amendment programme — with real-time monitoring alerts as conditions change.</p>
      </div>
    </div>
  </div>
</section>

<!-- ── ABOUT / TEAM ─────────────────────────── -->
<section class="about" id="team">
  <div class="about-inner">
    <div class="fade-up">
      <div class="section-eyebrow">About Us</div>
      <h2 class="section-title">Australian Soil Science,<br>Built for Australian Farms</h2>
      <div class="about-text">
        <p>Crop Monitor was built by agronomists and soil scientists who saw a gap between laboratory soil data and practical farm management. We've taken the rigour of Albrecht's BCSR methodology and made it accessible to every Australian farmer — from Riverina broadacre to Barossa viticulture to Victorian dairy.</p>
        <p>Our platform integrates lab results, weather data, soil moisture sensors and irrigation records into a single dashboard — so you spend less time compiling data and more time acting on it.</p>
      </div>
      <div class="about-metrics">
        <div class="about-metric fade-up">
          <div class="about-metric-num">768</div>
          <div class="about-metric-label">Trees planted on client farms</div>
        </div>
        <div class="about-metric fade-up">
          <div class="about-metric-num">678</div>
          <div class="about-metric-label">Farms on platform</div>
        </div>
        <div class="about-metric fade-up">
          <div class="about-metric-num">800+</div>
          <div class="about-metric-label">Soil profiles analysed</div>
        </div>
        <div class="about-metric fade-up">
          <div class="about-metric-num">13:2:1</div>
          <div class="about-metric-label">Target Ca:Mg:K ratio</div>
        </div>
      </div>
    </div>
    <div class="fade-up">
      <div class="team-cards">
        <div class="team-card">
          <div class="team-avatar">MD</div>
          <h4>Mark Duncan</h4>
          <span>Founder · Agronomist</span>
        </div>
        <div class="team-card">
          <div class="team-avatar">CB</div>
          <h4>Cynthia Baker</h4>
          <span>Soil Scientist</span>
        </div>
        <div class="team-card">
          <div class="team-avatar">PW</div>
          <h4>Peter Wright</h4>
          <span>Water Quality Lead</span>
        </div>
        <div class="team-card">
          <div class="team-avatar">SW</div>
          <h4>Steven Wilson</h4>
          <span>Platform Engineer</span>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ── CONTACT ──────────────────────────────── -->
<section class="contact-section" id="contact">
  <div class="contact-inner">
    <div class="fade-up">
      <div class="section-eyebrow">Contact Us</div>
      <h2 class="section-title">Let's Talk About<br>Your Soil</h2>
      <p class="section-sub" style="margin-bottom:2rem;">Whether you're curious about the Albrecht Method, looking to start monitoring, or want a consult on existing soil test results — we're here.</p>
      <?php if ($contactSuccess): ?>
        <div class="contact-alert contact-alert-success"><?= htmlspecialchars($contactSuccess, ENT_QUOTES, 'UTF-8') ?></div>
      <?php elseif ($contactError): ?>
        <div class="contact-alert contact-alert-error"><?= htmlspecialchars($contactError, ENT_QUOTES, 'UTF-8') ?></div>
      <?php endif; ?>

      <form class="contact-form" action="/controllers/contactSubmit.php" method="post">
        <input type="hidden" name="csrf_token" value="<?= generateCsrfToken() ?>">
        <div class="form-row">
          <div class="form-field">
            <label>First Name</label>
            <input type="text" name="first_name" placeholder="Mark" required>
          </div>
          <div class="form-field">
            <label>Last Name</label>
            <input type="text" name="last_name" placeholder="Duncan" required>
          </div>
        </div>
        <div class="form-field">
          <label>Email Address</label>
          <input type="email" name="email" placeholder="mark@example.com.au" required>
        </div>
        <div class="form-field">
          <label>Farm Type</label>
          <select name="farm_type">
            <option value="">Select your operation type</option>
            <option>Broadacre</option>
            <option>Viticulture</option>
            <option>Horticulture</option>
            <option>Dairy</option>
            <option>Mixed Farming</option>
          </select>
        </div>
        <div class="form-field">
          <label>Message</label>
          <textarea name="message" placeholder="Tell us about your farm and what you're trying to achieve…"></textarea>
        </div>
        <button type="submit" class="form-submit">Send Message</button>
      </form>
    </div>
    <div class="contact-info fade-up">
      <div class="contact-info-item">
        <div class="contact-info-icon">📞</div>
        <div>
          <div class="contact-info-label">Phone</div>
          <div class="contact-info-val">+61 2 1234 5678</div>
        </div>
      </div>
      <div class="contact-info-item">
        <div class="contact-info-icon">✉️</div>
        <div>
          <div class="contact-info-label">Email</div>
          <div class="contact-info-val">hello@cropmonitor.com.au</div>
        </div>
      </div>
      <div class="contact-info-item">
        <div class="contact-info-icon">📍</div>
        <div>
          <div class="contact-info-label">Office</div>
          <div class="contact-info-val">Level 4, 123 Collins Street<br>Melbourne VIC 3000</div>
        </div>
      </div>
      <div class="contact-info-item">
        <div class="contact-info-icon">🕐</div>
        <div>
          <div class="contact-info-label">Hours</div>
          <div class="contact-info-val">Mon–Fri 8:00am – 4:30pm AEST</div>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ── FOOTER ───────────────────────────────── -->
<footer>
  <div class="footer-inner">
    <div class="footer-top">
      <div>
        <a href="/" class="footer-logo">
          <div class="footer-logo-mark">🌿</div>
          <span class="footer-logo-text">Crop Monitor</span>
        </a>
        <p class="footer-tagline">Albrecht Method soil science for Australian conditions.</p>
      </div>
      <div class="footer-nav-group">
        <h5>Platform</h5>
        <ul>
          <li><a href="#science">The Science</a></li>
          <li><a href="#services">Services</a></li>
          <li><a href="#how-it-works">How It Works</a></li>
          <li><a href="/login/login.php">Sign In</a></li>
        </ul>
      </div>
      <div class="footer-nav-group">
        <h5>Company</h5>
        <ul>
          <li><a href="#team">Our Team</a></li>
          <li><a href="#contact">Contact</a></li>
          <li><a href="/login/register.php">Register</a></li>
        </ul>
      </div>
      <div class="footer-nav-group">
        <h5>Resources</h5>
        <ul>
          <li><a href="#">Albrecht Method Guide</a></li>
          <li><a href="#">Sampling Protocols</a></li>
          <li><a href="#">BCSR Calculator</a></li>
        </ul>
      </div>
    </div>
    <div class="footer-bottom">
      <p class="footer-copy">© 2026 Crop Monitor. All Rights Reserved.</p>
      <p class="footer-badge">Built on Albrecht BCSR Methodology</p>
    </div>
  </div>
</footer>

<script>
  // Fade-up on scroll
  const observer = new IntersectionObserver((entries) => {
    entries.forEach(e => {
      if (e.isIntersecting) { e.target.classList.add('visible'); }
    });
  }, { threshold: 0.12 });
  document.querySelectorAll('.fade-up').forEach(el => observer.observe(el));

  // Nav scroll shadow
  window.addEventListener('scroll', () => {
    document.querySelector('nav').style.boxShadow =
      window.scrollY > 10 ? '0 2px 20px rgba(0,0,0,0.06)' : 'none';
  });

  // Smooth scroll for nav links
  document.querySelectorAll('a[href^="#"]').forEach(a => {
    a.addEventListener('click', e => {
      const target = document.querySelector(a.getAttribute('href'));
      if (target) {
        e.preventDefault();
        target.scrollIntoView({ behavior: 'smooth', block: 'start' });
      }
    });
  });
</script>
</body>
</html>