/* ==========================================================================
   Atelier photo — présentation musée + maintenance médias
   Inspiré des portfolios photographes (pleine image, typo fluide, air).
   ========================================================================== */

html {
  hanging-punctuation: first last;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, video {
  max-width: 100%;
  height: auto;
}

/* ── Typo fluide ────────────────────────────────────────────────────────── */
body:not(.edit-mode) h1,
body:not(.edit-mode) .el-text-inner h1 {
  font-weight: 300;
  letter-spacing: 0.08em;
  line-height: 1.12;
}

body:not(.edit-mode) .gallery-block-title {
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ── Galerie publique : rythme + hover ciné ─────────────────────────────── */
.gallery-grid-layout,
.gallery-masonry-layout,
.gallery-portfolio-layout,
.gallery-justified-layout {
  gap: clamp(6px, 1vw, 18px) !important;
}

.gallery-item {
  isolation: isolate;
  background: #0a0a0a;
}

body:not(.edit-mode) .gallery-item img,
body:not(.edit-mode) .gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.01);
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), filter 0.45s ease;
}

body:not(.edit-mode) .gallery-item:hover img,
body:not(.edit-mode) .gallery-item:hover video {
  transform: scale(1.02);
  filter: contrast(1.02);
}

body:not(.edit-mode) .gallery-item-overlay {
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.62));
  opacity: 0;
  transition: opacity 0.35s ease;
}

body:not(.edit-mode) .gallery-item:hover .gallery-item-overlay,
body:not(.edit-mode) .gallery-item:focus-within .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-caption {
  font-family: var(--page-font-heading, var(--font-heading, Georgia, serif));
  font-weight: 400;
  font-size: clamp(0.8rem, 1.4vw, 1rem);
  letter-spacing: 0.04em;
}

/* ── Portails accueil : hauteur fluide ──────────────────────────────────── */
.ip-portals {
  min-height: min(88svh, 920px);
}

.ip-portal__title {
  font-weight: 300;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ── Lightbox : fond musée ──────────────────────────────────────────────── */
#lightbox:not(.hidden) {
  background: rgba(4, 4, 4, 0.94);
}

#lb-content img,
#lb-content video {
  max-height: min(86svh, 100dvh);
  max-width: min(96vw, 100%);
  object-fit: contain;
}

/* ── Médiathèque : zone d’import ────────────────────────────────────────── */
.upload-zone {
  border-style: dashed;
  border-width: 1.5px;
  padding: clamp(28px, 4vw, 48px) 20px;
  cursor: copy;
}

.upload-zone.drag-over {
  border-color: var(--color-accent, #c9a96e);
  box-shadow: inset 0 0 0 1px var(--color-accent, #c9a96e);
  transform: scale(1.01);
}

#modal-media.file-drag .modal-box {
  outline: 2px dashed var(--color-accent, #c9a96e);
  outline-offset: -8px;
}

.upload-queue {
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-text-muted, #888);
  text-align: left;
  max-height: 120px;
  overflow: auto;
}

.upload-queue li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Grille galerie admin : DnD ─────────────────────────────────────────── */
.gallery-media-grid.file-drop {
  outline: 2px dashed var(--color-accent, #c9a96e);
  outline-offset: 6px;
  background: rgba(var(--color-accent-rgb, 201, 169, 110), 0.06);
}

.gm-item {
  position: relative;
  touch-action: none;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0 4px;
}

.btn-upload-folder {
  opacity: 0.92;
}

.canvas-element {
  touch-action: none;
}

body:not(.edit-mode) #site-header,
body:not(.edit-mode) .site-header {
  backdrop-filter: saturate(1.2) blur(12px);
}

body:not(.edit-mode) .site-nav a {
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  text-transform: uppercase;
}

body:not(.edit-mode) .contact-form {
  max-width: min(640px, 100%);
}

body:not(.edit-mode) .contact-form-group input,
body:not(.edit-mode) .contact-form-group textarea,
body:not(.edit-mode) .contact-form-group select {
  border-radius: 0;
  background: transparent;
}

.gm-item.drop-before::before,
.gm-item.drop-after::after {
  content: '';
  position: absolute;
  top: 6%;
  bottom: 6%;
  width: 3px;
  background: var(--color-accent, #c9a96e);
  z-index: 4;
  border-radius: 2px;
}

.gm-item.drop-before::before { left: -5px; }
.gm-item.drop-after::after { right: -5px; }

.gm-item-tools {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: flex;
  gap: 4px;
  z-index: 3;
}

.gm-item-tools button {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
}

.gm-empty {
  grid-column: 1 / -1;
  padding: 2.5rem 1rem;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.9rem;
}

/* ── Barre admin ────────────────────────────────────────────────────────── */
body.edit-mode #admin-bar {
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}

/* ── Responsive global ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .ip-portals { min-height: auto; }
}

@media (max-width: 768px) {
  body:not(.edit-mode) .gallery-filter-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 8px;
    scrollbar-width: thin;
  }

  body:not(.edit-mode) .gallery-filter-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .gallery-media-grid,
  .dnd-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  }

  body:not(.edit-mode) .site-nav,
  body:not(.edit-mode) header.site-header {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  #page-canvas {
    overflow-x: clip;
  }

  .modal-box.modal-large,
  .modal-box {
    width: min(100vw, 100%);
    max-height: 100dvh;
    border-radius: 0;
  }
}

@media (max-width: 480px) {
  body:not(.edit-mode) .gallery-item-overlay {
    opacity: 1;
    background: linear-gradient(transparent 55%, rgba(0, 0, 0, 0.5));
  }
}

@media (hover: none) {
  body:not(.edit-mode) .gallery-item img,
  body:not(.edit-mode) .gallery-item video {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.edit-mode) .gallery-item img,
  body:not(.edit-mode) .gallery-item video,
  .ip-portal__bg {
    transition: none;
    animation: none;
    transform: none !important;
  }
}
