{% import "_macros.html" as macros %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>{% block title %}{{ config.title }}{% endblock title %}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    {% block favicon %}
    <link rel="icon" sizes="16x16 32x32" type="image/png" href="/icons8-developer-ddara-lineal-color-32.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/icons8-developer-ddara-lineal-color-76.png">
    {% endblock favicon %}
    {% include "_variables.html" %}
    <link href="https://fonts.googleapis.com/css?family=Alfa+Slab+One&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600&display=swap" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/normalize.css">
    <link rel="stylesheet" type="text/css" href="/juice.css">
    {% block head %}
    {% endblock head %}
</head>

<body>
  {% block header %}

  <header class="pos-absolute" style="background-color: transparent">
      {{ macros::render_header() }}
  </header>

  <div class="hero">
      {% block hero %}
      <section class="text-center">
        <h1 class="heading-text" style="font-size: 50px;">
          Andrew Coleman
        </h1>
        <h3 class="title-text">
          An experienced software engineer and architect. <br />
          Sometimes posting about hobbies and farming, too.
        </h3>
      </section>
      
      <div class="explore-more text"
           onclick="document.getElementById('overview').scrollIntoView({behavior: 'smooth'})">
           Explore More ⇩
      </div>

      <img class="hero-image" style="max-width: 512px;" src="/2020-11-11_07-52-28.jpg">

      <div class="explore-more text"
          onclick="document.getElementById('features').scrollIntoView({behavior: 'smooth'})">
          Explore More ⇩
      </div>
      <style>
          .hero section {
              padding: 0 5rem;
          }

          @media screen and (max-width: 768px) {
              .hero section {
                  padding: 0 2rem;
              }

              .hero-image {
                display: none;
              }
          }

          #social-media-links img {
            width: 32px;
            height: 32px;
          }

          #social-media-links a, #social-media-links a:hover {
            text-decoration: none;
          }
      </style>
      {% endblock hero %}
  </div>

  {% endblock header %}

  <main>
      {% block toc %}
      {% if section.toc %}
      {% set toc = section.toc %}
      {% elif page.toc %}
      {% set toc = page.toc %}
      {% endif %}
      {% if toc %}
      <div class="toc">
          <div class="toc-sticky">
              {% for h in toc %}
              <div class="toc-item">
                  <a class="subtext" href="{{h.permalink | safe}}">{{ h.title }}</a>
              </div>
              {% if h.children %}
              {% for h2 in h.children %}
              <div class="toc-item-child">
                  <a class="subtext" href="{{h2.permalink | safe}}"><small>- {{ h2.title }}</small></a>
              </div>
              {% endfor %}
              {% endif %}
              {% endfor %}
          </div>
      </div>
      {% endif %}
      {% endblock toc %}

      <div class="content text">
          {% block content %}
          <div id="features" class="heading-text">Overview</div>
          {{ section.content | safe }}
          {% endblock content %}
      </div>

      {% block sidebar %}
      {% endblock sidebar %}
  </main>

  {% block footer %}
  <footer>
    <small class="subtext text-center">
      Made with <img src="/icons8-code-16.png" alt="Code" /> and <img src="/icons8-heart-16.png" alt="heart" /> © Andrew Coleman 2023
    </small>
  </footer>
  {% endblock footer %}
</body>
<script>
  const scrollHandler = entries => {
      // Find the first entry which intersecting and ratio > 0.9 to highlight.
      let entry = entries.find(entry => {
          return entry.isIntersecting && entry.intersectionRatio > 0.9;
      });
      if (!entry) return;

      document.querySelectorAll(".toc a").forEach((item) => {
          item.classList.remove("active");
      });

      // let url = new URL(`#${entry.target.id}`);
      let link = document.querySelector(`.toc a[href$="${decodeURIComponent(`#${entry.target.id}`)}"]`)
      if (link) {
          link.classList.add("active");
          link.scrollIntoView({ behavior: "auto", block: "nearest" });
      }
  };
  // Set -100px root margin to improve highlight experience.
  const observer = new IntersectionObserver(scrollHandler, { threshold: 1 });
  let items = document.querySelectorAll('h1,h2,h3,h4,h5,h6');
  items.forEach(item => observer.observe(item));
</script>

</html>