# #145 — Masonry Archive with Lightbox Filmstrip

> Warm-stone variable-aspect masonry archive with category filters, full-screen lightbox, bottom thumbnail filmstrip, and swipe nav.

## Metadata

- **Index**: #145
- **Slug**: `masonry-lightbox-filmstrip`
- **Kind**: `ui`
- **Family**: Gallery & Archive
- **Theme**: `light`
- **Mobile Strength**: `native-first`
- **Tags**: `masonry`, `lightbox`, `filmstrip`, `swipe-nav`, `visual-archive`, `gallery`
- **Best For**: Creative inspiration and visual bookmarking, Architecture and photography portfolios, Editorial lookbooks and museum collections, Design asset and brand reference libraries
- **Real-World Inspiration**: [Cosmos](https://www.cosmos.so/)
- **Detail Page**: https://templates.michaelpitts.net/t/masonry-lightbox-filmstrip
- **Live Demo**: https://templates.michaelpitts.net/demos/masonry-lightbox-filmstrip.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/masonry-lightbox-filmstrip

## Why This Aesthetic Is Unique

Preserves each artwork's native aspect ratio in a serene masonry grid and opens into a cinema-grade lightbox where a synchronized filmstrip and touch-swipe gestures let curators glide across items.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Gallery Stone | `#F5F3EF` |
| `surface` | Matte Frame | `#FFFFFF` |
| `ink` | Archival Ink | `#1A1917` |
| `accent` | Ochre Terracotta | `#B45309` |
| `muted` | Plaster Gray | `#78736A` |

## Typography

- **Display**: `Newsreader`
- **Body**: `Inter`
- **Mono**: `JetBrains Mono`
- **Scale Notes**: 24px gallery header, 13px artwork captions, 11px mono index counter (04 / 12) and aspect ratio metadata.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=Inter:wght@500;600&family=Newsreader:wght@600;700&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@500;600&family=Newsreader:wght@600;700&display=swap">
  ```

## Layout Architecture

Responsive CSS multi-column masonry (4 cols desktop -> 2 cols mobile) with full-screen dark lightbox modal and centered scrollable thumbnail filmstrip.

## Interaction & Micro-Motion Rules

Category chips filter the masonry live; clicking any card opens the lightbox with ArrowLeft/ArrowRight/Escape keyboard navigation, touch swipe left/right, and clickable filmstrip thumbnails.

## Mobile & Responsive Rules

Uses a clean 2-column masonry grid at 390px with >=44px lightbox Prev/Next/Close targets and native horizontal touch swipe inside the lightbox stage.

## Agent Guardrails

### DO
- Set break-inside: avoid on masonry items so cards never split awkwardly across columns.
- Support keyboard arrows, Escape to close, and horizontal touch swipe inside the lightbox.
- Keep the active thumbnail centered and highlighted in the bottom lightbox filmstrip.

### DON'T
- Never crop diverse artworks into uniform squares when the goal is a variable-aspect archive.
- Avoid trapping keyboard focus behind the lightbox backdrop without an explicit Close button.

## Complete Standalone Starter Code

File: `demos/masonry-lightbox-filmstrip.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Atelier Archive — Masonry Lightbox &amp; Filmstrip</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet">
<style>
  :root {
    --bg: #F5F2EC;
    --surface: #ECE7DE;
    --card: #FBF9F5;
    --ink: #1C1917;
    --muted: #78716C;
    --border: rgba(28, 25, 23, 0.11);
    --accent: #B85231;
    --lightbox-bg: rgba(18, 16, 14, 0.96);
    --radius: 10px;
    --serif: 'Cormorant Garamond', Georgia, serif;
    --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
  }

  .masthead {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(245, 242, 236, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
  }

  .masthead-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 16px 24px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .top-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }

  .brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
  }

  .brand h1 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.85rem;
    letter-spacing: -0.02em;
    line-height: 1;
  }

  .brand .edition {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
  }

  .meta-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.82rem;
    color: var(--muted);
  }

  .saved-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
  }

  .saved-pill:hover { border-color: var(--ink); }
  .saved-pill[aria-pressed="true"] {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
  }

  .filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .filter-bar::-webkit-scrollbar { display: none; }

  .chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
  }

  .chip:hover {
    color: var(--ink);
    background: var(--surface);
  }

  .chip.active {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
  }

  .gallery-wrap {
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px 24px 64px;
  }

  .masonry {
    column-count: 4;
    column-gap: 18px;
  }

  .card {
    break-inside: avoid;
    margin-bottom: 18px;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
  }

  .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px rgba(28, 25, 23, 0.09);
  }

  .card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .card-art {
    width: 100%;
    display: block;
    background: var(--surface);
    position: relative;
  }

  .card-art svg {
    display: block;
    width: 100%;
    height: auto;
  }

  .card-save {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(28, 25, 23, 0.56);
    backdrop-filter: blur(8px);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.18s ease, background 0.18s ease, transform 0.15s ease;
    z-index: 2;
  }

  .card:hover .card-save,
  .card-save:focus-visible,
  .card-save.saved {
    opacity: 1;
  }

  .card-save.saved {
    background: var(--accent);
    border-color: var(--accent);
  }

  .card-caption {
    padding: 12px 14px 13px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }

  .card-title {
    font-family: var(--serif);
    font-size: 1.08rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
  }

  .card-tag {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    white-space: nowrap;
  }

  .empty-state {
    text-align: center;
    padding: 72px 20px;
    color: var(--muted);
    display: none;
  }

  .empty-state h2 {
    font-family: var(--serif);
    font-size: 1.6rem;
    color: var(--ink);
    margin-bottom: 8px;
  }

  /* Lightbox */
  .lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--lightbox-bg);
    color: #F5F2EC;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .lightbox.open {
    display: flex;
    opacity: 1;
  }

  .lb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(245, 242, 236, 0.1);
    gap: 12px;
  }

  .lb-counter {
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(245, 242, 236, 0.65);
  }

  .lb-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .lb-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(245, 242, 236, 0.18);
    background: rgba(245, 242, 236, 0.06);
    color: #F5F2EC;
    font-family: inherit;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease;
  }

  .lb-btn:hover {
    background: rgba(245, 242, 236, 0.15);
    border-color: rgba(245, 242, 236, 0.35);
  }

  .lb-btn.saved {
    background: var(--accent);
    border-color: var(--accent);
  }

  .lb-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 310px;
    position: relative;
  }

  .lb-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 72px;
    min-height: 0;
    touch-action: pan-y;
    user-select: none;
  }

  .lb-art-frame {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.55);
  }

  .lb-art-frame svg {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 230px);
    width: auto;
    height: auto;
  }

  .lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 1px solid rgba(245, 242, 236, 0.2);
    background: rgba(20, 18, 16, 0.72);
    color: #F5F2EC;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease;
    z-index: 4;
  }

  .lb-nav:hover { background: rgba(245, 242, 236, 0.18); }
  .lb-prev { left: 16px; }
  .lb-next { right: 16px; }

  .lb-aside {
    border-left: 1px solid rgba(245, 242, 236, 0.1);
    padding: 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
  }

  .lb-aside .kicker {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #D48466;
  }

  .lb-aside h2 {
    font-family: var(--serif);
    font-size: 1.9rem;
    font-weight: 500;
    line-height: 1.12;
  }

  .lb-aside .desc {
    font-size: 0.88rem;
    line-height: 1.6;
    color: rgba(245, 242, 236, 0.74);
  }

  .spec-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 14px;
    font-size: 0.8rem;
    padding-top: 12px;
    border-top: 1px solid rgba(245, 242, 236, 0.1);
  }

  .spec-list dt { color: rgba(245, 242, 236, 0.5); }
  .spec-list dd { color: #F5F2EC; text-align: right; }

  .swatches {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
  }

  .swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
  }

  .hint-keys {
    margin-top: auto;
    font-size: 0.74rem;
    color: rgba(245, 242, 236, 0.45);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .kbd {
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(245, 242, 236, 0.22);
    font-size: 0.7rem;
  }

  /* Filmstrip */
  .filmstrip-wrap {
    border-top: 1px solid rgba(245, 242, 236, 0.12);
    background: rgba(12, 10, 9, 0.9);
    padding: 10px 16px;
  }

  .filmstrip {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-behavior: smooth;
    justify-content: safe center;
  }
  .filmstrip::-webkit-scrollbar { display: none; }

  .thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    background: #24201C;
    padding: 0;
    cursor: pointer;
    opacity: 0.52;
    transition: opacity 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
  }

  .thumb:hover { opacity: 0.85; }
  .thumb.active {
    opacity: 1;
    border-color: #E28B6B;
    transform: translateY(-2px);
  }

  .thumb svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  @media (max-width: 1060px) {
    .masonry { column-count: 3; }
    .lb-body { grid-template-columns: 1fr 260px; }
  }

  @media (max-width: 760px) {
    .masthead-inner { padding: 12px 14px; gap: 10px; }
    .brand h1 { font-size: 1.48rem; }
    .gallery-wrap { padding: 14px 12px 48px; }
    .masonry { column-count: 2; column-gap: 12px; }
    .card { margin-bottom: 12px; }
    .card-save { opacity: 0.92; width: 44px; height: 44px; }
    .card-caption { padding: 9px 10px 10px; flex-direction: column; gap: 2px; }
    .card-title { font-size: 0.96rem; }

    .lb-body {
      grid-template-columns: 1fr;
      grid-template-rows: 1fr auto;
    }
    .lb-stage { padding: 14px 12px; }
    .lb-art-frame svg { max-height: 48vh; }
    .lb-nav { width: 44px; height: 44px; }
    .lb-prev { left: 8px; }
    .lb-next { right: 8px; }
    .lb-aside {
      border-left: none;
      border-top: 1px solid rgba(245, 242, 236, 0.12);
      padding: 14px 16px;
      gap: 8px;
      max-height: 28vh;
    }
    .lb-aside h2 { font-size: 1.35rem; }
    .hint-keys { display: none; }
    .thumb { width: 54px; height: 46px; }
  }
