/* gallery.css — masonry gallery + refined lightbox */
.section-gallery {
  background: transparent;
  padding: var(--space-section) var(--gutter);
}
.section-gallery .section-title { color: var(--ink); }
.section-gallery .gallery-lead {
  text-align: center;
  color: var(--muted);
  max-width: 46ch;
  margin: -1.5rem auto clamp(2.5rem, 5vw, 3.5rem);
  font-size: 0.98rem;
}

/* ===== Gallery blocks — three switchable modes (see js/config.js) =====
   Shared markup: .circular-gallery > .cg-head + .cg-viewport > .cg-stage > .cg-card
   Mode is set by js/gallery-view.js as a class on the block:
   .cg-mode-circular | .cg-mode-filmstrip | .cg-mode-grid                       */
.circular-gallery {
  max-width: 1500px;
  margin: 0 auto;
}
.circular-gallery + .circular-gallery { margin-top: clamp(3.5rem, 9vw, 7rem); }

.cg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto 1.4rem;
  padding: 0 0.4rem;
}
.cg-title {
  font-family: var(--font-heading);
  font-weight: 300;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.cg-title::before {
  content: '';
  display: inline-block;
  width: 26px; height: 2px;
  background: var(--terracotta);
  vertical-align: middle;
  margin-right: 0.7rem;
  transform: translateY(-0.25em);
}
.cg-controls { display: flex; gap: 0.55rem; }
.cg-arrow {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--charcoal);
  background: url("../images/Assets/parchment.jpg") center / cover, var(--paper);
  color: var(--charcoal);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.3s var(--ease), transform 0.3s var(--ease);
}
.cg-arrow:hover { filter: brightness(0.93); transform: translateY(-2px); }
.cg-arrow:active { transform: translateY(0); }

/* ---- Card: shared visuals (positioning is per-mode) ---- */
.cg-card {
  margin: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--stone-light);
  box-shadow: 0 26px 50px -22px rgba(30, 26, 22, 0.55);
  transform-origin: center center;
  -webkit-user-select: none;
  user-select: none;
}
.cg-card img {
  width: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.cg-card::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
  background: linear-gradient(180deg, rgba(30,26,22,0) 52%, rgba(30,26,22,0.55) 100%);
  pointer-events: none;
}
.cg-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 0.9rem 1rem 0.75rem;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.72;
  text-shadow: 0 1px 10px rgba(0,0,0,0.5);
  transition: opacity 0.3s var(--ease);
}

/* ============================================================
   MODE 1 — CIRCULAR (true 3D ring, scroll-driven; 21st.dev)
   Tall runway pins a full-viewport stage via position:sticky;
   the ring rotates as you scroll through the runway.
   ============================================================ */
.cg-mode-circular {
  position: relative;
  height: 320vh;            /* scroll runway: how much scroll = one full turn */
  --ring-cw: clamp(200px, 22vw, 300px);
}
.cg-mode-circular .cg-head { position: relative; z-index: 4; }
.cg-mode-circular .cg-controls { display: none; }
.cg-mode-circular .cg-viewport {
  position: sticky;
  top: 0;
  height: 100vh;
  perspective: 2000px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cg-mode-circular .cg-stage {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}
.cg-mode-circular .cg-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--ring-cw);
  height: calc(var(--ring-cw) * 1.34);
  margin-left: calc(var(--ring-cw) / -2);
  margin-top: calc(var(--ring-cw) * -0.67);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 30px 60px -22px rgba(30, 26, 22, 0.65);
  transition: opacity 0.3s linear;
  will-change: transform, opacity;
}
.cg-mode-circular .cg-card img { width: 100%; height: 100%; object-fit: cover; }
.cg-mode-circular .cg-label { opacity: 1; }

/* ============================================================
   MODE 2 — FILMSTRIP (large images, horizontal snap + drag)
   ============================================================ */
.cg-mode-filmstrip .cg-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  cursor: grab;
  touch-action: pan-y;
}
.cg-mode-filmstrip .cg-viewport::-webkit-scrollbar { display: none; }
.cg-mode-filmstrip.is-dragging .cg-viewport { cursor: grabbing; }
.cg-mode-filmstrip .cg-stage {
  display: flex;
  gap: clamp(1rem, 2.5vw, 2rem);
  padding: 0.4rem clamp(1rem, 14vw, 16%);
  height: clamp(340px, 66vh, 660px);
  align-items: stretch;
}
.cg-mode-filmstrip .cg-card {
  position: relative;
  flex: 0 0 auto;
  width: auto;            /* width follows the image's natural ratio */
  height: 100%;
  scroll-snap-align: center;
  cursor: pointer;
}
.cg-mode-filmstrip .cg-card img {
  width: auto;            /* keep original aspect ratio, no cropping */
  height: 100%;
  object-fit: contain;
}
.cg-mode-filmstrip .cg-label { opacity: 0.85; }

