/* =========================================================
   GALLERY.CSS — CODABYTE Portfolio Gallery (v2)
   Requires style.css for CSS vars & base
   ========================================================= */

/* ── Shell ──────────────────────────────────────────────── */
.gallery-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 120px var(--pad, 40px) 120px;
}

/* ── Page header ─────────────────────────────────────────── */
.gallery-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 48px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--line);
}

.gallery-header-left { min-width: 0; }

.gallery-eyebrow {
  font-family: var(--f-mono);
  font-size: .56rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--blue-hi);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.gallery-eyebrow::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--blue);
  flex-shrink: 0;
}

.gallery-title {
  font-family: var(--f-display);
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: .92;
  color: var(--ink);
}

.gallery-title em {
  font-family: var(--f-body);
  font-style: italic;
  font-weight: 300;
  color: var(--blue-hi);
}

.gallery-sub {
  margin-top: 20px;
  font-size: .95rem;
  color: var(--ink-mid);
  font-weight: 300;
  max-width: 46ch;
}

/* Header right — meta stack */
.gallery-meta-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: .56rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
}

.gallery-meta-stack .row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-meta-stack .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 10px var(--blue);
}

.gallery-meta-stack .num {
  color: var(--blue-hi);
  font-size: 1.4rem;
  letter-spacing: -.02em;
  font-family: var(--f-display);
  font-weight: 500;
  text-transform: none;
}

/* ── Filter bar (sticky) ─────────────────────────────────── */
.gallery-filters-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 calc(var(--pad, 40px) * -1) 36px;
  padding: 14px var(--pad, 40px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-mid);
  padding: 8px 16px;
  font-family: var(--f-mono);
  font-size: .56rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.filter-btn:hover {
  border-color: var(--blue-dim);
  color: var(--ink);
}

.filter-btn.active {
  border-color: var(--blue);
  color: var(--bg);
  background: var(--blue-hi);
}

.filter-btn.active .filter-count { color: var(--bg); opacity: .7; }

.filter-count {
  opacity: .5;
  font-size: .5rem;
}

/* ── Bento grid ──────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: 200px;
  grid-auto-flow: dense;
  gap: 14px;
}

/* Default card: tall (1×2) */
.gallery-card { grid-row: span 2; }

/* Variation classes (assigned via JS by index) */
.gallery-card.span-wide   { grid-column: span 2; grid-row: span 2; }
.gallery-card.span-tall   { grid-row: span 3; }
.gallery-card.span-large  { grid-column: span 2; grid-row: span 3; }
.gallery-card.span-square { grid-row: span 2; }

/* Featured always gets the biggest treatment */
.gallery-card.is-featured { grid-column: span 2; grid-row: span 3; }

@media (max-width: 1100px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); grid-auto-rows: 180px; }
}

@media (max-width: 720px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 170px; gap: 10px; }
  .gallery-card.span-wide,
  .gallery-card.span-large,
  .gallery-card.is-featured { grid-column: span 2; grid-row: span 2; }
  .gallery-card.span-tall { grid-row: span 2; }
}

@media (max-width: 420px) {
  .gallery-grid { grid-template-columns: 1fr; grid-auto-rows: 280px; }
  .gallery-card,
  .gallery-card.span-wide,
  .gallery-card.span-tall,
  .gallery-card.span-large,
  .gallery-card.is-featured { grid-column: span 1; grid-row: span 1; }
}

/* ── Gallery card ─────────────────────────────────────────── */
.gallery-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-1);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color .35s var(--ease), transform .35s var(--ease), box-shadow .35s var(--ease);
  animation: gcardIn .6s cubic-bezier(.25,.46,.45,.94) both;
  isolation: isolate;
}

@keyframes gcardIn {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.gallery-card:hover {
  border-color: var(--blue-dim);
  box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 1px var(--blue-glow);
  z-index: 2;
}

/* Card index number (top-right) */
.gc-index {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 5;
  font-family: var(--f-mono);
  font-size: .5rem;
  letter-spacing: .14em;
  color: rgba(216,224,246,.35);
  pointer-events: none;
  mix-blend-mode: difference;
}

/* Image wrapper */
.gc-img-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  line-height: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--bg-2);
}

