/* ===== gallery (grid + popup) — loaded after styles.css ===== */

/* gallery page hero */
.hero-visual.gallery{
  aspect-ratio: 2048/1462;
  background-image: url(images/gallery-banner.webp);
}

/* ---------- uneven (Pinterest-style) grid ----------
   gallery.js splits the tiles into columns; each tile keeps its own shape. */
.ggrid{
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.gcol{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 640px){
  .ggrid, .gcol{ gap: 6px; }
}

.gtile{
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--ink-2);
  color: var(--text-onink);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  overflow: hidden;
  aspect-ratio: 4/5;                 /* placeholder shape while loading */
  -webkit-tap-highlight-color: transparent;
}
.gtile.is-ready{ aspect-ratio: auto; } /* then it takes the picture's real shape */

.gtile img,
.gtile video{
  display: block;
  width: 100%;
  height: auto;
  transition: transform .5s ease, filter .2s ease;
}
.gtile:not(.is-ready) img,
.gtile:not(.is-ready) video{
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
}

/* title only appears when hovering with a mouse, and only if there is one */
.g-cap{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 32px 12px 10px;
  background: linear-gradient(to top, rgba(13,13,13,.85), rgba(13,13,13,0));
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity .2s ease;
}
@media (hover: hover){
  .gtile:hover img,
  .gtile:hover video{ filter: brightness(.82); }
  .gtile:hover .g-cap{ opacity: 1; }
}

