/* Galeries : une page claire et neutre, pour que les photos portent la couleur. */

:root {
  color-scheme: light dark;

  --paper: #eeeeeb;
  --ink: #1b1c1e;
  --muted: #62666b;
  --rule: #cfd0d1;
  --accent: #27467a;
  --placeholder: #dcdcd9;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --pad: clamp(16px, 4vw, 56px);
  --gap: 6px;
  --row-h: 240px;

  --v-bg: #0e0f10;
  --v-ink: #ecece9;
  --v-muted: #a4a8ad;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151617;
    --ink: #e7e7e4;
    --muted: #9a9ea3;
    --rule: #2d3033;
    --accent: #9db9e8;
    --placeholder: #222427;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
}

body.viewing { overflow: hidden; }

a { color: inherit; }

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

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) var(--pad) 48px;
}

/* ---------- Titres et fil d'Ariane ---------- */

h1 {
  margin: 0;
  font: 300 clamp(2.1rem, 5.5vw, 3.9rem)/1.08 var(--serif);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.crumbs {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.crumbs li + li::before {
  content: "/";
  margin: 0 0.6em;
  color: var(--rule);
}

.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.crumbs [aria-current] { color: var(--ink); }

.count {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.head { margin-bottom: clamp(28px, 5vw, 56px); }

/* ---------- Galeries (couvertures) ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: clamp(20px, 3vw, 36px) clamp(14px, 2vw, 24px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card { display: block; text-decoration: none; }

.cover {
  aspect-ratio: 3 / 2;
  background: var(--placeholder);
  overflow: hidden;
}

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

.card:hover .cover img { transform: scale(1.03); }

.card h2 {
  margin: 12px 0 0;
  font: 400 1.3rem/1.25 var(--serif);
}

.card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Photos : rangées justifiées ---------- */

.rows {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.rows::after { content: ""; flex-grow: 1000000; }

.rows li {
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row-h));
}

.rows a {
  display: block;
  width: 100%;
  aspect-ratio: var(--ar);
  background: var(--placeholder);
  overflow: hidden;
}

.rows img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cards + .rows,
.cards + .rule { margin-top: clamp(32px, 5vw, 64px); }

.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin-bottom: clamp(32px, 5vw, 64px);
}

/* ---------- Messages ---------- */

.notice {
  max-width: 34rem;
  margin: 0;
  font-size: 1.05rem;
}

.notice a { color: var(--accent); }

.notice strong {
  display: block;
  margin-bottom: 6px;
  font: 400 1.5rem/1.25 var(--serif);
}

footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 var(--pad) 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  background: var(--v-bg);
  color: var(--v-ink);
}

.viewer[hidden] { display: none; }

.v-figure {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 0 24px;
  min-height: 0;
}

.v-figure img {
  display: block;
  max-width: 100%;
  min-height: 0;
  flex: 0 1 auto;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.v-figure img.loading { opacity: 0.75; }

#v-cap {
  flex: none;
  max-width: 46rem;
  padding-top: 14px;
  text-align: center;
}

#v-cap:empty { display: none; }

#v-cap .t { font: 400 1.15rem/1.3 var(--serif); }
#v-cap .c { margin: 4px 0 0; color: var(--v-muted); font-size: 0.92rem; }
#v-cap .n { margin: 8px 0 0; color: var(--v-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.v-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--v-muted);
  cursor: pointer;
  text-decoration: none;
}

.v-btn:hover { color: var(--v-ink); background: rgba(255, 255, 255, 0.08); }
.viewer :focus-visible { outline-color: #9db9e8; }

.v-prev { grid-column: 1; grid-row: 1; justify-self: center; }
.v-next { grid-column: 3; grid-row: 1; justify-self: center; }
.v-close { position: absolute; top: 10px; right: 10px; }

@media (max-width: 640px) {
  :root { --row-h: 160px; --gap: 4px; }

  .viewer { grid-template-columns: 0 minmax(0, 1fr) 0; }

  .v-figure { padding: 56px 8px 72px; }

  .v-prev,
  .v-next {
    position: absolute;
    bottom: 12px;
    top: auto;
    background: rgba(255, 255, 255, 0.08);
  }
  .v-prev { left: calc(50% - 60px); }
  .v-next { left: calc(50% + 12px); }
}

@media (prefers-reduced-motion: reduce) {
  .cover img,
  .v-figure img { transition: none; }
  .card:hover .cover img { transform: none; }
}