</style>
</head>
<body>

<header class="masthead">
  <div class="masthead-inner">
    <div class="top-row">
      <div class="brand">
        <h1>Atelier Archive</h1>
        <span class="edition">Vol. IV &middot; Spatial &amp; Material Index</span>
      </div>
      <div class="meta-right">
        <span id="countLabel">12 studies</span>
        <button id="savedFilterBtn" class="saved-pill" type="button" aria-pressed="false">
          <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
          <span>Saved (<span id="savedCount">2</span>)</span>
        </button>
      </div>
    </div>
    <nav class="filter-bar" aria-label="Collection categories" id="filterBar"></nav>
  </div>
</header>

<main class="gallery-wrap">
  <div class="masonry" id="masonryGrid" aria-live="polite"></div>
  <div class="empty-state" id="emptyState">
    <h2>No saved studies yet</h2>
    <p>Bookmark any piece in the archive to build your personal reference board.</p>
  </div>
</main>

<div class="lightbox" id="lightbox" role="dialog" aria-modal="true" aria-label="Artwork lightbox">
  <div class="lb-header">
    <span class="lb-counter" id="lbCounter">1 / 12</span>
    <div class="lb-actions">
      <button class="lb-btn" id="lbSaveBtn" type="button" aria-label="Bookmark study">
        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
        <span id="lbSaveText">Save</span>
      </button>
      <button class="lb-btn" id="lbCloseBtn" type="button" aria-label="Close lightbox">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
      </button>
    </div>
  </div>

  <div class="lb-body">
    <div class="lb-stage" id="lbStage">
      <button class="lb-nav lb-prev" id="lbPrev" type="button" aria-label="Previous artwork">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
      </button>
      <div class="lb-art-frame" id="lbArtFrame"></div>
      <button class="lb-nav lb-next" id="lbNext" type="button" aria-label="Next artwork">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>
      </button>
    </div>

    <aside class="lb-aside">
      <span class="kicker" id="lbCategory">Architecture</span>
      <h2 id="lbTitle">Title</h2>
      <p class="desc" id="lbDesc"></p>
      <dl class="spec-list" id="lbSpecs"></dl>
      <div class="swatches" id="lbSwatches" aria-label="Color palette"></div>
      <div class="hint-keys">
        <span><span class="kbd">&larr;</span> <span class="kbd">&rarr;</span> Navigate</span>
        <span><span class="kbd">Esc</span> Close</span>
        <span>Swipe on touch</span>
      </div>
    </aside>
  </div>

  <div class="filmstrip-wrap">
    <div class="filmstrip" id="filmstrip" role="tablist" aria-label="Artwork filmstrip"></div>
  </div>
