/* ============================================================
   LIGHTBOX
   Overlay modal for artwork cards on category/work pages.
   Uses existing design tokens from main.css.
   ============================================================ */

/* ── Container (full-screen fixed layer) ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.lightbox.is-open {
  visibility: visible;
  opacity: 1;
}

/* ── Backdrop ── */
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 11, 7, 0.88);
  cursor: pointer;
}

/* ── Panel — image fills the frame, thin info bar docked at bottom ── */
.lightbox__panel {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  width: 100%;
  max-width: 96vw;
  max-height: 94vh;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  transform: translateY(8px);
  transition: transform var(--transition-base);
}

.lightbox.is-open .lightbox__panel {
  transform: translateY(0);
}

/* ── Close button ── */
.lightbox__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(250, 248, 244, 0.9);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.lightbox__close:hover,
.lightbox__close:focus-visible {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  outline: none;
}

/* ── Prev / Next buttons ── */
.lightbox__prev,
.lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(250, 248, 244, 0.9);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.lightbox__prev { left: var(--space-3); }
.lightbox__next { right: var(--space-3); }

.lightbox__prev:hover,
.lightbox__prev:focus-visible,
.lightbox__next:hover,
.lightbox__next:focus-visible {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  outline: none;
}

.lightbox__prev[hidden],
.lightbox__next[hidden] {
  display: none;
}

/* ── Image area — fills the grid's 1fr row ── */
.lightbox__image-wrap {
  position: relative;
  background: var(--color-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 200px;
}

.lightbox__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 100%;
  transition: opacity var(--transition-fast);
}

.lightbox__img.is-loading {
  opacity: 0.4;
}

/* Loading shimmer */
.lightbox__img-loading {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--color-surface-alt) 0%,
    var(--color-surface) 50%,
    var(--color-surface-alt) 100%
  );
  background-size: 200% 100%;
  animation: lightbox-shimmer 1.4s ease infinite;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.lightbox__img-loading.is-active {
  opacity: 1;
}

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

/* ── Info bar — thin horizontal strip at the bottom ── */
.lightbox__info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-6);
  overflow-y: hidden;
  overflow-x: auto;
  flex-wrap: nowrap;
  flex-shrink: 0;
  border-top: 1px solid var(--color-border-light);
}

.lightbox__title {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-heading);
  line-height: var(--leading-tight);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}

/* ── Specs (dl) ── */
.lightbox__specs {
  display: flex;
  flex-direction: row;
  gap: var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.lightbox__specs dt {
  display: inline;
  color: var(--color-text-muted);
  font-weight: 400;
}

.lightbox__specs dd {
  display: inline;
  color: var(--color-text);
  margin: 0;
}

.lightbox__specs .spec-row {
  display: flex;
  gap: var(--space-1);
}

/* ── Description — hidden in the desktop bar (too long for one line) ── */
.lightbox__description {
  display: none;
}

/* ── Actions ── */
.lightbox__actions {
  display: flex;
  flex-direction: row;
  gap: var(--space-2);
  margin-left: auto;
  flex-shrink: 0;
}

.lightbox__inquire[hidden] {
  display: none;
}

/* ── Drag handle (mobile only) ── */
.lightbox__handle {
  display: none;
}

/* ── Swipe drag: disable panel transition while finger is down ── */
.lightbox__panel.is-dragging {
  transition: none;
}

/* ── Rubber-band: brief shake when swiping at list boundary ── */
.lightbox__panel.is-rubber-band {
  animation: lightbox-rubber-band 0.4s ease;
}

@keyframes lightbox-rubber-band {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-14px); }
  45%  { transform: translateX(10px); }
  65%  { transform: translateX(-6px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/* ── Cinema mode ── */
.lightbox.is-cinema .lightbox__panel {
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  background: #000;
  grid-template-rows: 1fr;
}

.lightbox.is-cinema .lightbox__backdrop {
  background: #000;
}

.lightbox.is-cinema .lightbox__info {
  display: none;
}

.lightbox.is-cinema .lightbox__image-wrap {
  max-height: 100vh;
  background: #000;
}

.lightbox.is-cinema .lightbox__img {
  max-height: 100vh;
  cursor: zoom-out;
}

/* Chrome (close/prev/next) fades out in cinema mode but stays keyboard-accessible */
.lightbox.is-cinema .lightbox__close,
.lightbox.is-cinema .lightbox__prev,
.lightbox.is-cinema .lightbox__next {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.lightbox.is-cinema .lightbox__close:focus-visible,
.lightbox.is-cinema .lightbox__prev:focus-visible,
.lightbox.is-cinema .lightbox__next:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Tap-to-exit hint: fades in then out */
.lightbox.is-cinema .lightbox__image-wrap::after {
  content: 'Tap to exit full screen';
  position: absolute;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  padding: var(--space-2) var(--space-4);
  border-radius: 100px;
  pointer-events: none;
  animation: cinema-hint 2.4s ease forwards;
}

@keyframes cinema-hint {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Responsive: bottom-sheet on mobile ── */
@media (max-width: 700px) {
  .lightbox {
    padding: 0;
    align-items: flex-end;
  }

  .lightbox__panel {
    grid-template-rows: auto auto 1fr;
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* Drag handle pill */
  .lightbox__handle {
    display: block;
    grid-column: 1 / -1;
    width: 36px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: var(--space-3) auto 0;
    pointer-events: none;
  }

  /* Image: fixed portion of the sheet */
  .lightbox__image-wrap {
    max-height: 50vw;
    min-height: 200px;
  }

  .lightbox__img {
    max-height: 50vw;
  }

  /* Info: restore vertical card layout */
  .lightbox__info {
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    overflow-y: auto;
    overflow-x: hidden;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-5) var(--space-8);
    border-top: 1px solid var(--color-border-light);
  }

  .lightbox__title {
    font-size: var(--text-xl);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    min-width: auto;
    flex-shrink: 1;
  }

  .lightbox__specs {
    flex-direction: column;
    gap: var(--space-2);
    white-space: normal;
  }

  /* Show description on mobile */
  .lightbox__description {
    display: block;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: var(--leading-normal);
    margin: 0;
  }

  .lightbox__description:empty {
    display: none;
  }

  .lightbox__actions {
    flex-direction: column;
    gap: var(--space-3);
    margin-left: 0;
    width: 100%;
  }

  .lightbox__prev { left: var(--space-2); }
  .lightbox__next { right: var(--space-2); }
}
