/* Force spinner hidden state regardless of flex or other styles */
.scroll-spinner[hidden] {
  display: none !important;
}

/* assets/css/main-layout.css
   Main page layout and components for NetPix.
   Loads after base.css — overrides global resets where needed.
   ──────────────────────────────────────────────────────────── */

/* ── Page container ───────────────────────────────────────────────────────── */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 0.75rem;
}

/* ── Banner ───────────────────────────────────────────────────────────────── */
.main-banner {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(135deg, rgba(255, 107, 157, 0.1) 0%, rgba(255, 179, 198, 0.1) 100%);
  border-radius: 12px;
  margin-bottom: 3rem;
  /* Needed when a cover image is present */
  position: relative;
  overflow: hidden;
  /* Mobile Safari (WebKit) bug: border-radius + overflow:hidden does not clip
     absolutely-positioned children (e.g. the cover <img>) on its own.
     A compositing layer must be forced via translateZ(0) to make the engine
     honour the clip — otherwise the image bleeds outside the card and widens
     the page, allowing horizontal swipe on mobile. */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Full-bleed modifier — breaks the banner out of the container's horizontal
   padding so the image stretches edge-to-edge. Border-radius is removed so
   the edges sit flush with the viewport. Negative margins mirror the container
   padding (mobile: 0.75rem, small phones: 0.4rem, desktop: 2rem — see the
   responsive overrides in the media queries below).
   NOTE: --bleed is kept for potential future use but --fade is the primary toggle. */
.main-banner--bleed {
  border-radius: 0;
  margin-left:  -0.75rem;
  margin-right: -0.75rem;
}

/* ── Cover image variant ──────────────────────────────────────────────────── */
.main-banner--cover {
  /* Dark fallback so the text is readable before the image loads */
  background: #111;
  /* Card radius is inherited from .main-banner (12 px) — fade modifier removes it */
  /* Taller so the photo has room to breathe */
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(3rem + 20px) 2rem calc(3rem + 20px) 2rem;
}

/* Fade modifier — applied on top of --cover when fade-edges is enabled.
   Makes the card background transparent so the page background shows through
   the faded image edges, and removes the card border-radius so the gradient
   fade is the only boundary. */
.main-banner--cover.main-banner--fade {
  background: transparent;
  border-radius: 0;
}

/* The cover photo itself — fills the card, edges crop */

.main-banner__cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  display: block;
}

/* Fade overlay — painted on top of the image (and scrim) via ::after.
   Uses the actual page background colour (--color-background) and fades it
   to transparent toward the centre. This paint-over approach is more reliable
   than CSS masks: masks fade image pixels to alpha-transparent, which then
   depends on correct GPU compositing-layer alpha blending — a path that breaks
   in dark mode because the compositing layer boundary renders as a hard line.
   Painting the background colour ON TOP avoids that chain entirely and
   automatically adapts to both themes via the CSS variable.
   --hero-fade-depth controls how far the opaque ramp runs in from each edge. */
.main-banner--fade::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3; /* above image (0), scrim ::before (1), and banner-content (2) */
  pointer-events: none;
  background:
    linear-gradient(to right,
      var(--color-background) 0%,
      transparent var(--hero-fade-depth, 18%),
      transparent calc(100% - var(--hero-fade-depth, 18%)),
      var(--color-background) 100%
    ),
    linear-gradient(to bottom,
      var(--color-background) 0%,
      transparent var(--hero-fade-depth, 18%),
      transparent calc(100% - var(--hero-fade-depth, 18%)),
      var(--color-background) 100%
    );
}

/* Scrim overlay — sits between image and text for legibility */
.main-banner--cover::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* Dark scrim for light-text mode (default) */
.main-banner--text-light::before {
  background: rgba(0, 0, 0, 0.38);
}

/* Light scrim for dark-text mode */
.main-banner--text-dark::before {
  background: rgba(255, 255, 255, 0.45);
}

/* Banner content sits above image + scrim */
.main-banner--cover .banner-content {
  position: relative;
  z-index: 2;
  width: 100%;
}