</div>

<script>
const ITEMS = [
  {
    id: 'travertine-arch',
    title: 'Travertine Colonnade IV',
    category: 'Architecture',
    creator: 'Studio Vermeer, Milan',
    year: '2024',
    medium: 'Honed Roman travertine & noon shadow',
    ratio: '3:4',
    colors: ['#E9E2D4', '#C4B39B', '#7A6450', '#231F1C'],
    desc: 'Rhythmic recessed barrel vaults cut from porous limestone, photographed at solar zenith to isolate geometric shadow bands.',
    svg: `<svg viewBox="0 0 360 480" xmlns="http://www.w3.org/2000/svg">
      <rect width="360" height="480" fill="#E9E2D4"/>
      <rect x="0" y="370" width="360" height="110" fill="#D5C8B5"/>
      <path d="M40 480 V180 A140 140 0 0 1 320 180 V480 Z" fill="#C4B39B"/>
      <path d="M84 480 V192 A96 96 0 0 1 276 192 V480 Z" fill="#7A6450"/>
      <path d="M126 480 V206 A54 54 0 0 1 234 206 V480 Z" fill="#231F1C"/>
      <polygon points="84,370 276,370 330,480 30,480" fill="#A9967D" opacity="0.55"/>
      <line x1="0" y1="370" x2="360" y2="370" stroke="#231F1C" stroke-opacity="0.18"/>
    </svg>`
  },
  {
    id: 'ochre-vessel',
    title: 'Kiln Vessel No. 19',
    category: 'Ceramics',
    creator: 'Hana Takahashi',
    year: '2025',
    medium: 'Wood-fired stoneware, raw iron slip',
    ratio: '4:3',
    colors: ['#F2ECE1', '#C86743', '#8B3E24', '#3B2821'],
    desc: 'Asymmetric coil-built amphora balancing raw terracotta grit against a matte oxidized lip.',
    svg: `<svg viewBox="0 0 440 330" xmlns="http://www.w3.org/2000/svg">
      <rect width="440" height="330" fill="#F2ECE1"/>
      <ellipse cx="220" cy="272" rx="110" ry="18" fill="#D6CBB8"/>
      <path d="M180 72 C180 56 260 56 260 72 L248 118 C298 145 308 218 264 268 L176 268 C132 218 142 145 192 118 Z" fill="#C86743"/>
      <path d="M220 62 C244 62 260 66 260 72 L248 118 C298 145 308 218 264 268 L220 268 Z" fill="#9D482A" opacity="0.55"/>
      <ellipse cx="220" cy="72" rx="40" ry="9" fill="#3B2821"/>
      <path d="M168 186 Q220 206 272 186" stroke="#F2ECE1" stroke-width="2" fill="none" opacity="0.45"/>
      <circle cx="96" cy="96" r="28" fill="#E3D7C4"/>
    </svg>`
  },
  {
    id: 'louver-noon',
    title: 'Solar Louver Study',
    category: 'Light Studies',
    creator: 'M. Lindqvist',
    year: '2024',
    medium: 'Cast concrete & 14:30 daylight',
    ratio: '4:5',
    colors: ['#262320', '#5E554B', '#DFCBB2', '#F7F1E7'],
    desc: 'Diagonal shafts of late-afternoon light slicing across a board-formed concrete stairwell.',
    svg: `<svg viewBox="0 0 360 450" xmlns="http://www.w3.org/2000/svg">
      <rect width="360" height="450" fill="#262320"/>
      <g fill="#DFCBB2">
        <polygon points="0,30 360,120 360,156 0,66"/>
        <polygon points="0,110 360,200 360,236 0,146" opacity="0.9"/>
        <polygon points="0,190 360,280 360,316 0,226" opacity="0.8"/>
        <polygon points="0,270 360,360 360,396 0,306" opacity="0.65"/>
        <polygon points="0,350 360,440 360,450 0,386" opacity="0.45"/>
      </g>
      <rect x="235" y="0" width="125" height="450" fill="#1B1917" opacity="0.42"/>
      <circle cx="118" cy="210" r="46" fill="#F7F1E7" opacity="0.22"/>
    </svg>`
  },
  {
    id: 'swiss-grid-08',
    title: 'Exhibition Poster 08',
    category: 'Typography',
    creator: 'Keller & Sohn, Basel',
    year: '2023',
    medium: '2-color offset lithograph on cotton rag',
    ratio: '3:4',
    colors: ['#F4EFE6', '#181715', '#C8472C', '#D6CEC0'],
    desc: 'Constructivist modular grid pairing bold grotesque numerals with negative-space vertical cadence.',
    svg: `<svg viewBox="0 0 360 480" xmlns="http://www.w3.org/2000/svg">
      <rect width="360" height="480" fill="#F4EFE6"/>
      <g stroke="#181715" stroke-opacity="0.14" stroke-width="1">
        <line x1="90" y1="0" x2="90" y2="480"/><line x1="180" y1="0" x2="180" y2="480"/><line x1="270" y1="0" x2="270" y2="480"/>
        <line x1="0" y1="120" x2="360" y2="120"/><line x1="0" y1="240" x2="360" y2="240"/><line x1="0" y1="360" x2="360" y2="360"/>
      </g>
      <circle cx="180" cy="210" r="92" fill="#C8472C"/>
      <rect x="90" y="210" width="180" height="150" fill="#181715"/>
      <text x="32" y="88" font-family="sans-serif" font-weight="700" font-size="48" fill="#181715" letter-spacing="-2">KUNST</text>
      <text x="34" y="424" font-family="sans-serif" font-weight="600" font-size="14" fill="#181715" letter-spacing="3">BASEL · 14.09—28.11</text>
      <circle cx="270" cy="120" r="24" fill="#181715"/>
    </svg>`
  },
  {
    id: 'monolith-steps',
    title: 'Cantilevered Stair, Kyoto',
    category: 'Architecture',
    creator: 'Kengo Studio Archive',
    year: '2025',
    medium: 'Poured-in-place basalt concrete',
    ratio: '1:1',
    colors: ['#DDD7CC', '#9E9689', '#5A554E', '#24221F'],
    desc: 'Stepped brutalist volume emerging from a gravel courtyard, softened by overcast northern sky.',
    svg: `<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
      <rect width="400" height="400" fill="#DDD7CC"/>
      <polygon points="40,340 40,290 110,290 110,240 180,240 180,190 250,190 250,140 340,140 340,340" fill="#5A554E"/>
      <polygon points="40,290 80,265 150,265 110,290" fill="#9E9689"/>
      <polygon points="110,240 150,215 220,215 180,240" fill="#9E9689"/>
      <polygon points="180,190 220,165 290,165 250,190" fill="#9E9689"/>
      <polygon points="250,140 290,115 380,115 340,140" fill="#9E9689"/>
      <polygon points="340,140 380,115 380,315 340,340" fill="#24221F"/>
      <line x1="0" y1="340" x2="400" y2="340" stroke="#24221F" stroke-width="1.5" opacity="0.25"/>
    </svg>`
  },
  {
    id: 'olive-branch',
    title: 'Pressed Olive & Shadow',
    category: 'Botanicals',
    creator: 'Clara Benitez',
    year: '2024',
    medium: 'Cyanotype & warm gum bichromate',
    ratio: '3:4',
    colors: ['#EFE8DA', '#5A6B54', '#2F3B2B', '#C7B69B'],
    desc: 'Field herbarium study capturing delicate leaf venation against raw linen paper.',
    svg: `<svg viewBox="0 0 360 480" xmlns="http://www.w3.org/2000/svg">
      <rect width="360" height="480" fill="#EFE8DA"/>
      <rect x="26" y="26" width="308" height="428" fill="none" stroke="#C7B69B" stroke-width="1.5"/>
      <path d="M175 420 C168 310 194 210 182 78" stroke="#2F3B2B" stroke-width="3.5" fill="none" stroke-linecap="round"/>
      <g fill="#5A6B54">
        <ellipse cx="140" cy="320" rx="44" ry="14" transform="rotate(-32 140 320)"/>
        <ellipse cx="222" cy="292" rx="46" ry="14" transform="rotate(28 222 292)"/>
        <ellipse cx="136" cy="238" rx="48" ry="14" transform="rotate(-26 136 238)"/>
        <ellipse cx="228" cy="206" rx="44" ry="13" transform="rotate(30 228 206)"/>
        <ellipse cx="144" cy="154" rx="40" ry="12" transform="rotate(-34 144 154)"/>
        <ellipse cx="216" cy="128" rx="36" ry="11" transform="rotate(26 216 128)"/>
        <ellipse cx="182" cy="78" rx="12" ry="30" fill="#2F3B2B"/>
      </g>
      <circle cx="196" cy="252" r="9" fill="#2F3B2B"/>
      <circle cx="164" cy="186" r="8" fill="#2F3B2B"/>
    </svg>`
  },
  {
    id: 'amber-aperture',
    title: 'Oculus Refracted',
    category: 'Light Studies',
    creator: 'Atelier Nord',
    year: '2025',
    medium: 'Cast amber resin & plaster wall',
    ratio: '16:10',
    colors: ['#1E1A18', '#D98A3C', '#F2C57C', '#8C4A27'],
    desc: 'Warm chromatic halo projected through a circular skylight onto hand-troweled lime plaster.',
    svg: `<svg viewBox="0 0 480 300" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <radialGradient id="sunGlow" cx="58%" cy="46%" r="52%">
          <stop offset="0%" stop-color="#F7DFB0"/>
          <stop offset="45%" stop-color="#D98A3C"/>
          <stop offset="85%" stop-color="#6E351B"/>
          <stop offset="100%" stop-color="#1E1A18"/>
        </radialGradient>
      </defs>
      <rect width="480" height="300" fill="url(#sunGlow)"/>
      <circle cx="280" cy="138" r="76" fill="#F2C57C" opacity="0.88"/>
      <circle cx="262" cy="148" r="76" fill="#1E1A18" opacity="0.28"/>
      <rect x="0" y="246" width="480" height="54" fill="#171412" opacity="0.65"/>
    </svg>`
  },
  {
    id: 'cobalt-bowl',
    title: 'Glazed Tea Chawan',
    category: 'Ceramics',
    creator: 'Sora Ceramic Lab',
    year: '2024',
    medium: 'Porcelain, cobalt ash glaze',
    ratio: '1:1',
    colors: ['#ECEAE4', '#2F486E', '#6D88AD', '#1B2536'],
    desc: 'Wheel-thrown ceremonial bowl with pooled cobalt glaze breaking pale across the rim.',
    svg: `<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
      <rect width="400" height="400" fill="#ECEAE4"/>
      <ellipse cx="200" cy="304" rx="116" ry="20" fill="#D4CFC5"/>
      <path d="M84 156 C84 268 134 302 200 302 C266 302 316 268 316 156 Z" fill="#2F486E"/>
      <path d="M98 156 C108 242 150 282 200 282 C250 282 292 242 302 156 Z" fill="#6D88AD" opacity="0.35"/>
      <ellipse cx="200" cy="156" rx="116" ry="30" fill="#1B2536"/>
      <ellipse cx="200" cy="158" rx="102" ry="22" fill="#466591"/>
      <rect x="164" y="294" width="72" height="12" rx="3" fill="#B9AE9C"/>
    </svg>`
  },
  {
    id: 'editorial-specimen',
    title: 'Didone Specimen Sheet',
    category: 'Typography',
    creator: 'Foundry Neuf, Paris',
    year: '2025',
    medium: 'Letterpress on 300gsm mould-made paper',
    ratio: '4:5',
    colors: ['#1E1D1B', '#F3EEE5', '#B85231', '#8C8478'],
    desc: 'High-contrast serif display study examining hairline terminals and teardrop ball proportions.',
    svg: `<svg viewBox="0 0 360 450" xmlns="http://www.w3.org/2000/svg">
      <rect width="360" height="450" fill="#1E1D1B"/>
      <text x="30" y="250" font-family="Georgia, serif" font-size="220" fill="#F3EEE5" font-style="italic">Aa</text>
      <line x1="30" y1="296" x2="330" y2="296" stroke="#B85231" stroke-width="2"/>
      <text x="30" y="334" font-family="sans-serif" font-size="12" fill="#8C8478" letter-spacing="2.5">DISPLAY SERIF · 72PT / 80PT</text>
      <text x="30" y="366" font-family="Georgia, serif" font-size="18" fill="#F3EEE5" opacity="0.82">Form follows proportion &amp; light.</text>
      <circle cx="312" cy="54" r="14" fill="#B85231"/>
    </svg>`
  },
  {
    id: 'fig-silhouette',
    title: 'Mediterranean Fig Study',
    category: 'Botanicals',
    creator: 'Elena Marchetti',
    year: '2023',
    medium: 'Charcoal & warm chalk on laid paper',
    ratio: '4:3',
    colors: ['#E8E0D2', '#3A322C', '#7D6A58', '#B79C7E'],
    desc: 'Broad palmate fig leaves rendered in flat tonal blocks inspired by southern courtyard walls.',
    svg: `<svg viewBox="0 0 440 330" xmlns="http://www.w3.org/2000/svg">
      <rect width="440" height="330" fill="#E8E0D2"/>
      <circle cx="326" cy="96" r="52" fill="#D5C6B0"/>
      <path d="M120 330 C138 240 160 190 212 140" stroke="#3A322C" stroke-width="4" fill="none"/>
      <path d="M212 140 C168 92 122 104 118 144 C92 152 96 196 138 202 C142 238 188 242 214 206 C248 232 288 210 278 172 C312 162 308 118 268 116 C262 78 220 76 212 140 Z" fill="#3A322C"/>
      <path d="M212 140 L166 146 M212 140 L168 190 M212 140 L256 154 M212 140 L236 106" stroke="#E8E0D2" stroke-width="2" opacity="0.55"/>
    </svg>`
  },
  {
    id: 'pavilion-pool',
    title: 'Reflecting Pavilion',
    category: 'Architecture',
    creator: 'Mies Archive Homage',
    year: '2024',
    medium: 'Green marble, blackened steel, still water',
    ratio: '16:10',
    colors: ['#DCE2DF', '#4A6158', '#1F2A26', '#A7B5AE'],
    desc: 'Horizontal roof plane hovering over a mirror-still basin framed by dark serpentine stone.',
    svg: `<svg viewBox="0 0 480 300" xmlns="http://www.w3.org/2000/svg">
      <rect width="480" height="175" fill="#DCE2DF"/>
      <rect y="175" width="480" height="125" fill="#A7B5AE"/>
      <rect x="44" y="72" width="392" height="16" fill="#1F2A26"/>
      <rect x="118" y="88" width="10" height="87" fill="#1F2A26"/>
      <rect x="352" y="88" width="10" height="87" fill="#1F2A26"/>
      <rect x="192" y="88" width="118" height="87" fill="#4A6158"/>
      <rect x="192" y="175" width="118" height="72" fill="#4A6158" opacity="0.4"/>
      <line x1="60" y1="216" x2="420" y2="216" stroke="#FFFFFF" stroke-opacity="0.45" stroke-width="1.5"/>
      <line x1="120" y1="246" x2="360" y2="246" stroke="#FFFFFF" stroke-opacity="0.3" stroke-width="1"/>
    </svg>`
  },
  {
    id: 'terrazzo-plinth',
    title: 'Stacked Terrazzo Plinth',
    category: 'Ceramics',
    creator: 'Atelier Pietra',
    year: '2025',
    medium: 'Crushed Carrara marble & pigmented lime',
    ratio: '3:4',
    colors: ['#F0EAE0', '#C67B5C', '#4E5B52', '#262321'],
    desc: 'Modular sculptural pedestal pairing geometric balance with hand-honed aggregate speckles.',
    svg: `<svg viewBox="0 0 360 480" xmlns="http://www.w3.org/2000/svg">
      <rect width="360" height="480" fill="#F0EAE0"/>
      <rect x="92" y="254" width="176" height="164" rx="4" fill="#DCD3C5"/>
      <circle cx="180" cy="184" r="70" fill="#C67B5C"/>
      <rect x="132" y="74" width="96" height="40" rx="20" fill="#4E5B52"/>
      <g fill="#262321" opacity="0.35">
        <circle cx="122" cy="292" r="5"/><circle cx="164" cy="318" r="7"/><circle cx="222" cy="284" r="4"/>
        <circle cx="204" cy="356" r="6"/><circle cx="136" cy="378" r="5"/><circle cx="242" cy="382" r="7"/>
      </g>
      <g fill="#C67B5C" opacity="0.55">
        <circle cx="186" cy="296" r="4"/><circle cx="152" cy="352" r="6"/><circle cx="232" cy="326" r="5"/>
      </g>
    </svg>`
  }
];

