/* =====================
   Gallery (Grid-based)
   ===================== */

#gallery-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 30px;
  align-items: start;
  max-width: inherit;
  justify-content: center;
}

#content .box-container {
  padding: 30px;
}

.gallery-item {
  position: relative;              /* caption can be absolutely placed */
  display: block;
  margin: 0;
  transition: transform .2s ease;
}

.gallery-box {
  position: relative;              /* create stacking context */
  z-index: 0;                      /* image below caption */
  display: block;
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  cursor: pointer;
  border-radius: 10px;
  transition: transform .2s ease, filter .2s ease;
  box-shadow: 0 0 15px rgba(0,0,0,.3);
  will-change: transform, filter;
}

.gallery-caption{
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: auto;
  max-width: calc(100% - 36px);
  padding: 6px 10px !important;
  border-radius: 8px;
  background: rgba(0,0,0,.46);
  font-size: 14px !important;
  line-height: 1.2;
  height: auto;
  backdrop-filter: blur(8px);
  z-index: 2;
  pointer-events: none;
  transform: translateZ(0);
  transition: transform .2s ease, opacity .2s ease;
}

.caption-date {
  font-size: .9em;
  color: #ffffff94;
  text-shadow: 0 0 10px #000;
}

.caption-text {
  color: #fff;
  text-shadow: 0 0 10px #000;
}

/* Hover only if device supports hover (image only) */
@media (hover:hover) {
  .gallery-item:hover .gallery-box {
    filter: brightness(1.1);
    transform: translateY(-2px);
  }
  .gallery-item:hover .gallery-caption {
    transform: translateY(-2px);
  }
}

/* Touch devices: no hover dimming */
@media (hover:none) {
  .gallery-item:hover .gallery-box {
    filter: none;
    transform: none;
  }
}


/* =====================
   Lightbox
   ===================== */

body.lightbox-lock {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

#lightbox-container {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 99;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(20px);
  transition: opacity .15s ease-in-out;
}

#lightbox {
  width: auto;
  height: auto;
  margin: 8vh auto;
  position: relative;
}

#lb-img {
  width: auto !important;
  max-height: 75vh !important;            /* JS updates to avoid overlap */
  background-size: contain;
  background-repeat: no-repeat;
  margin: -30px auto 20px auto;            /* leaves space below close btn */
  display: block;
  border-radius: 10px;
  box-shadow: 0 0 100px rgba(0,0,0,.5);
  transition: transform .08s ease-out;    /* zoom/pan smoothness */
}

/* Close button — fixed to viewport so it never scrolls with content */
a.lb-close {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 200;
  width: 42px;
  height: 42px;
  padding: 0;
  display: block;
  background-image: url('img/lightbox-close.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60% 60%;
  background-color: rgba(233, 30, 40, 0.95);
  border-radius: 50%;
  border: 1px solid rgba(168, 0, 0, 0.9);
  box-shadow: 0 2px 10px rgba(0,0,0,.55);
  cursor: pointer;
  transition: transform .15s, filter .15s, background-color .15s;
}
a.lb-close:hover { transform: scale(1.07); filter: brightness(1.05); }

/* Controls bar (JS pins ~30px from bottom; we also give top margin) */
#lightbox-controls {
  display: flex;
  width: 280px;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  margin: 40px auto 20px auto;
  background: rgba(20,20,20,.35);
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 30px rgba(0,0,0,.25);
}

#lb-prev a,
#lb-next a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  width: 56px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  background: rgba(255,255,255,.9);
  color: #111;
  transition: transform .15s, filter .15s, background-color .15s;
  box-shadow: 0 2px 18px rgba(0,0,0,.25);
}

@media (hover:hover) {
  #lb-prev a:hover,
  #lb-next a:hover { transform: translateY(-1px); filter: brightness(0.95); }
}

#lb-prev img,
#lb-next img {
  display: block;
  margin: auto;
}
#lb-prev img:hover,
#lb-next img:hover { filter: invert(); }

#lb-prev { float: left; }
#lb-next { float: right; }

