/* ============================================================
   GALLERY.CSS — Loaded after styles.css on gallery.html
   ------------------------------------------------------------
   Layout:
     1. PAGE HEADER (hero)
     2. CATEGORIES + 250+ STAT BLOCK
     3. FILTER TABS
     4. SQUARE GRID — 1:1 cards with hover zoom
     5. CARD STYLES
     6. LIGHTBOX — full-size image popup
     7. RESPONSIVE
============================================================ */

/* ============================================================
   1. PAGE HEADER
============================================================ */
.page-header {
  padding: clamp(40px, 5vw, 64px) 0 clamp(20px, 3vw, 32px);
}
.ph-bread {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 18px;
}
.ph-bread .ph-sep {
  margin: 0 8px;
  opacity: 0.4;
}
.ph-title {
  font-size: clamp(34px, 5vw, 64px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--secondary);
  margin-bottom: 18px;
}
.ph-title .serif-em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}
.ph-sub {
  font-size: clamp(15px, 1.3vw, 18px);
  line-height: 1.6;
  color: #4a6885;
  max-width: 640px;
}

/* ============================================================
   2. GALLERY META — Categories + 250+ stat (kept from before)
============================================================ */
.gallery-meta {
  padding: clamp(40px, 5vw, 64px) 0 0;
}
.gm-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(28px, 3.5vw, 56px);
  align-items: stretch;
}
.gm-categories {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: clamp(18px, 2.2vw, 24px);
  padding: clamp(28px, 3.2vw, 44px);
}
.gm-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  border: 1px solid var(--line);
  color: var(--secondary);
  padding: 6px 13px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.gm-pill::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.gm-categories h2 {
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--secondary);
  margin-bottom: clamp(20px, 2.4vw, 28px);
}
.gm-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px clamp(16px, 2vw, 28px);
}
.gm-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--secondary);
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.gm-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.gm-stat {
  background: var(--secondary);
  color: var(--primary);
  border-radius: clamp(18px, 2.2vw, 24px);
  padding: clamp(32px, 4vw, 52px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.gm-stat::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: clamp(80px, 10vw, 140px);
  height: clamp(80px, 10vw, 140px);
  background: var(--accent);
  opacity: 0.12;
  border-radius: 50%;
  transform: translate(40%, -40%);
}
.gm-stat-num {
  font-family: var(--serif);
  font-size: clamp(56px, 7vw, 88px);
  line-height: 1;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 16px;
  font-weight: 400;
}
.gm-stat h3 {
  font-size: clamp(16px, 1.5vw, 19px);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--primary);
  margin-bottom: 12px;
  line-height: 1.3;
}
.gm-stat p {
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(240, 248, 255, 0.78);
  margin: 0;
}

/* ============================================================
   3. FILTER TABS
============================================================ */
.gallery-grid-section {
  padding: clamp(40px, 5vw, 64px) 0 clamp(60px, 7vw, 100px);
}

.cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: clamp(28px, 3.5vw, 44px);
  padding-bottom: clamp(20px, 2.4vw, 28px);
  border-bottom: 1px solid var(--line);
}
.cat-tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--secondary);
  padding: 8px 16px;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.24s var(--ease);
}
.cat-tab:hover {
  border-color: var(--secondary);
  background: var(--primary-soft);
}
.cat-tab.active {
  background: var(--secondary);
  border-color: var(--secondary);
  color: var(--primary);
}

/* ============================================================
   4. SQUARE GRID — 1:1 cards
   ------------------------------------------------------------
   Responsive: auto-fill columns of min 240px wide.
   - Desktop:  4-5 cards per row
   - Tablet:   3 cards per row
   - Mobile:   2 cards per row
============================================================ */
.g-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
}

/* ============================================================
   5. CARD STYLES
============================================================ */
.g-card {
  cursor: pointer;
  border-radius: 16px;
  overflow: visible;
  transition: transform 0.32s var(--ease-out);
  outline: none;
}
.g-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Image container — 1:1 square with hover zoom */
.g-card-img {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--primary-soft);
  box-shadow: 0 4px 14px -8px rgba(0, 50, 98, 0.18);
  transition: box-shadow 0.32s var(--ease);
}
.g-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.55s var(--ease-out);
}

/* Subtle hover zoom on image (image scales, frame stays still) */
.g-card:hover .g-card-img img {
  transform: scale(1.08);
}
.g-card:hover .g-card-img {
  box-shadow: 0 20px 40px -22px rgba(0, 50, 98, 0.35);
}

/* Subtle dark overlay + zoom icon on hover */
.g-card-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 50, 98, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.32s var(--ease);
  pointer-events: none;
}
.g-card:hover .g-card-img::after {
  opacity: 1;
}

