<?php include $_SERVER['DOCUMENT_ROOT'] . '/app/boot.php';
$show_full_width = true; // if we want to skip the left and right columns
include common(); ?>

<section class="campaign-section" aria-labelledby="campaign-title" role="region">
	<div class="campaign-text">
		<h1 id="campaign-title">
			Education is a <span class="highlight">never-ending job</span>,<br>
			particularly in a democracy
		</h1>
		<p class="signature">
			<span class="line" aria-hidden="true"></span>
			<span class="visually-hidden">Quote by U.S. Senator Herb Kohl:</span>
			U.S. SENATOR, HERB KOHL
		</p>
	</div>
</section>

<div class="principles-container">
	<nav class="leading-principles" id="leading_principles" aria-label="Leading Principles" role="navigation">
		<div class="content desktop tablet">
			<h2 class="h3-like" id="leading-principles-heading">LEADING PRINCIPLES</h2>
			<ul class="principles" aria-labelledby="leading-principles-heading">
				<li data-section="supporting" class="active">
					<a href="#supporting" aria-current="page">
						<strong>Supporting</strong>
						<span>Education &amp; Young People</span>
					</a>
				</li>
				<li data-section="sparking">
					<a href="#sparking">
						<strong>Sparking</strong>
						<span>Civic Engagement</span>
					</a>
				</li>
				<li data-section="engaging">
					<a href="#engaging">
						<strong>Engaging</strong>
						<span>Collaboration</span>
					</a>
				</li>
				<li data-section="funding">
					<a href="#funding">
						<strong>Funding</strong>
						<span>Available</span>
					</a>
				</li>
				<li data-section="celebrating">
					<a href="#celebrating">
						<strong>Celebrating</strong>
						<span>Excellence In Education</span>
					</a>
				</li>
			</ul>
		</div>
		<details class="content mobile">
			<summary><h3 id="leading-principles-heading">LEADING PRINCIPLES</h3></summary>
			<ul class="principles" aria-labelledby="leading-principles-heading">
				<li data-section="supporting" class="active">
					<a href="#supporting" aria-current="page">
						<strong>Supporting</strong>
						<span>Education &amp; Young People</span>
					</a>
				</li>
				<li data-section="sparking">
					<a href="#sparking">
						<strong>Sparking</strong>
						<span>Civic Engagement</span>
					</a>
				</li>
				<li data-section="engaging">
					<a href="#engaging">
						<strong>Engaging</strong>
						<span>Collaboration</span>
					</a>
				</li>
				<li data-section="funding">
					<a href="#funding">
						<strong>Funding</strong>
						<span>Available</span>
					</a>
				</li>
				<li data-section="celebrating">
					<a href="#celebrating">
						<strong>Celebrating</strong>
						<span>Excellence In Education</span>
					</a>
				</li>
			</ul>
		</details>
	</nav>
	
	<section class="section" id="supporting">
		<div class="container">
			<div class="text-image">
				<div class="text">
					<h2 class="h1-like">We <span class="emphasis">support</span> education and young people.</h2>
					<p>We believe in investing in young people. We support organizations that provide access, resources, and inspiration for youth.</p>
					<a href="/supporting-education-young-people/" class="button-like primary">Learn how we support</a>
				</div>
				<div class="image-fixed-container">
					<img class="section-image" id="supporting-image" src="assets/images/support.png" alt="Supporting Youth"/>
				</div>
			</div>
		</div>
	</section>

	<section class="section" id="sparking">
		<div class="container">
			<div class="text-image reverse">
				<div class="text">
					<h2 class="h1-like">We <span class="emphasis">spark</span> civic engagement.</h2>
					<!-- OG: --><!-- <p>We promote civic responsibility and active public life. Opportunities must be inclusive and representative.</p> -->
					<!-- Second: --><!-- <p>Civic engagement begins with creating opportunities for people to see themselves as active participants in their community and democracy. Inclusive dialogue and access to trusted information and education along with civic responsibility and service to others help build a stronger, more connected community. </p> -->
					<!-- Third: --><!-- <p>We recognize that stronger, more connected communities begin by creating opportunities for people to see themselves as active participants in their community and democracy.</p> -->
					<p>We recognize that communities are strengthened by creating opportunities for people to see themselves as active participants in their community and democracy</p>
					<a href="/sparking-civic-engagement/" class="button-like primary">Learn how we spark</a>
				</div>
				<div class="image-fixed-container">
					<img class="section-image" src="assets/images/spark.png" alt="Civic Engagement"/>
				</div>
			</div>
		</div>
	</section>

	<section class="section" id="engaging">
		<div class="container">
			<div class="text-image">
				<div class="text">
					<h2 class="h1-like">We <span class="emphasis">engage</span> in collaboration to get things done.</h2>
					<p>Through collaboration, we help create systemic change by uniting partners and stakeholders.</p>
					<a href="/engaging-collaboration/" class="button-like primary">Learn how we collaborate</a>
				</div>
				<div class="image-fixed-container">
					<img class="section-image" src="assets/images/engage.png" alt="Collaboration"/>
				</div>
			</div>
		</div>
	</section>

	<section class="section" id="funding">
		<div class="container">
			<div class="text-image reverse">
				<div class="text">
					<h2 class="h1-like">We <span class="emphasis">fund</span> meaningful opportunities.</h2>
					<p>We provide grants to initiatives that create opportunities and support thriving communities.</p>
					<a href="/funding-opportunities/" class="button-like primary">Learn how & where we fund</a>
				</div>
				<div class="image-fixed-container">
					<img class="section-image" src="assets/images/fund.png" alt="Funding Opportunities"/>
				</div>
			</div>
		</div>
	</section>

	<section class="section" id="celebrating">
		<div class="container">
			<div class="text-image">
				<div class="text">
					<h2 class="h1-like">We <span class="emphasis">celebrate</span> excellence in education.</h2>
					<p>We recognize teachers and leaders who go above and beyond in the field of education.</p>
					<a href="/celebrating-excellence-in-education/" class="button-like primary">Learn how we celebrate excellence</a>
				</div>
				<div class="image-fixed-container">
					<!-- TODO: replace with db -->
					<!-- <img class="section-image" src="assets/images/celebrate_red.png" alt="Celebrating Excellence"/> -->


					<div class="section-image teachers-of-year">

						<?
						$stmt = $dbh->prepare("SELECT `year` FROM `teachers_of_the_year` ORDER BY `year` DESC LIMIT 1");
						$stmt->execute();
						$latest_year = $stmt->fetchColumn();
						$stmt = null;
						?>

                        <h3>Teachers of the Year <?=$latest_year?></h3>
						<?
						// Fetch recent teachers of the year
						$stmt = $dbh->prepare("SELECT * FROM `teachers_of_the_year` WHERE `year`=:latest_year ORDER BY `order` LIMIT 5");
						$stmt->bindParam(':latest_year', $latest_year);
						$stmt->execute();
						while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                            $teachers[] = $row;
                        }

                        if (isset($teachers) && $teachers) {
                            foreach ($teachers as $teacher) {
                                ?>
                                <div class="teacher-card">
									<? if (isset($teacher['teacher_image']) && $teacher['teacher_image']) {?>
                                    	<div class="teacher-image" style="background-image: url('<?=$teacher['teacher_image']?>');"></div>
									<?} else {?>
										<div class="teacher-image default"></div>
									<?}?>
                                    <div class="teacher-info">
										<? if (isset($teacher['fullname']) && $teacher['fullname']) {?>
                                        	<h4 class="teacher-name"><?php echo htmlspecialchars($teacher['fullname']); ?></h4>
										<?}?>

										<? if (isset($teacher['position']) && $teacher['position']) {?>
											<p class="teacher-position">
												<!-- <svg width="11.4409342px" height="12px" viewBox="0 0 11.4409342 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M7.65192255,2.37967219 L7.68551308,2.34608166 C8.14579855,1.89222473 8.37977698,1.25678855 8.32373314,0.612810357 C8.29940029,0.28949731 8.04241666,0.0325136831 7.71910361,0.00818083073 C7.07512542,-0.0478630142 6.43968924,0.186115423 5.98583231,0.646400886 C5.7136036,0.91826173 5.51680836,1.2562865 5.41479331,1.62724434 C4.97059712,1.03375275 4.33020849,0.617143042 3.60762284,0.451575816 C3.49001558,0.425174186 3.3672569,0.463520797 3.28558879,0.552170854 C3.20392068,0.64082091 3.17575047,0.766306358 3.21168962,0.881358043 C3.24762877,0.996409728 3.34221725,1.08354856 3.45982451,1.10995019 C4.24724383,1.2871733 4.89754666,1.83955408 5.19981392,2.58793347 C4.78994974,2.44306594 4.35807873,2.37032977 3.92337381,2.37295409 C1.75762854,2.37554536 0.00259127138,4.13058262 0,6.2963279 C0,8.29832344 1.61906351,12 3.92337381,12 C4.47959601,12 5.02936521,11.8808511 5.53571921,11.6506583 C5.65530338,11.5966244 5.79234898,11.5966244 5.91193314,11.6506583 C6.41349998,11.8809696 6.95892516,12.0001381 7.51084233,12 C9.82187074,12 11.4409342,8.29832344 11.4409342,6.2963279 C11.4385557,4.18351908 9.76349341,2.45202737 7.65192255,2.37967219 M6.46281782,1.1233864 C6.77663602,0.80538966 7.21273382,0.638790503 7.65864066,0.666555203 C7.65864066,0.706863838 7.66535877,0.747172473 7.66535877,0.780763003 C7.66447421,1.19063253 7.50286366,1.58380448 7.21524567,1.87581425 C6.89466398,2.18626668 6.45808963,2.34723822 6.01270473,2.31920924 C5.97861461,1.8736653 6.14340293,1.43586947 6.46281782,1.1233864 M7.51084233,11.3281892 C7.05420922,11.3266879 6.60310166,11.2282228 6.18737548,11.0393106 C6.04161512,10.9736465 5.88369256,10.9393155 5.72382618,10.938539 C5.56384834,10.9382861 5.40571126,10.9726637 5.26027687,11.0393106 C4.83978271,11.228142 4.38431847,11.3265589 3.92337381,11.3281892 C2.1901025,11.3281892 0.671810584,8.19083375 0.671810584,6.2963279 C0.675245212,5.19362592 1.23561481,4.16732201 2.16137861,3.56821864 C3.08714241,2.96911528 4.25293568,2.87834161 5.26027687,3.32692512 C5.40125486,3.39269096 5.55482792,3.42707299 5.71038997,3.4276967 L5.72382618,3.4276967 C5.88369256,3.42692026 6.04161512,3.39258927 6.18737548,3.32692512 C6.60360933,3.14032504 7.05469561,3.04415436 7.51084233,3.04476178 C9.3077211,3.04476178 10.7654188,4.49945295 10.7691237,6.2963279 C10.7691237,8.19083375 9.24411364,11.3281892 7.51084233,11.3281892" fill-rule="nonzero"></path></svg> -->
												<svg width="9.53411168px" height="10px" viewBox="0 0 9.53411168 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M6.376602,1.98306012 L6.40459411,1.95506801 C6.78816532,1.57685391 6.98314735,1.04732377 6.93644414,0.510675287 C6.91616677,0.241247753 6.70201375,0.0270947354 6.43258622,0.00681735881 C5.89593773,-0.0398858444 5.3664076,0.155096182 4.98819349,0.538667394 C4.76133624,0.765218093 4.59734021,1.0469054 4.51232767,1.35603692 C4.14216418,0.861460606 3.608507,0.514285858 3.0063523,0.376313173 C2.90834626,0.354311814 2.80604736,0.386267324 2.7379906,0.460142369 C2.66993384,0.534017414 2.64645868,0.638588619 2.67640796,0.734465021 C2.70635725,0.830341423 2.78518099,0.902957117 2.88318703,0.924958472 C3.53936979,1.07264439 4.0812888,1.5329617 4.33317818,2.15661119 C3.9916247,2.03588824 3.6317322,1.97527477 3.26947811,1.9774617 C1.46469042,1.97962109 0.00215939277,3.44215212 0,5.24693981 C0,6.9152694 1.34921956,10 3.26947811,10 C3.7329966,10 4.19113759,9.90070908 4.61309925,9.70888169 C4.71275272,9.66385346 4.82695738,9.66385346 4.92661085,9.70888169 C5.34458321,9.90080777 5.79910418,10.0001149 6.25903515,10 C8.18489212,10 9.53411168,6.9152694 9.53411168,5.24693981 C9.53212958,3.48626583 8.13624435,2.0433561 6.376602,1.98306012 M5.38568141,0.936155315 C5.64719657,0.671158037 6.01061139,0.532325408 6.38220042,0.555462658 C6.38220042,0.589053187 6.38779884,0.622643715 6.38779884,0.650635823 C6.38706172,0.992193755 6.25238626,1.31983704 6.01270461,1.56317851 C5.7455532,1.82188886 5.38174125,1.95603181 5.01058717,1.93267433 C4.98217874,1.56138772 5.11950234,1.19655787 5.38568141,0.936155315 M6.25903515,9.44015746 C5.87850756,9.43890638 5.50258461,9.35685213 5.15614613,9.19942534 C5.03467917,9.14470521 4.90307704,9.11609605 4.76985505,9.11544902 C4.63654019,9.1152382 4.50475929,9.14388623 4.38356397,9.19942534 C4.03315218,9.35678483 3.65359866,9.43879891 3.26947811,9.44015746 C1.82508538,9.44015746 0.559842142,6.82569465 0.559842142,5.24693981 C0.562704332,4.32802151 1.02967899,3.47276827 1.80114881,2.97351548 C2.57261862,2.47426268 3.54411299,2.39861796 4.38356397,2.77243754 C4.50104563,2.82724241 4.62902317,2.8558941 4.75865821,2.85641386 L4.76985505,2.85641386 C4.90307704,2.85576683 5.03467917,2.82715767 5.15614613,2.77243754 C5.50300767,2.61693748 5.87891289,2.53679525 6.25903515,2.53730144 C7.7564341,2.53730144 8.97118212,3.74954405 8.97426954,5.24693981 C8.97426954,6.82569465 7.70342788,9.44015746 6.25903515,9.44015746" fill="#0F4979" fill-rule="nonzero"></path></svg>
												<?php echo htmlspecialchars($teacher['position']); ?>
											</p>
										<?}?>

										<? if ((isset($teacher['hsname']) && $teacher['hsname']) || (isset($teacher['hsdistrict']) && $teacher['hsdistrict'])) {?>
											<p class="teacher-school">
												<?php echo htmlspecialchars($teacher['hsname']);?>
												<? if (isset($teacher['hsname']) && $teacher['hsname'] && isset($teacher['hsdistrict']) && $teacher['hsdistrict']) {
													print ' in ';
												}?>
												<?php echo htmlspecialchars($teacher['hsdistrict']); ?>
											</p>
										<?}?>
                                    </div>
                                </div>
                                <?
                            }
                        }
						?>
					</div>
					

				</div>
			</div>
		</div>
	</section>