#lb-index {
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: .2px;
  opacity: .85;
}

.lb-control-disabled {
  background: rgba(185,185,185,.45) !important;
  opacity: .55 !important;
}
.lb-control-disabled:hover {
  background: rgba(185,185,185,.45) !important;
  opacity: .55 !important;
}

/* --- Tag pills --- */
#tags.tag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 10px 16px;
}
#tags .tag-pill {
  display: inline-block;
  background: #38b6ff36;
  color: #0074b8;
  text-decoration: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 2.6vw, 18px);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: filter .15s ease, transform .15s ease;
  text-transform: capitalize;
}
#tags .tag-pill:hover { filter: brightness(.95); transform: translateY(-1px); }

/* =====================
   Album title — Set ID chip
   ===================== */

/* Container next to "Album: <name>" */
#itemsTitle #setIdBadge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
  font-size: 0.9em;
  opacity: 0.9;
}

/* The code chip that shows the ID */
#itemsTitle #setIdCode {
  position: relative;               /* enables ::after overlay */
  display: inline-block;            /* stable box for the overlay */
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  user-select: none;
  white-space: nowrap;              /* keep id on one line */
  cursor: pointer;
  transition: filter .15s ease;
}

/* Hover text swap WITHOUT layout shift:
   - make original text transparent
   - overlay "Copy" via ::after */
#itemsTitle #setIdCode:hover {
  color: transparent;               /* text stays in flow; width unchanged */
}
#itemsTitle #setIdCode::after {
  content: 'Copy';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s ease;
}
#itemsTitle #setIdCode:hover::after {
  opacity: 1;
}

/* When copied (JS adds .is-copied for ~3s), show "Copied" */
#itemsTitle #setIdCode.is-copied {
  color: transparent;
}
#itemsTitle #setIdCode.is-copied::after {
  content: 'Copied';
  opacity: 1;
}

/* Optional hover polish */
@media (hover:hover) {
  #itemsTitle #setIdCode:hover {
    filter: brightness(1.05);
  }
}


/* =====================
   Admin thumb controls (Replace / Delete)
   ===================== */

/* Ensure each card is a positioning context */
.thumb {
  position: relative;
}

/* Controls cluster in the top-right corner */
.thumb .controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  gap: 6px;
  z-index: 5;
}

/* Reset any legacy sprite/pseudo styles on icon buttons */
.thumb .controls .icon-btn,
.thumb .controls .icon-btn::before,
.thumb .controls .icon-btn::after {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  content: none !important;
}

/* Icon button base */
.thumb .controls .icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, background-color .12s ease;
  backdrop-filter: blur(2px);
  background-color: rgba(0,0,0,.25);     /* subtle pill behind icon */
}

/* Icon image inside the button */
.thumb .controls .icon-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  pointer-events: none;                  /* keep clicks on the button */
  filter: none;
}

/* Hover effects */
@media (hover:hover) {
  .thumb .controls .icon-btn:hover {
    transform: translateY(-1px);
    background-color: rgba(0,0,0,.35);
    filter: brightness(1.05);
  }
}

/* (Optional) danger tint for delete buttons if you add .is-danger to them */
.thumb .controls .icon-btn.is-danger:hover {
  background-color: rgba(160, 0, 0, .45);
}


/* Responsive */
@media (max-width:1000px) {
  #gallery-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
  .gallery-box { aspect-ratio: 3/4; object-position: center; }

  #lightbox { width: 90% !important; height: 100% !important; }
  #lb-img   { width: 100% !important; height: auto !important; background-size: cover !important; margin: 70px auto 20px auto;  }

  a.lb-close {
    width: 36px !important;
    height: 36px !important;
  }

  #lightbox-controls { height: 50px !important; }
  #lb-next a, #lb-prev a { height: 50px !important; width: 50px !important; }
  #lb-next img, #lb-prev img { max-height: 50px !important; width: 50px !important; }
  #lb-index { font-size: clamp(16px, 4.8vw, 20px) !important; padding: 10px !important; }
}

@media (max-width:520px) {
  #gallery-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
}
