---
import Default from '@astrojs/starlight/components/Head.astro';
---

<Default><slot /></Default>

<script>
  // Lightbox: click-to-zoom on article images. Loaded once per page; auto-reattaches
  // after Starlight client-side navigation.
  import mediumZoom from 'medium-zoom';
  import 'medium-zoom/dist/style.css';

  const SELECTOR = '.sl-markdown-content img:not(.no-zoom)';
  let zoom: ReturnType<typeof mediumZoom> | null = null;

  function refresh() {
    if (!zoom) {
      zoom = mediumZoom(SELECTOR, {
        background: 'rgba(10, 22, 40, 0.92)',
        margin: 32,
      });
    } else {
      zoom.detach();
      zoom.attach(SELECTOR);
    }
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', refresh, { once: true });
  } else {
    refresh();
  }
  document.addEventListener('astro:after-swap', refresh);
</script>
