/* ============================================================
   Manech — dessin et peinture
   Direction : catalogue de musée. Papier, encre, filets.
   Voir DESIGN.md à la racine du projet.
   ============================================================ */

:root {
  --paper: #F3F3F1;
  --surface: #FFFFFF;
  --ink: #141414;
  --ink-2: #6B6B67;
  --rule: #E3E3E0;
  --rule-2: #C9C9C4;
  --accent: #7B2233;
  --accent-soft: #F1E7E9;
  --veil: rgba(243, 243, 241, 0.97);

  --marge: clamp(20px, 5vw, 64px);
  --utile: min(1320px, calc(100% - 2 * var(--marge)));
  --section: clamp(64px, 10vh, 128px);
  --gouttiere: 24px;

  --serif: "Newsreader", Georgia, serif;
  --sans: "Archivo", "Helvetica Neue", sans-serif;

  --courbe: cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 160ms var(--courbe),
              text-decoration-color 160ms var(--courbe);
}

a:hover { color: var(--accent); text-decoration-color: var(--accent); }

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

::selection { background: var(--accent-soft); }

/* ---------- en-tête ---------- */

.entete {
  border-bottom: 1px solid var(--rule);
}

.entete .interieur {
  width: var(--utile);
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0;
  flex-wrap: wrap;
}

.marque {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.marque:hover { color: var(--ink); }

.marque .sous {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
  letter-spacing: 0.04em;
  margin-left: 10px;
}

.nav {
  display: flex;
  gap: 26px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 450;
}

.nav a { text-decoration: none; padding: 4px 0; }

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--accent);
  box-shadow: inset 0 -1px 0 var(--accent);
}

/* ---------- structure ---------- */

main {
  width: var(--utile);
  margin: 0 auto;
}

.section { margin-top: var(--section); }

.titre-page {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(35px, 5vw, 55px);
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: clamp(40px, 7vh, 88px) 0 0;
}

.chapo {
  font-size: 20px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 68ch;
  margin: 18px 0 0;
}

.surtitre {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin: 0 0 10px;
}

/* ---------- accueil : entrées de catégorie ---------- */

.entrees {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gouttiere);
  margin-top: clamp(40px, 6vh, 72px);
}

.entree {
  border-top: 1px solid var(--ink);
  padding-top: 18px;
  text-decoration: none;
  display: block;
}

.entree:hover { color: var(--ink); }

