/* ============================================================
   Gallery page — extends style.css, reuses its CSS variables
   (--bg, --surface, --magenta, --grad, etc.)
   ============================================================ */

/* ---- Hero ---- */
/* Same treatment as #blog-hero / .page-hero on the other pages */
#gallery-hero {
  padding: 8.5rem 0 3rem;
  text-align: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

#gallery-hero::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -120px;
  width: 360px;
  height: 360px;
  background: var(--grad);
  opacity: 0.18;
  filter: blur(80px);
  border-radius: 50%;
  pointer-events: none;
}

#gallery-hero::after {
  content: '';
  position: absolute;
  bottom: -140px;
  left: -140px;
  width: 320px;
  height: 320px;
  background: var(--grad);
  opacity: 0.12;
  filter: blur(90px);
  border-radius: 50%;
  pointer-events: none;
}

#gallery-hero h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.7rem);
  font-weight: 800;
  color: var(--white);
  margin-bottom: 0.9rem;
  line-height: 1.5;
}

#gallery-hero p {
  max-width: 560px;
  margin: 0 auto;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 2;
}

.gallery-hero-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.6rem;
}

@media (max-width: 640px) {
  #gallery-hero { padding: 7.5rem 0 2.5rem; }
}

/* ---- Featured fanned card stack ---- */
.fc-wrap {
  position: relative;
  z-index: 1;
  margin: 3.2rem auto 0;
  max-width: 920px;
}

.fc-stack {
  position: relative;
  height: 350px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-card {
  position: absolute;
  width: 320px;
  height: 320px;
  border: none;
  padding: 0;
  border-radius: 1.4rem;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  transition: transform 0.55s cubic-bezier(.22,.85,.32,1), opacity 0.5s ease, box-shadow 0.4s ease;
  transform: translateX(0) rotate(0deg) scale(0.6);
  opacity: 0;
}

.fc-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.fc-card.pos-0 {
  transform: translateX(0) translateY(0) rotate(0deg) scale(1);
  opacity: 1;
  box-shadow: 0 24px 55px rgba(210, 53, 138, 0.35);
  border-color: var(--border-glow);
}

.fc-card.pos-1 {
  transform: translateX(160px) translateY(19px) rotate(9deg) scale(0.86);
  opacity: 0.9;
}

.fc-card.pos-n1 {
  transform: translateX(-160px) translateY(19px) rotate(-9deg) scale(0.86);
  opacity: 0.9;
}

.fc-card.pos-2 {
  transform: translateX(288px) translateY(40px) rotate(16deg) scale(0.72);
  opacity: 0.55;
}

.fc-card.pos-n2 {
  transform: translateX(-288px) translateY(40px) rotate(-16deg) scale(0.72);
  opacity: 0.55;
}

.fc-card.fc-hidden {
  transform: translateX(0) translateY(40px) scale(0.55);
  opacity: 0;
  pointer-events: none;
}

.fc-card.pos-0:hover img {
  transform: scale(1.06);
}

.fc-card img {
  transition: transform 0.5s ease;
}

.fc-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1.6rem;
}

.fc-arrow {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.fc-arrow svg { width: 18px; height: 18px; }

.fc-arrow:hover {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  transform: translateY(-2px);
}

@media (max-width: 640px) {
  .fc-stack { height: 290px; }
  .fc-card { width: 240px; height: 260px; }
  .fc-card.pos-1 { transform: translateX(120px) translateY(16px) rotate(9deg) scale(0.82); }
  .fc-card.pos-n1 { transform: translateX(-120px) translateY(16px) rotate(-9deg) scale(0.82); }
  .fc-card.pos-2 { transform: translateX(205px) translateY(34px) rotate(15deg) scale(0.66); }
  .fc-card.pos-n2 { transform: translateX(-205px) translateY(34px) rotate(-15deg) scale(0.66); }
}

@media (max-width: 420px) {
  .fc-stack { height: 260px; }
  .fc-card { width: 240px; height: 225px; }
  .fc-card.pos-2, .fc-card.pos-n2 { opacity: 0; pointer-events: none; }
}

/* ---- Toolbar (filters) ---- */
#gallery-toolbar {
  background: var(--bg);
  padding: 2.2rem 0 0.5rem;
}

.pg-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  max-width: 900px;
  margin: 0 auto;
}

.pg-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.pg-tab:hover {
  color: var(--pink);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

.pg-tab.active {
  color: var(--white);
  background: var(--grad);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(210, 53, 138, 0.35);
  transform: translateY(-1px);
}

.pg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 1rem;
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
}

.pg-tab.active .pg-count {
  background: rgba(255, 255, 255, 0.28);
}

/* ---- Grid section ---- */
#gallery-grid-section {
  padding: 2.2rem 0 7rem;
  background: var(--bg);
}

.pg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.3rem;
}

@media (max-width: 1080px) {
  .pg-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .pg-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}

@media (max-width: 460px) {
  .pg-grid { grid-template-columns: 1fr; }
}