/* Zoom icon overlay (bottom-right) */
.g-card-zoom {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--secondary);
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(8px) scale(0.85);
  transition: all 0.32s var(--ease-out);
  pointer-events: none;
}
.g-card-zoom svg {
  width: 16px;
  height: 16px;
}
.g-card:hover .g-card-zoom {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Body below image */
.g-card-body {
  padding: 14px 4px 0;
}

.g-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* Category tag — uses brand colors */
.g-card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--secondary);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: all 0.24s var(--ease);
}
.g-card-tag::before {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
}
.g-card:hover .g-card-tag {
  background: var(--accent);
  color: var(--secondary);
}
.g-card:hover .g-card-tag::before {
  background: var(--secondary);
}

.g-card-date {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
}

.g-card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Error state — when image fails to load */
.g-card-img.error {
  background: var(--primary-soft);
}
.g-card-img.error img {
  display: none;
}
.g-card-img.error::before {
  content: '🖼';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 32px;
  opacity: 0.3;
}

/* ============================================================
   LOADING + EMPTY STATES (kept from before)
============================================================ */
.journal-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  text-align: center;
}
.journal-loading p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-mute);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: gallerySpin 0.8s linear infinite;
}
@keyframes gallerySpin {
  to { transform: rotate(360deg); }
}
.journal-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
}
.journal-empty h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 8px;
}
.journal-empty p {
  font-size: 14px;
  color: var(--ink-mute);
  margin: 0;
}
.journal-empty code {
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}

/* ============================================================
   6. LIGHTBOX — full-size image popup
============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(60px, 7vw, 80px) clamp(16px, 4vw, 60px) clamp(20px, 3vw, 40px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lightbox.open {
  display: flex;
  opacity: 1;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 16, 36, 0.94);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}

/* Top bar with count + close */
.lightbox-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 18px clamp(16px, 3vw, 32px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 3;
}
.lightbox-count {
  color: rgba(240, 248, 255, 0.7);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lightbox-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(240, 248, 255, 0.08);
  border: 1px solid rgba(240, 248, 255, 0.15);
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.24s var(--ease);
}
.lightbox-close:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--secondary);
  transform: rotate(90deg);
}
.lightbox-close svg {
  width: 20px;
  height: 20px;
}

/* Prev / Next arrows */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(240, 248, 255, 0.08);
  border: 1px solid rgba(240, 248, 255, 0.15);
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  transition: all 0.24s var(--ease);
}
.lightbox-prev { left: clamp(12px, 2vw, 32px); }
.lightbox-next { right: clamp(12px, 2vw, 32px); }
.lightbox-nav:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--secondary);
}
.lightbox-nav svg {
  width: 22px;
  height: 22px;
}

/* The figure containing image + caption */
.lightbox-frame {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 1100px;
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;

  /* Slight entrance animation */
  animation: lbEnter 0.36s var(--ease-out);
}
@keyframes lbEnter {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.lightbox-frame img {
  max-width: 100%;
  /* min-height: 0 lets the image shrink below its natural height when caption takes space */
  min-height: 0;
  /* flex-shrink lets the image absorb any height pressure from the caption */
  flex: 0 1 auto;
  max-height: 58vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  background: var(--secondary-deep);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
}

/* Caption stays at its natural height, never shrinks */
.lightbox-info {
  text-align: center;
  max-width: 720px;
  padding: 0 20px;
  flex-shrink: 0;
}
.lightbox-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--secondary);
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.lightbox-info h3 {
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--primary);
  margin: 0 0 8px;
}
.lightbox-date {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 248, 255, 0.6);
  font-weight: 600;
  margin: 0 0 12px;
}
.lightbox-desc {
  font-size: 14.5px;
  line-height: 1.6;
  color: rgba(240, 248, 255, 0.82);
  margin: 0;
  max-width: 560px;
  margin: 0 auto;
}

/* Body scroll lock while lightbox is open */
body.lightbox-open {
  overflow: hidden;
}

/* ============================================================
   7. RESPONSIVE
============================================================ */
@media (max-width: 880px) {
  .gm-grid { grid-template-columns: 1fr; }
  .gm-list { grid-template-columns: 1fr; }
  .g-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
  }
  .lightbox-frame img { max-height: 50vh; }
  .lightbox-nav { width: 44px; height: 44px; }
}

@media (max-width: 540px) {
  .g-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .g-card-img { border-radius: 12px; }
  .g-card-title { font-size: 13.5px; }
  .g-card-tag { font-size: 9.5px; padding: 4px 10px; }
  .g-card-zoom { width: 32px; height: 32px; bottom: 8px; right: 8px; }
  .g-card-zoom svg { width: 14px; height: 14px; }

  .lightbox { padding: 56px 12px 16px; }
  .lightbox-frame { gap: 12px; }
  .lightbox-frame img { max-height: 42vh; }
  .lightbox-info { padding: 0 8px; }
  .lightbox-info h3 { font-size: 17px; }
  .lightbox-desc { font-size: 13px; }
  /* On phones, move nav arrows to bottom corners so they don't overlap the image */
  .lightbox-nav {
    bottom: 12px;
    top: auto;
    transform: none;
    width: 40px;
    height: 40px;
  }
  .lightbox-prev { left: 16px; }
  .lightbox-next { right: 16px; left: auto; }
}