/* small play badge on videos */
.g-play{
  position: absolute;
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(13,13,13,.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.g-play::after{
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-38%, -50%);
  border-left: 9px solid var(--paper);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

@media (max-width: 640px){
  .gtile{ border-radius: 10px; }
  .g-play{ top: 7px; right: 7px; width: 24px; height: 24px; }
  .g-play::after{ border-left-width: 8px; border-top-width: 5px; border-bottom-width: 5px; }
}

/* ---------- filter chips (gallery page) ---------- */
.gfilter{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.gchip{
  font-family: var(--body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(13,13,13,.55);
  color: var(--text-onink);
  border: 1px solid rgba(239,235,225,.25);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.gchip:hover{ border-color: var(--rust-2); }
.gchip.is-on{
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}
@media (max-width: 640px){
  .gchip{ font-size: 12.5px; padding: 7px 13px; }
}

/* ---------- popup (Instagram-style) ---------- */
html.gm-lock{ overflow: hidden; }

.gmodal{
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  color: var(--text-onink);
  overflow: hidden;
}
.gmodal[open]{
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 76px;
}
.gmodal::backdrop{
  background: rgba(0,0,0,.82);
}

/* --aw / --ah = the most room the picture may take (width / height).
   --r = the picture's shape (width ÷ height), filled in by gallery.js. */
.gm-panel{
  --aw: calc(100vw - 152px);
  --ah: calc(100dvh - 48px);
  position: relative;
  display: flex;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  animation: gm-in .2s ease-out;
}
.gm-panel.has-text{
  --aw: calc(100vw - 152px - 360px);
  background: var(--ink-2);
}
@keyframes gm-in{
  from{ opacity: 0; transform: scale(.97); }
}

.gm-media{
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.gm-media img,
.gm-media video{
  display: block;
  width: min(var(--aw), calc(var(--ah) * var(--r, 1)));
  height: auto;
  max-height: var(--ah);
  object-fit: contain;
}
.gm-media .gm-yt{
  display: block;
  width: min(var(--aw), calc(var(--ah) * 16 / 9));
  aspect-ratio: 16/9;
  border: 0;
}
/* a very wide picture next to a text panel still gets a sensible height */
.gm-panel.has-text .gm-media{ min-height: min(460px, var(--ah)); }

/* the text panel: only shown when the item has a title or description */
.gm-info{
  display: none;
  position: relative;
  width: 360px;
  flex: none;
  border-left: 1px solid var(--line-dark);
}
.gm-panel.has-text .gm-info{ display: block; }
.gm-scroll{
  position: absolute;             /* panel height follows the picture, text scrolls */
  inset: 0;
  overflow-y: auto;
  padding: 26px 24px 22px;
}
.gm-title{
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text-onink);
  margin: 0 0 12px;
}
.gm-desc{
  font-size: 14.5px;
  line-height: 1.65;
  color: #cfcabd;
}
.gm-desc p{ margin: 0 0 .9em; }
.gm-desc p:last-child{ margin-bottom: 0; }
.gm-date{
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted-onink);
  margin: 16px 0 0;
}
.gm-src{
  display: inline-block;
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--rust-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
}
.gm-src:hover{ border-bottom-color: currentColor; }
.gm-title[hidden], .gm-date[hidden], .gm-src[hidden]{ display: none; }

/* close (top right of the screen) */
.gm-close{
  position: absolute;
  top: 12px; right: 14px;
  z-index: 3;
  width: 40px; height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  opacity: .9;
}
.gm-close:hover{ opacity: 1; }
.gm-close svg{ width: 26px; height: 26px; }

/* round prev / next arrows at the screen edges */
.gm-arrow{
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 36px; height: 36px;
  margin-top: -18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(239,235,225,.92);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  transition: background .15s ease;
}
.gm-arrow:hover{ background: var(--paper); }
.gm-arrow svg{ width: 20px; height: 20px; }
.gm-prev{ left: 20px; }
.gm-next{ right: 20px; }
.gmodal.is-single .gm-arrow{ display: none; }

.gm-close svg, .gm-arrow svg{
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* phones + small tablets: a card that's only as tall as what's in it,
   picture on top, words underneath */
/* ---------- several pictures in one post (Instagram-style carousel) ---------- */

/* little stacked-pictures badge on the grid tile */
.g-stack{
  position: absolute;
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(13,13,13,.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.g-stack svg{
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 15px; height: 15px;
  fill: none;
  stroke: var(--paper);
  stroke-width: 2;
}

/* arrows over the picture + dots below it, only when the card has several */
.gm-sl{
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 32px; height: 32px;
  margin-top: -16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(239,235,225,.92);
  color: var(--ink);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  transition: background .15s ease, opacity .15s ease;
}
.gm-panel.has-slides .gm-sl{ display: flex; }
.gm-sl:hover{ background: var(--paper); }
.gm-sl.is-off{ opacity: 0; pointer-events: none; visibility: hidden; }
.gm-sl svg{
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gm-sl-prev{ left: 12px; }
.gm-sl-next{ right: 12px; }

.gm-dots{
  position: absolute;
  left: 0; right: 0; bottom: 12px;
  z-index: 2;
  display: none;
  justify-content: center;
  gap: 7px;
}
.gm-panel.has-slides .gm-dots{ display: flex; }
.gm-dot{
  width: 8px; height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(239,235,225,.5);
  cursor: pointer;
  transition: background .15s ease;
}
.gm-dot.is-on{ background: var(--paper); }

@media (max-width: 760px){
  .gmodal[open]{ padding: 60px 12px 24px; }
  .gm-panel{
    --aw: calc(100vw - 24px);
    --ah: calc(100dvh - 84px);
    flex-direction: column;
    border-radius: 8px;
  }
  .gm-panel.has-text{
    --aw: calc(100vw - 24px);
    --ah: 62dvh;
    width: 100%;
  }
  .gm-panel.has-text .gm-media{ min-height: 0; }
  .gm-info{
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--line-dark);
  }
  .gm-scroll{
    position: static;
    max-height: calc(100dvh - 84px - 62dvh);
    padding: 14px 16px 16px;
  }
  .gm-title{ font-size: 17px; margin-bottom: 8px; }
  .gm-desc{ font-size: 14px; }
  .gm-date{ margin-top: 10px; }
  .gm-src{ margin-top: 10px; }

  .gm-close{ top: 10px; right: 8px; }
  .gm-arrow{
    width: 30px; height: 30px;
    margin-top: -15px;
    background: rgba(239,235,225,.8);
  }
  .gm-arrow svg{ width: 17px; height: 17px; }
  .gm-prev{ left: 4px; }
  .gm-next{ right: 4px; }
}
