{{ define "title" }}Tangled &middot; The next-generation social coding platform{{ end }}

{{ define "extrameta" }}
    <!-- Open Graph Meta Tags -->
    <meta property="og:title" content="Tangled · The next-generation social coding platform" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="https://tangled.org" />
    <meta property="og:description" content="The next-generation social coding platform." />
    <meta property="og:image" content="https://assets.tangled.network/tangled_og.png" />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="630" />

    <!-- Twitter Card Meta Tags -->
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content="Tangled" />
    <meta name="twitter:description" content="The next-generation social coding platform." />
    <meta name="twitter:image" content="https://assets.tangled.network/tangled_og.png" />

    <!-- Additional SEO -->
    <meta name="description" content="The next-generation social coding platform. Host repositories on your infrastructure with knots, use stacked pull requests, and run CI with spindles." />
    <link rel="canonical" href="https://tangled.org" />

    <script>
      document.addEventListener('DOMContentLoaded', () => {
        const videos = document.querySelectorAll('video[data-hls]');
        if (!videos.length) return;

        const attach = () => {
          videos.forEach((video) => {
            const src = video.dataset.hls;
            if (video.canPlayType('application/vnd.apple.mpegurl')) {
              video.src = src;
            } else if (window.Hls && Hls.isSupported()) {
              const hls = new Hls();
              hls.loadSource(src);
              hls.attachMedia(video);
            }
          });
        };

        const needsHls = Array.from(videos).some(
          (v) => !v.canPlayType('application/vnd.apple.mpegurl')
        );
        if (!needsHls) {
          attach();
          return;
        }

        const script = document.createElement('script');
        script.src = '/static/hls.min.js';
        script.onload = attach;
        document.head.appendChild(script);
      });
    </script>
    <script>
      document.addEventListener('DOMContentLoaded', () => {
        document.querySelectorAll('[data-bsky-carousel]').forEach(el => {
          let maxRatio = 0;
          el.querySelectorAll('img[data-aspect]').forEach(img => {
            const [w, h] = img.dataset.aspect.split(':').map(Number);
            if (h > 0) maxRatio = Math.max(maxRatio, w / h);
          });
          if (maxRatio > 0) {
            el.style.height = Math.min(Math.round(el.clientWidth / maxRatio), 400) + 'px';
          }
        });
      });
    </script>
{{ end }}


{{ define "content" }}
  <div class="flex flex-col gap-20 md:gap-40 my-20 md:my-32">
    <div class="relative">
      <div class="hidden md:block absolute inset-0 pointer-events-none z-0 opacity-50 dark:opacity-5
        [mask-image:linear-gradient(to_bottom,black_0%,black_60%,transparent_100%)]
        [-webkit-mask-image:linear-gradient(to_bottom,black_0%,black_60%,transparent_100%)]
        [mask-repeat:no-repeat] [-webkit-mask-repeat:no-repeat]
        [mask-size:100%_100%] [-webkit-mask-size:100%_100%]">
        <div class="absolute inset-0 bg-slate-200 dark:bg-slate-400
          [mask-image:url('https://assets.tangled.network/Rope.svg')]
          [-webkit-mask-image:url('https://assets.tangled.network/Rope.svg')]
          [mask-repeat:no-repeat] [-webkit-mask-repeat:no-repeat]
          [mask-position:10%_center] [-webkit-mask-position:10%_center]
          [mask-size:contain] [-webkit-mask-size:contain]"></div>
      </div>
      <div class="relative z-10 flex flex-col gap-20 md:gap-40">
        {{ template "timeline/fragments/hero" . }}
        {{ template "timeline/fragments/preview" . }}
      </div>
    </div>
    {{ template "features1" . }}
    {{ template "features2" . }}
    {{ template "features3" . }}
    {{ template "recentUpdates" . }}
    {{ if .ShowNewsletter }}{{ template "newsletter" . }}{{ end }}
  </div>
{{ end }}

{{ block "topbarLayout" . }}
  <header class="max-w-screen-xl mx-auto w-full col-span-full md:col-span-1 md:col-start-2" style="z-index: 20;">
     {{ if .LoggedInUser }}
      <div id="upgrade-banner"
           hx-get="/upgradeBanner"
           hx-trigger="load"
           hx-swap="innerHTML">
      </div>
    {{ end }}
    {{ template "layouts/fragments/topbar" . }}
  </header>
{{ end }}

{{ block "footerLayout" . }}
  <footer class="z-10">
    {{ template "layouts/fragments/footerFull" . }}
  </footer>
{{ end }}

