@font-face {
  font-family: "Playfair Display";
  src: url("fonts/PlayfairDisplay-Regular.woff2") format("woff2"),
       url("fonts/PlayfairDisplay-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f7f3ee;
  --ink: #2b2622;
  --muted: #8a8178;
  --accent: #2b2622; /* texte d'accent : foncé sur fond clair… */
  --gap: 6px;
  --pad: clamp(8px, 2vw, 28px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151311;
    --ink: #ece6dd;
    --muted: #8f867b;
    --accent: #ffffff; /* …blanc sur fond sombre */
  }
}

* { box-sizing: border-box; }

/* scrollbar toujours présente : la largeur de la grille ne change pas après le 1er calcul */
html { -webkit-text-size-adjust: 100%; overflow-y: scroll; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

html.lb-open { overflow: hidden; }

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

.hero {
  text-align: center;
  padding: clamp(48px, 12vh, 120px) var(--pad) clamp(28px, 6vh, 56px);
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-family: "Playfair Display", var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.count {
  margin: 14px 0 28px;
  font-size: 0.9rem;
  color: var(--muted);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.cta svg { width: 16px; height: 16px; fill: currentColor; }

.cta:hover,
.cta:focus-visible {
  background: var(--accent);
  color: var(--bg);
}

/* ---------- Grille ---------- */

main { padding: 0 var(--pad) 48px; }

#grid { display: flex; flex-direction: column; gap: var(--gap); }

.row { display: flex; gap: var(--gap); }

.tile {
  position: relative;
  flex: none;
  display: block;
  overflow: hidden;
  border-radius: 3px;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.5s ease;
}

.tile.loaded img { opacity: 1; }

@media (hover: hover) {
  .tile:hover img { transform: scale(1.04); }
}

.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.empty { text-align: center; color: var(--muted); }

/* ---------- Visionneuse ---------- */

.lb {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  background: #0b0a09;
  color: #f2ede6;
  touch-action: pan-y pinch-zoom;
}

.lb.open { display: block; }
.lb:focus { outline: none; }

.lb-stage { position: absolute; inset: 0; }

.lb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.5s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-img.in { opacity: 1; }

.lb-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.lb.loading .lb-spinner { opacity: 1; animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.lb-bar,
.lb-nav,
.lb-caption {
  transition: opacity 0.4s ease;
}

.lb-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}

.lb-count { font-size: 0.85rem; letter-spacing: 0.06em; opacity: 0.85; padding-left: 6px; }

.lb-actions { display: flex; align-items: center; gap: 2px; }

.lb button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lb button:hover { background: rgba(255, 255, 255, 0.12); }

.lb button:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* Menu de téléchargement (web / HD) */
.lb-dlwrap { position: relative; }

.lb-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(24, 21, 19, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.lb-menu[hidden] { display: none; }

.lb-menu a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 12px;
  border-radius: 8px;
  color: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

/* Survol / navigation clavier : l'option visée est nettement mise en évidence */
.lb-menu a:hover,
.lb-menu a:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 3px 0 0 #fff; /* barre blanche à gauche */
  outline: none;
}

.lb-menu a:active { background: rgba(255, 255, 255, 0.28); }

.lb-menu small { font-size: 0.78rem; opacity: 0.6; white-space: nowrap; transition: opacity 0.12s ease; }

.lb-menu a:hover small,
.lb-menu a:focus-visible small { opacity: 1; }

.lb svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb .i-play, .lb .i-pause { fill: currentColor; stroke: none; }
.lb .i-pause { display: none; }
.lb.playing .i-play { display: none; }
.lb.playing .i-pause { display: block; }

.lb button.txt { width: auto; padding: 0 12px; border-radius: 22px; font-size: 0.85rem; }

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.35);
}

.lb-nav svg,
.lb-top svg { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }

.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 40px 24px calc(20px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: var(--serif);
  font-size: 1.1rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.lb-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  pointer-events: none;
}

.lb-progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: rgba(255, 255, 255, 0.75);
  transform-origin: left;
  transform: scaleX(0);
}

.lb.playing .lb-progress i { animation: progress var(--show-ms, 5000ms) linear forwards; }

@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Pendant le diaporama, l'interface s'efface après quelques secondes d'inactivité */
.lb.idle { cursor: none; }
.lb.idle .lb-bar,
.lb.idle .lb-nav,
.lb.idle .lb-caption { opacity: 0; pointer-events: none; }

/* Sur écran tactile, les flèches gênent : le swipe suffit */
@media (hover: none) {
  .lb-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
  .tile:hover img { transform: none; }
}
