/* =========================================================
   Franck Baur, portfolio
   ========================================================= */

/* ---------- Polices --------------------------------------
   Nunito (texte) et Jost (logo, titres) : licence libre OFL.
   Pour utiliser les polices Adobe d'origine (Clone Rounded Latin
   et Futura PT), créer un projet web sur fonts.adobe.com, autoriser
   le nom de domaine, puis ajouter dans le <head> de chaque page :
   <link rel="stylesheet" href="https://use.typekit.net/XXXXXXX.css">
   Elles passeront automatiquement devant Nunito et Jost. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jost-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jost-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Réglages généraux ---------------------------- */
:root {
  --ink: #1c1c1c;
  --muted: #767676;
  --line: #e8e8e8;
  --paper: #ffffff;
  --placeholder: #f2f2f2;

  --font-text: "clone-rounded-latin", "Nunito", system-ui, sans-serif;
  --font-title: "futura-pt", "Jost", "Futura", sans-serif;

  --page-max: 1440px;
  --text-max: 680px;
  --pad: clamp(16px, 3vw, 40px);   /* marges latérales */
  --gap: 10px;                      /* espace entre les photos */
  --block: clamp(40px, 6vw, 88px);  /* espace entre les blocs */
  --row-h: clamp(200px, 20vw, 290px); /* hauteur cible des galeries */
}

*, *::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: 400 17px/1.7 var(--font-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: inherit; text-decoration: none; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---------- En-tête --------------------------------------- */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 36px) var(--pad) clamp(28px, 4vw, 52px);
}

.logo {
  grid-column: 2;
  grid-row: 1;
  font: 700 clamp(22px, 2.3vw, 30px)/1 var(--font-title);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.site-nav {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  gap: 22px;
}

.site-nav a {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: currentColor;
}

/* ---------- Accueil : vignettes des projets -------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(28px, 3.5vw, 48px) clamp(12px, 1.6vw, 20px);
}

.card { display: block; }

.card-img {
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--placeholder);
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.2, 0.6, 0.2, 1), opacity 0.4s;
}

.card-title {
  display: block;
  margin-top: 14px;
  font: 600 13px/1.4 var(--font-text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.2s;
}

@media (hover: hover) {
  .card:hover .card-img img { transform: scale(1.035); }
  .cards:hover .card:not(:hover) .card-img img { opacity: 0.75; }
}

/* ---------- Page projet ---------------------------------- */
.project-title {
  margin: 0 auto clamp(20px, 2.5vw, 32px);
  font: 600 clamp(26px, 3.4vw, 44px)/1.15 var(--font-title);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

.project > * + * { margin-top: var(--block); }
.project > h1 + * { margin-top: 0; }

.text {
  max-width: var(--text-max);
  margin-left: auto;
  margin-right: auto;
}

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

.text.intro {
  text-align: center;
  font-size: clamp(17px, 1.4vw, 19px);
  text-wrap: balance;
}

.text.story { text-wrap: pretty; hyphens: auto; }

.banner { max-width: 900px; margin-left: auto; margin-right: auto; }
.banner img { width: 100%; }

/* Logo seul en tête de page (Regards Maraîchers) */
.banner-logo img { width: min(100%, 280px); margin: 0 auto; }

/* Rangées de photos à hauteur égale (la largeur suit le format de chaque photo) */
.rows { display: grid; gap: var(--gap); }

.rows.compact {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

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

.row > .photo { flex: calc(var(--w) / var(--h)) 1 0; }

/* Photo seule : jamais plus haute que l'écran */
.row.single > .photo {
  flex: none;
  width: min(100%, calc(88vh * var(--w) / var(--h)));
  margin: 0 auto;
}

/* Galerie justifiée : rangées remplies automatiquement */
.justified {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

.justified > .photo {
  flex-grow: calc(var(--w) / var(--h) * 100);
  flex-basis: calc(var(--row-h) * var(--w) / var(--h));
}

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

/* Dernière rangée (réglée par site.js) */
.justified.fill-last::after,
.justified.center-last::after { display: none; }
.justified.center-last { justify-content: center; }
.justified > .photo.last-row { flex-grow: 0; }

.photo {
  min-width: 0;
  display: block;
  position: relative;
  aspect-ratio: var(--w) / var(--h);
  background: var(--placeholder);
  cursor: zoom-in;
  overflow: hidden;
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s;
}

@media (hover: hover) {
  .photo:hover img { opacity: 0.92; }
}

/* Vidéos et podcast */
.video {
  width: min(100%, 1100px);
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: var(--w) / var(--h);
  background: #191919;
}

.video.portrait { width: min(100%, calc(85vh * var(--w) / var(--h))); }

.video video,
.video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #191919;
}

.video-figure { margin-left: 0; margin-right: 0; margin-bottom: 0; }

.video-figure figcaption {
  max-width: var(--text-max);
  margin: 14px auto 0;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}

/* Bouton (lien vers une chaîne, un site...) */
.cta { text-align: center; }

.cta a {
  display: inline-block;
  padding: 13px 24px;
  border: 1px solid var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background-color 0.2s, color 0.2s;
}

.cta a:hover { background: var(--ink); color: var(--paper); }

.embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed {
  max-width: var(--text-max);
  margin-left: auto;
  margin-right: auto;
}

/* Navigation entre projets */
.project-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding-top: clamp(28px, 3vw, 40px);
  border-top: 1px solid var(--line);
}

.project-nav a { display: grid; gap: 6px; }
.project-nav .next { text-align: right; }

.project-nav .label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-nav .name {
  font: 600 clamp(18px, 2vw, 24px)/1.2 var(--font-title);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

.project-nav a:hover .name { opacity: 0.6; }

/* ---------- Contact --------------------------------------- */
.contact {
  min-height: 45vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.contact p { margin: 0 0 10px; font-size: clamp(18px, 2vw, 22px); }

.contact p a {
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s;
}

.contact p a:hover { border-bottom-color: var(--ink); }

/* ---------- Pied de page ---------------------------------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: var(--page-max);
  margin: clamp(56px, 8vw, 112px) auto 0;
  padding: 24px var(--pad) 32px;
  font-size: 13px;
  color: var(--muted);
}

.site-footer a:hover { color: var(--ink); }

/* ---------- Visionneuse (lightbox) ------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.97);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0s 0.25s;
  touch-action: pan-y;
}

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

.lightbox img {
  max-width: calc(100vw - 2 * clamp(16px, 7vw, 96px));
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.2s;
}

.lightbox img.is-loading { opacity: 0; }

.lightbox button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.lightbox button:hover { opacity: 1; }
.lightbox button svg { width: 26px; height: 26px; }

.lightbox .lb-close { top: 12px; right: 12px; }
.lightbox .lb-prev { left: clamp(4px, 2vw, 24px); top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: clamp(4px, 2vw, 24px); top: 50%; transform: translateY(-50%); }

.lightbox .lb-count {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

body.lb-lock { overflow: hidden; }

/* ---------- Écrans moyens et petits ----------------------- */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

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

  body { font-size: 16px; }

  .site-header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 14px;
  }
  .logo { grid-column: 1; grid-row: 1; }
  .site-nav { grid-column: 1; grid-row: 2; }

  /* Les rangées de photos passent l'une sous l'autre */
  .row { flex-direction: column; }
  .row > .photo { flex: none; width: 100%; }

  .lightbox button.lb-prev,
  .lightbox button.lb-next { display: none; }
  .lightbox img { max-width: 100vw; }

  .site-footer { justify-content: center; text-align: center; }
}

@media (max-width: 540px) {
  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