{{ block "bodyClasses" . }}
  bg-transparent bg-gradient-to-b from-white to-slate-100 dark:bg-none dark:bg-gray-900
{{ end }}

{{ block "mainLayout" . }}
  <div class="flex-grow relative">
    <div
      class="absolute opacity-50 dark:opacity-5 inset-x-0 top-0 bottom-[-50px] md:bottom-[-150px] pointer-events-none w-full [mask-image:linear-gradient(to_top,transparent_0px,black_250px)] [-webkit-mask-image:linear-gradient(to_top,transparent_0px,black_250px)] [mask-repeat:no-repeat] [-webkit-mask-repeat:no-repeat] [mask-size:100%_100%] [-webkit-mask-size:100%_100%]">
      <div class="absolute inset-0 bg-slate-200 dark:bg-slate-400 [mask-image:url('https://assets.tangled.network/yarn_ball_mask.svg')] [-webkit-mask-image:url('https://assets.tangled.network/yarn_ball_mask.svg')] [mask-repeat:no-repeat] [-webkit-mask-repeat:no-repeat] [mask-position:right_bottom] [-webkit-mask-position:right_bottom] [mask-size:auto] [-webkit-mask-size:auto]"></div>
    </div>
    <div class="max-w-screen-xl mx-auto flex flex-col gap-4 relative z-10">
      {{ block "contentLayout" . }}
      <main>
        {{ block "content" . }}{{ end }}
      </main>
      {{ end }}

      {{ block "contentAfterLayout" . }}
      <main>
        {{ block "contentAfter" . }}{{ end }}
      </main>
      {{ end }}
    </div>
  </div>
{{ end }}

