/* ============================================================
   Hugon Veneer — Gallery
   Photo book grid, gallery cards, lightbox, filter tabs
   ============================================================ */

/* -----------------------------------------------
   Photo book / gallery grid
   ----------------------------------------------- */
.photo-book {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
@media (max-width: 1023px) { .photo-book { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .photo-book { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .photo-book { grid-template-columns: 1fr; } }

/* Masonry-ish rhythm: vary aspect ratio across cards */
.photo-book .gallery-card:nth-child(5n+1) { aspect-ratio: 4 / 3; }
.photo-book .gallery-card:nth-child(5n+2) { aspect-ratio: 3 / 4; }
.photo-book .gallery-card:nth-child(5n+3) { aspect-ratio: 1 / 1; }
.photo-book .gallery-card:nth-child(5n+4) { aspect-ratio: 4 / 3; }
.photo-book .gallery-card:nth-child(5n+5) { aspect-ratio: 4 / 5; }

/* -----------------------------------------------
   Gallery card
   ----------------------------------------------- */
.gallery-card {
  position: relative;
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-white);
  cursor: pointer;
  isolation: isolate;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow var(--t-base) var(--t-ease),
    transform var(--t-base) var(--t-ease);
}
.gallery-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.gallery-card__image-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Warm gradient placeholder for gallery image area */
.gallery-card__image-wrap .img-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    var(--color-bg-alt) 0%,
    var(--color-accent-soft) 50%,
    var(--color-bg-alt) 100%
  );
}

.gallery-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-5);
  background: linear-gradient(
    to top,
    rgba(26, 14, 8, 0.85) 0%,
    rgba(26, 14, 8, 0.30) 45%,
    transparent 75%
  );
  color: var(--color-white);
  opacity: 0;
  transition: opacity var(--t-base) var(--t-ease);
}
.gallery-card:hover .gallery-card__overlay { opacity: 1; }
.gallery-card:focus-within .gallery-card__overlay { opacity: 1; }

.gallery-card__eyebrow {
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--color-accent);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-2);
}

.gallery-card__title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--color-white);
  margin: 0 0 var(--space-2);
}

.gallery-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}
.gallery-card__meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* Status badge on card (top-right) */
.gallery-card__status {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 2;
}
.gallery-card__status .status-active,
.gallery-card__status .status-archived,
.gallery-card__status .status-sold {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* -----------------------------------------------
   Gallery filter tabs
   ----------------------------------------------- */
.gallery-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-8);
  align-items: center;
}

.gallery-filter__label {
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--color-muted);
  font-weight: var(--fw-semibold);
  margin-right: var(--space-3);
}

.gallery-filter__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  color: var(--color-text-soft);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  text-decoration: none;
  text-transform: none;
  transition:
    color var(--t-fast) var(--t-ease),
    background-color var(--t-fast) var(--t-ease),
    border-color var(--t-fast) var(--t-ease);
}
.gallery-filter__tab:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.gallery-filter__tab.is-active {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

.gallery-filter__count {
  font-size: var(--fs-xs);
  color: var(--color-muted);
  background: var(--color-bg-alt);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
}
.gallery-filter__tab.is-active .gallery-filter__count {
  background: rgba(255, 255, 255, 0.2);
  color: var(--color-white);
}

/* -----------------------------------------------
   Image placeholder / shimmer
   ----------------------------------------------- */
.img-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--color-bg-alt) 25%,
    var(--color-border) 50%,
    var(--color-bg-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  overflow: hidden;
}
.img-placeholder.is-loaded { animation: none; }

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

/* Aspect-ratio variants */
.img-placeholder--4-3  { aspect-ratio: 4 / 3; }
.img-placeholder--3-4  { aspect-ratio: 3 / 4; }
.img-placeholder--1-1  { aspect-ratio: 1 / 1; }
.img-placeholder--16-9 { aspect-ratio: 16 / 9; }
.img-placeholder--2-3  { aspect-ratio: 2 / 3; }

/* SVG icon inside placeholder */
.img-placeholder__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  stroke: rgba(255, 255, 255, 0.25);
  fill: none;
  stroke-width: 1.5;
}

/* -----------------------------------------------
   Lightbox
   ----------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--t-base) var(--t-ease),
    visibility 0s linear var(--t-base);
}
.lightbox.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--t-base) var(--t-ease), visibility 0s;
}
body.has-lightbox-open { overflow: hidden; }

.lightbox__container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1400px;
  max-height: 100%;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-6);
}
@media (max-width: 1023px) {
  .lightbox__container { grid-template-columns: 1fr; }
}

.lightbox__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.lightbox img,
.lightbox__image {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
}

.lightbox__caption {
  position: absolute;
  left: 50%;
  bottom: var(--space-3);
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-4);
  background: rgba(26, 14, 8, 0.7);
  color: var(--color-white);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.lightbox__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--color-white);
  border-radius: var(--radius-md);
  overflow-y: auto;
  align-self: start;
  max-height: 100%;
}
.lightbox__info h3 {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  color: var(--color-primary);
  margin: 0;
}
.lightbox__info .eyebrow { color: var(--color-secondary); }
.lightbox__info dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}
.lightbox__info dt {
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--color-muted);
  font-weight: var(--fw-semibold);
}
.lightbox__info dd {
  font-size: var(--fs-sm);
  color: var(--color-text);
  margin: 0;
}

/* Lightbox close & nav buttons */
.lightbox__close,
.lightbox__nav {
  position: absolute;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-white);
  color: var(--color-primary);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  transition:
    background-color var(--t-fast) var(--t-ease),
    transform var(--t-fast) var(--t-ease);
  z-index: 2;
}
.lightbox__close {
  top: var(--space-5);
  right: var(--space-5);
}
.lightbox__close:hover {
  background: var(--color-bg);
  transform: rotate(90deg);
}
.lightbox__nav--prev {
  left: var(--space-5);
  top: 50%;
  transform: translateY(-50%);
}
.lightbox__nav--next {
  right: 380px;
  top: 50%;
  transform: translateY(-50%);
}
@media (max-width: 1023px) {
  .lightbox__nav--next { right: var(--space-5); }
}
.lightbox__nav:hover {
  background: var(--color-bg);
  transform: translateY(-50%) scale(1.05);
}
.lightbox__nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: translateY(-50%) scale(1);
}
.lightbox__close svg,
.lightbox__nav svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Lightbox counter */
.lightbox__counter {
  position: absolute;
  top: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-4);
  background: rgba(26, 14, 8, 0.7);
  color: var(--color-white);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}

/* -----------------------------------------------
   Empty / loading states
   ----------------------------------------------- */
.gallery-empty {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-muted);
}
.gallery-empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--color-muted-light);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}
.gallery-empty h3 {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.gallery-empty p {
  font-size: var(--fs-sm);
  max-width: 40ch;
  margin: 0 auto;
}

.gallery-loading {
  text-align: center;
  padding: var(--space-12) 0;
  color: var(--color-muted);
}
.gallery-loading__spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-secondary);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-3);
  animation: gallery-spin 0.8s linear infinite;
}

@keyframes gallery-spin {
  to { transform: rotate(360deg); }
}
