/* Reset and full-bleed canvas */
html {
  height: 100%;
  min-height: 100dvh;
  background-color: #000;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #000;
  color: #fff;
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  padding: 0;
  padding-bottom: max(100px, env(safe-area-inset-bottom));
}

html::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: env(safe-area-inset-bottom);
  pointer-events: none;
  z-index: 9999;
  background: #000;
}

#app {
  min-height: 100%;
}

/* Gallery container uses rows laid out by JS */
#gallery {
  display: block;
  width: 100vw;
  overflow: hidden;
  /* Optimisations pour le scroll sur mobile */
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
  contain: layout style paint;
}

.row {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
}

.tile {
  position: relative;
  flex: 0 0 auto;
  line-height: 0;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease, filter 180ms ease;
  will-change: transform;
  /* Optimisations pour le chargement des images */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tile:hover img {
  transform: scale(1.02);
  filter: brightness(1.02);
}

/* Lightbox */
#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Support pour les unités dynamiques viewport */
  background: #000; /* Fond noir opaque pour masquer complètement la mosaïque */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000; /* Z-index très élevé pour être au-dessus de tout */
  touch-action: pan-y;
  /* S'assurer que la lightbox couvre tout l'écran sur iOS */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#lightbox[aria-hidden="false"] { display: flex; }

#lightbox-track {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.lightbox-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  will-change: transform, opacity;
}

#lightbox-close {
  position: fixed;
  top: 8px;
  right: 12px;
  background: transparent;
  color: #fff;
  border: 0;
  font-size: 0; /* hide text glyph, use SVG */
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: #fff;
  border: 0;
  font-size: 0; /* hide text glyph, use SVG */
  width: 56px;
  height: 56px;
  border-radius: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

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

/* Ensure controls are above the image */
#lightbox-close, .lightbox-nav { z-index: 1101; }

/* Controls are text-only (no background), with subtle motion */
.glass-btn {
  background: transparent;
  box-shadow: none;
  transition: transform 160ms ease, opacity 200ms ease;
}
.glass-btn:focus { outline: none; }
.glass-btn:active { transform: translateY(1px); }
@media (hover: hover) and (pointer: fine) {
  /* Cross lifts more */
  #lightbox-close.glass-btn:hover { transform: translateY(-3px); }
  /* Preserve vertical centering while sliding horizontally */
  #lightbox-next.glass-btn:hover { transform: translateY(-50%) translateX(3px); }
  #lightbox-prev.glass-btn:hover { transform: translateY(-50%) translateX(-3px); }
}

/* Icon styling (thin, elegant strokes) */
.icon { width: 24px; height: 24px; display: block; }
.icon path {
  stroke: #fff;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Auto-hide controls */
/* Only hide controls, not the image */
#lightbox.controls-hidden .lightbox-nav,
#lightbox.controls-hidden #lightbox-close { opacity: 0; pointer-events: none; }

/* Floating badge top-left */
#badge {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.16);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}

#badge img { display: block; height: 22px; width: auto; }

/* Hide mouse cursor and controls on inactivity */
body.cursor-hidden { cursor: none; }

/* Hide badge when lightbox is open */
body.lightbox-open #badge { display: none; }

/* Hide arrows when explicitly requested */
#lightbox.no-arrows .lightbox-nav { display: none; }

/* Bottom-left credit badge in lightbox */
#lightbox-credit {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 1101;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.16);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
  color: #fff;
  font-size: 7px;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

/* Styles spécifiques pour iOS/Safari */
@supports (-webkit-touch-callout: none) {
  #lightbox {
    /* Forcer la lightbox à couvrir tout l'écran sur iOS */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: calc(100vh + env(safe-area-inset-top) + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #000 !important;
    z-index: 999999 !important;
  }
  
  /* Masquer complètement la galerie quand la lightbox est ouverte */
  body.lightbox-open #gallery {
    display: none !important;
  }
  
  /* S'assurer que le badge est masqué */
  body.lightbox-open #badge {
    display: none !important;
  }
}

/* Styles pour les écrans très petits (mobile) */
@media (max-width: 768px) {
  #lightbox {
    /* Sur mobile, s'assurer que la lightbox couvre tout l'écran */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: #000 !important;
    z-index: 999999 !important;
  }
  
  /* Masquer la galerie sur mobile quand la lightbox est ouverte */
  body.lightbox-open #gallery {
    display: none !important;
  }
  
  /* Optimisations de scroll pour mobile */
  body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  .tile img {
    /* Désactiver les transitions sur mobile pour de meilleures performances */
    transition: none;
  }
  
  .tile:hover img {
    /* Pas d'effet hover sur mobile */
    transform: none;
    filter: none;
  }
}

