/* ==========================================================================
   COMPONENTS - Reusable UI elements
   ========================================================================== */

/* Sections */
.section {
  margin-bottom: var(--section-stack-space);
}

.section-intro {
  display: grid;
  gap: var(--gap);
}

.section-media {
  width: 100%;
  height: auto;
}

.section-content h1 {
  margin: 0 0 16px;
  letter-spacing: 0;
  font-size: var(--size-h1);
  line-height: 1;
  /* a long word never leaves the column: French hyphenation, else a break */
  overflow-wrap: break-word;
  hyphens: auto;
}

.section-content h2 {
  margin: 0 0 12px;
  letter-spacing: 0.08em;
  font-size: clamp(var(--heading-h2-min), 3vw, var(--heading-h2-max));
}

.section-content h3 {
  margin: 0 0 8px;
  letter-spacing: 0.04em;
  font-size: clamp(var(--heading-h3-min), 2.5vw, var(--heading-h3-max));
}

.section-text {
  font-size: var(--text-md);
  line-height: var(--line-height-body);
  max-width: var(--content-max-width);
}

.section-text p {
  margin: 0 0 1em;
}

.section-text p:last-child {
  margin-bottom: 0;
}

.section-subtitle {
  font-family: var(--font-ui);
  color: var(--muted);
  font-size: var(--text-base);
  letter-spacing: 0.04em;
}

@media (min-width: 960px) {
  .section-intro {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}

/* Hero */
.hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.hero-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(calc(100% - (var(--gap) * 2)), 42rem);
  padding: var(--hero-overlay-padding);
  background: rgba(15, 15, 15, 0.5);
}

.hero-content h1 {
  font-size: clamp(32px, 6vw, 72px);
  margin: 0;
}

/* Cards */
.card-list {
  display: grid;
  gap: 24px;
}

.card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--fg);
  overflow: hidden;
}

.card-media {
  width: 100%;
  height: 320px;
  object-fit: cover;
}

.card-overlay-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* Only a card with an image lays its text over it (a card without image keeps its text in flow) */
.card-overlay .card-overlay-content {
  position: absolute;
  inset: 0;
  justify-content: flex-end;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.7));
}

.card-year {
  font-size: 13px;
  color: var(--muted);
}

@media (min-width: 960px) {
  .card-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

/* Table */
.table-wrapper {
  overflow-x: auto;
}

.projets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.projets-table th,
.projets-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.projets-table th {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: normal;
}

.projets-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.projets-table a {
  color: var(--fg);
  text-decoration: none;
}

.projets-table a:hover {
  color: var(--accent);
}

.projets-table .type-projet-tournee {
  color: var(--accent);
}

.projets-table .type-projet-dediee {
  color: #7eb8da;
}

.projets-table .type-projet-lieux-communs {
  color: #a0d995;
}

/* ==========================================================================
   MANUAL GALLERY GRID - Shared project gallery rows
   ========================================================================== */

.dediee-gallery-section,
.plc-gallery-section,
.plc-add-gallery {
  --manual-gallery-gap: 8px;
  --manual-gallery-title-indent: 200px;
  --manual-gallery-item-padding: 0;
}

.dediee-gallery-section,
.plc-gallery-section {
  padding: 40px var(--gap);
}

.dediee-gallery-subtitle,
.plc-gallery-subtitle {
  position: relative;
  z-index: 2;
  margin-bottom: -16px;
}

.dediee-gallery-subtitle .tournee-creation-label,
.plc-gallery-subtitle .tournee-creation-label {
  display: inline-block;
  font-family: var(--font-title);
  font-size: clamp(25px, 2.35vw, 50px);
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 0.9;
  color: var(--fg);
  white-space: pre-line;
  max-width: 100%;
  word-break: break-word;
  padding-left: var(--manual-gallery-title-indent);
  text-indent: calc(-1 * var(--manual-gallery-title-indent));
}

.dediee-gallery-grid,
.plc-gallery-grid {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--manual-gallery-gap);
  width: 100%;
}

.dediee-gallery-row,
.plc-gallery-row {
  display: grid;
  gap: var(--manual-gallery-gap);
}

.dediee-gallery-row-1,
.plc-gallery-row-1 {
  grid-template-columns: minmax(0, 1fr);
}

.dediee-gallery-row-2,
.plc-gallery-row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dediee-gallery-row-3,
.plc-gallery-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dediee-gallery-row-4,
.plc-gallery-row-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dediee-gallery-row-5,
.plc-gallery-row-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.dediee-gallery-row-6,
.plc-gallery-row-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.dediee-gallery-item,
.plc-gallery-item {
  margin: 0;
  padding: var(--manual-gallery-item-padding);
}

.dediee-gallery-item img,
.plc-gallery-item img {
  width: 100%;
  aspect-ratio: 1.45 / 1;
  object-fit: cover;
}