{{ define "features1" }}
  {{ $labelStyle := "normal-case cursor-pointer w-auto md:w-full p-4 md:px-6 rounded bg-white dark:bg-gray-800 font-medium text-base md:text-lg opacity-50 border border-gray-200 dark:border-gray-700 relative overflow-hidden" }}
  {{ $spanStyle := "z-10 items-center justify-between gap-2 w-full" }}
  {{ $connectorStyle := "w-0.5 h-6 bg-gray-200 dark:bg-gray-700 opacity-0 mx-auto" }}
  {{ $contentStyle := "hidden bg-white dark:bg-gray-800 rounded shadow-sm border border-gray-200 dark:border-gray-700 grid-cols-1 animate-fadein" }}
  {{ $progressOverlayStyle := "absolute inset-0 bg-gray-600/10 dark:bg-gray-100/10 w-0 transition-none" }}

  <style>
    @media (max-width: 768px) {
      .features-grid:has(#feature-prs:checked) {
        grid-template-columns: 1fr auto auto;
      }

      .features-grid:has(#feature-knots:checked) {
        grid-template-columns: auto 1fr auto;
      }

      .features-grid:has(#feature-spindles:checked) {
        grid-template-columns: auto auto 1fr;
      }

      #feature-prs:checked ~ label[for="feature-prs"] .label-text,
      #feature-knots:checked ~ label[for="feature-knots"] .label-text,
      #feature-spindles:checked ~ label[for="feature-spindles"] .label-text {
        display: inline-flex !important;
      }
      #feature-prs:checked ~ label[for="feature-prs"] .icon-only,
      #feature-knots:checked ~ label[for="feature-knots"] .icon-only,
      #feature-spindles:checked ~ label[for="feature-spindles"] .icon-only {
        display: none !important;
      }
    }
  </style>

  <div class="features-grid w-full grid grid-cols-3 gap-x-6 px-2">
    <input type="radio" id="feature-prs" name="feature" class="peer/prs hidden" checked />
    <input type="radio" id="feature-knots" name="feature" class="peer/knots hidden" />
    <input type="radio" id="feature-spindles" name="feature" class="peer/spindles hidden" />

    <label for="feature-prs" class="{{ $labelStyle }} peer-checked/prs:opacity-100 peer-checked/prs:shadow-sm">
      <span class="label-text hidden md:inline-flex {{ $spanStyle }}">Stacked Pull-Requests {{ i "git-pull-request" "size-5" }}</span>
      <span class="icon-only inline-flex md:hidden {{ $spanStyle }}">{{ i "git-pull-request" "size-5" }}</span>
      <div class="{{ $progressOverlayStyle }}" data-progress="prs"></div>
    </label>

    <label for="feature-knots" class="{{ $labelStyle }} peer-checked/knots:opacity-100 peer-checked/knots:shadow-sm">
      <span class="label-text hidden md:inline-flex {{ $spanStyle }}">Completely self-hostable {{ i "hard-drive" "size-5" }}</span>
      <span class="icon-only inline-flex md:hidden {{ $spanStyle }}">{{ i "hard-drive" "size-5" }}</span>
      <div class="{{ $progressOverlayStyle }}" data-progress="knots"></div>
    </label>

    <label for="feature-spindles" class="{{ $labelStyle }} peer-checked/spindles:opacity-100 peer-checked/spindles:shadow-sm">
      <span class="label-text hidden md:inline-flex {{ $spanStyle }}">MicroVM-based CI {{ i "layers-2" "size-5" }}</span>
      <span class="icon-only inline-flex md:hidden {{ $spanStyle }}">{{ i "layers-2" "size-5" }}</span>
      <div class="{{ $progressOverlayStyle }}" data-progress="spindles"></div>
    </label>

    <div class="{{ $connectorStyle }} peer-checked/prs:opacity-100"></div>
    <div class="{{ $connectorStyle }} peer-checked/knots:opacity-100"></div>
    <div class="{{ $connectorStyle }} peer-checked/spindles:opacity-100"></div>

    {{ $titleStyle := "text-2xl md:text-6xl my-2 md:mb-4 text-black dark:text-white font-medium" }}
    {{ $textContentStyle := "p-4 md:p-6 md:text-xl" }}
    {{ $imgContentStyle := "w-full overflow-hidden place-content-center bg-gradient-to-b from-slate-50 to-slate-100 dark:from-gray-800 dark:to-gray-900 border-t border-gray-200 dark:border-gray-700" }}
    {{ $linkDesktopStyle := "hover:no-underline items-center gap-2 p-3 text-base btn" }}

    <div class="col-span-3 {{ $contentStyle }} peer-checked/prs:grid">
      <div class="{{ $textContentStyle }} flex gap-4 md:gap-8">
        <section class="space-y-4">
          <h1 class="{{ $titleStyle }}">Pull requests, reimagined</h1>
          <p class="text-gray-600 dark:text-gray-400">
          Break down large features into small, reviewable chunks. Stack pull
          requests on top of each other and ship faster with round-based code
          reviews. Tangled natively supports stacking using Jujutsu.
          </p>
          <a href="https://blog.tangled.org/stacking" class="hover:no-underline inline-flex items-center gap-2 text-sm md:text-base text-black dark:text-white font-medium">
            Learn more
            {{ i "arrow-right" "size-4" }}
          </a>
        </section>
        <div class="w-fit hidden md:flex items-center">
          <div class="size-32 rounded-full flex items-center justify-center bg-yellow-100 dark:bg-yellow-900 -mr-4" >
            {{ i "wand-sparkles" "size-16 text-yellow-500 dark:text-yellow-500" }}
          </div>
          <div class="size-40 rounded-full flex items-center justify-center bg-green-100 dark:bg-green-900 z-10">
            {{ i "git-pull-request-arrow" "size-24 text-green-500 dark:text-green-500 rotate-12" }}
          </div>
        </div>
      </div>
      <div class="{{ $imgContentStyle }} relative overflow-hidden flex items-center justify-center">
        <div class="w-[120%] md:w-full flex">
          <picture class="w-full">
            <source srcset="https://assets.tangled.network/home-page-prs-dark.svg" media="(prefers-color-scheme: dark)" />
            <img src="https://assets.tangled.network/home-page-prs-light.svg" class="w-full block" alt="A list of stacked pull requests with CI checks and PR comments"/>
          </picture>
        </div>
      </div>
    </div>

    <div class="col-span-3 {{ $contentStyle }} peer-checked/knots:grid">
      <div class="{{ $textContentStyle }} flex place-content-between gap-4 md:gap-8">
        <section class="space-y-4">
          <h1 class="{{ $titleStyle }}">Run it at home</h1>
          <p class="text-gray-600 dark:text-gray-400">
            Host your repositories on your own infrastructure with <a href="https://docs.tangled.org/knot-self-hosting-guide.html#knot-self-hosting-guide" class="no-underline">knots</a>.
            Run CI on your own machines with <a href="https://docs.tangled.org/spindles.html#self-hosting-guide" class="no-underline">spindles</a>.
            <br>
            Don't want to self-host? All are welcome on our hosted instances.
          </p>
          <a href="https://docs.tangled.org/knot-self-hosting-guide.html#knot-self-hosting-guide" class="hover:no-underline inline-flex items-center gap-2 text-sm md:text-base text-black dark:text-white font-medium">
            Learn more
            {{ i "arrow-right" "size-4" }}
          </a>
        </section>
        <div class="w-fit hidden md:flex items-center">
          <div class="size-32 rounded-full flex items-center justify-center bg-blue-100 dark:bg-blue-900 -mr-4" >
            {{ i "workflow" "size-16 text-blue-500 dark:text-blue-500" }}
          </div>
          <div class="size-40 rounded-full flex items-center justify-center bg-yellow-100 dark:bg-yellow-900 z-10">
            {{ i "server" "size-24 text-yellow-500 dark:text-yellow-500" }}
          </div>
        </div>
      </div>
      <div class="{{ $imgContentStyle }} relative overflow-hidden flex items-center justify-center">
        <div class="w-[120%] md:w-full flex">
          <picture class="w-full">
            <source srcset="https://assets.tangled.network/home-page-self-host-dark.svg" media="(prefers-color-scheme: dark)" />
            <img src="https://assets.tangled.network/home-page-self-host-light.svg" class="w-full block" alt="A world map with knots hosting code on servers in different locations across the world" />
          </picture>
        </div>
      </div>
    </div>

    <div class="col-span-3 {{ $contentStyle }} peer-checked/spindles:grid">
      <div class="{{ $textContentStyle }} flex place-content-between gap-4 md:gap-8">
        <section class="space-y-4">
          <h1 class="{{ $titleStyle }}">Nix-powered CI</h1>
          <p class="text-gray-600 dark:text-gray-400">
            Run your CI in NixOS powered microVMs. Build containers with Docker
            or setup up services like Postgres, Redis.
            <br>
            Inputs are cached making subsequent runs <em>quick</em>.
          </p>
          <a href="https://blog.tangled.org/spindle-microvm/" class="hover:no-underline inline-flex items-center gap-2 text-sm md:text-base text-black dark:text-white font-medium">
            Learn more
            {{ i "arrow-right" "size-4" }}
          </a>
        </section>
        <div class="w-fit hidden md:flex items-center">
          <div class="size-32 rounded-full flex items-center justify-center bg-green-100 dark:bg-green-900 -mr-4" >
            {{ i "package" "size-16 text-green-500 dark:text-green-500" }}
          </div>
          <div class="size-40 rounded-full flex items-center justify-center bg-indigo-100 dark:bg-indigo-900 z-10">
            {{ i "snowflake" "size-24 text-indigo-500 dark:text-indigo-500 rotate-12" }}
          </div>
        </div>
      </div>
      <div class="{{ $imgContentStyle }} flex items-end justify-center pb-0 overflow-hidden">
        <div class="w-[120%] md:w-full flex">
          <picture class="w-full">
            <source srcset="https://assets.tangled.network/home-page-ci-dark.svg" media="(prefers-color-scheme: dark)" />
            <img src="https://assets.tangled.network/home-page-ci-light.svg" class="w-full block" alt="The Tangled UI showing status checks, a Nix-based CI workflow YAML file, and logs from a CI job"/>
          </picture>
        </div>
      </div>
    </div>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      const featureIds = ['feature-prs', 'feature-knots', 'feature-spindles'];
      const progressNames = ['prs', 'knots', 'spindles'];
      let currentIndex = 0;
      let timerInterval = null;

      function stopTimer() {
        if (timerInterval) {
          clearInterval(timerInterval);
          timerInterval = null;
        }
        document.querySelectorAll('[data-progress]').forEach(el => {
          el.classList.remove('animate-progress');
        });
      }

      const firstProgress = document.querySelector('[data-progress="prs"]');
      if (firstProgress) {
        firstProgress.classList.add('animate-progress');
      }

      document.querySelectorAll('label[for^="feature-"]').forEach(label => {
        label.addEventListener('click', stopTimer);
      });

      timerInterval = setInterval(function() {
        document.querySelectorAll('[data-progress]').forEach(el => {
          el.classList.remove('animate-progress');
          void el.offsetWidth; // force reflow
        });

        currentIndex = (currentIndex + 1) % featureIds.length;
        document.getElementById(featureIds[currentIndex]).checked = true;

        const activeProgress = document.querySelector('[data-progress="' + progressNames[currentIndex] + '"]');
        if (activeProgress) {
          activeProgress.classList.add('animate-progress');
        }
      }, 10000);
    });
  </script>
{{ end }}

