.gallery-layout { gap:4px; display:flex; align-items:flex-start; justify-content:center; max-width: calc(120px + 980px + 8px); margin: 0 auto; }
.gallery-center { display:flex; flex-direction:column; align-items:center; }
.gallery-center .gallery-toolbar, .gallery-center .gallery-layout { width: calc(var(--gallery-strip-w,120px) + 980px + 8px); }
.gallery-viewer-col { flex:1; display:flex; align-items:flex-start; padding:0; max-width:980px; margin: 0 auto; }
.gallery-strip-col { width:var(--gallery-strip-w,120px); padding:0; flex:0 0 var(--gallery-strip-w,120px); }
.gallery-viewer { margin:0; }
.camera-strip { display:flex; flex-direction:column; gap:6px; overflow-y:auto; padding:2px; width:120px; max-height:68vh; background:linear-gradient(180deg,#fff,#fbfbfc); border-radius:6px; box-shadow:0 8px 20px rgba(22,28,45,0.04); margin-right:0; }
.filter-panel { display:flex; flex-direction:row; gap:8px; padding:6px 6px; margin-bottom:10px; align-items:center; }
.filter-panel .form-label { display:none; }
.gallery-toolbar { max-width:980px; margin:0 auto; }
.gallery-toolbar.align-to-viewer { padding-left: var(--gallery-strip-w,120px); }

/* root variable for strip width (fallback to 120px) */
:root { --gallery-strip-w: 120px; }
.gallery-collage{
  width:100%;
  margin:20px auto 1.25rem;
  position:relative; /* ensure overlay absolute positions inside this container */
  display:flex;
  justify-content:center; /* center the grid */
  padding:12px 0;
}
.collage-frame{
  --collage-size: min(760px, 86vw);
  width: var(--collage-size);
  height: var(--collage-size);
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Soft light-blue to white gradient for a gentle sky-like backdrop */
  background: linear-gradient(180deg, #e6f7ff 0%, #ffffff 100%);
  box-shadow: 0 18px 48px rgba(9,30,66,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
  border: 6px solid rgba(255,255,255,0.6);
}

.collage-grid{
  display:grid;
  /* denser packing: allow more, smaller columns that wrap to fill the circular frame */
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap:6px;
  align-items:start;
  width: calc(var(--collage-size) - 56px);
  max-width: calc(var(--collage-size) - 56px);
  grid-auto-flow: dense;
  margin:0 auto; /* ensure centering when grid narrower than container */
}
.collage-grid .collage-thumb{
  display:block;
  width:100%;
  aspect-ratio: 1 / 1; /* ensure square cell so border-radius:50% makes a circle */
  overflow:hidden;
  border-radius:50%;
  position:relative;
  cursor:pointer;
  background:linear-gradient(180deg,#f8f9fb,#ffffff);
  box-shadow: var(--shadow, 0 8px 22px rgba(22,28,45,0.08));
  transform-origin:center center;
  /* use CSS vars for per-tile offsets and rotation so JS can randomize them */
  transform: translate(var(--ox,0px), var(--oy,0px)) rotate(var(--rot,0deg)) scale(1);
  transition: transform 260ms cubic-bezier(.2,.9,.2,1), box-shadow 260ms ease, opacity 260ms ease;
  opacity:0; /* animated in by JS */
}
.collage-grid .collage-thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  transform-origin:center center;
  border-radius:50%;
}

/* subtle parallax: child img uses CSS vars set via JS */
.collage-grid { --tx: 0px; --ty: 0px; }
.collage-grid .collage-thumb img { transform: translate3d(var(--tx), var(--ty), 0) scale(1); transition: transform 320ms cubic-bezier(.2,.9,.2,1); }

/* span helpers to make a visually-interesting mosaic */
.collage-thumb.span1 { grid-column: span 1; grid-row: span 1; }
.collage-thumb.span1 { grid-column: span 1; grid-row: span 1; }
.collage-thumb.span2 { grid-column: span 2; grid-row: span 2; }
.collage-thumb.span3 { grid-column: span 3; grid-row: span 3; }
.collage-thumb.span4 { grid-column: span 2; grid-row: span 1; }

/* subtle rotation alternation for organic feel */
.collage-thumb.rotate-1{ --rot: -1.5deg; }
.collage-thumb.rotate-2{ --rot: 1deg; }
.collage-thumb:hover{ transform: translate(0,0) rotate(0deg) scale(1.03); z-index:60; box-shadow:0 22px 48px rgba(22,28,45,0.16); }

/* overlap/cluster offsets - subtle offsets to create overlapping circles */
.collage-thumb.overlap-1{ z-index:22; }
.collage-thumb.overlap-2{ z-index:20; }
.collage-thumb.overlap-3{ z-index:18; }
.collage-thumb.overlap-4{ z-index:16; }
.collage-thumb.overlap-5{ z-index:24; }

/* gentle soft-edge mask/blur for tiles: subtle feathered vignette */
.collage-grid .collage-thumb::before{
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 50%;
  /* soft radial vignette that lightens/feathers the edges */
  background: radial-gradient(circle at center, rgba(255,255,255,0) 62%, rgba(255,255,255,0.06) 82%, rgba(255,255,255,0.12) 100%);
  mix-blend-mode: overlay;
}

/* WebKit mask fallback to actually feather the image edge where supported */
.collage-grid .collage-thumb img{
  -webkit-mask-image: radial-gradient(circle at center, rgba(0,0,0,1) 64%, rgba(0,0,0,0.85) 78%, rgba(0,0,0,0) 100%);
  mask-image: radial-gradient(circle at center, rgba(0,0,0,1) 64%, rgba(0,0,0,0.85) 78%, rgba(0,0,0,0) 100%);
}

/* increase z-index for larger spans so they sit above neighbors */
.collage-thumb.span2, .collage-thumb.span3 { z-index:4; }

/* overlay caption on hover */
.collage-thumb::after{
  content:''; position:absolute; left:0; right:0; bottom:0; height:36px; background:linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 100%); opacity:0; transition:opacity 180ms ease; pointer-events:none; border-bottom-left-radius:8px; border-bottom-right-radius:8px;
}
.collage-thumb:hover::after{ opacity:1; }

/* entrance animation */
@keyframes collageIn { from { opacity:0; transform: translateY(10px) scale(.98) } to { opacity:1; transform: translateY(0) scale(1) } }
.collage-thumb.animate-in{ animation-name: collageIn; animation-duration: 420ms; animation-fill-mode: both; animation-timing-function: cubic-bezier(.2,.9,.2,1); }
.collage-footer{color:#666}

/* overlay CTA centered on the collage */
.collage-overlay{ position:absolute; left:0; right:0; top:0; bottom:0; display:flex; align-items:center; justify-content:center; pointer-events:none; z-index:100; }
.collage-overlay-inner{ pointer-events:auto; text-align:center; background:rgba(255,255,255,0.88); backdrop-filter: blur(4px); padding:8px 12px; border-radius:999px; box-shadow:0 12px 36px rgba(22,28,45,0.12); display:flex; gap:10px; align-items:center; }
.collage-count{ font-weight:600; color:#111; font-size:0.95rem; }
.collage-enter-btn{ width:48px; height:48px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; background: linear-gradient(90deg,#0d6efd,#5aa3ff); border:none; color:#fff; font-size:18px; line-height:1; box-shadow:0 8px 28px rgba(13,110,253,0.18); cursor:pointer; padding:0; }
.collage-enter-btn{ z-index:110; }
.collage-enter-btn:active{ transform: scale(.98); }

@media (max-width:480px){
  .collage-enter-btn{ width:40px; height:40px; font-size:16px }
  .collage-count{ font-size:0.85rem }
}

/* Mobile image zoom overlay */
.image-zoom-overlay{ position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,0.7); z-index:1200; padding:18px; }
.image-zoom-overlay.hidden{ display:none; }
.image-zoom-inner{ position:relative; max-width:100%; max-height:100%; display:flex; align-items:center; justify-content:center; }
.image-zoom-inner img{ max-width:100%; max-height:100%; object-fit:contain; border-radius:8px; box-shadow:0 24px 60px rgba(2,6,23,0.6); }
.image-zoom-close{ position:absolute; top:-12px; right:-12px; width:40px; height:40px; border-radius:50%; border:none; background:#fff; color:#111; font-size:22px; line-height:1; box-shadow:0 8px 20px rgba(0,0,0,0.3); cursor:pointer; }

@media (min-width:769px){
  /* hide the zoom overlay styles on larger screens (we only enable on mobile) */
  .image-zoom-overlay{ display:none !important; }
}

/* exit animation when entering gallery */
.gallery-collage.collage-exit{ transition: transform 340ms ease, opacity 320ms ease; transform: scale(.98); opacity:0; pointer-events:none; }

@media (max-width:480px){
  .collage-grid{grid-template-columns: repeat(4, 1fr); gap:6px; max-width:420px}
  .collage-grid .collage-thumb{aspect-ratio:1/1}
}

@media (max-width:360px){
  /* reduce overlap on very small screens */
  .collage-thumb.overlap-1, .collage-thumb.overlap-2, .collage-thumb.overlap-3, .collage-thumb.overlap-4, .collage-thumb.overlap-5 { transform: none; }
}

@media (max-width:360px){
  .collage-grid{grid-template-columns: repeat(3, 1fr); max-width:320px }
  .collage-thumb.span3{ grid-column: span 2; }
}
.gallery-toolbar .toolbar-left { display:flex; gap:8px; align-items:center; }
.gallery-toolbar .toolbar-left .form-select { margin-bottom:0; }

@media (max-width: 768px) {
  /* Keep filters side-by-side where possible; allow wrapping if space is very tight */
  .gallery-toolbar .toolbar-left { flex-direction:row; align-items:center; gap:8px; flex-wrap:wrap; width:100%; }
  .gallery-toolbar .toolbar-left .form-select { flex: 1 1 calc(50% - 8px); min-width:120px; box-sizing:border-box; margin:0; width:auto !important; }
  /* Prefer year smaller than category on narrow screens */
  #gallery-toolbar .form-select#filter-year { flex-basis: calc(35% - 8px); min-width:90px; }
  #gallery-toolbar .form-select#filter-category { flex-basis: calc(65% - 8px); min-width:120px; }
}
.filter-panel .form-select { font-size:0.9rem; min-width:0; }
.filter-panel .form-select#filter-year { width:88px; }
.filter-panel .form-select#filter-category { width:120px; }

/* Style gallery dropdowns to match site inputs: rounded, subtle shadow, consistent padding */
#gallery-toolbar .form-select {
  background: var(--color-card-bg, #fff);
  border: 1px solid rgba(22,28,45,0.06);
  box-shadow: 0 8px 20px rgba(22,28,45,0.04);
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--color-text, #111);
  min-height: 36px;
  -webkit-appearance: auto; -moz-appearance: auto; appearance: auto;
  cursor: pointer;
  /* keep a bit of right padding so the native arrow isn't obscured */
  padding-right: 36px;
}

#gallery-toolbar .form-select:focus {
  outline: none;
  border-color: rgba(13,110,253,0.9);
  box-shadow: 0 6px 26px rgba(13,110,253,0.08), 0 0 0 4px rgba(13,110,253,0.06);
}

/* small variant spacing */
#gallery-toolbar .form-select.form-select-sm { padding: 6px 10px; font-size:0.95rem; }

/* ensure selects shrink nicely on small screens */
@media (max-width:768px){
  /* Ensure toolbar spacing remains consistent on small devices; keep selects responsive */
  #gallery-toolbar .toolbar-left { width:100%; gap:8px; }
  #gallery-toolbar .form-select { box-sizing:border-box; margin:0; }
  #gallery-toolbar .form-select#filter-year { max-width: none; }
}

/* Increase visible space for the two primary filters on desktop */
#gallery-toolbar .form-select#filter-category { min-width: 180px; max-width: 42vw; }
#gallery-toolbar .form-select#filter-year { min-width: 110px; max-width: 20vw; }

/* Ensure toolbar selects show affordance in contexts where appearance was removed elsewhere */
.gallery-toolbar .toolbar-left .form-select { -webkit-appearance: auto; appearance: auto; }

/* keep filters visible when scrolling the strip */
.gallery-strip-col { position:relative; }
.filter-panel { position:sticky; top:80px; z-index:3; background:transparent; }
.camera-thumb { flex: 0 0 auto; display:block; width:108px; height:72px; background:linear-gradient(180deg,#ffffff,#fffaf6); border-radius:8px; overflow:hidden; box-shadow: 0 6px 18px rgba(22,28,45,0.06); border:2px solid transparent; transition:transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease; }
.camera-thumb img { width:100%; height:100%; object-fit:cover; display:block; transition:transform 220ms ease; }
.camera-thumb:hover { transform:translateY(-4px); box-shadow:0 10px 30px rgba(22,28,45,0.08); }
.camera-thumb:focus { outline: none; box-shadow:0 10px 30px rgba(13,110,253,0.12); }
.camera-thumb.selected { border-color: #0d6efd; box-shadow: 0 8px 28px rgba(13,110,253,0.14); transform:scale(1.03); }
.gallery-viewer.inpage { display:block; padding:6px 0; background:transparent; }
.gallery-viewer.inpage .viewer-inner { display:flex; gap:8px; align-items:flex-start; }
.gallery-viewer.inpage .viewer-stage { position:relative; padding:0; background:transparent; border:none; min-height:0; text-align:left; flex:1 1 auto; display:flex; gap:12px; align-items:flex-start; flex-direction:row; flex-wrap:nowrap; width:100%; }
.gallery-viewer.inpage .viewer-stage .viewer-decorative { position:absolute; left:4px; top:4px; font-size:28px; color:#0d6efd; opacity:0.06; pointer-events:none; }
.gallery-viewer.inpage .viewer-stage img { max-width:100%; max-height:68vh; border-radius:6px; box-shadow:none; display:block; margin:0; }
.gallery-viewer.inpage .viewer-caption { color:var(--color-text); margin-top:8px; text-align:center; font-weight:500; font-size:0.95rem; }
.viewer-media { display:block; text-align:left; max-width:100%; margin:0; }
.viewer-media img { display:block; width:100%; height:auto; max-height:68vh; object-fit:contain; }
.viewer-media .viewer-caption, .viewer-media .viewer-controls { text-align:center; }

/* Make viewer-body flexible so it grows/shrinks with the available space */
.viewer-body { display:flex; flex-direction:column; align-items:flex-start; justify-content:flex-start; flex:1 1 auto; min-width:0; }

/* Ensure the viewer-stage columns behave responsively */
.gallery-viewer.inpage .viewer-stage { align-items:flex-start; }
.gallery-strip-col { flex:0 0 auto; }

/* Thumbnails: make them fluid within the strip column */
.camera-thumb { width:calc(100% - 12px); height:auto; aspect-ratio:3/2; }
.camera-thumb img { width:100%; height:100%; object-fit:cover; }

@media (min-width: 992px) {
  .camera-thumb { width:108px; height:72px; aspect-ratio:unset; }
}

/* viewer-body constrains the right column (image + caption + controls) */
/* (removed duplicate inline-block declaration) */

/* When the viewer-stage contains the strip and the image, ensure responsive stacking */
@media (max-width: 992px) {
  /* Keep viewer-stage horizontal (strip left, viewer right) on narrow screens; shrink strip */
  .gallery-viewer.inpage .viewer-stage { flex-direction:row; }
  .gallery-strip-col { width:var(--gallery-strip-w,80px); flex:0 0 var(--gallery-strip-w,80px); }
  .camera-strip { max-height:60vh; flex-direction:column; overflow-y:auto; }
  .viewer-body { width: calc(100% - var(--gallery-strip-w,80px)); }
}
.viewer-close { border-radius:999px; }
.viewer-controls { display:flex; gap:12px; justify-content:center; margin-top:6px; }
.viewer-controls .btn { min-width:44px; padding:6px 10px; border-radius:8px; }
.viewer-controls .btn.btn-outline-primary { border-color: rgba(13,110,253,0.12); color:#0d6efd; background:transparent; }
.viewer-controls .btn.btn-outline-primary:hover { background: rgba(13,110,253,0.06); }

/* caption subtle divider */
.viewer-caption:before { content: ''; display:block; width:40px; height:2px; background:linear-gradient(90deg,#0d6efd 0%, rgba(13,110,253,0.25) 100%); margin:0 auto 8px auto; border-radius:2px; }

/* viewer skeleton for loading state */
.viewer-skeleton { position:absolute; left:0; right:0; top:0; bottom:0; border-radius:8px; background:linear-gradient(90deg,#f6f7fb 25%, #eef2ff 50%, #f6f7fb 75%); background-size:200% 100%; animation: shimmer 1.4s linear infinite; box-shadow: inset 0 0 0 1px rgba(13,110,253,0.02); pointer-events:none; }
.viewer-skeleton.hidden { opacity:0; visibility:hidden; transition:opacity 220ms ease, visibility 220ms ease; display:none !important; }

@keyframes shimmer { 0% { background-position:200% 0 } 100% { background-position:-200% 0 } }

/* viewer-embedded filters positioned top-left inside the viewer */
.viewer-filters { position:absolute; left:18px; top:18px; display:flex; gap:8px; align-items:center; z-index:4; }
.viewer-filters .form-select { min-width:72px; font-size:0.85rem; padding:4px 8px; }
.viewer-filters .form-select#filter-category { min-width:120px; }
.viewer-filters .form-select#filter-year { min-width:80px; }
.viewer-filters.d-none { display:none !important; }

/* vertical scrollbar affordance */
.camera-strip::-webkit-scrollbar { width:10px; }
.camera-strip::-webkit-scrollbar-thumb { background:rgba(0,0,0,0.12); border-radius:8px; }

@media (max-width: 992px) {
  /* Small / narrow screens: keep the strip vertical on the left, but shrink it */
  .gallery-layout { flex-direction:row; gap:8px; }
  .gallery-viewer-col { width:100%; max-width:calc(100% - 88px); }
  .gallery-strip-col { width:80px; flex:0 0 80px; }
  .camera-strip { flex-direction:column; width:80px; max-height:60vh; overflow-y:auto; padding:6px 4px; }
  .camera-thumb { width:64px; height:44px; margin:6px 0; }
  .viewer-body { min-width:0; }
}

/* Responsive adjustments for multiple breakpoints */
@media (min-width: 1200px) {
  .gallery-layout { max-width: calc(120px + 980px + 8px); }
  .gallery-strip-col { width:120px; }
  .camera-thumb { width:108px; height:72px; }
}

@media (min-width: 992px) and (max-width:1199px) {
  .gallery-layout { max-width: calc(100px + 880px + 8px); }
  .gallery-strip-col { width:100px; }
  .camera-thumb { width:92px; height:64px; }
  .viewer-media { max-width:880px; }
}

@media (min-width: 768px) and (max-width:991px) {
  .gallery-layout { max-width: calc(96px + 720px + 8px); }
  .gallery-strip-col { width:96px; }
  .camera-thumb { width:86px; height:58px; }
  .viewer-media { max-width:720px; }
}

@media (max-width: 767px) {
  /* Small mobile: keep strip left but compact; image fills remaining space */
  :root { --gallery-strip-w:72px; }
  .gallery-layout { max-width:100%; padding:0 8px; }
  .gallery-strip-col { width:var(--gallery-strip-w); flex:0 0 var(--gallery-strip-w); }
  .camera-strip { flex-direction:column; width:var(--gallery-strip-w); max-height:56vh; padding:4px 2px; }
  .camera-thumb { width:calc(var(--gallery-strip-w) - 12px); height:auto; aspect-ratio:3/2; margin:6px 0; }
  .viewer-body { flex:1 1 auto; min-width:0; }
  .gallery-viewer-col { width:100%; max-width:calc(100% - var(--gallery-strip-w)); }
  .viewer-media { width:100%; }
  .viewer-media img { width:100%; height:auto; max-height:65vh; object-fit:cover; }
  .gallery-toolbar { width:100%; padding:0 12px; }
}

/* Gallery filter heading (shows selected Year and Category) */
.gallery-filter-heading{
  margin-top: 0.35rem;
  margin-bottom: 0.9rem;
  font-family: "Playfair Display", "Times New Roman", serif;
  font-weight: 600;
  font-size: clamp(1rem, 2.6vw, 1.6rem);
  color: var(--color-primary-dark);
  letter-spacing: 0.01em;
  text-align: center;
  display: block;
}
.gallery-filter-heading.small-sub {
  font-weight:500;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Improve accessibility hit areas on small screens */
.camera-thumb .btn, .viewer-controls .btn { min-width:44px; }
