/* Galerie Expo École du Renard — thème clair, inspiration Material 3. */

:root {
  --bg: #faf7f4;
  --surface: #ffffff;
  --surface-2: #f3ede8;
  --on-surface: #1f1b18;
  --on-surface-muted: #6b625c;
  --primary: #a4441f;
  --primary-hover: #8a3717;
  --on-primary: #ffffff;
  --outline: #e0d7d0;
  --focus: #0b57d0;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 24px;
  --elev-1: 0 1px 2px rgba(31, 27, 24, .08), 0 1px 3px 1px rgba(31, 27, 24, .06);
  --elev-2: 0 2px 6px 2px rgba(31, 27, 24, .08), 0 1px 2px rgba(31, 27, 24, .1);
  --elev-3: 0 4px 12px 4px rgba(31, 27, 24, .1), 0 2px 4px rgba(31, 27, 24, .12);
  --ease: cubic-bezier(.2, 0, 0, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1rem, .95rem + .2vw, 1.0625rem);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius-s);
}

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -120%);
  z-index: 100;
  padding: .75rem 1.25rem;
  background: var(--surface);
  color: var(--on-surface);
  border-radius: 0 0 var(--radius-m) var(--radius-m);
  box-shadow: var(--elev-2);
  font-weight: 600;
}
.skip-link:focus { transform: translate(-50%, 0); }

/* ---------- En-tête ---------- */

.site-header {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1.25rem 1.5rem;
  text-align: center;
}

.logo {
  display: inline-block;
  border-radius: 50%;
  line-height: 0;
}
.logo img {
  width: clamp(120px, 22vw, 180px);
  height: auto;
  margin-inline: auto;
}

.eyebrow {
  margin: 1.5rem 0 .25rem;
  color: var(--on-surface-muted);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 .75rem;
  font-size: clamp(1.75rem, 1.3rem + 2.2vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -.015em;
  font-weight: 700;
  text-wrap: balance;
}

.intro,
.credits {
  margin: 0 auto .5rem;
  max-width: 36rem;
  color: var(--on-surface-muted);
  text-wrap: pretty;
}
.credits { font-size: .9375rem; }

.actions { margin: 1.75rem 0 0; }

.button {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  padding: .625rem 1.5rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--elev-1);
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.button:hover {
  background: var(--primary-hover);
  color: var(--on-primary);
  box-shadow: var(--elev-2);
}
.button:active { transform: translateY(1px); box-shadow: var(--elev-1); }

/* ---------- Galerie ---------- */

main {
  max-width: 82rem;
  margin: 0 auto;
  padding: 0 clamp(.75rem, 2vw, 1.5rem) 3rem;
}

.section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin: 2rem 0 1.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: .01em;
  scroll-margin-top: 1rem;
}

.badge {
  padding: .125rem .625rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--on-surface-muted);
  font-size: .8125rem;
  font-weight: 600;
}

.empty {
  padding: 3rem 1rem;
  border: 1px dashed var(--outline);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--on-surface-muted);
  text-align: center;
}

/* Mosaïque en colonnes : conserve les proportions de chaque photo. */
.grid {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 4 16rem;
  column-gap: clamp(.5rem, 1.2vw, 1rem);
}

.cell {
  break-inside: avoid;
  margin-bottom: clamp(.5rem, 1.2vw, 1rem);
}

.tile {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--surface-2);
  box-shadow: var(--elev-1);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.tile:hover { box-shadow: var(--elev-3); transform: translateY(-2px); }
.tile:active { transform: translateY(0); }

.tile img {
  width: 100%;
  height: auto;
  /* Placeholder flou (LQIP) affiché sous l'image le temps du chargement. */
  background-size: cover;
  background-position: center;
  transition: opacity .3s var(--ease);
}

/* ---------- Pied de page ---------- */

.site-footer {
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--outline);
  color: var(--on-surface-muted);
  font-size: .875rem;
  text-align: center;
}
.site-footer p { margin: .25rem 0; }
.counter { font-variant-numeric: tabular-nums; }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: center;
  gap: .5rem;
  padding: clamp(.5rem, 2vw, 1.5rem);
  background: rgba(24, 20, 18, .94);
  backdrop-filter: blur(4px);
  animation: fade .2s var(--ease);
}
.lightbox[hidden] { display: none; }

.lightbox__bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #fff;
}

.lightbox__count {
  margin: 0;
  padding-inline-start: .5rem;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .85);
}

.lightbox__figure {
  grid-column: 2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-width: 0;
  height: 100%;
}

.lightbox__figure img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius-s);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  animation: zoom .22s var(--ease);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  transition: background-color .18s var(--ease);
}
.icon-button:hover { background: rgba(255, 255, 255, .26); }
.icon-button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.icon-button svg { width: 26px; height: 26px; fill: currentColor; }
.icon-button[disabled] { opacity: .3; cursor: default; }
.icon-button[disabled]:hover { background: rgba(255, 255, 255, .12); }

.nav--prev { grid-column: 1; grid-row: 2; }
.nav--next { grid-column: 3; grid-row: 2; }

.spinner {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner[hidden] { display: none; }

body.is-locked { overflow: hidden; }

@keyframes fade { from { opacity: 0; } }
@keyframes zoom { from { opacity: 0; transform: scale(.97); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 40rem) {
  .lightbox {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .lightbox__figure { grid-column: 1; }
  .nav--prev,
  .nav--next { grid-column: 1; grid-row: 3; }
  .nav--prev { justify-self: start; }
  .nav--next { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .tile:hover { transform: none; }
}

@media (prefers-contrast: more) {
  :root {
    --on-surface-muted: #3d3733;
    --outline: #8a817b;
    --primary: #83320f;
  }
  .tile { box-shadow: none; outline: 1px solid var(--outline); }
}

@media print {
  .skip-link,
  .actions,
  .lightbox { display: none !important; }
  body { background: #fff; }
  .grid { columns: 2; }
  .tile { box-shadow: none; }
}