{{ define "features2" }}
  {{ $cardStyle := "w-full max-w-[548px] bg-white dark:bg-gray-800 rounded shadow-sm border border-gray-200 dark:border-gray-700 p-4 md:p-6 flex flex-col" }}
  {{ $imgBoxStyle := "w-full rounded overflow-hidden outline outline-1 -outline-offset-1 outline-gray-200 dark:outline-gray-700 bg-gradient-to-b from-slate-50 to-slate-100 dark:from-gray-800 dark:to-gray-900 mb-6" }}
  {{ $titleStyle := "text-2xl md:text-3xl font-bold mb-2 md:mb-3 text-gray-900 dark:text-gray-100" }}
  {{ $descriptionStyle := "text-gray-600 dark:text-gray-300 leading-relaxed mb-6 flex-1" }}
  {{ $linkStyle := "hover:no-underline inline-flex items-center gap-2 text-sm md:text-base text-black dark:text-white font-medium" }}

  <div class="w-full max-w-screen-xl mx-auto px-2">
    <div class="text-center mb-10 md:mb-16 space-y-3">
      <h2 class="text-3xl md:text-4xl font-bold text-gray-900 dark:text-gray-100">Tools to help you work</h2>
      <p class="text-lg text-gray-600 dark:text-gray-400">For when the internet shows up in your inbox.</p>
    </div>

    <div class="flex flex-col md:flex-row items-center md:items-stretch md:justify-center gap-6">
      <div class="{{ $cardStyle }}">
        <div class="{{ $imgBoxStyle }}">
          <picture class="block">
            <source srcset="https://assets.tangled.network/home-page-vouching-dark.svg" media="(prefers-color-scheme: dark)" />
            <img src="https://assets.tangled.network/home-page-vouching-light.svg" class="block w-full h-auto" alt="A globe with contributors carrying coloured trust shields, connected in a web" />
          </picture>
        </div>
        <h3 class="{{ $titleStyle }}">A web of trust</h3>
        <p class="{{ $descriptionStyle }}">
          Vouch for the people you collaborate with. Trusted contributors carry
          a green shield right where you interact with them, so you and your
          circle can tell real work from LLM spam at a glance.
        </p>
        <a href="https://blog.tangled.org/vouching/" class="{{ $linkStyle }}">
          Learn more
          {{ i "arrow-right" "size-4" }}
        </a>
      </div>

      <div class="{{ $cardStyle }}">
        <div class="{{ $imgBoxStyle }}">
          <picture class="block">
            <source srcset="https://assets.tangled.network/home-page-focus-dark.svg" media="(prefers-color-scheme: dark)" />
            <img src="https://assets.tangled.network/home-page-focus-light.svg" class="block w-full h-auto" alt="A focus-mode inbox stepping through issues, pull requests, and mentions one at a time" />
          </picture>
        </div>
        <h3 class="{{ $titleStyle }}">Focus mode</h3>
        <p class="{{ $descriptionStyle }}">
          Focus Mode is a new way to clear notifications: lock in and knock out
          your list one item at a time, with a task bar that nudges you to stay
          on track until the queue is empty.
        </p>
        <a href="https://blog.tangled.org/newsletter-03/#focus-mode" class="{{ $linkStyle }}">
          Learn more
          {{ i "arrow-right" "size-4" }}
        </a>
      </div>
    </div>
  </div>
{{ end }}

