/* =========================================================
 * Fichier: /assets/pages/galerie-std/galerie-std-detail.css
 * ========================================================= */

/* =========================================================
 * PARTIE 1: GLOBALS (Variables :root requises)
 * ========================================================= */
@import 'https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800&display=swap';
:root {
  --accent: #FF6233;
  --accent-ink: #f7f6f5;
  --bg: #fff;
  --text: #222;
  --muted: #777;
  --surface: #fff;
  --surface-2: #f1f2f4;
  --shadow: rgb(0 0 0 / 12%);
  --border: rgb(0 0 0 / 8%);
  --stroke: var(--border);
  --font-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", roboto, arial, sans-serif;
  --radius: 12px;
}
:root[data-theme="dark"] {
  --bg: #101114;
  --text: #ececec;
  --muted: #b7b7b7;
  --surface: #14161a;
  --surface-2: #1a1c20;
  --shadow: rgb(0 0 0 / 35%);
  --border: rgb(255 255 255 / 12%);
  --stroke: var(--border);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114;
    --text: #ececec;
    --muted: #b7b7b7;
    --surface: #14161a;
    --surface-2: #1a1c20;
    --shadow: rgb(0 0 0 / 35%);
    --border: rgb(255 255 255 / 12%);
    --stroke: var(--border);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  margin: 0;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}
img, video { max-width: 100%; height: auto; display: block; }
figure { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2 { font-weight: 800; margin: 0; }
p { margin: 0; }

/* =========================================================
 * PARTIE 2: LAYOUT DE LA PAGE
 * ========================================================= */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}
.empty-gallery {
  text-align: center;
  padding: 3rem 1rem;
  font-style: italic;
  color: var(--muted);
}
.galerie-detail-h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  color: var(--text);
  margin: 2rem 0 1rem;
  border-bottom: 2px solid var(--stroke);
  padding-bottom: 0.5rem;
}

/* =========================================================
 * PARTIE 3: GRILLE DES MÉDIAS
 * ========================================================= */
.galerie-detail-grid {
  display: grid;
  gap: 16px;
}
.landscape-grid,
.video-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.portrait-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.item {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
}
.item figure { width: 100%; height: 100%; }
.item img,
.item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.item img { cursor: zoom-in; }
.item figcaption {
  padding: .5rem .75rem;
  color: var(--muted);
  font-size: .9rem;
  background: var(--surface);
  border-top: 1px solid var(--stroke);
}

/* =========================================================
 * PARTIE 4: LIGHTBOX & TOAST (MIS À JOUR)
 * ========================================================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lightbox[hidden] {
  display: grid;
}
.lightbox:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-content img {
  /* CORRIGÉ: S'assure que l'image tient dans l'écran */
  max-width: 90vw;
  max-height: 85vh; /* Laisse de la place pour la légende */
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  color: #333;
  border: none;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 1002;
}
.lightbox-close:hover { background: #eee; }

/* NOUVEAU: Styles pour les flèches */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(30, 30, 30, 0.5);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 1001;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}
.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.7);
}
.lightbox-nav.prev { left: 1rem; }
.lightbox-nav.next { right: 1rem; }

/* NOUVEAU: Style pour la légende */
#lightbox-caption {
  width: 100%;
  max-width: 70vw;
  text-align: center;
  color: white;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.75rem;
  border-radius: 0 0 4px 4px;
  font-size: 0.9rem;
  margin-top: -4px; /* Colle au bas de l'image */
  opacity: 0.8;
  transition: opacity 0.2s;
}
/* Cache si vide */
#lightbox-caption:empty {
  display: none;
}
.lightbox-content:hover #lightbox-caption {
  opacity: 1;
}


@media (max-width: 768px) {
  .lightbox { display: none; }
  .galerie-detail-grid .item img { cursor: default; }
}

/* TOAST */
.protection-toast {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 1001;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  transition: bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.protection-toast.is-visible {
  bottom: 20px;
}