/* ============================================================
   MODE 3 — GRID (editorial justified masonry)
   ============================================================ */
.cg-mode-grid .cg-viewport { overflow: visible; }
.cg-mode-grid .cg-stage {
  columns: 3;
  column-gap: clamp(0.8rem, 1.6vw, 1.4rem);
  max-width: 1300px;
  margin: 0 auto;
}
.cg-mode-grid .cg-card {
  position: relative;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 clamp(0.8rem, 1.6vw, 1.4rem);
  cursor: pointer;
}
.cg-mode-grid .cg-card img {
  height: auto;
  transition: transform 0.7s var(--ease);
}
.cg-mode-grid .cg-card:hover img { transform: scale(1.05); }
.cg-mode-grid .cg-controls { display: none; }
.cg-mode-grid .cg-label { opacity: 0; }
.cg-mode-grid .cg-card:hover .cg-label { opacity: 1; }

@media (max-width: 900px) { .cg-mode-grid .cg-stage { columns: 2; } }
@media (max-width: 560px) { .cg-mode-grid .cg-stage { columns: 1; } }

/* ============================================================
   MODE 4 — JUSTIFIED (Flickr-style rows, equal height, no crop)
   ============================================================ */
.cg-mode-justified .cg-viewport { overflow: visible; }
.cg-mode-justified .cg-stage {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1.2vw, 1rem);
  --row-h: clamp(180px, 26vh, 300px);
}
.cg-mode-justified .cg-card {
  position: relative;
  flex: var(--ar, 1.5) 1 calc(var(--ar, 1.5) * var(--row-h));
  aspect-ratio: var(--ar, 1.5);
  max-height: calc(var(--row-h) * 1.6);  /* tame the last row */
  cursor: pointer;
}
.cg-mode-justified .cg-card img { height: 100%; }
.cg-mode-justified .cg-controls { display: none; }
.cg-mode-justified .cg-label { opacity: 0; }
.cg-mode-justified .cg-card:hover .cg-label { opacity: 1; }

/* ============================================================
   MODE 5 — FADER (one full image at a time, crossfade)
   ============================================================ */
.cg-mode-fader .cg-viewport {
  position: relative;
  height: clamp(340px, 68vh, 680px);
  overflow: hidden;
}
.cg-mode-fader .cg-stage { position: absolute; inset: 0; }
.cg-mode-fader .cg-card {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s var(--ease);
  cursor: pointer;
  background: transparent;
  box-shadow: none;
}
.cg-mode-fader .cg-card.is-active { opacity: 1; visibility: visible; }
.cg-mode-fader .cg-card img { height: 100%; object-fit: contain; }
.cg-mode-fader .cg-label { opacity: 0.9; }

/* ============================================================
   MODE 6 — BENTO (Airbnb-style hero mosaic: 1 big + 4 small)
   ============================================================ */
.cg-mode-bento .cg-viewport { position: relative; overflow: hidden; border-radius: var(--radius-lg); }
.cg-mode-bento .cg-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  height: clamp(320px, 58vh, 560px);
  justify-content: start;
}
/* Cards are placed into slots b1..b5 by JS (paged); hidden unless on this page */
.cg-mode-bento .cg-card { position: relative; border-radius: 4px; cursor: pointer; display: none; }
.cg-mode-bento .cg-card img { height: 100%; }
.cg-mode-bento .cg-card.b-on { display: block; }
/* featured (big) tile: its column sizes to the image's OWN aspect ratio
   -> original ratio, no crop, no letterbox bars; thumbnails fill the rest. */
