{% extends "base.html" %}

{% block head %}
<script>
  (function() {
    var theme = localStorage.getItem('theme');
    if (theme !== 'light') {
      document.documentElement.classList.add('dark');
    }
  })();
</script>
{% endblock %}

{% block content %}
<div class="w-screen relative left-1/2 -ml-[50vw] -mt-[calc(var(--header-height)+3rem)] -mb-12">
  <!-- Navigation -->
  <nav class="fixed top-0 left-0 right-0 bg-white dark:bg-gray-900 shadow-md dark:shadow-none border-b border-gray-200 dark:border-gray-800 z-50 h-16">
    <div class="max-w-6xl mx-auto px-4 h-full flex justify-between items-center">
      <a href="#hero" class="text-xl font-bold text-gray-900 dark:text-white hover:text-blue-500 dark:hover:text-blue-400 transition-colors">
        {{ site.config.title }}
      </a>
      <div class="flex items-center gap-4">
        <div class="hidden md:flex space-x-8 items-center">
          <a href="#about" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">About</a>
          {% if site.data.highlights %}<a href="#highlights" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Highlights</a>{% endif %}
          {% if site.data.experience %}<a href="#experience" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Experience</a>{% endif %}
          {% if site.collections.projects %}<a href="#projects" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Projects</a>{% endif %}
          {% if site.data.education %}<a href="#education" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Education</a>{% endif %}
        </div>
        <button
          id="portfolio-theme-toggle"
          class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors p-2"
          aria-label="Toggle theme"
        >
          <svg id="moon-icon" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 hidden dark:block" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
          </svg>
          <svg id="sun-icon" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 block dark:hidden" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
          </svg>
        </button>
        <input type="checkbox" id="nav-toggle" class="hidden peer" />
        <label for="nav-toggle" class="md:hidden flex items-center cursor-pointer text-gray-900 dark:text-white">
          <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
          </svg>
        </label>
      </div>
      <div class="hidden peer-checked:flex peer-checked:flex-col peer-checked:absolute peer-checked:top-16 peer-checked:left-0 peer-checked:right-0 peer-checked:bg-gray-100 dark:peer-checked:bg-gray-800 peer-checked:border-b peer-checked:border-gray-300 dark:peer-checked:border-gray-700 peer-checked:p-4 peer-checked:space-y-4 md:hidden">
        <a href="#about" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">About</a>
        {% if site.data.highlights %}<a href="#highlights" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Highlights</a>{% endif %}
        {% if site.data.experience %}<a href="#experience" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Experience</a>{% endif %}
        {% if site.collections.projects %}<a href="#projects" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Projects</a>{% endif %}
        {% if site.data.education %}<a href="#education" class="text-gray-700 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition-colors">Education</a>{% endif %}
      </div>
    </div>
  </nav>

  <!-- Hero Section -->
  <section id="hero" class="min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-900 dark:to-gray-800 pt-16">
    <div class="text-center px-4">
      {% if site.config.extra.avatar %}
      <img
        src="{{ site.config.extra.avatar }}"
        alt="{{ site.config.title }}"
        class="rounded-lg mx-auto mb-6 border-2 border-blue-500 dark:border-blue-400 object-cover"
        style="width: 180px; height: 180px;"
      />
      {% endif %}
      <h1 class="text-5xl md:text-7xl font-bold text-gray-900 dark:text-white mb-4">
        Hi, I'm <span class="text-blue-500 dark:text-blue-400">{{ site.config.title }}</span>
      </h1>
      {% if site.config.extra.tagline %}
      <p class="text-xl md:text-2xl text-gray-600 dark:text-gray-300 mb-8">{{ site.config.extra.tagline }}</p>
      {% endif %}

      <div class="flex gap-4 justify-center flex-wrap">
        <a href="#experience" class="px-6 py-3 bg-purple-500 text-white rounded-lg hover:bg-purple-600 transition-colors inline-flex items-center gap-2 whitespace-nowrap">
          <svg xmlns="http://www.w3.org/2000/svg" class="flex-shrink-0" style="width: 14px; height: 14px;" viewBox="0 0 20 20" fill="currentColor">
            <path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"/>
          </svg>
          Experience
        </a>
        {% set linkedin_url = site.config.extra.linkedin | default(value="") %}
        {% if linkedin_url %}
        <a href="{{ linkedin_url }}" target="_blank" rel="noopener noreferrer" class="px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors inline-flex items-center gap-2 whitespace-nowrap">
          <svg xmlns="http://www.w3.org/2000/svg" class="flex-shrink-0" style="width: 14px; height: 14px;" viewBox="0 0 24 24" fill="currentColor">
            <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/>
          </svg>
          LinkedIn
        </a>
        {% endif %}
        {% set github_url = site.config.extra.github | default(value="") %}
        {% if github_url %}
        <a href="{{ github_url }}" target="_blank" rel="noopener noreferrer" class="px-6 py-3 bg-gray-700 text-white rounded-lg hover:bg-gray-600 transition-colors inline-flex items-center gap-2 whitespace-nowrap">
          <svg xmlns="http://www.w3.org/2000/svg" class="flex-shrink-0" style="width: 14px; height: 14px;" viewBox="0 0 24 24" fill="currentColor">
            <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
          </svg>
          GitHub
        </a>
        {% endif %}
        <a href="#projects" class="px-6 py-3 bg-teal-500 text-white rounded-lg hover:bg-teal-600 transition-colors inline-flex items-center gap-2 whitespace-nowrap">
          <svg xmlns="http://www.w3.org/2000/svg" class="flex-shrink-0" style="width: 14px; height: 14px;" viewBox="0 0 20 20" fill="currentColor">
            <path fill-rule="evenodd" d="M3 5a2 2 0 012-2h10a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2V5zm11 1H6v8l4-2 4 2V6z" clip-rule="evenodd"/>
          </svg>
          Projects
        </a>
      </div>
    </div>
  </section>

  <!-- About Section -->
  <section id="about" class="py-20 bg-white dark:bg-gray-900">
    <div class="max-w-6xl mx-auto px-4">
      <h2 class="text-4xl font-bold text-center mb-12 text-gray-900 dark:text-white">About Me</h2>
      {% if home %}
      <div class="max-w-3xl mx-auto space-y-8">
        <div class="text-gray-600 dark:text-gray-300 leading-relaxed text-lg text-center [&>p]:mb-8 [&>p:last-child]:mb-0">
          {{ home.content | safe }}
        </div>
      </div>
      {% endif %}
    </div>
  </section>

  <!-- Highlights Section -->
  {% if site.data.highlights %}
  <section id="highlights" class="py-20 bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-900 dark:to-gray-800">
    <div class="max-w-6xl mx-auto px-4">
      <div class="text-center mb-12">
        <h2 class="text-4xl font-bold text-gray-900 dark:text-white">Highlights</h2>
      </div>
      <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
        {% for item in site.data.highlights.items %}
        <a href="{{ item.link }}" target="_blank" rel="noopener noreferrer" class="block bg-white dark:bg-gray-900 rounded-lg shadow-lg overflow-hidden border border-gray-200 dark:border-gray-700 hover:shadow-xl transition-all hover:scale-105 cursor-pointer flex flex-col">
          {% if item.image %}
          <img src="{{ item.image }}" alt="{{ item.title }}" class="w-full h-48 object-cover" />
          {% endif %}
          <div class="p-6 flex-1">
            <h3 class="text-xl font-bold mb-3 text-gray-900 dark:text-white">{{ item.title }}</h3>
            <p class="text-gray-600 dark:text-gray-300 leading-relaxed">{{ item.description }}</p>
          </div>
        </a>
        {% endfor %}
      </div>
    </div>
  </section>
  {% endif %}

  <!-- Experience Section -->
  {% if site.data.experience %}
  <section id="experience" class="py-20 bg-white dark:bg-gray-900">
    <div class="max-w-4xl mx-auto px-4">
      <h2 class="text-4xl font-bold text-center mb-12 text-gray-900 dark:text-white">Experience</h2>
      <div class="space-y-8">
        {% for job in site.data.experience.jobs %}
        <div class="border-l-4 border-blue-500 pl-6">
          <h3 class="text-2xl font-bold text-gray-900 dark:text-white">{{ job.title }}</h3>
          <p class="text-lg text-gray-600 dark:text-gray-300 mb-2">{{ job.company }}</p>
          <p class="text-sm text-gray-500 dark:text-gray-400 mb-4">{{ job.period }}</p>
          <ul class="space-y-2">
            {% for achievement in job.achievements %}
            <li class="flex items-start">
              <span class="text-blue-500 dark:text-blue-400 mr-2">&bull;</span>
              <span class="text-gray-600 dark:text-gray-300">{{ achievement }}</span>
            </li>
            {% endfor %}
          </ul>
        </div>
        {% endfor %}
      </div>
    </div>
  </section>
  {% endif %}

  <!-- Projects Section -->
  {% if site.collections.projects %}
  <section id="projects" class="py-20 bg-gray-100 dark:bg-gray-800">
    <div class="max-w-6xl mx-auto px-4">
      <h2 class="text-4xl font-bold text-center mb-12 text-gray-900 dark:text-white">Projects</h2>
      <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
        {% for item in site.collections.projects.items %}
        <a href="{{ item.frontmatter.extra.link | default(value='#') }}" target="_blank" rel="noopener noreferrer" class="block bg-white dark:bg-gray-900 rounded-lg shadow-lg overflow-hidden hover:shadow-xl transition-all border border-gray-200 dark:border-gray-700 hover:scale-105 cursor-pointer">
          <div class="p-6">
            <h3 class="text-xl font-bold mb-3 text-gray-900 dark:text-white">{{ item.title }}</h3>
            <p class="text-gray-600 dark:text-gray-300 mb-4 leading-relaxed">{{ item.content | striptags | truncate(length=120) }}</p>
            {% if item.frontmatter.extra.technologies %}
            <div class="flex flex-wrap gap-2">
              {% for tech in item.frontmatter.extra.technologies %}
              <span class="px-3 py-1 bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded text-sm border border-gray-200 dark:border-gray-700">{{ tech }}</span>
              {% endfor %}
            </div>
            {% endif %}
          </div>
        </a>
        {% endfor %}
      </div>
    </div>
  </section>
  {% endif %}

  <!-- Education Section -->
  {% if site.data.education %}
  <section id="education" class="py-20 bg-gray-100 dark:bg-gray-800">
    <div class="max-w-4xl mx-auto px-4">
      <h2 class="text-4xl font-bold text-center mb-12 text-gray-900 dark:text-white">Education</h2>
      <div class="space-y-8">
        {% for degree in site.data.education.degrees %}
        <div class="bg-white dark:bg-gray-900 p-6 rounded-lg shadow-md border border-gray-200 dark:border-gray-700">
          <h3 class="text-2xl font-bold text-gray-900 dark:text-white mb-2">{{ degree.degree }}</h3>
          <p class="text-lg text-blue-500 dark:text-blue-400 mb-1">{{ degree.institution }}</p>
          <p class="text-sm text-gray-500 dark:text-gray-400 mb-3">{{ degree.period }}</p>
          <p class="text-gray-600 dark:text-gray-300">{{ degree.description }}</p>
        </div>
        {% endfor %}
      </div>
    </div>
  </section>
  {% endif %}

  <!-- Footer -->
  <footer class="py-8 bg-gray-200 dark:bg-black border-t border-gray-300 dark:border-gray-800">
    <div class="max-w-6xl mx-auto px-4 text-center">
      <p class="text-gray-500 dark:text-gray-400">
        Built with
        <a href="https://github.com/matthewjberger/bamboo" target="_blank" rel="noopener noreferrer" class="text-blue-500 dark:text-blue-400 hover:text-blue-600 dark:hover:text-blue-300">Bamboo</a>
      </p>
    </div>
  </footer>
</div>

<style>
  html {
    scroll-behavior: smooth;
  }
</style>

<script>
  document.getElementById('portfolio-theme-toggle').addEventListener('click', function() {
    var html = document.documentElement;
    if (html.classList.contains('dark')) {
      html.classList.remove('dark');
      localStorage.setItem('theme', 'light');
    } else {
      html.classList.add('dark');
      localStorage.setItem('theme', 'dark');
    }
  });
</script>
{% endblock %}