{{ define "features3" }}
  {{ $cardStyle := "bg-white dark:bg-gray-800 rounded shadow-sm border border-gray-200 dark:border-gray-700" }}
  {{ $cardInnerStyle := "flex flex-row items-center gap-4 md:gap-6 p-4 md:p-6 md:pt-8 relative" }}
  {{ $contentStyle := "flex-1 flex flex-col" }}
  {{ $titleStyle := "text-xl md:text-2xl font-bold mb-2 md:mb-3 text-gray-900 dark:text-gray-100" }}
  {{ $descriptionStyle := "text-gray-600 dark:text-gray-300 text-sm md:text-base leading-relaxed mb-5 md:mb-0" }}
  {{ $linkMobileStyle := "hover:no-underline inline-flex md:hidden items-center gap-2 text-sm text-black dark:text-white font-medium" }}
  {{ $iconContainerStyle := "relative shrink-0 w-24 h-24 md:w-48 md:h-48" }}
  {{ $iconCircleStyle := "rounded-full flex items-center justify-center border border-gray-200 dark:border-gray-700" }}
  {{ $linkDesktopStyle := "hover:no-underline hidden md:inline-flex absolute -bottom-10 -right-14 items-center gap-2 p-3 text-base btn" }}

  <div class="relative">
    <div class="hidden md:block absolute -top-32 -bottom-32 inset-x-0 pointer-events-none z-0 opacity-50 dark:opacity-5
      [mask-image:linear-gradient(to_bottom,transparent_0%,black_15%,black_85%,transparent_100%)]
      [-webkit-mask-image:linear-gradient(to_bottom,transparent_0%,black_15%,black_85%,transparent_100%)]
      [mask-repeat:no-repeat] [-webkit-mask-repeat:no-repeat]
      [mask-size:100%_100%] [-webkit-mask-size:100%_100%]">
      <div class="absolute inset-0 bg-slate-200 dark:bg-slate-400
        [mask-image:url('https://assets.tangled.network/rope-2.svg')]
        [-webkit-mask-image:url('https://assets.tangled.network/rope-2.svg')]
        [mask-repeat:no-repeat] [-webkit-mask-repeat:no-repeat]
        [mask-position:-400px_center] [-webkit-mask-position:-400px_center]
        [mask-size:auto_200%] [-webkit-mask-size:auto_200%]"></div>
    </div>
  <div class="relative z-10 w-full flex flex-col gap-6 md:gap-40 max-w-5xl mx-auto px-2">
    <div class="{{ $cardStyle }} md:mr-32">
      <div class="{{ $cardInnerStyle }}">
        {{ $moreLink := "https://docs.tangled.org/quick-start-guide.html#login-or-sign-up" }}
        <div class="{{ $contentStyle }}">
          <h2 class="{{ $titleStyle }}">Built on AT Protocol</h2>
          <p class="{{ $descriptionStyle }}">
            <a class="underline" href="https://atproto.com/">AT Protocol</a> enables federated code-collaboration. Submit
            pull-requests or bug-reports to any repository hosted on any
            server.
            <br>
            <br>
            Bring an existing AT Protocol account (such as your Bluesky
            account), or signup for one with us.
          </p>
          <a href="{{ $moreLink }}" class="{{ $linkMobileStyle }}">
            Learn more
            {{ i "arrow-right" "size-4" }}
          </a>
        </div>
        <div class="{{ $iconContainerStyle }}">
          <div class="{{ $iconCircleStyle }} w-full h-full bg-blue-100 dark:bg-blue-900/50">
            {{ i "at-sign" "size-12 md:size-24" "text-blue-500 dark:text-blue-500" "rotate-12" }}
          </div>
          <div class="{{ $iconCircleStyle }} absolute -top-2 -left-2 w-10 h-10 md:w-16 md:h-16 rounded-full bg-white dark:bg-gray-800 -rotate-12">
            {{ i "globe" "size-4 md:size-8" "text-blue-500 dark:text-blue-500" }}
          </div>
          <a href="{{ $moreLink }}" class="{{ $linkDesktopStyle }}">
            Learn more
            {{ i "arrow-right" "size-4" }}
          </a>
        </div>
      </div>
    </div>

    <div class="{{ $cardStyle }} md:ml-32">
      <div class="{{ $cardInnerStyle }}">
        {{ $moreLink := "https://tangled.org/core" }}
        <div class="{{ $contentStyle }}">
          <h2 class="{{ $titleStyle }}">Free and open source</h2>
          <p class="{{ $descriptionStyle }}">
            All of Tangled is open source and built with the community!
            Check out the <a class="underline" href="https://tangled.org/core">monorepo</a> and join in on the fun.
            <br>
            <br>
            We welcome contributions however big or small. You can start contributing by picking up a
            <a class="underline" href="https://tangled.org/tangled.org/core/issues?q=state%3Aopen+label%3Agood-first-issue">good-first-issue</a>.
          </p>
          <a href="{{ $moreLink }}" class="{{ $linkMobileStyle }}">
            View source
            {{ i "arrow-right" "size-4" }}
          </a>
        </div>
        <div class="{{ $iconContainerStyle }}">
          <div class="{{ $iconCircleStyle }} w-full h-full bg-green-100 dark:bg-green-900/50">
            {{ i "package-open" "size-12 md:size-24" "text-green-500 dark:text-green-500" "-rotate-12" }}
          </div>
          <div class="absolute -top-2 -left-2 w-10 h-10 md:w-16 md:h-16 rounded-full bg-white dark:bg-gray-800 flex items-center justify-center border border-gray-200 dark:border-gray-700 rotate-12">
            {{ i "heart" "size-4 md:size-8" "text-green-500 dark:text-green-500" }}
          </div>
          <a href="{{ $moreLink }}" class="{{ $linkDesktopStyle }}">
            View source
            {{ i "arrow-right" "size-4" }}
          </a>
        </div>
      </div>
    </div>

    <div class="{{ $cardStyle }} md:mr-32">
      <div class="{{ $cardInnerStyle }}">
        {{ $moreLink := "/timeline" }}
        <div class="{{ $contentStyle }}">
          <h2 class="{{ $titleStyle }}">Social coding is back</h2>
          <p class="{{ $descriptionStyle }}">
            Discover trending projects, follow your friends and star your favourite repositories. Coding is better together!
          </p>
          <a href="{{ $moreLink }}" class="{{ $linkMobileStyle }}">
            Explore timeline
            {{ i "arrow-right" "size-4" }}
          </a>
        </div>
        <div class="{{ $iconContainerStyle }}">
          <div class="{{ $iconCircleStyle }} w-full h-full bg-amber-100 dark:bg-amber-900/50">
            {{ i "message-circle-heart" "size-12 md:size-24" "text-amber-500 dark:text-amber-500" "rotate-12" }}
          </div>
          <div class="absolute -top-2 -left-2 w-10 h-10 md:w-16 md:h-16 rounded-full bg-white dark:bg-gray-800 flex items-center justify-center border border-gray-200 dark:border-gray-700 -rotate-12">
            {{ i "users" "size-4 md:size-8" "text-amber-500 dark:text-amber-500" }}
          </div>
          <a href="{{ $moreLink }}" class="{{ $linkDesktopStyle }}">
            Explore timeline
            {{ i "arrow-right" "size-4" }}
          </a>
        </div>
      </div>
    </div>
  </div>
  </div>
{{ end }}