.cg-mode-bento .cg-card.b1 { grid-column: 1; grid-row: 1 / 3; }
.cg-mode-bento .cg-card.b1 img { width: auto; height: 100%; object-fit: contain; }
.cg-mode-bento .cg-card.b2 { grid-column: 2; grid-row: 1; }
.cg-mode-bento .cg-card.b3 { grid-column: 3; grid-row: 1; }
.cg-mode-bento .cg-card.b4 { grid-column: 2; grid-row: 2; }
.cg-mode-bento .cg-card.b5 { grid-column: 3; grid-row: 2; }
.cg-mode-bento .cg-label { opacity: 0; }
.cg-mode-bento .cg-card:hover .cg-label { opacity: 1; }
/* top arrows (feature the big image) centered */
.cg-mode-bento .cg-head { justify-content: center; }
.cg-mode-bento .cg-card { transition: opacity 0.35s var(--ease); }
/* bottom-right page pager (whole-bento paging) */
.cg-bento-pager {
  position: absolute;
  right: 16px; bottom: 16px;
  z-index: 3;
  display: flex; align-items: center; gap: 0.5rem;
}
.cg-bento-arrow {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--charcoal);
  background: url("../images/Assets/parchment.jpg") center / cover, var(--paper);
  color: var(--charcoal);
  font-size: 1.1rem; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px -8px rgba(30,26,22,0.5);
  transition: filter 0.25s var(--ease), transform 0.25s var(--ease);
}
.cg-bento-arrow:hover { filter: brightness(0.93); transform: translateY(-1px); }
.cg-bento-count {
  font-family: var(--font-body);
  font-size: 0.78rem; letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--charcoal);
  /* same parchment surface as the arrows next to it */
  background: url("../images/Assets/parchment.jpg") center / cover, var(--paper);
  border: 1px solid var(--charcoal);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  box-shadow: 0 6px 18px -8px rgba(30,26,22,0.5);
}
@media (max-width: 640px) {
  /* mobile: show the featured image at its natural ratio, full width */
  .cg-mode-bento .cg-stage { display: block; height: auto; }
  .cg-mode-bento .cg-card.b1 { width: 100%; }
  .cg-mode-bento .cg-card.b1 img { width: 100%; height: auto; }
  .cg-mode-bento .cg-card.b2,
  .cg-mode-bento .cg-card.b3,
  .cg-mode-bento .cg-card.b4,
  .cg-mode-bento .cg-card.b5 { display: none; }
  .cg-bento-pager { display: none; }   /* mobile: no bottom pager, top arrows navigate */
}

/* ============================================================
   MODE 7 — THUMBS (big main image + thumbnail strip)
   ============================================================ */
.cg-mode-thumbs .cg-thumb-main {
  height: clamp(320px, 60vh, 600px);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-radius: var(--radius-lg);
  background: var(--stone-light);
}
.cg-mode-thumbs .cg-thumb-main img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: pointer; }
.cg-mode-thumbs .cg-stage {
  display: flex; gap: 0.6rem;
  overflow-x: auto; padding: 0.9rem 0.2rem;
  scrollbar-width: none;
}
.cg-mode-thumbs .cg-stage::-webkit-scrollbar { display: none; }
.cg-mode-thumbs .cg-card {
  position: relative; flex: 0 0 auto;
  width: clamp(88px, 12vw, 132px); aspect-ratio: 3 / 2;
  cursor: pointer; opacity: 0.5; transition: opacity 0.3s var(--ease);
}
.cg-mode-thumbs .cg-card img { height: 100%; }
.cg-mode-thumbs .cg-card.is-active { opacity: 1; outline: 2px solid var(--terracotta); outline-offset: 2px; }
.cg-mode-thumbs .cg-label { display: none; }

/* ============================================================
   MODE 8 — BEFOREAFTER (draggable comparison slider)
   ============================================================ */