/* Skeleton shimmer until image loads */
.gc-img-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, var(--bg-1) 30%, var(--bg-3) 50%, var(--bg-1) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  z-index: 1;
  transition: opacity .4s;
}

.gc-img-wrap.loaded::before { opacity: 0; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.gc-img-wrap::after {
  /* right-click shield */
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background: transparent;
}

.gc-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 2;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
  opacity: 0;
  transform: scale(1.02);
  transition: transform .8s cubic-bezier(.25,.46,.45,.94),
              filter .4s,
              opacity .5s;
}

.gc-img-wrap.loaded img { opacity: 1; transform: scale(1); }

.gallery-card:hover .gc-img-wrap img {
  transform: scale(1.07);
  filter: brightness(.7) saturate(1.1);
}

/* Hover overlay */
.gc-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px 18px 16px;
  background: linear-gradient(to top,
    rgba(6,7,16,.92) 0%,
    rgba(6,7,16,.55) 38%,
    transparent 70%);
  opacity: 0;
  transition: opacity .35s var(--ease);
  pointer-events: none;
}

.gallery-card:hover .gc-overlay { opacity: 1; }

.gc-category {
  font-family: var(--f-mono);
  font-size: .5rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--blue-hi);
  margin-bottom: 6px;
  transform: translateY(8px);
  transition: transform .4s var(--ease) .05s;
}

.gc-title {
  font-family: var(--f-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: #fff;
  line-height: 1.15;
  letter-spacing: -.01em;
  transform: translateY(8px);
  transition: transform .4s var(--ease) .1s;
}

.gc-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 10px;
  transform: translateY(8px);
  transition: transform .4s var(--ease) .15s;
}

.gc-date {
  font-family: var(--f-mono);
  font-size: .5rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.42);
}

.gc-view {
  width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  transition: background .25s, border-color .25s;
}

.gallery-card:hover .gc-view { background: var(--blue); border-color: var(--blue); }

.gallery-card:hover .gc-category,
.gallery-card:hover .gc-title,
.gallery-card:hover .gc-bottom { transform: translateY(0); }

/* Featured tag */
.gallery-card.is-featured .gc-featured-tag {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 5;
  font-family: var(--f-mono);
  font-size: .48rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  background: var(--blue);
  color: var(--bg);
  padding: 4px 9px;
  font-weight: 500;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gallery-card.is-featured .gc-featured-tag::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--bg);
  animation: featPulse 1.8s infinite;
}

@keyframes featPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* ── Loader / empty ──────────────────────────────────────── */
.gallery-loader {
  grid-column: 1 / -1;
  padding: 80px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.gallery-loader-dots { display: flex; gap: 5px; }

.gld {
  width: 5px; height: 5px;
  background: var(--blue);
  border-radius: 50%;
  animation: gPulse 1.4s infinite ease-in-out;
}
.gld:nth-child(2) { animation-delay: .2s; }
.gld:nth-child(3) { animation-delay: .4s; }

@keyframes gPulse {
  0%, 80%, 100% { transform: scale(.4); opacity: .25; }
  40%           { transform: scale(1);  opacity: 1;   }
}

.gallery-loader-text,
.gallery-empty {
  font-family: var(--f-mono);
  font-size: .6rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 100px 20px;
}

/* ── Lightbox ─────────────────────────────────────────────── */
#galleryLightbox {
  position: fixed;
  inset: 0;
  z-index: 9900;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s cubic-bezier(.25,.46,.45,.94);
}

#galleryLightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4,5,12,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
}

.lb-panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100%;
}

/* ── Image side ──────────────────────────────────────────── */
.lb-img-side {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 96px 64px;
  position: relative;
}

.lb-img-frame {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  animation: lbImgIn .5s cubic-bezier(.25,.46,.45,.94);
}

@keyframes lbImgIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

.lb-img-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  background: transparent;
}