{{ define "changelog" }}
  <div class="w-full px-2 py-16 md:py-24">
    <h2 class="text-3xl md:text-4xl font-bold mb-8 text-gray-900 dark:text-gray-100">Changelog</h2>

    <div class="grid grid-cols-1 gap-6 mb-6">
      {{ range $index := list 0 1 2 3 }}
        <div class="bg-white dark:bg-gray-800 rounded shadow-sm border border-gray-200 dark:border-gray-700 p-6">
          <div class="flex items-center gap-2 mb-3">
            <span class="text-xs font-medium text-gray-500 dark:text-gray-400">v1.{{ sub 3 $index }}.0</span>
            <span class="text-xs text-gray-400 dark:text-gray-500">•</span>
            <span class="text-xs text-gray-500 dark:text-gray-400">Feb {{ sub 16 $index }}, 2026</span>
          </div>
          <h3 class="text-lg font-semibold mb-2 text-gray-900 dark:text-gray-100">Feature Update {{ sub 4 $index }}</h3>
          <p class="text-sm text-gray-600 dark:text-gray-300 leading-relaxed">
            Improvements to the platform including bug fixes, performance enhancements, and new features.
          </p>
        </div>
      {{ end }}
    </div>

    <div class="flex justify-end">
      <a href="/changelog" class="hover:no-underline inline-flex items-center gap-2 px-4 py-2 text-base btn">
        View full changelog
        {{ i "arrow-right" "size-4" }}
      </a>
    </div>
  </div>
{{ end }}