const CATEGORIES = ['All', 'Architecture', 'Ceramics', 'Light Studies', 'Botanicals', 'Typography'];

let activeCategory = 'All';
let showSavedOnly = false;
const savedIds = new Set(['travertine-arch', 'amber-aperture']);
let currentList = [...ITEMS];
let lightboxIndex = -1;

const filterBar = document.getElementById('filterBar');
const masonryGrid = document.getElementById('masonryGrid');
const emptyState = document.getElementById('emptyState');
const countLabel = document.getElementById('countLabel');
const savedCount = document.getElementById('savedCount');
const savedFilterBtn = document.getElementById('savedFilterBtn');

const lightbox = document.getElementById('lightbox');
const lbCounter = document.getElementById('lbCounter');
const lbArtFrame = document.getElementById('lbArtFrame');
const lbCategory = document.getElementById('lbCategory');
const lbTitle = document.getElementById('lbTitle');
const lbDesc = document.getElementById('lbDesc');
const lbSpecs = document.getElementById('lbSpecs');
const lbSwatches = document.getElementById('lbSwatches');
const lbSaveBtn = document.getElementById('lbSaveBtn');
const lbSaveText = document.getElementById('lbSaveText');
const filmstrip = document.getElementById('filmstrip');
const lbStage = document.getElementById('lbStage');