@media (max-width: 959px) {
  .dediee-gallery-section,
  .plc-gallery-section,
  .plc-add-gallery {
    padding: 20px var(--gap);
  }

  .dediee-gallery-item,
  .plc-gallery-item {
    padding: 0;
  }

  .dediee-gallery-row-3,
  .dediee-gallery-row-4,
  .dediee-gallery-row-5,
  .dediee-gallery-row-6,
  .plc-gallery-row-3,
  .plc-gallery-row-4,
  .plc-gallery-row-5,
  .plc-gallery-row-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dediee-gallery-row-3 .dediee-gallery-item:last-child,
  .dediee-gallery-row-5 .dediee-gallery-item:last-child,
  .plc-gallery-row-3 .plc-gallery-item:last-child,
  .plc-gallery-row-5 .plc-gallery-item:last-child {
    grid-column: 1 / -1;
  }

  .dediee-gallery-subtitle .tournee-creation-label,
  .plc-gallery-subtitle .tournee-creation-label {
    font-size: clamp(28px, 8vw, 48px);
  }
}

@media (min-width: 960px) {
  .dediee-gallery-section,
  .plc-gallery-section {
    padding: 60px var(--gap);
  }

  /* Fiches Lieux communs, modèle Parlement de la maquette (F12) : une seule
     grille de 3 colonnes, gouttière de 8px ; les images en plus continuent
     la même grille et la dernière rangée part de la gauche */
  .plc-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .plc-gallery-row {
    display: contents;
  }
}

/* ==========================================================================
   HOVER PIXEL EFFECT — Reusable greyscale + random white pixel overlay
   Usage: Add .hover-pixel-effect to any container with position: relative.
   The container must have an <img> or <video> child to apply greyscale to.
   JS (site.js) generates the pixel overlay.
   ========================================================================== */

.hover-pixel-effect {
  position: relative;
}

/* Greyscale the image/video on hover */
.hover-pixel-effect:hover img,
.hover-pixel-effect:hover video {
  filter: grayscale(1);
}

/* Pixel overlay — generated by JS, hidden until hover */
.hover-pixel-effect .pixel-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.pixel-overlay .pixel {
  position: absolute;
  width: 13px;
  height: 13px;
  background: white;  opacity: 0;
  animation: pixelFadeIn 0.05s ease forwards;
}

@keyframes pixelFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }}

/* ==========================================================================
   HOVER GREYSCALE EFFECT — Reusable greyscale-only hover
   Usage: Add .hover-greyscale-effect to any container with an <img> or <video>.
   ========================================================================== */

.hover-greyscale-effect {
  position: relative;
}

.hover-greyscale-effect img,
.hover-greyscale-effect video {
  transition: filter 0.4s ease;
}

.hover-greyscale-effect:hover img,
.hover-greyscale-effect:hover video {
  filter: grayscale(1);
}

/* ==========================================================================
   LIGHTBOX — Fullscreen image modal for galleries
   ========================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

.lightbox-content {
  position: relative;
  z-index: 1;
  width: 90vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.lightbox-title {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 60px;
  margin: 0;
  font-size: clamp(18px, 3vw, 36px);
  font-weight: normal;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.lightbox-title-project {
  font-family: inherit;
  text-transform: none;
}

.lightbox-title-separator {
  font-family: inherit;
}

.lightbox-title-gallery {
  font-family: var(--font-title);
  text-transform: uppercase;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.lightbox-close:hover {
  opacity: 0.7;
}

.lightbox-close svg {
  width: 32px;
  height: 32px;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 0.7;
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-prev svg,
.lightbox-next svg {
  width: 40px;
  height: 40px;
}

.lightbox-figure {
  position: relative;
  margin: 0;
  max-width: calc(100% - 140px);
  max-height: calc(100% - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Click zones on image (left/right halves) */
.lightbox-click-prev,
.lightbox-click-next {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  cursor: pointer;
  z-index: 1;
}

.lightbox-click-prev {
  left: 0;
  cursor: w-resize;
}

.lightbox-click-next {
  right: 0;
  cursor: e-resize;
}

/* Hide click zones if only one image */
.lightbox.is-single .lightbox-click-prev,
.lightbox.is-single .lightbox-click-next {
  display: none;
}

/* Hide prev/next if only one image */
.lightbox.is-single .lightbox-prev,
.lightbox.is-single .lightbox-next {
  display: none;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .lightbox-prev,
  .lightbox-next {
    width: 44px;
    height: 44px;
  }

  .lightbox-prev svg,
  .lightbox-next svg {
    width: 28px;
    height: 28px;
  }

  .lightbox-figure {
    max-width: calc(100% - 100px);
  }

  .lightbox-title {
    font-size: clamp(18px, 5vw, 28px);
    padding: 12px 50px;
  }
}
