/* ===== Aftermath Gallery ===== */

/* mount */
#aftermath-gallery {
  max-width: 4000px;
  margin: 0 auto;
  padding: 12px;
}

.afg-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px;
  max-width: 95vw;
}
.afg-caption-overlay {
  /* put caption back into normal document flow */
  position: static;        /* ← key change */
  transform: none;
  left: auto;
  bottom: auto;
  z-index: auto;

  margin-top: 14px;        /* space under image */

  max-width: min(92vw, 980px);
  padding: 10px 12px;

  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-align: center;

  border: 1px solid rgba(120,255,160,0.28);
  background: rgba(0,0,0,0.55);
  color: rgba(160,255,190,0.95);
  text-shadow: 0 0 10px rgba(120,255,160,0.35);
  border-radius: 10px;

  display: none;           /* JS controls visibility */
  pointer-events: none;
}

.afg-caption-overlay::before {
  content: "LOG ENTRY: ";
  opacity: 0.75;
}
/* ===== Grid Layout ===== */

.afg-grid {
  column-count: 4;
  column-gap: 14px;
}

/* ultrawide monitors */
@media (min-width: 2200px) {
  .afg-grid {
    column-count: 5;
  }
}

/* laptops / desktops */
@media (max-width: 1200px) {
  .afg-grid {
    column-count: 3;
  }
}

/* tablets + phones */
@media (max-width: 900px) {
  .afg-grid {
    column-count: 2;
    column-gap: 10px;
  }
}

/* ===== Grid Items ===== */

.afg-item {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}

.afg-item img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
  transform: scale(1);
  transition: transform 140ms ease;
}

.afg-item:hover img {
  transform: scale(1.02);
}

/* ===== Lightbox Base ===== */

.afg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: none;
  place-items: center;
  z-index: 9999;
  touch-action: pan-y;
}

.afg-lightbox.is-open {
  display: grid;
}

/* ===== CRT Overlays ===== */

/* scanlines */
.afg-lightbox::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0.18),
      rgba(0,0,0,0.18) 1px,
      rgba(0,0,0,0.06) 2px,
      rgba(0,0,0,0.06) 3px
    );
  mix-blend-mode: multiply;
  opacity: 0.55;
  animation: afg-scan-drift 8s linear infinite;
  z-index: 1;
}

/* grain */
.afg-lightbox::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.22;
  z-index: 1;
}

/* ===== Lightbox Image ===== */

.afg-lightbox img {
  max-width: min(96vw, 1400px);
  max-height: calc(92vh - 90px);
  object-fit: contain;
  border-radius: 12px;
  z-index: 2;

  filter:
    contrast(1.08)
    saturate(0.92)
    drop-shadow(0 0 10px rgba(120,255,160,0.16))
    drop-shadow(0 0 28px rgba(120,255,160,0.08));
}

.afg-lightbox.is-open img {
  animation: afg-phosphor-pulse 3.2s ease-in-out infinite;
}

/* ===== Controls ===== */

.afg-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.afg-btn {
  pointer-events: all;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid rgba(120,255,160,0.35);
  background: rgba(0,0,0,0.55);
  color: rgba(160,255,190,0.95);
  font-family: ui-monospace, monospace;
  font-size: 26px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(120,255,160,0.35);
  transition: background 120ms ease;
}

.afg-btn:hover {
  background: rgba(120,255,160,0.15);
}

.afg-btn.prev { left: 18px; }
.afg-btn.next { right: 18px; }

.afg-close {
  pointer-events: all;
  position: absolute;
  top: 16px;
  right: 16px;
  border: 1px solid rgba(120,255,160,0.35);
  background: rgba(0,0,0,0.55);
  color: rgba(160,255,190,0.95);
  font-family: ui-monospace, monospace;
  font-size: 16px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

/* ===== Hint ===== */

.afg-hint {
  color: rgba(255,255,255,0.7);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  text-align: center;
  margin-top: 10px;
}

/* ===== Animations ===== */

@keyframes afg-phosphor-pulse {
  0% {
    filter:
      contrast(1.08)
      saturate(0.92)
      drop-shadow(0 0 10px rgba(120,255,160,0.16))
      drop-shadow(0 0 28px rgba(120,255,160,0.08));
  }
  50% {
    filter:
      contrast(1.08)
      saturate(0.92)
      drop-shadow(0 0 14px rgba(120,255,160,0.20))
      drop-shadow(0 0 36px rgba(120,255,160,0.12));
  }
  100% {
    filter:
      contrast(1.08)
      saturate(0.92)
      drop-shadow(0 0 10px rgba(120,255,160,0.16))
      drop-shadow(0 0 28px rgba(120,255,160,0.08));
  }
}

@keyframes afg-scan-drift {
  0% { background-position: 0 0; }
  100% { background-position: 0 4px; }
}