/* Staggered reveal wave */
.pg-grid .pg-item:nth-child(4n+1) { transition-delay: 0s; }
.pg-grid .pg-item:nth-child(4n+2) { transition-delay: .07s; }
.pg-grid .pg-item:nth-child(4n+3) { transition-delay: .14s; }
.pg-grid .pg-item:nth-child(4n+4) { transition-delay: .21s; }

.pg-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 1.3rem;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1), border-color 0.4s ease, box-shadow 0.4s ease, opacity .35s ease;
}

.pg-item.pg-hidden {
  display: none;
}

.pg-item:hover,
.pg-item:focus-visible {
  transform: translateY(-6px);
  border-color: var(--border-glow);
  box-shadow: 0 16px 42px rgba(210, 53, 138, 0.2);
  outline: none;
}

.pg-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 25% 15%, rgba(210, 53, 138, 0.14), transparent 60%),
    var(--surface2);
}

.pg-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.35));
  transition: transform 0.5s cubic-bezier(.2,.8,.2,1);
}

.pg-item:hover .pg-media img {
  transform: scale(1.08) translateY(-4px);
}

.pg-badge {
  position: absolute;
  top: 0.8rem;
  inset-inline-start: 0.8rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--magenta);
  background: rgba(20, 9, 28, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-glow);
  border-radius: 2rem;
  padding: 0.25rem 0.75rem;
  z-index: 2;
}

body.light .pg-badge {
  background: rgba(255, 255, 255, 0.374);
  /* color: #e879b8 !important; */
    font-weight: 700;
    /* text-shadow: 0 1px 2px rgba(0, 0, 0, 0.878); */
}

.pg-scrim {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  /* background: linear-gradient(to top, rgba(5, 2, 9, 0.92) 0%, rgba(5, 2, 9, 0.35) 45%, transparent 75%); */
  opacity: 0;
  transition: opacity 0.35s ease;
  padding: 1.2rem;
  text-align: center;
}

.pg-item:hover .pg-scrim,
.pg-item:focus-visible .pg-scrim {
  opacity: 1;
}

.pg-zoom {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  transform: translateY(10px) scale(0.85);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
  box-shadow: 0 8px 20px rgba(210, 53, 138, 0.4);
}

.pg-item:hover .pg-zoom {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.pg-zoom svg { width: 18px; height: 18px; }

.pg-name {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
  transform: translateY(10px);
  opacity: 0;
  transition: transform 0.35s ease 0.05s, opacity 0.35s ease 0.05s;
}

.pg-item:hover .pg-name {
  transform: translateY(0);
  opacity: 1;
}

.pg-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 0;
  font-size: 0.95rem;
}

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

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(6, 3, 11, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 1.5rem;
}

.lightbox.show {
  opacity: 1;
  visibility: visible;
}

.lightbox-counter {
  position: absolute;
  top: 1.4rem;
  inset-inline-start: 1.6rem;
  z-index: 20;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.4rem 1rem;
}

.lightbox-close {
  position: absolute;
  top: 1.1rem;
  inset-inline-end: 1.4rem;
  z-index: 20;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: #fff;
  touch-action: manipulation;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.lightbox-close:hover {
  background: var(--grad-h);
  border-color: transparent;
  transform: rotate(90deg);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: #fff;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
  z-index: 20;
  touch-action: manipulation;
}

.lightbox-nav:hover {
  background: var(--grad-h);
  border-color: transparent;
}

.lightbox-nav svg { width: 22px; height: 22px; }

.lightbox-prev { left: 1.2rem; }
.lightbox-next { right: 1.2rem; }

.lightbox-prev:hover { transform: translateY(-50%) translateX(-3px); }
.lightbox-next:hover { transform: translateY(-50%) translateX(3px); }

@media (max-width: 720px) {
  .lightbox-nav { width: 42px; height: 42px; }
  .lightbox-nav svg { width: 18px; height: 18px; }
  .lightbox-prev { left: 0.5rem; }
  .lightbox-next { right: 0.5rem; }
}

.lightbox-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 1rem;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  background: var(--surface2);
  padding: 1.2rem;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.lightbox-stage img.fade {
  opacity: 0;
  transform: scale(0.97);
}

.lightbox-caption {
  text-align: center;
  margin-top: 1.2rem;
  max-width: 700px;
}

.lightbox-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--magenta);
  border: 1px solid var(--border-glow);
  border-radius: 2rem;
  padding: 0.2rem 0.9rem;
  margin-bottom: 0.6rem;
}

.lightbox-caption h3 {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.6;
}

.lightbox-thumbs {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.4rem;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.3rem 0.2rem 0.6rem;
  scrollbar-width: thin;
}

.lightbox-thumbs::-webkit-scrollbar { height: 5px; }
.lightbox-thumbs::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }

.lightbox-thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 0.6rem;
  padding: 0.35rem;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.lightbox-thumb:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.lightbox-thumb.active {
  opacity: 1;
  border-color: var(--magenta);
}

@media (max-width: 640px) {
  .lightbox-thumbs { display: none; }
  .lightbox-stage img { max-height: 55vh; padding: 0.7rem; }
}