---
/**
 * Native-vs-WebGL GAL comparison strips for the WebGL-port blog post.
 *
 * Each scenario from the GAL regression suite (tests/gal-regression) is rendered
 * twice — once by KiCad's native OpenGL GAL, once by the new WebGL GAL — and the
 * two are laid side by side so the reader can eyeball parity, exactly the way the
 * suite is validated. Source PNGs are the committed baselines (1600×1200);
 * astro:assets <Picture> emits responsive AVIF/WebP at build time.
 */
import { Picture } from 'astro:assets';
import alphaNative from '../assets/gal/gal-alpha-blending-native.png';
import alphaWebgl from '../assets/gal/gal-alpha-blending-webgl.png';
import xfNative from '../assets/gal/gal-transform-api-native.png';
import xfWebgl from '../assets/gal/gal-transform-api-webgl.png';

const pairs = [
  {
    title: 'Alpha blending',
    native: alphaNative,
    webgl: alphaWebgl,
    caption:
      'Overlapping translucent fills plus a fading alpha ramp, native OpenGL and WebGL come out close.',
  },
  {
    title: 'The Transform() API',
    native: xfNative,
    webgl: xfWebgl,
    caption:
      'A scenario the other way round: KiCad’s Transform() entry point is dead code on the desktop, so our "correct" implementation doesn\'t matter in the end.',
  },
];
---

<div class="gal-compare not-prose">
  {pairs.map((p) => (
    <figure class="gal-pair">
      <div class="gal-pair__grid">
        <div class="gal-shot">
          <span class="gal-shot__tag">Native OpenGL</span>
          <Picture
            src={p.native}
            formats={['avif', 'webp']}
            widths={[320, 640, 800]}
            sizes="(max-width: 700px) 90vw, 340px"
            alt={`${p.title} rendered by KiCad's native OpenGL GAL`}
            loading="lazy"
            decoding="async"
          />
        </div>
        <div class="gal-shot">
          <span class="gal-shot__tag gal-shot__tag--webgl">WebGL</span>
          <Picture
            src={p.webgl}
            formats={['avif', 'webp']}
            widths={[320, 640, 800]}
            sizes="(max-width: 700px) 90vw, 340px"
            alt={`${p.title} rendered by the new WebGL GAL`}
            loading="lazy"
            decoding="async"
          />
        </div>
      </div>
      <figcaption><strong>{p.title}.</strong> {p.caption}</figcaption>
    </figure>
  ))}
</div>

<style>
  .gal-compare {
    display: grid;
    gap: 1.75rem;
    margin: 2rem 0;
  }
  .gal-pair {
    margin: 0;
  }
  .gal-pair__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  .gal-shot {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-soft);
  }
  /* astro:assets <Picture> emits the <img>; style it globally within the shot. */
  .gal-shot :global(img) {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: contain;
  }
  .gal-shot__tag {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 1;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.02em;
    color: var(--fg);
    background: rgba(11, 16, 32, 0.82);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.12rem 0.4rem;
  }
  .gal-shot__tag--webgl {
    color: #fff;
    background: var(--brand-600);
    border-color: transparent;
  }
  .gal-pair figcaption {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--fg-muted);
  }
  @media (max-width: 460px) {
    .gal-pair__grid {
      grid-template-columns: 1fr;
    }
  }
</style>