/* Text colours when cover image is present */
.main-banner--text-light .main-banner__wordmark,
.main-banner--text-light h1,
.main-banner--text-light p {
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Subtitle opacity is controlled by --hero-sub-opacity (set via admin settings).
   Default 0.72 matches the original design intent (dimmer than wordmark). */
.main-banner--text-light p {
  color: rgba(255, 255, 255, var(--hero-sub-opacity, 0.72));
}

.main-banner--text-dark .main-banner__wordmark,
.main-banner--text-dark h1,
.main-banner--text-dark p {
  color: #1a1a1a;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.5);
}

.main-banner--text-dark p {
  color: rgba(26, 26, 26, var(--hero-sub-opacity, 0.65));
}

.main-banner h1 {
  font-size: clamp(1.8rem, 8.8vw, 3.5rem);
  font-weight: 400;
  letter-spacing: clamp(0.9rem, 1.8vw, 0.95rem);
  margin-bottom: 1rem;
  color: #333;
  white-space: nowrap;
  line-height: 1.1;
}

.main-banner__wordmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
}

.main-banner__wordmark span {
  display: inline-block;
}

.main-banner p {
  font-size: clamp(0.9rem, 3.8vw, 1.2rem);
  color: #999;
  margin-bottom: 2rem;
  font-weight: 300;
  white-space: nowrap;
}

/* Upload button — override base.css global button padding */
.btn-open-popup {
  margin-top: 80px;
  padding: 1rem 3rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: #2ECC71;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn-open-popup:hover {
  background: #27AE60;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(46, 204, 113, 0.4);
}

/* ── Entries grid section ─────────────────────────────────────────────────── */
.entries-grid {
  margin-top: 3rem;
}

.entries-grid h2 {
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 2rem;
  color: #333;
}

/* ── Search ───────────────────────────────────────────────────────────────── */
.search-container {
  margin-bottom: 2rem;
}

.search-wrapper {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
  max-width: 500px;
  margin: 0 auto 2rem;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Override base.css width:100% on inputs */
.search-wrapper input[type="text"] {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  border: none;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  background: white;
}

.search-wrapper input[type="text"]:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

.search-wrapper button {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  padding: 0 1.5rem;
  height: auto;
  -ms-flex-item-align: stretch;
  align-self: stretch;
  background: #4A90E2;
  border: none;
  border-radius: 0;
  cursor: pointer;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  transition: background 0.2s;
}

.search-wrapper button:hover {
  background: #357ABD;
}

.search-wrapper svg {
  color: white;
  display: block;
}

/* ── Photo grid ───────────────────────────────────────────────────────────────
   MINIMUM 2 COLUMNS on all screens — guaranteed with the 2-column fallback
   for browsers that don't support CSS Grid or auto-fill properly (older Android).

   Strategy:
   1. Fallback — explicit 2-column grid for all screens (old browsers see this)
   2. Modern browsers override with auto-fill minmax for fluid columns
   ──────────────────────────────────────────────────────────────────────────── */
.entries-wrapper {
  /* ── Fallback: always at least 2 equal columns ── */
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr 0.5rem 1fr;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 1.25rem;
  /* Smooth opacity-fade when filter changes swap the grid content */
  transition: opacity 0.12s;
}

/* ── Modern browsers: fluid auto-fill, minimum 160px per cell ── */
@supports (grid-template-columns: repeat(auto-fill, minmax(160px, 1fr))) {
  .entries-wrapper {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
  }
}

/* ── Grid items ──────────────────────────────────────────────────────────── */
.grid-item {
  position: relative;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
  /* Prevent item shrinking below its column width */
  min-width: 0;
}

.grid-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* New photo slide-in animation */
.grid-item.new-photo {
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
}

.grid-item.animate-in {
  animation: slideInPhoto 0.5s ease forwards;
}

@keyframes slideInPhoto {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Position badge ───────────────────────────────────────────────────────────
   Top-left corner — rank number + vote count.
   ──────────────────────────────────────────────────────────────────────────── */
.position-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 0.2rem 0.5rem;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: 0.7rem;
  line-height: 1;
  /* Prevent badge text wrapping on very narrow columns */
  white-space: nowrap;
}

.position-badge__num {
  font-weight: 700;
  color: #4A90E2;
}

.position-badge__sep {
  color: #ccc;
}

.position-badge__votes {
  font-weight: 500;
  color: #555;
}

/* NEW badge — always in the DOM for approved cards; CSS drives visibility */
.new-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #2ECC71;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  z-index: 10;
  /* Hidden by default — shown via the data-votes/data-status selector below */
  display: none;
}

/* Show NEW badge for cards marked new by NewBadgeTracker (localStorage-based) */
.grid-item.is-new .new-badge {
  display: block;
}

/* Hide position badge while a card has no votes or is still pending.
   When the vote poller sets data-votes to a non-zero value the position
   badge becomes visible automatically — no JS needed. */
.grid-item[data-status="pending"] .position-badge,
.grid-item[data-status="approved"][data-votes="0"] .position-badge {
  display: none;
}