.entree .nom {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.15;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.entree .nom .nombre {
  font-family: var(--sans);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.entree:hover .nom { color: var(--accent); }

.entree .apercu {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.entree .apercu img {
  width: 33.33%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--surface);
  transition: opacity 220ms var(--courbe);
}

.entree:hover .apercu img { opacity: 0.86; }

/* ---------- barre d'outils de galerie ---------- */

.outils {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-top: clamp(32px, 5vh, 56px);
  padding: 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  align-items: center;
  font-family: var(--sans);
  font-size: 14px;
}

.groupe {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.groupe>span.etiquette {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.filtre {
  font: inherit;
  background: none;
  border: 0;
  padding: 8px 2px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 0;
}

.filtre:hover { color: var(--ink); }

.filtre[aria-pressed="true"] {
  color: var(--accent);
  box-shadow: inset 0 -1px 0 var(--accent);
}

.recherche {
  font: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule-2);
  padding: 8px 2px;
  color: var(--ink);
  width: 170px;
  border-radius: 0;
}

.recherche::placeholder { color: var(--ink-2); }

.recherche:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

/* --- tri : menu déroulant maison (papier / encre / filet) --- */

.tri { position: relative; }

.tri-bouton {
  font-family: var(--sans);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.tri-bouton:hover { border-color: var(--ink-2); }

.tri-bouton:focus { outline: none; border-color: var(--accent); }

.tri-fleche {
  width: 11px;
  height: 7px;
  flex: none;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='7'><path d='M1 1.5l4.5 4 4.5-4' fill='none' stroke='%236B6B67' stroke-width='1.4'/></svg>") no-repeat center;
  transition: transform 180ms var(--courbe);
}

.tri-bouton[aria-expanded="true"] .tri-fleche { transform: rotate(180deg); }

.tri-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: max(100%, 210px);
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--rule);
}

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

.tri-menu:not([hidden]) { animation: triApparait 160ms var(--courbe); }

@keyframes triApparait {
  from { opacity: 0; transform: translateY(-4px); }
}

.tri-option {
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 14px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  border-top: 1px solid var(--rule);
  transition: background-color 120ms var(--courbe);
}

.tri-option:first-child { border-top: 0; }

.tri-option:hover,
.tri-option:focus { background: var(--paper); }

.tri-option:focus { outline-offset: -2px; }

.tri-option[aria-selected="true"] { color: var(--accent); }

.compte {
  margin-left: auto;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.vide {
  font-family: var(--serif);
  color: var(--ink-2);
  padding: 48px 0;
  display: none;
}

/* ---------- galerie ---------- */

.galerie {
  margin-top: clamp(28px, 4vh, 48px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gouttiere);
  align-items: start;
}

.galerie.justifiee {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gouttiere);
}

.vignette {
  margin: 0;
  position: relative;
}

.galerie.justifiee .vignette {
  flex-grow: 1;
  flex-basis: 0;
  min-width: 190px;
}

.galerie .vignette[hidden] { display: none; }

.titre-section {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 clamp(20px, 3vh, 32px);
}

.vignette>a {
  display: block;
  position: relative;
  text-decoration: none;
  background: var(--surface);
}

.vignette img {
  width: 100%;
  transition: transform 220ms var(--courbe);
}

.vignette>a:hover img { transform: scale(1.015); }

.vignette .cartel {
  padding-top: 12px;
}

.vignette .cartel .nom {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.25;
}

.vignette .cartel .fiche {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin-top: 3px;
}

/* pastille « détails » discret */
.indice {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-family: var(--sans);
  font-size: 11px;
  background: var(--veil);
  color: var(--ink);
  padding: 3px 7px;
  line-height: 1;
}

/* ---------- page d'œuvre ---------- */

.fiche-oeuvre {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: clamp(32px, 5vw, 72px);
  margin-top: clamp(32px, 5vh, 64px);
  align-items: start;
}

@media (max-width: 860px) {
  .fiche-oeuvre { grid-template-columns: 1fr; }
}

/* carrousel façon Instagram : défilement natif + scroll-snap */
.carrousel { position: relative; }

.pistes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  background: var(--surface);
  border: 1px solid var(--rule);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pistes::-webkit-scrollbar { display: none; }

.visuel {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.visuel img {
  max-height: 76vh;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.carrousel.simple .pistes { border: 0; background: none; }
.carrousel.simple .visuel img { max-height: none; width: 100%; cursor: zoom-in; }

.reglages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
}

.points {
  display: flex;
  gap: 7px;
  align-items: center;
}

.points button {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--rule-2);
  cursor: pointer;
}

.points button[aria-current="true"] { background: var(--accent); }

.compteur {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.legende {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 10px 0 0;
  min-height: 1.5em;
}

.fleches { display: flex; gap: 4px; }

.fleches button {
  font: inherit;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink);
  width: 44px;
  height: 44px;
  cursor: pointer;
  border-radius: 0;
  line-height: 1;
}

.fleches button:hover { border-color: var(--accent); color: var(--accent); }

.fleches button:disabled { opacity: 0.35; cursor: default; }
.fleches button:disabled:hover { border-color: var(--rule); color: var(--ink); }

/* cartel (fiche d'œuvre) */
.cartel-oeuvre h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}

.cartel-oeuvre .meta {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.cartel-oeuvre .meta span { display: block; }

.suite {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: clamp(40px, 7vh, 80px);
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 14px;
}

.suite a { text-decoration: none; max-width: 46%; }

.suite a:hover .titre-lien { color: var(--accent); }

.suite .sens {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.suite .titre-lien {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink);
}

.suite .droite { text-align: right; margin-left: auto; }

/* ---------- visionneuse plein écran ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: var(--veil);
  display: none;
  z-index: 40;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.lightbox.ouverte { display: flex; flex-direction: column; }

.lightbox .haut {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
  gap: 16px;
}

.lightbox .fermer {
  font: inherit;
  background: none;
  border: 1px solid var(--rule-2);
  width: 44px;
  height: 44px;
  cursor: pointer;
  color: var(--ink);
  border-radius: 0;
}

.lightbox .fermer:hover { border-color: var(--accent); color: var(--accent); }

.lightbox .scene {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.lightbox .scene img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 200ms var(--courbe);
}

.lightbox .scene img.zoomee { cursor: zoom-out; }

.lightbox .bas {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-top: 12px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-2);
}

.lightbox .bas button {
  font: inherit;
  background: none;
  border: 1px solid var(--rule-2);
  width: 44px;
  height: 44px;
  cursor: pointer;
  color: var(--ink);
  border-radius: 0;
}

.lightbox .bas button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.lightbox .bas button:disabled { opacity: 0.35; }

body.verrouillee { overflow: hidden; }

/* ---------- à propos ---------- */

.prose {
  max-width: 68ch;
  margin-top: clamp(32px, 5vh, 56px);
}

.a-completer {
  border: 1px dashed var(--rule-2);
  background: var(--surface);
  padding: 28px;
  margin-top: 32px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.7;
}

.a-completer strong { color: var(--accent); font-weight: 500; }

/* ---------- pied de page ---------- */

.pied {
  border-top: 1px solid var(--rule);
  margin-top: var(--section);
}

.pied .interieur {
  width: var(--utile);
  margin: 0 auto;
  padding: 26px 0 40px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pied a { text-decoration-color: var(--rule-2); }

/* ---------- apparitions ---------- */

@keyframes monter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.apparait { animation: monter 420ms var(--courbe) both; }
.apparait:nth-child(2) { animation-delay: 40ms; }
.apparait:nth-child(3) { animation-delay: 80ms; }
.apparait:nth-child(4) { animation-delay: 120ms; }
.apparait:nth-child(5) { animation-delay: 160ms; }
.apparait:nth-child(6) { animation-delay: 200ms; }

.vignette.visible { animation: monter 380ms var(--courbe) both; }

/* ---------- mobile ---------- */

@media (max-width: 700px) {
  :root { --gouttiere: 14px; }

  .galerie {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .galerie.justifiee { display: grid; }

  .nav { gap: 18px; font-size: 14px; }

  .compte { margin-left: 0; }

  .suite { flex-direction: column; }
  .suite a { max-width: 100%; }
  .suite .droite { text-align: left; margin-left: 0; }

  .visuel img { max-height: 64vh; }
}

/* ---------- mouvement réduit ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }

  .pistes { scroll-behavior: auto; }
  .vignette>a:hover img { transform: none; }
}

/* ---------- porte d'accès ---------- */

html.ferme { overflow: hidden; }

html.ferme .site { display: none; }

.porte { display: none; }

html.ferme .porte {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--paper);
  padding: var(--marge);
}

.porte-fiche {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--ink);
  padding: clamp(28px, 6vw, 44px);
}

.porte-surtitre {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.porte-titre {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 34px);
  line-height: 1.1;
}

.porte-note {
  margin: 0 0 26px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

.porte-etiquette {
  display: block;
  margin-bottom: 8px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.porte-champ {
  width: 100%;
  font-family: var(--sans);
  font-size: 22px;
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: 0;
  padding: 12px 14px;
  appearance: none;
}

.porte-champ:hover { border-color: var(--ink-2); }

.porte-champ:focus {
  outline: none;
  border-color: var(--accent);
}

.porte-champ[aria-invalid="true"] { border-color: var(--accent); }

.porte-erreur {
  margin: 10px 0 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--accent);
}

.porte-erreur[hidden] { display: none; }

.porte-bouton {
  margin-top: 22px;
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 13px 16px;
  cursor: pointer;
  transition: background-color 160ms var(--courbe),
              border-color 160ms var(--courbe);
}

.porte-bouton:hover { background: var(--accent); border-color: var(--accent); }

.porte-bouton:disabled { opacity: 0.5; cursor: default; }

.porte-noscript {
  margin: 18px 0 0;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--accent);
}
