/* ==========================================================================
   Atelier des Méditerranées — feuille de style unique
   Typographie Epilogue, fond gris clair, textes bleu foncé, accent rouge.

   Conventions de nommage
   ----------------------
   .container / .container--narrow  largeurs de contenu (80vw / 70vw)
   .site-header, .site-footer       chrome du site
   .entry-*                         page de détail (projet, à propos)
   .main--home                      accueil : diaporama plein hauteur
   .is-active, .nav-open            états ajoutés par le JavaScript
   ========================================================================== */

/* Polices ------------------------------------------------------------------ */
@font-face {
  font-family: 'Epilogue';
  src: url('../fonts/epilogue-300.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Epilogue';
  src: url('../fonts/epilogue-300-italic.ttf') format('truetype');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Epilogue';
  src: url('../fonts/epilogue-500.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Epilogue';
  src: url('../fonts/epilogue-500-italic.ttf') format('truetype');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

/* Variables ---------------------------------------------------------------- */
:root {
  --bg: #f5f5f5;
  --fg: #11425d;         /* texte : bleu foncé, jamais noir */
  --white: #fff;
  --muted: #767676;
  --line: #11425d;       /* filets, cadres et aplats du même bleu que le texte */
  --line-soft: #cfcfcf;
  --accent: #f0404e;     /* couleur active : survol des liens, logo, titres de cartes */
  --visited: #097c90;    /* liens déjà visités */
  --placeholder: #e6e6e6;

  --font: 'Epilogue', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-size: clamp(1.05rem, 0.97rem + 0.35vw, 1.38rem);
  --font-size-small: 0.8rem;

  --pad: 1.5rem;
  --content-width: 80vw; /* titres, pages de détail, publications */
  --grid-width: 70vw;    /* sections : intro + grille de cartes */
  --gap: 0.5rem;

  /* Hauteur du bandeau, utilisée par le diaporama d'accueil sur téléphone
     (voir .main--home .hero dans « Adaptation mobile »). Valeur de repli sans
     JavaScript : hauteur du logo (248px de large, ratio 126/434,6 du fichier
     assets/img/logo.svg) + padding vertical du bandeau (1rem + 1.25rem).
     assets/js/header-height.js la remplace par la hauteur mesurée. */
  --header-h: calc(248px * 126 / 434.6 + 2.25rem);
}

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

html {
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* Sur Safari iOS, `100vh` correspond à la grande fenêtre (barres d'outils
     masquées) : la page dépasse alors la zone visible et le diaporama
     d'accueil se retrouve en partie sous la barre d'adresse. `100svh`
     (petite fenêtre) est utilisé quand il est supporté, avec `100vh` en
     repli pour les navigateurs plus anciens. */
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--font-size);
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1 0 auto;
}

/* Accueil : le conteneur principal devient une colonne pour que le
   diaporama prenne toute la hauteur restante (voir .main--home .hero). */
.main--home {
  display: flex;
  flex-direction: column;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

/* Liens de contenu déjà visités : couleur dédiée (--visited). Les liens de
   navigation et les cartes gardent leur couleur pour rester lisibles sur les
   visuels. La couleur active du survol reste prioritaire (règle suivante). */
:where(.prose, .entry-cv, .site-footer) a:visited {
  color: var(--visited);
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 0.02em;
  text-underline-offset: 0.25em;
}

p {
  margin: 0 0 1em;
}

p:last-child {
  margin-bottom: 0;
}

figure {
  margin: 0;
}

strong,
b {
  font-weight: 500;
}

em,
i {
  font-style: italic;
}

button {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 1.35rem + 2.4vw, 3rem);
}

h2 {
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem);
}

:focus-visible {
  outline: 1px dotted var(--fg);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* Utilitaires -------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--fg);
  color: var(--bg);
}

.skip-link:focus {
  top: 1rem;
}

/* Largeurs de contenu ------------------------------------------------------ */
.container,
.container--narrow {
  max-width: 100%;
  margin-right: auto;
  margin-left: auto;
}

.container {
  width: var(--content-width);
}