/* ── Club badge overlay ──────────────────────────────────────────────────── */
/* Small club badge sits in the bottom-left corner of each gallery card.
   pointer-events: none so clicks pass through to the vote/share buttons.
   40×40 provides good readability on both mobile and desktop cards. */
.grid-item__club-badge {
  position: absolute;
  bottom: calc(3rem + 5px);
  /* sit above the vote bar */
  left: 3px;
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  /* subtle backdrop so the badge reads on any photo */
  background: rgba(255, 255, 255, 0.15);
}

/* ── Uploader avatar overlay ────────────────────────────────────────────── */
/* Mirrors .grid-item__club-badge but sits in the bottom-right corner.
   Circle crop, thin white border, same elevation as the club badge.
   pointer-events: none so clicks reach the vote/share buttons underneath. */
.grid-item__uploader-avatar {
  position: absolute;
  bottom: calc(3rem + 5px);
  right: 3px;
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  background: rgba(255, 255, 255, 0.15);
}

.pending-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #f39c12;
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  z-index: 10;
}

/* Grid image */
.grid-image {
  width: 100%;
  height: 160px;
  /* compact on mobile */
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  /* Discourage saving: block iOS long-press Save Image and drag-to-desktop */
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* ── Vote button area ─────────────────────────────────────────────────────── */
.vote {
  padding: 0.3rem 0.3rem;
  text-align: center;
  background: white;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* Override base.css global button padding */
.vote-button {
  flex: 1;
  width: auto;
  min-height: 40px;
  padding: 0.625rem 0.8rem;
  background: #2ECC71;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1;
  white-space: nowrap;
  transition: all 0.2s;
}

.vote-button:hover {
  background: #27AE60;
  transform: translateY(-1px);
}

.vote-button:disabled,
.grid-share-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.grid-share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: #4A90E2;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
}

.grid-share-button:hover {
  background: #357ABD;
  transform: translateY(-1px);
}

.grid-share-button svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Hide all share buttons when the visitor arrived via an anon share link.
   Class is set by share-button.js and covers all card sources. */
.anon-share-visitor .js-share-photo,
.anon-share-visitor #lightboxShareBtn {
  display: none;
}

/* ── Empty / error states ─────────────────────────────────────────────────── */
.no-photos {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: #999;
  font-size: 1.1rem;
}

.error {
  grid-column: 1 / -1;
  background: #fee;
  color: #c33;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
}

.offline-notice {
  grid-column: 1 / -1;
  background: #fff8e1;
  color: #7a6000;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

/* ── Winners chip ────────────────────────────────────────────────────────── */
/* Inline chip below "photo gallery" heading, links to the winners page.
   Visible to everyone so first-time visitors can discover past champions. */
.winners-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-full, 9999px);
  padding: 0.35rem 0.85rem 0.35rem 0.65rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: #92400e;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  margin-bottom: 0.75rem;
  align-self: flex-start;
}

.winners-chip:hover {
  background: #fef3c7;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.winners-chip__trophy {
  font-size: 1rem;
  line-height: 1;
}

.winners-chip__arrow {
  font-size: 0.85em;
  opacity: 0.7;
}

/* ── Action pose pill ────────────────────────────────────────────────────── */
/* Highlights the monthly challenge set by an admin. */
.action-pose-pill {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(46, 204, 113, 0.15);
  color: #1a7a45;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Row holds title + optional ⓘ button — nowrap keeps them together */
.action-pose-pill__row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

/* Secondary label above the title — smaller and muted */
.action-pose-pill__label {
  font-size: 0.8rem;
  opacity: 0.75;
  line-height: 1;
}

/* Title is on its own row so it gets full pill width */
.action-pose-pill__title {
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 0;
}

.action-pose-pill__info {
  background: none;
  border: none;
  cursor: pointer;
  color: #1a7a45;
  /* Large enough to read and tap comfortably on mobile */
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.action-pose-pill__desc {
  width: 100%;
  font-size: 0.8125rem;
  line-height: 1.55;
  opacity: 0.92;
  padding-top: 0.25rem;
  white-space: pre-line;
}

.action-pose-pill__img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  object-fit: cover;
}

/* ── Gallery filter bar ──────────────────────────────────────────────────── */
/* Chip row that replaces the old single-field search bar. */

/* Invisible sentinel placed directly above the filter bar.
   Height matches the bar so content below doesn't jump when the bar
   transitions into sticky mode and leaves the normal flow. */
.gallery-filter-sentinel {
  height: 0;
  /* Height is set dynamically by JS once the bar's rendered height is known */
}

.gallery-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0.25rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  /* Contain horizontal scroll so a swipe on the bar doesn't pan the whole page */
  overscroll-behavior-x: contain;
  /* Smooth momentum scroll on iOS */
  -webkit-overflow-scrolling: touch;
  /* Inset scroll so first/last chip isn't flush with the edge */
  scroll-padding-inline: 0.75rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Always show scroll cue if pills overflow */
  min-height: 44px;
  /* Pre-declare transition so animation runs in both directions (undocking too) */
  transition: box-shadow 0.35s ease, background 0.35s ease, padding 0.35s ease;
}