function renderFilters() {
  filterBar.innerHTML = '';
  CATEGORIES.forEach(cat => {
    const btn = document.createElement('button');
    btn.type = 'button';
    btn.className = 'chip' + (activeCategory === cat && !showSavedOnly ? ' active' : '');
    btn.textContent = cat;
    btn.addEventListener('click', () => {
      activeCategory = cat;
      showSavedOnly = false;
      savedFilterBtn.setAttribute('aria-pressed', 'false');
      renderFilters();
      renderGrid();
    });
    filterBar.appendChild(btn);
  });
}

function getFilteredItems() {
  return ITEMS.filter(item => {
    if (showSavedOnly) return savedIds.has(item.id);
    return activeCategory === 'All' || item.category === activeCategory;
  });
}

function renderGrid() {
  currentList = getFilteredItems();
  savedCount.textContent = savedIds.size;
  countLabel.textContent = `${currentList.length} ${currentList.length === 1 ? 'study' : 'studies'}`;

  masonryGrid.innerHTML = '';
  if (currentList.length === 0) {
    emptyState.style.display = 'block';
    return;
  }
  emptyState.style.display = 'none';

  currentList.forEach((item, idx) => {
    const card = document.createElement('article');
    card.className = 'card';
    card.tabIndex = 0;
    card.setAttribute('role', 'button');
    card.setAttribute('aria-label', `Open ${item.title} in lightbox`);

    const isSaved = savedIds.has(item.id);
    card.innerHTML = `
      <div class="card-art">
        ${item.svg}
        <button class="card-save ${isSaved ? 'saved' : ''}" type="button" aria-label="${isSaved ? 'Remove from saved' : 'Save study'}" aria-pressed="${isSaved}">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="${isSaved ? 'currentColor' : 'none'}" stroke="currentColor" stroke-width="2"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
        </button>
      </div>
      <div class="card-caption">
        <span class="card-title">${item.title}</span>
        <span class="card-tag">${item.category}</span>
      </div>
    `;

    const saveBtn = card.querySelector('.card-save');
    saveBtn.addEventListener('click', (e) => {
      e.stopPropagation();
      toggleSave(item.id);
    });

    card.addEventListener('click', () => openLightbox(idx));
    card.addEventListener('keydown', (e) => {
      if (e.key === 'Enter' || e.key === ' ') {
        e.preventDefault();
        openLightbox(idx);
      }
    });

    masonryGrid.appendChild(card);
  });
}

