/* ==========================================================================
   Flickr-Style Lightbox — flickr-lightbox.css
   ========================================================================== */

/* ---- Overlay ---- */
#flb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #0d0d0d;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#flb-overlay.is-open {
  display: flex;
}

/* ---- Barra superiore ---- */
#flb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #111;
  flex-shrink: 0;
  min-height: 48px;
}

#flb-topbar-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 80px);
}

#flb-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

#flb-close:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}

#flb-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ---- Area principale (immagine + pannello info) ---- */
#flb-main {
  display: flex;
  flex: 1 1 auto;
  overflow: hidden;
}

/* ---- Stage foto ---- */
#flb-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  overflow: hidden;
}

#flb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.25s ease;
}

#flb-stage img.is-loading {
  opacity: 0;
}

/* Spinner */
#flb-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#flb-spinner.is-visible {
  opacity: 1;
}

#flb-spinner::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: flb-spin 0.7s linear infinite;
}

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

/* Frecce navigazione */
.flb-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.55);
  border: none;
  color: #fff;
  cursor: pointer;
  width: 44px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
  z-index: 2;
  padding: 0;
}

.flb-nav-btn:hover {
  background: rgba(0,0,0,.85);
}

.flb-nav-btn.is-hidden {
  display: none;
}

.flb-nav-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#flb-prev { left: 12px; }
#flb-next { right: 12px; }

/* ---- Pannello informazioni (lato destro su desktop) ---- */
#flb-panel {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid #e0e0e0;
}

/* ---- Titolo / Didascalia nel pannello ---- */
#flb-panel-caption {
  padding: 16px 20px 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 14px;
}

#flb-panel-caption h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: #111;
  line-height: 1.3;
}

#flb-panel-caption p {
  margin: 0;
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}

/* ---- Statistiche date ---- */
#flb-panel-stats {
  padding: 14px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flb-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #666;
}

.flb-stat-row strong {
  color: #333;
  font-weight: 600;
}

/* ---- Sezione EXIF ---- */
#flb-panel-exif {
  padding: 14px 20px 20px;
  flex: 1;
}

#flb-panel-exif h4 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  font-weight: 700;
}

.flb-exif-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 8px;
}

.flb-exif-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.flb-exif-item.flb-exif-full {
  grid-column: 1 / -1;
}

.flb-exif-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  font-weight: 600;
}

.flb-exif-value {
  font-size: 13px;
  color: #222;
  font-weight: 500;
}

.flb-exif-icon {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flb-exif-icon svg {
  width: 14px;
  height: 14px;
  fill: #aaa;
  flex-shrink: 0;
}

.flb-no-exif {
  font-size: 13px;
  color: #aaa;
  font-style: italic;
}

/* ---- Striscia thumbnail ---- */
#flb-thumbstrip-wrap {
  background: #111;
  flex-shrink: 0;
  padding: 8px 0;
  border-top: 1px solid #222;
}

#flb-thumbstrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

#flb-thumbstrip::-webkit-scrollbar {
  height: 4px;
}

#flb-thumbstrip::-webkit-scrollbar-track {
  background: transparent;
}

#flb-thumbstrip::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 2px;
}

.flb-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.15s, opacity 0.15s;
  opacity: 0.65;
}

.flb-thumb:hover {
  opacity: 1;
  border-color: rgba(255,255,255,.5);
}

.flb-thumb.is-active {
  border-color: #fff;
  opacity: 1;
}

.flb-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Contatore foto ---- */
#flb-counter {
  color: #aaa;
  font-size: 12px;
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive — sotto 768px il pannello va in basso
   ========================================================================== */
@media (max-width: 767px) {
  #flb-main {
    flex-direction: column;
  }

  #flb-stage {
    min-height: 50vh;
  }

  #flb-panel {
    width: 100%;
    max-height: 45vh;
    border-left: none;
    border-top: 1px solid #e0e0e0;
  }

  .flb-nav-btn {
    width: 36px;
    height: 52px;
  }

  #flb-prev { left: 4px; }
  #flb-next { right: 4px; }
}

/* ==========================================================================
   Sezione mappa GPS (Leaflet)
   ========================================================================== */

#flb-panel-map {
  border-top: 1px solid #eee;
  padding: 14px 20px 20px;
  display: none; /* mostrata via JS solo se ci sono coordinate */
}

.flb-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.flb-map-extlink {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #2271b1;
  text-decoration: none;
  font-weight: 500;
}

.flb-map-extlink:hover {
  text-decoration: underline;
}

.flb-map-extlink svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.flb-map-coords {
  font-size: 11px;
  color: #888;
  margin-bottom: 8px;
  font-family: monospace;
}

#flb-leaflet-map {
  width: 100%;
  height: 180px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #ddd;
}

/* Marker personalizzato */
.flb-map-marker {
  background: none !important;
  border: none !important;
}

.flb-map-marker svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35));
}

/* Fix Leaflet z-index dentro il nostro overlay */
#flb-overlay .leaflet-pane,
#flb-overlay .leaflet-top,
#flb-overlay .leaflet-bottom {
  z-index: 1 !important;
}

#flb-overlay .leaflet-control-zoom {
  z-index: 2 !important;
}

@media (max-width: 767px) {
  #flb-leaflet-map {
    height: 140px;
  }
}
