/* Gallery homepage — masonry waterfall + modal. Loaded on is_home() only. */

/* Full-bleed gallery: the theme constrains .main to 54% width on desktop.
   This stylesheet loads only on the homepage, so widen it here for the
   masonry grid to actually use the full viewport. */
.container .main {
  width: 100%;
}

/* ---------- header ---------- */
.gallery-header {
  text-align: center;
  padding: 0 0 14px;
}
.gallery-title {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: 2px;
}
.gallery-sub {
  margin: 0;
  color: #999;
  font-size: 13px;
}
.gallery-search {
  margin: 16px auto 0;
  max-width: 480px;
}
.gallery-search input {
  width: 100%;
  padding: 9px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  color: #333;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.gallery-search input:focus {
  border-color: #e26d6d;
  box-shadow: 0 0 0 3px rgba(226, 109, 109, .12);
  background: #fff;
}
.gallery-search input::placeholder { color: #bbb; }

/* ---------- tag bar ---------- */
.tagbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 6px auto 22px;
  max-width: 900px;
  padding: 0 12px;
}
.tagbar .chip {
  border: 1px solid #e3e3e3;
  color: #666;
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .18s ease;
  user-select: none;
}
.tagbar .chip:hover {
  border-color: #e26d6d;
  color: #e26d6d;
}
.tagbar .chip.on {
  background: #e26d6d;
  border-color: #e26d6d;
  color: #fff;
}

/* ---------- masonry ----------
   Row-major (grid auto-flow: row) so works read left→right, newest at
   top-left — unlike CSS columns which stack vertically by age. Tile heights
   are staggered via aspect-ratio spans set in JS (grid-auto-rows: 6px). */
.masonry {
  --cols: 3;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-flow: row dense;
  grid-auto-rows: 6px;
  gap: 14px;
  width: 100%;
}
.masonry .tile {
  margin: 0;
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: #f4f4f4;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.load-sentinel {
  text-align: center;
  color: #bbb;
  padding: 22px 0 40px;
  font-size: 13px;
}
.load-sentinel[hidden] { display: none; }
.masonry .tile img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .4s ease, opacity .5s ease;
  opacity: 0;
}
.masonry .tile img.loaded { opacity: 1; }
.masonry .tile:hover img {
  transform: scale(1.03);
}
.masonry .tile .cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 26px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .25s ease;
}
.masonry .tile:hover .cap { visibility: visible; opacity: 1; }
.masonry .tile .cap .t-ago { font-size: 12px; opacity: .85; white-space: nowrap; }
.masonry .load {
  grid-column: 1 / -1;
  text-align: center;
  color: #aaa;
  padding: 20px 0;
  font-size: 13px;
}

/* column count matched by JS (applyLayout); these are no-JS fallbacks only */
@media (max-width: 920px)  { .masonry { --cols: 2; } }
@media (max-width: 540px)  { .masonry { --cols: 1; } }
@media (min-width: 1400px) { .masonry { --cols: 4; } }
@media (min-width: 1700px) { .masonry { --cols: 5; } }

/* ---------- modal ---------- */
.g-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
}
.g-modal[hidden] { display: none; }
.g-modal .stage {
  position: relative;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.g-modal .stage img.g-img {
  max-width: 94vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .5);
}
.g-modal .viewer {
  width: 92vw;
  height: 82vh;
  background: #000;
}
.g-modal .g-cap {
  color: #eee;
  text-align: center;
  padding: 14px 0 0;
  max-width: 80vw;
}
.g-modal .g-cap .g-title { font-size: 17px; font-weight: 600; }
.g-modal .g-cap .g-date { font-size: 13px; color: #bbb; margin-top: 2px; }

.g-modal .close {
  position: absolute;
  top: 16px; right: 22px;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  opacity: .8;
}
.g-modal .close:hover { opacity: 1; }
.g-modal .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, .14);
  border: none;
  color: #fff;
  font-size: 26px;
  width: 46px; height: 64px;
  cursor: pointer;
  border-radius: 8px;
  opacity: .7;
  transition: opacity .2s;
}
.g-modal .nav:hover { opacity: 1; background: rgba(255,255,255,.26); }
.g-modal .nav.prev { left: 12px; }
.g-modal .nav.next { right: 12px; }
@media (max-width: 540px) { .g-modal .nav { width: 38px; height: 52px; font-size: 20px; } }