</div>

<section class="who-we-are">
	<div class="content">
		<h2>Who <span>We</span> Are</h2>
		<p>At Herb Kohl Philanthropies, we carry on Herb Kohl’s legacy of supporting the welfare and development of young people. We believe these investments pay the greatest dividends in our collective future. Through various funding initiatives, we hope our efforts lead to transformational relationships between learners and leaders. Learn more about our grants, programs, partnerships, and collaborations.</p>
		<a href="/about-hkp/" class="button-like primary">Learn More About HKP</a>
	</div>
</section>


<script>
	let last_active_section = null;
	function centerTextImageOnScroll() { // handles text-image centering on scroll
		document.querySelectorAll('.section').forEach(function(section) { // for each section
			const sectionImage = section.querySelector('.image-fixed-container'); // get the image container
			if (!sectionImage) return;

			const rect = section.getBoundingClientRect();
			const windowHeight = window.innerHeight;

			// Check if section is taking up more than half the viewport
			const principlesContainer = document.querySelector('.principles-container');
			const pcRect = principlesContainer.getBoundingClientRect();
			const sectionVisibleHeight = Math.min(rect.bottom, windowHeight) - Math.max(rect.top, 0);
			const sectionTakesHalfViewport = sectionVisibleHeight > windowHeight * 0.95;
			const pcFillsViewport = pcRect.top <= 0 && pcRect.bottom >= windowHeight;

			if (pcFillsViewport) { // if principles container takes up full view
				if (sectionTakesHalfViewport) { // If section is taking up more than 75% of the viewport
					section.querySelector('.emphasis').classList.add('line');
					// Remove active class from all principle items
					document.querySelectorAll('#leading_principles .principles li').forEach(function(li) {
						li.classList.remove('active');
					});
					// Add active class to the matching principle item
					const activeLi = document.querySelectorAll(`#leading_principles .principles li[data-section="${section.id}"]`);
					if (activeLi) {
						// console.log(activeLi);
						activeLi.forEach(function(li) {
							li.classList.add('active');
						});
					}
					// Center the .section-image vertically in the viewport
					sectionImage.classList.add('fixed');
					last_active_section = section.id; // Store the last active section
				} else {
					if (section.id === last_active_section) {
						sectionImage.classList.add('fixed');
					} else {
						sectionImage.classList.remove('fixed');
					}
				}
			} else { // if principles container is not in full view
				sectionImage.classList.remove('fixed'); // remove all fixed styles
			}
		});
	}

	const container = document.querySelector('.principles-container');
	const nav = document.getElementById('leading_principles');
	const navInitialOffset = nav.offsetTop;
	const navHeight = nav.offsetHeight;

	function onScroll() { // handles leading priciples fixing and unfixing
		const containerRect = container.getBoundingClientRect();
		if (containerRect.top <= 0 && containerRect.bottom >= window.innerHeight) { // if container is in view
			nav.classList.add('fixed-leading-principles');
		} else {
			nav.classList.remove('fixed-leading-principles');
		}

		// Smoothly bring nav even with container
		if (containerRect.top > 0 && nav.getBoundingClientRect().top <= 0) {
			nav.style.transform = `translateY(${containerRect.top * -1}px)`;
		} else {
			nav.style.transform = '';
		}

		// smoothly scroll away at end of sections
		if (containerRect.bottom < window.innerHeight) {
			// Get the last .section element inside the container
			const lastSection = container.querySelector('.section:last-of-type');
			if (lastSection) {
				const lastSectionRect = lastSection.getBoundingClientRect();
				// Calculate the distance from the top of the viewport to the last section's top
				nav.style.top = (((containerRect.top - window.innerHeight) * -1) - (window.innerHeight - containerRect.bottom) - (window.innerHeight - 45)) + 'px';
			}
		} else {
			nav.style.top = '0';
			// nav.style.bottom = '';
		}
	}

	document.addEventListener('DOMContentLoaded', function() {
        window.addEventListener('scroll', centerTextImageOnScroll);
        window.addEventListener('resize', centerTextImageOnScroll);
        centerTextImageOnScroll();
		
		window.addEventListener('scroll', onScroll);
	});
</script>

<?php include("assets/footer.php"); ?>
