/* =====================================================================
   Lightbox (shared)
   Folosit pe: / (homepage – preview portofoliu) si /portofoliu (galerie completa).
   HTML-ul live in <body> al fiecarei pagini; JS-ul live in homepage.js (sau
   portfolio.js, daca pagina il are). Stilurile aici acopera ambele.
   ===================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 100);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base, 0.18s ease);
}

.lightbox[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 11, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@media (max-width: 767px) {
  .lightbox-overlay {
    background: rgba(8, 14, 9, 0.94);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.lightbox-dialog {
  position: relative;
  width: min(1100px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  border-radius: var(--radius-xl, 16px);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(4, 99, 7, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lightbox-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md, 1rem);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(4, 99, 7, 0.12);
  background: rgba(255, 255, 255, 0.94);
  flex: 0 0 auto;
}

.lightbox-counter {
  font-weight: 700;
  color: var(--text-secondary, #5a4f3a);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

.lightbox-close {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1.5px solid rgba(4, 99, 7, 0.2);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary, #0a330d);
  font-size: 1.6rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-base, 0.18s ease),
              transform var(--transition-base, 0.18s ease);
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(4, 99, 7, 0.08);
  transform: scale(1.06);
  outline: none;
}

.lightbox-media {
  position: relative;
  background: #fff;
  display: grid;
  place-items: center;
  padding: var(--space-lg, 1.5rem);
  flex: 1 1 auto;
  touch-action: pan-y;
  min-height: 0;
}

.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(4, 99, 7, 0.18);
  background: rgba(255, 255, 255, 0.95);
  color: var(--accent, #046307);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(30, 42, 31, 0.16);
  cursor: pointer;
  transition: background var(--transition-base, 0.18s ease),
              transform var(--transition-base, 0.18s ease);
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  background: rgba(4, 99, 7, 0.08);
  outline: none;
  transform: translateY(-50%) scale(1.06);
}

.lightbox-prev { left: 0.75rem; }
.lightbox-next { right: 0.75rem; }

.lightbox-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base, 0.18s ease);
}

.lightbox.is-loading .lightbox-loading {
  opacity: 1;
}

.lightbox-spinner {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 3px solid rgba(4, 99, 7, 0.16);
  border-top-color: var(--accent, #046307);
  animation: lightbox-spin 0.9s linear infinite;
}

@keyframes lightbox-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-spinner { animation: none; }
  .lightbox { transition: none; }
}

/* Subtle bottom hint pill (auto-dismiss). */
.lightbox-hint {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%) translateY(8px);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.lightbox-hint.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* When the lightbox is open, lock body scroll. */
body.lightbox-open {
  overflow: hidden;
}

/* ---------------------------------------------------------------------
   Mobile presentation: full-bleed, dramatic, swipe-first.
   --------------------------------------------------------------------- */
@media (max-width: 767px) {
  .lightbox-dialog {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: 0;
    background: #0b110c;
    box-shadow: none;
  }

  .lightbox-topbar {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 4;
    padding: 0.75rem 0.9rem;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    border-bottom: 0;
  }

  .lightbox-counter {
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  }

  .lightbox-close {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.95);
    color: #0b2e0e;
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  }

  .lightbox-media {
    padding: 0;
    background: transparent;
  }

  .lightbox-img {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    border-radius: 0;
    box-shadow: none;
  }

  /* Pe ecran ingust ascundem sagetile — folosim swipe. */
  .lightbox-nav {
    display: none;
  }

  .lightbox-hint {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    bottom: 1.25rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}