.container--narrow {
  width: var(--grid-width);
}

/* En-tête ------------------------------------------------------------------ */
/* `sticky` et non `fixed` : il reste ancré en haut de la fenêtre au
   défilement tout en gardant sa place dans le flux, ce dont dépend la hauteur
   du diaporama d'accueil (.main--home .hero). Le `background` opaque évite que
   le contenu ne se voie à travers, et `.nav-menu` en position absolue reste
   accroché à l'en-tête sur mobile. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 1rem var(--pad) 1.25rem;
  background: var(--bg);
}

.header-inner {
  display: grid;
  grid-template-columns: 33.33% 1fr;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: block;
  width: max-content;
  max-width: 100%;
  color: var(--fg);
}

/* Logo SVG en ligne : il hérite de la couleur du lien, donc il passe
   en couleur active au survol. */
.brand svg {
  display: block;
  width: 248px;
  max-width: 100%;
  height: auto;
}

.brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.nav-menu {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: clamp(0.92rem, 0.86rem + 0.22vw, 1.38rem);
  line-height: 1.3;
}

.nav-menu a {
  display: block;
  padding: 0.25rem 0;
}

.nav-menu a:hover,
.nav-menu a.is-active {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.nav-toggle {
  display: none;
  padding: 0.4rem 0;
  border: 0;
  background: none;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Section (Projets, Activités, Jardiner) ----------------------------------- */
.section-title {
  padding: 1rem 0 2.25rem;
}

.section-intro {
  margin-bottom: 2.5rem;
}

/* Texte de présentation de l'accueil (facultatif), sous le diaporama */
.home-intro {
  padding-top: 2.5rem;
}

/* Texte riche (markdown Kirby) */
.prose {
  max-width: 72ch;
}

.prose p,
.prose ul,
.prose ol {
  margin-bottom: 1.2em;
}

.prose ul,
.prose ol {
  padding-left: 1.25em;
}

.prose p:last-child,
.prose ul:last-child,
.prose ol:last-child {
  margin-bottom: 0;
}

/* Filtres par catégorie ---------------------------------------------------- */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.75rem;
}

.category-filter {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.category-filter:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.category-filter[aria-pressed='true'] {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

/* Grille de cartes --------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  margin: 0 0 4rem;
  padding: 0;
  list-style: none;
}

.card a {
  display: block;
}

.card a:hover {
  text-decoration: none;
}

.card figure {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--placeholder);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.35s ease;
}

/* Voile bleu foncé affiché au survol : l'image s'efface un peu (on voit
   mieux le titre) sans perdre le contraste du texte blanc. */
.card figure::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.card figcaption {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  color: var(--bg);
  font-size: clamp(0.95rem, 0.82rem + 0.35vw, 1.125rem);
  font-weight: 300;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.75);
  transition: color 0.25s ease;
}

.card figcaption span {
  max-width: 22ch;
}

.card a:hover img {
  opacity: 0.7;
}

.card a:hover figure::after {
  opacity: 0.35;
}

.card a:hover figcaption {
  color: var(--accent);
}

/* Diaporama d'accueil ------------------------------------------------------ */
.hero {
  position: relative;
  width: 100%;
  height: 60vh;
  min-height: 320px;
  overflow: hidden;
  background: var(--placeholder);
}

/* Sur l'accueil, le diaporama occupe toute la hauteur disponible entre
   l'en-tête et le pied de page (main est alors une colonne flexible). La
   hauteur minimale évite qu'il ne s'écrase quand un texte de présentation
   est ajouté sous le diaporama. */
.main--home .hero {
  flex: 1 1 0;
  height: auto;
  min-height: 320px;
}

/* Le rail et l'image sont positionnés en absolu dans le cadre du diaporama :
   sur l'accueil, la hauteur de `.hero` est calculée par le flex du `main`.
   Une chaîne de `height: 100%` sous une hauteur issue du flex n'est pas
   résolue de façon fiable par WebKit (Safari iOS) : l'image retombait sur sa
   hauteur naturelle et `object-fit: cover` n'avait donc plus rien à rogner.
   Avec `inset: 0`, la hauteur de référence devient celle, définitive, du
   cadre : le cadrage est identique dans tous les moteurs. */
.hero-track {
  position: absolute;
  inset: 0;
  display: flex;
  transition: transform 1.2s ease;
  will-change: transform;
}

.hero-track.is-resetting {
  transition: none;
}

.hero-slide {
  position: relative;
  flex: 0 0 100%;
  height: 100%;
}

.hero-slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 4rem var(--pad) 1.25rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent);
  color: var(--white);
  font-size: clamp(0.8rem, 0.75rem + 0.2vw, 0.95rem);
  line-height: 1.4;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.75);
  white-space: pre-line;
  pointer-events: none;
}