function toggleSave(id) {
  if (savedIds.has(id)) savedIds.delete(id);
  else savedIds.add(id);

  renderGrid();
  if (lightboxIndex >= 0) {
    const active = currentList[lightboxIndex];
    if (!active) {
      closeLightbox();
    } else {
      updateLightboxSaveState(active.id);
    }
  }
}

function updateLightboxSaveState(id) {
  const saved = savedIds.has(id);
  lbSaveBtn.classList.toggle('saved', saved);
  lbSaveText.textContent = saved ? 'Saved' : 'Save';
}

function renderFilmstrip() {
  filmstrip.innerHTML = '';
  currentList.forEach((item, idx) => {
    const btn = document.createElement('button');
    btn.type = 'button';
    btn.className = 'thumb' + (idx === lightboxIndex ? ' active' : '');
    btn.setAttribute('aria-label', `Jump to ${item.title}`);
    btn.innerHTML = item.svg;
    btn.addEventListener('click', () => showLightboxItem(idx));
    filmstrip.appendChild(btn);
  });
}

function showLightboxItem(idx) {
  if (currentList.length === 0) return;
  lightboxIndex = (idx + currentList.length) % currentList.length;
  const item = currentList[lightboxIndex];

  lbCounter.textContent = `${lightboxIndex + 1} / ${currentList.length}`;
  lbArtFrame.innerHTML = item.svg;
  lbCategory.textContent = item.category;
  lbTitle.textContent = item.title;
  lbDesc.textContent = item.desc;
  lbSpecs.innerHTML = `
    <dt>Creator</dt><dd>${item.creator}</dd>
    <dt>Year</dt><dd>${item.year}</dd>
    <dt>Medium</dt><dd>${item.medium}</dd>
    <dt>Aspect</dt><dd>${item.ratio}</dd>
  `;
  lbSwatches.innerHTML = item.colors
    .map(c => `<span class="swatch" style="background:${c}" title="${c}"></span>`)
    .join('');

  updateLightboxSaveState(item.id);

  const thumbs = filmstrip.querySelectorAll('.thumb');
  thumbs.forEach((t, i) => {
    t.classList.toggle('active', i === lightboxIndex);
    if (i === lightboxIndex) {
      t.scrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' });
    }
  });
}