/* Sticky state — applied by JS via IntersectionObserver on the sentinel above */
.gallery-filter-bar--sticky {
  position: -webkit-sticky;
  position: sticky;
  /* 4rem = navbar height; sits flush beneath it */
  top: 4rem;
  z-index: 100;
  background: #fff;
  /* Bleed to page edges so it fills the full width under the nav */
  margin-left:  -0.75rem;
  margin-right: -0.75rem;
  padding-left:  0.75rem;
  padding-right: 0.75rem;
  /* Extra vertical breathing room in sticky state */
  padding-top:    0.5rem;
  padding-bottom: 0.4rem;
  /* Shadow + background fade in smoothly when bar docks under the nav */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09);
  transition: box-shadow 0.35s ease, background 0.35s ease, padding 0.35s ease;
}

.gallery-filter-bar::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari/WebKit */
}


.gallery-filter-chip {
  border: 1.5px solid #ccc;
  background: none;
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  color: #555;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.5;
  height: 38px;
  display: flex;
  align-items: center;
  /* Prevent chips from shrinking — the bar scrolls, chips stay full size */
  flex-shrink: 0;
  /* Suppress native mobile tap rectangle flash */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gallery-filter-chip--active {
  background: #27ae60;
  border-color: #27ae60;
  color: #fff;
}

/* Only apply hover on real pointer devices — on mobile, :hover sticks after
   a tap and makes a deactivated chip look like it's still on. */
@media (hover: hover) and (pointer: fine) {
  .gallery-filter-chip:hover {
    background: #27ae60;
    border-color: #27ae60;
    color: #fff;
  }
}


.gallery-filter-select {
  border: 1.5px solid #ccc;
  border-radius: 20px;
  /* Extra right padding so the native dropdown arrow doesn't crowd the text */
  padding: 0.3rem 1.4rem 0.3rem 0.9rem;
  font-size: 1rem;
  background: none;
  cursor: pointer;
  color: #555;
  line-height: 1.5;
  height: 38px;
  width: 110px;
  min-width: 100px;
  max-width: 125px;
  display: flex;
  align-items: center;
  flex: 0 0 110px;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}

.gallery-filter-search {
  flex: 1;
  min-width: 120px;
  max-width: 200px;
  border: 1.5px solid #ccc;
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  outline-offset: 2px;
}

/* ── Infinite scroll sentinel & spinner ─────────────────────────────────── */
.scroll-spinner {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0 0.5rem;
}

.scroll-spinner__ring {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #27ae60;
  border-radius: 50%;
  animation: scroll-spin 0.7s linear infinite;
}

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

/* Zero-height invisible div that the IntersectionObserver watches */
.scroll-sentinel {
  height: 1px;
  width: 100%;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────────
   display:none when closed — fully removed from flow so the invisible
   overlay never intercepts cursor events on desktop.
   ──────────────────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.lightbox[data-state="open"],
.lightbox[data-state="closing"] {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}

.lightbox[data-state="open"] {
  opacity: 1;
  pointer-events: auto;
}

.lightbox[data-state="closing"] {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.lightbox__container {
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  max-width: 92vw;
  max-height: 90vh;
  z-index: 1;
  transform: scale(0.96);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.lightbox[data-state="open"] .lightbox__container {
  transform: scale(1);
}

.lightbox[data-state="closing"] .lightbox__container {
  transform: scale(0.96);
  transition: transform 0.22s ease-in;
}

.lightbox__image {
  display: block;
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* Discourage saving: block iOS long-press Save Image and drag-to-desktop */
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  /* Blur-up cross-fade when full-res swaps in */
  transition: filter 0.35s ease, transform 0.35s ease;
}

/* Blurred placeholder state — thumb shown while full-res loads */
.lightbox__image--loading {
  filter: blur(16px);
  /* Slight overscan hides the blurred soft edge */
  transform: scale(1.04);
}

/* ── Image wrap: positions close button and spinner over image area ─────── */
.lightbox__image-wrap {
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  /* Prevent the container collapsing before any src is set */
  min-width: min(80vw, 320px);
  min-height: min(50vw, 220px);
  /* No overflow:hidden — close button sits inside but extends to the corner */
  border-radius: 8px;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.lightbox__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, 0.9);
  -webkit-animation: lightbox-spin 0.7s linear infinite;
  animation: lightbox-spin 0.7s linear infinite;
  opacity: 1;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 3;
}

.lightbox__container--loaded .lightbox__spinner {
  opacity: 0;
}

@-webkit-keyframes lightbox-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes lightbox-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.lightbox__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  cursor: pointer;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, transform 0.15s;
  z-index: 2;
}

.lightbox__close:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: scale(1.1);
}

/* Hardcode stroke so SVG colour is reliable across browsers */
.lightbox__close svg {
  width: 18px;
  height: 18px;
  stroke: white;
}

.lightbox__vote-btn {
  margin-top: 0;
  flex: 1;
  width: 100%;
  min-height: 48px;
  padding: 0 1.1rem;
  background: #2ECC71;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.98rem;
  line-height: 1;
  white-space: nowrap;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(46, 204, 113, 0.35);
}

.lightbox__vote-btn:hover {
  background: #27AE60;
  transform: translateY(-2px);
}

.lightbox__actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.3rem 0.3rem;
  width: 100%;
  max-width: 92vw;
  justify-content: center;
  align-items: center;
}