.hero-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: none;
  padding: 0.35rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--white);
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.hero.is-ready .hero-toggle {
  display: block;
}

.hero-toggle:hover {
  border-color: var(--white);
  background: rgba(0, 0, 0, 0.75);
}

.hero-toggle:focus-visible {
  outline-color: var(--white);
}

/* Page de détail (projet, à propos) ---------------------------------------- */
.entry-head {
  display: grid;
  grid-template-columns: 33.33% 1fr;
  gap: 1.5rem;
  padding: 1rem 0 2rem;
}

.entry-location {
  margin: 0;
  font-style: italic;
  text-align: right;
}

.entry-title {
  max-width: 72ch;
}

.entry-cover {
  width: 100%;
  height: clamp(260px, 46vw, 560px);
  margin: 0;
  background: var(--placeholder);
  overflow: hidden;
}

.entry-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entry-body {
  display: grid;
  grid-template-columns: 33.33% 1fr;
  gap: 1.5rem;
  padding: 2.75rem 0;
}

.entry-infos {
  font-size: 0.95rem;
  line-height: 1.7;
}

.entry-mission {
  margin: 0 0 1.2rem;
  font-weight: 700;
}

.entry-infos-list {
  margin: 0;
}

.entry-infos-item + .entry-infos-item {
  margin-top: 0.75rem;
}

.entry-infos-list dt {
  display: inline;
  font-weight: 700;
}

.entry-infos-list dt::after {
  content: " : ";
}

.entry-infos-list dd {
  display: inline;
  margin: 0;
}

.entry-infos-divers {
  margin-top: 1rem;
}

.entry-text {
  min-width: 0;
}

.entry-gallery {
  padding-bottom: 2rem;
}

.gallery-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 3;
  column-gap: 1rem;
}

.gallery-grid li {
  margin-bottom: 1rem;
  break-inside: avoid;
}

.gallery-grid a {
  display: block;
}

.gallery-grid img {
  width: 100%;
  height: auto;
  background: var(--placeholder);
}

.entry-after {
  padding-bottom: 4rem;
}

.entry-cv {
  padding-bottom: 3.5rem;
}

/* Publications ------------------------------------------------------------- */
.publication-group {
  margin-bottom: 3rem;
}

.publication-group h2 {
  margin-bottom: 1.25rem;
  font-size: 1.38rem;
}

.publication-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.publication-grid a {
  position: relative;
  display: block;
}

/* Pastille des visuels qui ouvrent un PDF au lieu de la visionneuse */
.publication-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.1rem 0.4rem;
  background: var(--fg);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
}

.publication-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--placeholder);
}

.publication-grid figcaption {
  margin-top: 0.4rem;
  font-size: var(--font-size-small);
  font-style: italic;
  line-height: 1.4;
}

/* Page simple / erreur ----------------------------------------------------- */
.page {
  padding: 1rem 0 4rem;
}

.page .section-title {
  padding-bottom: 2rem;
}

.text-link {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* Plan du site ------------------------------------------------------------- */
/* Page non listée (/plan-du-site), liée depuis le pied de page : toutes les
   pages publiées, les sections en gras et leurs pages en retrait. */
.sitemap {
  margin-top: 3rem;
}

.sitemap-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sitemap-list > .sitemap-item {
  margin-bottom: 1.1rem;
}

.sitemap-list > .sitemap-item > a {
  font-weight: 500;
}

.sitemap-list .sitemap-list {
  margin-top: 0.35rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line-soft);
}