function openLightbox(idx) {
  lightboxIndex = idx;
  renderFilmstrip();
  showLightboxItem(idx);
  lightbox.classList.add('open');
  document.body.style.overflow = 'hidden';
}

function closeLightbox() {
  lightbox.classList.remove('open');
  document.body.style.overflow = '';
  lightboxIndex = -1;
}

savedFilterBtn.addEventListener('click', () => {
  showSavedOnly = !showSavedOnly;
  savedFilterBtn.setAttribute('aria-pressed', String(showSavedOnly));
  renderFilters();
  renderGrid();
});

document.getElementById('lbCloseBtn').addEventListener('click', closeLightbox);
document.getElementById('lbPrev').addEventListener('click', () => showLightboxItem(lightboxIndex - 1));
document.getElementById('lbNext').addEventListener('click', () => showLightboxItem(lightboxIndex + 1));
lbSaveBtn.addEventListener('click', () => {
  if (lightboxIndex >= 0 && currentList[lightboxIndex]) {
    toggleSave(currentList[lightboxIndex].id);
  }
});

lightbox.addEventListener('click', (e) => {
  if (e.target === lightbox || e.target === lbStage) closeLightbox();
});

document.addEventListener('keydown', (e) => {
  if (lightboxIndex < 0) return;
  if (e.key === 'Escape') closeLightbox();
  else if (e.key === 'ArrowRight') showLightboxItem(lightboxIndex + 1);
  else if (e.key === 'ArrowLeft') showLightboxItem(lightboxIndex - 1);
});

// Touch swipe navigation on lightbox stage
let touchStartX = 0;
let touchStartY = 0;
lbStage.addEventListener('touchstart', (e) => {
  touchStartX = e.changedTouches[0].clientX;
  touchStartY = e.changedTouches[0].clientY;
}, { passive: true });

lbStage.addEventListener('touchend', (e) => {
  const dx = e.changedTouches[0].clientX - touchStartX;
  const dy = e.changedTouches[0].clientY - touchStartY;
  if (Math.abs(dx) > 42 && Math.abs(dx) > Math.abs(dy)) {
    if (dx < 0) showLightboxItem(lightboxIndex + 1);
    else showLightboxItem(lightboxIndex - 1);
  }
}, { passive: true });

renderFilters();
renderGrid();
</script>
</body>
</html>
```