.lightbox__share-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 8px;
  background: #4A90E2;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(74, 144, 226, 0.35);
}

.lightbox__share-btn:hover {
  background: #357ABD;
  transform: translateY(-2px);
}

.lightbox__share-btn svg {
  width: 20px;
  height: 20px;
  stroke: white;
}

/* Mobile-first touch targets: increase hit area on phones */
@media screen and (max-width: 767px) {
  .lightbox__vote-btn {
    min-height: 52px;
    padding: 0 1.2rem;
  }

  .lightbox__share-btn {
    width: 52px;
    height: 52px;
  }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* Small phones (< 400px) — keep 2 columns but tighten gap */
@media screen and (max-width: 400px) {
  .page-container {
    padding: 0.5rem 0.4rem;
  }

  .gallery-filter-bar--sticky {
    margin-left:  -0.4rem;
    margin-right: -0.4rem;
    padding-left:  0.4rem;
    padding-right: 0.4rem;
  }

  .main-banner--bleed {
    margin-left:  -0.4rem;
    margin-right: -0.4rem;
  }

  .entries-wrapper {
    gap: 0.35rem;
  }

  .grid-image {
    height: 130px;
  }

  .main-banner h1 {
    font-size: clamp(1.55rem, 11vw, 2rem);
    letter-spacing: clamp(0.12rem, 1.5vw, 0.3rem);
  }

  .main-banner__wordmark {
    gap: clamp(0.12rem, 1.5vw, 0.3rem);
  }

  .main-banner p {
    font-size: clamp(0.82rem, 3.5vw, 1rem);
  }
}

/* Tablets and up */
@media screen and (min-width: 768px) {
  .grid-image {
    height: 200px;
  }

  /* Desktop: drop chip/select font to match the search field at that breakpoint */
  .gallery-filter-chip,
  .gallery-filter-select {
    font-size: 0.8125rem;
    height: 36px;
    padding-inline: 0.85rem;
  }

  /* Custom-select chip variant also needs the desktop override since it has its own rule */
  .npx-select--chip .npx-select__trigger {
    font-size: 0.8125rem;
  }

  .page-container {
    padding: 1.5rem 2rem;
  }

  /* Adjust sticky bar bleed to match the wider desktop padding */
  .gallery-filter-bar--sticky {
    margin-left:  -2rem;
    margin-right: -2rem;
    padding-left:  2rem;
    padding-right: 2rem;
  }

  .main-banner--bleed {
    margin-left:  -2rem;
    margin-right: -2rem;
  }

  .vote-button {
    font-size: 1rem;
    padding: 0.875rem;
  }

  .main-banner h1 {
    font-size: 3.5rem;
    letter-spacing: clamp(0.9rem, 1.8vw, 0.95rem);
  }

  .main-banner p {
    font-size: 1.2rem;
  }

  /* Lightbox close button — slightly smaller on mobile */
  .lightbox__close {
    top: 3px;
    right: 3px;
    width: 32px;
    height: 32px;
  }

  .lightbox__close svg {
    width: 16px;
    height: 16px;
  }
}

/* Desktop */
@media screen and (min-width: 1024px) {
  .grid-image {
    height: 220px;
  }
}