.sitemap-list .sitemap-list .sitemap-item {
  margin-bottom: 0.1rem;
}

.sitemap-place {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: var(--font-size-small);
}

/* Pied de page ------------------------------------------------------------- */
.site-footer {
  padding: 1.5rem var(--pad);
  border-top: 1px solid var(--line);
  font-size: var(--font-size-small);
  line-height: 1.6;
}

.footer-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.footer-inner p {
  margin: 0;
}

.footer-email {
  text-align: right;
}

/* Lien vers le plan du site : sur sa propre ligne, sous les coordonnées */
.footer-plan {
  grid-column: 1 / -1;
}

/* Visionneuse d'images ----------------------------------------------------- */
.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.92);
}

.lightbox-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  z-index: 2;
  padding: 0.75rem 1rem;
  border: 0;
  background: none;
  color: var(--white);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close {
  top: 0.5rem;
  right: 0.75rem;
}

.lightbox-prev {
  top: 50%;
  left: 0.5rem;
  transform: translateY(-50%);
}

.lightbox-next {
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
}

/* Adaptation mobile -------------------------------------------------------- */
@media (max-width: 900px) {
  :root {
    --content-width: calc(100% - 2.5rem);
    --grid-width: calc(100% - 2.5rem);
    /* Repli sans JavaScript : logo mobile de 190px de large. */
    --header-h: calc(190px * 126 / 434.6 + 2.25rem);
  }

  .header-inner {
    grid-template-columns: 1fr auto;
    gap: 1rem;
  }

  .brand svg {
    width: 190px;
  }

  .nav {
    justify-content: flex-end;
  }

  .nav-toggle {
    display: inline-block;
  }

  .nav-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem var(--pad) 1.75rem;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    font-size: 1.2rem;
  }

  body.nav-open .nav-menu {
    display: flex;
  }

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

  .gallery-grid {
    columns: 2;
  }

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

  .footer-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-email {
    text-align: left;
  }

  /* Accueil : le bandeau et le diaporama occupent exactement la hauteur de
     l'écran, le pied de page passant sous la ligne de flottaison (il reste
     accessible par défilement). `100svh` = la petite fenêtre, celle qui est
     visible quand les barres d'outils du navigateur sont déployées : rien ne
     se cache dessous et la hauteur ne change pas quand elles se replient.
     `--header-h` est mesurée par assets/js/header-height.js (repli en haut du
     fichier). La première déclaration sert de repli aux navigateurs sans
     unités `svh` (Safari iOS < 15.4). `min-height: 320px` (règle de base)
     garde un diaporama lisible en paysage. */
  .main--home .hero {
    flex: 0 0 auto;
    height: calc(100vh - var(--header-h));
    height: calc(100svh - var(--header-h));
  }
}

@media (max-width: 760px) {
  .entry-head,
  .entry-body {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .entry-head {
    padding-bottom: 1.5rem;
  }

  .entry-location {
    text-align: left;
  }

  .entry-body {
    padding: 2rem 0;
  }

  .category-filters {
    flex-wrap: nowrap;              /* une seule ligne */
    overflow-x: auto;               /* le débordement devient défilable */
    overscroll-behavior-x: contain; /* évite le "swipe" qui change de page sur iOS */
    scrollbar-width: none;          /* Firefox : barre masquée */
    scroll-snap-type: x proximity;  /* les pilules se calent proprement */
    padding-bottom: 0.35rem;        /* évite que le focus (outline) soit rogné */
  }

  .category-filters::-webkit-scrollbar {
    display: none;                  /* Chrome / Safari : barre masquée */
  }

  .category-filter {
    flex: 0 0 auto;                 /* sinon les pilules rétrécissent au lieu de défiler */
    white-space: nowrap;
    scroll-snap-align: start;
  }
}

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

  .gallery-grid {
    columns: 1;
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }

  .category-filter {
    font-size: 0.66rem;
  }
}

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

  .hero-track {
    transition: none;
  }
}


