/* ═══════════════════════════════════════════════════════════════════
   gallery.css  —  Masonry grid, skeleton loaders, full-screen modal
   ═══════════════════════════════════════════════════════════════════ */

/* ── Full-width container for gallery page ──────────────────────── */
/* Override the base 860px max-width so the grid stretches edge-to-edge. */
body.gallery-page .container {
  max-width: none;
  width: 100%;
  margin: 0;           /* remove centering auto-margins */
  padding: 4;
}

/* Give the header its own comfortable padding instead */
body.gallery-page .gallery-header {
  padding: 1.8rem 2rem 1.4rem;
}

/* ── Gallery header ─────────────────────────────────────────────── */
.gallery-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.gallery-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--pine-teal);
}

.gallery-count {
  font-size: 0.9rem;
  color: var(--hunter-green);
  opacity: 0.7;
}

/* ── Masonry grid — 5 columns default ──────────────────────────── */
.gallery-grid {
  columns: 5;
  column-gap: 8px;
}

/* ── Image card — no border radius ─────────────────────────────── */
.img-card {
  display: inline-block;   /* required for CSS columns */
  width: 100%;
  break-inside: avoid;
  margin-bottom: 8px;

  position: relative;
  overflow: hidden;
  border-radius: 0;        /* flat edges */
  background: var(--dust-grey);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.img-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(30, 46, 38, 0.2);
}

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

/* Image fills column width; height is natural — this creates masonry */
.img-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;        /* flat edges */
  transition: opacity 0.3s ease;
  opacity: 0;
}

.img-card img.loaded { opacity: 1; }

/* Hover overlay */
.img-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(30, 46, 38, 0.62) 0%,
    transparent 52%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
  padding: 8px 10px;
  border-radius: 0;
}

.img-card:hover .img-card-overlay,
.img-card:focus-visible .img-card-overlay { opacity: 1; }

.img-card-name {
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-shadow: 0 1px 4px rgba(0,0,0,0.55);
}

/* ── Bottom loader area ─────────────────────────────────────────── */
.gallery-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0 1.5rem;
  gap: 1.2rem;
}

/* Load More button */
.load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 3.4rem;
  background: var(--fern);
  color: #000;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  border: none;
  border-radius: 100px;    /* pill shape */
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(52, 78, 65, 0.38);
  transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}

.load-more-btn:hover {
  background: var(--hunter-green);
  box-shadow: 0 7px 24px rgba(52, 78, 65, 0.52);
  transform: translateY(-2px);
}
.load-more-btn:active { transform: scale(0.96); box-shadow: none; }
.load-more-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.load-more-btn svg { width: 18px; height: 18px; stroke-width: 2.5; }

/* Bottom progress spinner */
.load-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(88, 129, 87, 0.18);
  border-top-color: var(--fern);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.load-spinner[hidden] { display: none; }

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

/* ── End-of-results ─────────────────────────────────────────────── */
.gallery-end {
  text-align: center;
  padding: 2.5rem 0 1rem;
  font-size: 0.88rem;
  color: var(--hunter-green);
  opacity: 0.55;
}

/* ── Modal overlay ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 12, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.visible  { opacity: 1; }
.modal-overlay[hidden]  { display: none !important; }

/* ── Modal inner ────────────────────────────────────────────────── */
.modal-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  max-width: 1600px;
  padding: 3.5rem 1rem 1rem;
  box-sizing: border-box;
}

/* ── Top controls: Download + Close ────────────────────────────── */
.modal-controls {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.modal-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;          /* buttons stay circular */
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
  backdrop-filter: blur(4px);
}

.modal-btn:hover        { background: rgba(255,255,255,0.24); transform: scale(1.08); }
.modal-btn:active       { transform: scale(0.95); }
.modal-btn svg          { width: 20px; height: 20px; stroke-width: 2; }
.modal-btn--close:hover { background: rgba(210, 60, 60, 0.45); }

/* ── Prev / Next arrows ─────────────────────────────────────────── */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;          /* circular nav arrows */
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease;
  z-index: 10;
}

.modal-nav:hover { background: rgba(255,255,255,0.22); }
.modal-nav--prev { left: 14px; }
.modal-nav--next { right: 14px; }
.modal-nav svg   { width: 26px; height: 26px; stroke-width: 2; }

/* ── Image area ─────────────────────────────────────────────────── */
.modal-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  min-height: 0;
}

.modal-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;            /* flat edges on modal image */
  opacity: 0;
  transition: opacity 0.26s ease;
  display: block;
}

.modal-img.loaded { opacity: 1; }

/* ── Spinner ────────────────────────────────────────────────────── */
.modal-spinner {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--dry-sage);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.modal-spinner.hidden { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Caption bar ────────────────────────────────────────────────── */
.modal-caption {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.2rem 0;
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
  gap: 1rem;
}

.modal-filename { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-size     { white-space: nowrap; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   Responsive breakpoints
   ≥ 1400px  →  5 columns  (default above)
   1100–1400 →  4 columns
    768–1100 →  3 columns
    480–768  →  2 columns
       < 480 →  1 column
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 1400px) {
  .gallery-grid { columns: 4; }
}

@media (max-width: 1100px) {
  .gallery-grid { columns: 3; }
}

@media (max-width: 768px) {
  body.gallery-page .gallery-header { padding: 1.2rem 1rem 1rem; }

  .gallery-grid { columns: 2; column-gap: 6px; }
  .img-card     { margin-bottom: 6px; }

  /* Tighten modal on tablets */
  .modal-nav     { width: 40px; height: 40px; }
  .modal-nav svg { width: 22px; height: 22px; }
}

@media (max-width: 480px) {
  .gallery-title { font-size: 1.4rem; }

  .gallery-grid { columns: 2; column-gap: 4px; }
  .img-card     { margin-bottom: 4px; }

  /* Hide side arrows on small phones */
  .modal-nav    { display: none; }

  .modal-inner  { padding: 3rem 0.4rem 0.5rem; }
  .modal-btn    { width: 38px; height: 38px; }
  .modal-btn svg { width: 17px; height: 17px; }

  .modal-caption { font-size: 0.72rem; }
}