.lb-img-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 144px);
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
  box-shadow: 0 30px 120px rgba(0,0,0,.7);
}

.lb-watermark {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 5;
  font-family: var(--f-mono);
  font-size: .46rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255,255,255,.18);
  pointer-events: none;
  user-select: none;
}

/* ── Info side ───────────────────────────────────────────── */
.lb-info-side {
  width: 400px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.lb-info-side::-webkit-scrollbar { width: 3px; }
.lb-info-side::-webkit-scrollbar-thumb { background: var(--line-2); }

.lb-info-inner {
  padding: 72px 36px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.lb-eyebrow {
  font-family: var(--f-mono);
  font-size: .54rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--blue-hi);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.lb-eyebrow::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--blue);
}

.lb-title {
  font-family: var(--f-display);
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 10px;
}

.lb-date {
  font-family: var(--f-mono);
  font-size: .55rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.lb-desc {
  font-size: .92rem;
  line-height: 1.75;
  color: var(--ink-mid);
  font-weight: 300;
  margin-bottom: 32px;
}

.lb-meta-head {
  font-family: var(--f-mono);
  font-size: .5rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-meta-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.lb-meta-table {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 32px;
  background: var(--line);
  border: 1px solid var(--line);
}

.lb-meta-row {
  display: flex;
  background: var(--bg-2);
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  transition: background .2s;
}
.lb-meta-row:hover { background: var(--bg-3); }

.lb-meta-key {
  font-family: var(--f-mono);
  font-size: .5rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  flex-shrink: 0;
}

.lb-meta-val {
  font-family: var(--f-mono);
  font-size: .6rem;
  color: var(--blue-hi);
  text-align: right;
}

.lb-nav-hint {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: .48rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
  line-height: 1.9;
}

/* ── Close button ────────────────────────────────────────── */
.lb-close-btn {
  position: absolute;
  top: 20px; right: 20px;
  z-index: 10;
  width: 42px; height: 42px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  color: var(--ink-mid);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
  border-radius: 50%;
}

.lb-close-btn:hover {
  border-color: var(--blue);
  color: var(--ink);
  background: var(--blue-glow-soft);
  transform: rotate(90deg);
}

/* ── Arrows — fixed positioning ──────────────────────────── */
.lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(11,13,26,.7);
  border: 1px solid var(--line-2);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .25s var(--ease);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lb-arrow svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-arrow:hover {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--bg);
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 0 30px var(--blue-glow);
}

.lb-arrow:active { transform: translateY(-50%) scale(.95); }

.lb-arrow-prev { left: 28px; }
.lb-arrow-next { right: 28px; }

.lb-counter {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--f-mono);
  font-size: .56rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(216,224,246,.45);
  pointer-events: none;
  padding: 6px 14px;
  border: 1px solid var(--line);
  background: rgba(11,13,26,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
}

.lb-counter strong {
  color: var(--blue-hi);
  font-weight: 400;
}

/* ── Mobile lightbox ──────────────────────────────────────── */
@media (max-width: 900px) {
  .lb-panel { flex-direction: column; }

  .lb-img-side {
    flex: 0 0 auto;
    max-height: 56vh;
    padding: 60px 14px 14px;
  }

  .lb-img-frame img { max-height: calc(56vh - 80px); }

  .lb-info-side {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    flex: 1;
  }

  .lb-info-inner { padding: 28px 22px 32px; }

  .lb-arrow { width: 42px; height: 42px; }
  .lb-arrow-prev { left: 10px; }
  .lb-arrow-next { right: 10px; }

  .lb-watermark { display: none; }

  .lb-counter { bottom: auto; top: 14px; }
}

@media (max-width: 700px) {
  .gallery-header {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .gallery-meta-stack { align-items: flex-start; }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .lb-img-frame,
  .gc-img-wrap img,
  .gc-overlay,
  .gc-category, .gc-title, .gc-bottom,
  .gc-img-wrap::before,
  .gc-featured-tag::before {
    animation: none !important;
    transition: none !important;
  }
}