.cg-mode-beforeafter .cg-viewport { position: relative; }
.cg-ba {
  position: relative;
  height: clamp(320px, 60vh, 600px);
  overflow: hidden; border-radius: var(--radius-lg);
  background: var(--stone-light);
  user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
.cg-ba-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.cg-ba-before { z-index: 2; }
.cg-ba-handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px; background: #fff; z-index: 3;
  cursor: ew-resize; box-shadow: 0 0 12px rgba(0,0,0,0.4);
}
.cg-ba-handle span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.cg-ba-handle span::before, .cg-ba-handle span::after {
  content: ''; position: absolute; top: 50%; width: 0; height: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.cg-ba-handle span::before { left: 9px; border-right: 7px solid var(--ink); }
.cg-ba-handle span::after { right: 9px; border-left: 7px solid var(--ink); }

/* ============================================================
   MODE 9 — PANELS (horizontal accordion, active expands)
   ============================================================ */
.cg-mode-panels .cg-stage { display: flex; gap: 0.5rem; height: clamp(340px, 60vh, 560px); }
.cg-mode-panels .cg-card {
  position: relative; flex: 1; min-width: 0; cursor: pointer;
  transition: flex 0.55s var(--ease);
}
.cg-mode-panels .cg-card.is-active { flex: 5; }
.cg-mode-panels .cg-card img { height: 100%; }
.cg-mode-panels .cg-label { opacity: 0; }
.cg-mode-panels .cg-card.is-active .cg-label { opacity: 1; }

/* ============================================================
   MODE 10 — DECK (stacked cards with depth, flick the top one)
   ============================================================ */
.cg-mode-deck .cg-viewport {
  position: relative; height: clamp(340px, 60vh, 580px);
  display: flex; align-items: center; justify-content: center;
}
.cg-mode-deck .cg-stage { position: relative; width: clamp(280px, 50vw, 560px); height: 84%; }
.cg-mode-deck .cg-card {
  position: absolute; inset: 0; margin: auto;
  height: 100%; aspect-ratio: 3 / 2;
  transition: transform 0.45s var(--ease), opacity 0.45s var(--ease);
  cursor: grab; will-change: transform; touch-action: pan-y;
}
.cg-mode-deck.is-dragging .cg-card { cursor: grabbing; }
.cg-mode-deck .cg-card img { height: 100%; }

/* ============================================================
   MODE 11 — ZOOMGRID (uniform square grid, hover zoom)
   ============================================================ */
.cg-mode-zoomgrid .cg-stage { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cg-mode-zoomgrid .cg-card { position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer; }
.cg-mode-zoomgrid .cg-card img { height: 100%; transition: transform 0.6s var(--ease); }
.cg-mode-zoomgrid .cg-card:hover img { transform: scale(1.12); }
.cg-mode-zoomgrid .cg-label { opacity: 0; }
.cg-mode-zoomgrid .cg-card:hover .cg-label { opacity: 1; }
@media (max-width: 900px) { .cg-mode-zoomgrid .cg-stage { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .cg-mode-zoomgrid .cg-stage { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   MODE 12 — MARQUEE (auto-scrolling ribbon, pause on hover)
   ============================================================ */
.cg-mode-marquee .cg-viewport { overflow: hidden; }
.cg-mode-marquee .cg-stage {
  display: flex; width: max-content;
  animation: cg-marquee 46s linear infinite;
}
.cg-mode-marquee:hover .cg-stage { animation-play-state: paused; }
.cg-marquee-track { display: flex; gap: 1rem; padding-right: 1rem; }
.cg-mode-marquee .cg-card {
  position: relative; flex: 0 0 auto;
  height: clamp(220px, 34vh, 360px); cursor: pointer;
}
.cg-mode-marquee .cg-card img { width: auto; height: 100%; }
@keyframes cg-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ============================================================
   MODE 13 — STORY (full-width vertical scrollytelling)
   ============================================================ */
.cg-mode-story .cg-viewport { overflow: visible; }
.cg-mode-story .cg-stage {
  display: flex; flex-direction: column; gap: clamp(2rem, 6vh, 5rem);
  max-width: 1100px; margin: 0 auto;
}
.cg-mode-story .cg-card {
  position: relative; width: 100%; cursor: pointer;
  opacity: 0; transform: translateY(42px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.cg-mode-story .cg-card.in { opacity: 1; transform: none; }
.cg-mode-story .cg-card img { height: auto; }
.cg-mode-story .cg-card::after { display: none; }
.cg-mode-story .cg-label {
  position: static; text-align: left; padding: 0.8rem 0 0;
  color: var(--muted); text-shadow: none; opacity: 1;
}

/* ============================================================
   MODE 14 — PEEK (one centered image dominant, neighbours peek)
   ============================================================ */
.cg-mode-peek .cg-viewport {
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; cursor: grab; touch-action: pan-y;
}
.cg-mode-peek .cg-viewport::-webkit-scrollbar { display: none; }
.cg-mode-peek.is-dragging .cg-viewport { cursor: grabbing; }
.cg-mode-peek .cg-stage {
  display: flex; gap: clamp(1rem, 3vw, 2.4rem);
  padding: 1rem clamp(10vw, 22vw, 26%);
  height: clamp(340px, 64vh, 640px); align-items: center;
}
.cg-mode-peek .cg-card {
  position: relative; flex: 0 0 auto; height: 100%; width: auto;
  scroll-snap-align: center; cursor: pointer; will-change: transform;
  transition: opacity 0.25s var(--ease);
}
.cg-mode-peek .cg-card img { width: auto; height: 100%; }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(18, 16, 14, 0.96);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
}
.lightbox.active { opacity: 1; pointer-events: auto; }

.lightbox-img {
  max-width: 90vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--white);
  cursor: pointer;
  font-size: 1.4rem;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.85;
  transition: all 0.3s var(--ease);
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover {
  opacity: 1; background: rgba(255,255,255,0.14);
}
.lightbox-close { top: 1.4rem; right: 1.6rem; font-size: 1.6rem; }
.lightbox-prev { left: 1.6rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1.6rem; top: 50%; transform: translateY(-50%); }

.lightbox-counter {
  position: absolute;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   Subpage galleries (werkstatt.html / kunst.html) — stacked, titled sections
   generated by tools/build_subpages.py
   --------------------------------------------------------------------------- */
.sub-galleries { display: flex; flex-direction: column; gap: clamp(3rem, 7vw, 5.5rem); }
.sub-galleries .circular-gallery { margin: 0; }

.cg-group {
  font-family: var(--font-heading);
  font-weight: 300;
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  color: var(--ink);
  text-align: center;
  margin: clamp(1.5rem, 4vw, 3rem) 0 0;
  position: relative;
  padding-bottom: 1.2rem;
}
.cg-group::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 64px; height: 1px;
  background: var(--terracotta);
  opacity: 0.55;
}
