/* ==========================================================================
   Gallery page only. Loaded after style.css (which has the header, tokens, etc.)
   ========================================================================== */

:root {
  --img-bg: #fff;
}

:root[data-theme="dark"] {
  --img-bg: #2a2a2a;
}

/* The gallery never scrolls: it is one infinite, draggable surface */
html,
body {
  height: 100%;
  overflow: hidden;
}


/* 1. Infinite grid
   ========================================================================== */
.grid {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.grid.is-dragging {
  cursor: grabbing;
}

.cell {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--cell-w);
  height: var(--cell-h);
  will-change: transform;
}

.cell img {
  width: var(--img-size);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--img-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}

.cell img.loaded {
  opacity: 1;
}

:root[data-theme="dark"] .cell img {
  filter: invert(0.91);
}


/* 2. Lightbox (full-screen viewer)
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  background: var(--bg);
  color: var(--text);
  touch-action: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s linear 0.3s;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s;
}

/* Title and text */
.lb-side {
  display: flex;
  flex: 0 0 240px;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 32px 24px;
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

.lb-side h2 {
  font-size: 14px;
  font-weight: 500;
}

.lb-side p {
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.75;
}

/* Image area. The frame is sized to the picture by gallery.js (see fitFrame). */
.lb-stage {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 16px; /* keep PAD in gallery.js in sync: 2 x this value */
}

/* The frame is the "window" the zoomed picture is clipped to */
.lb-frame {
  overflow: hidden;
  cursor: zoom-in; /* magnifying glass with + */
  touch-action: none;
  outline-offset: 4px;
}

.lb-frame.is-zoomed {
  cursor: zoom-out; /* magnifying glass with - */
}

.lb-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transition: transform 0.3s ease; /* the zoom-in / zoom-out animation */
}

:root[data-theme="dark"] .lb-frame img {
  filter: invert(0.91);
}

.lightbox .close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}

.lightbox .close:hover {
  color: var(--accent);
}


/* 3. Responsive
   ========================================================================== */

/* Phones: text goes under the picture */
@media (max-width: 700px) {
  .lightbox {
    flex-direction: column-reverse;
  }

  .lb-side {
    flex: 0 0 auto;
    max-height: 30vh;
    padding: 16px 20px 24px;
    overflow-y: auto;
  }

  .lb-stage {
    width: 100%;
    padding: 12px;
  }
}