{{ define "recentUpdates" }}
  <div class="w-full px-2 py-16 md:py-24">
    <h2 class="px-4 text-3xl md:text-4xl font-bold text-gray-900 dark:text-gray-100 mb-2">Recent updates</h2>
    <p class="px-4 mb-8 text-gray-500 dark:text-gray-400">
      Follow <a href="https://bsky.app/profile/tangled.org">@tangled.org</a> on Bluesky for more!
    </p>
    <div class="columns-1 md:columns-2 lg:columns-3 gap-6">
      {{ range $index, $post := .BlueskyPosts }}
        <div class="{{ if ge $index 3 }}hidden md:block{{ end }}">
          {{ template "post" $post }}
        </div>
      {{ end }}
    </div>
  </div>
{{ end }}

{{ define "post" }}
  {{ $author := or .AuthorDid "tangled.org" }}
  <div class="bg-white dark:bg-gray-800 rounded shadow-sm border border-gray-200 dark:border-gray-700 px-6 py-4 flex flex-col gap-2 break-inside-avoid mb-6">
    <div class="flex items-center justify-between text-sm text-gray-500 dark:text-gray-400">
      <a href="https://bsky.app/profile/{{ $author }}" target="_blank" rel="noopener noreferrer" class="flex items-center gap-2 no-underline hover:no-underline">
        {{ template "user/fragments/picHandle" $author }}
      </a>
      <span>{{ template "repo/fragments/shortTimeAgo" .CreatedAt }}</span>
    </div>
    <p class="text-gray-900 dark:text-gray-100 text-base leading-relaxed whitespace-pre-wrap">{{ .Text }}</p>

    {{ if .Embed }}
      {{ if .Embed.Images }}
        {{ if eq (len .Embed.Images) 1 }}
          {{ with index .Embed.Images 0 }}
            <img src="{{ .Fullsize }}" alt="{{ .Alt }}"
              class="rounded w-full h-auto object-cover border border-gray-200 dark:border-gray-700"
              loading="lazy" />
          {{ end }}
        {{ else }}
          {{ $total := len .Embed.Images }}
          <div class="flex overflow-x-auto gap-1.5 rounded"
               style="scrollbar-width: none; -ms-overflow-style: none;"
               data-bsky-carousel>
            {{ range $i, $img := .Embed.Images }}
              <div class="relative flex-shrink-0 h-full">
                <img src="{{ $img.Fullsize }}" alt="{{ $img.Alt }}"
                  class="h-full w-auto rounded object-cover border border-gray-200 dark:border-gray-700"
                  loading="lazy"
                  {{ if $img.AspectRatio }}data-aspect="{{ $img.AspectRatio.Width }}:{{ $img.AspectRatio.Height }}"{{ end }} />
                <span class="absolute top-2 right-2 bg-black/60 text-white text-xs font-medium px-1.5 py-0.5 rounded pointer-events-none select-none tabular-nums">{{ add $i 1 }}/{{ $total }}</span>
              </div>
            {{ end }}
          </div>
        {{ end }}
      {{ else if .Embed.External }}
        <a href="{{ .Embed.External.Uri }}" target="_blank" rel="noopener noreferrer" class="hover:no-underline block border border-gray-200 dark:border-gray-700 rounded overflow-hidden hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
          {{ if .Embed.External.Thumb }}
            <img src="{{ .Embed.External.Thumb }}" alt="" class="w-full h-48 object-cover" loading="lazy" />
          {{ end }}
          <div class="p-3">
            <div class="font-medium text-gray-900 dark:text-gray-100 text-sm mb-1">{{ .Embed.External.Title }}</div>
            <div class="text-xs text-gray-600 dark:text-gray-400 line-clamp-2">{{ .Embed.External.Description }}</div>
            <div class="text-xs text-gray-500 dark:text-gray-500 mt-1">{{ .Embed.External.Uri }}</div>
          </div>
        </a>
      {{ else if .Embed.Video }}
        <video
          class="rounded w-full h-auto max-h-[32rem] bg-black border border-gray-200 dark:border-gray-700"
          controls
          preload="none"
          playsinline
          {{ with .Embed.Video.Thumbnail }}poster="{{ . }}"{{ end }}
          {{ with .Embed.Video.Alt }}aria-label="{{ . }}"{{ end }}
          data-hls="{{ .Embed.Video.Playlist }}"
        ></video>
      {{ end }}
    {{ end }}

    <a href="https://bsky.app/profile/{{ $author }}/post/{{ .Rkey }}"
      target="_blank"
      rel="noopener noreferrer"
      class="flex items-center justify-between gap-4 text-sm text-gray-500 dark:text-gray-400 pt-2 no-underline hover:no-underline">
      <div class="flex items-center gap-4">
        <div class="flex items-center gap-1">
          {{ i "heart" "size-4" }}
          <span>{{ .LikeCount }}</span>
        </div>
        <div class="flex items-center gap-1">
          {{ i "repeat-2" "size-4" }}
          <span>{{ .RepostCount }}</span>
        </div>
        <div class="flex items-center gap-1">
          {{ i "message-square" "size-4 -scale-x-1" }}
          <span>{{ add64 .ReplyCount .QuoteCount }}</span>
        </div>
      </div>
      {{ i "arrow-up-right" "size-4" }}
    </a>
  </div>
{{ end }}

{{ define "newsletter" }}
  <div class="w-full px-2 py-16 md:py-24">
    <div class="max-w-2xl mx-auto text-center space-y-6">
      <h2 class="text-3xl md:text-6xl font-bold text-gray-900 dark:text-gray-100">Stay in the loop</h2>
      <p class="text-xl text-gray-600 dark:text-gray-300">
        We've got a newsletter! Punch in your email to stay updated on what we're shipping at Tangled.
      </p>
      {{ template "timeline/fragments/newsletterForm" (dict "Id" "home" "Variant" "hero") }}
    </div>
  </div>
{{ end }}
