/* Durlinsdorf – feuille de style unique du site */

:root {
  --rouge: #ba372a;
  --vert: #33805a;
  --menu: #1e3a5f;        /* couleur de la barre de menu (ex. rouge : var(--rouge), vert : #2e7a4f) */
  --fond: #f6f1e7;
  --papier: #fffdf8;
  --texte: #2b2620;
  --discret: #6b6257;
  --bord: #e2d8c6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 1.05rem/1.6 Verdana, Geneva, "DejaVu Sans", sans-serif;
}

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

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

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

header { background: var(--papier); text-align: center; }
/* Le bandeau occupe toute la largeur de la fenêtre */
header img { display: block; width: 100%; }

/* ---------- Menu ---------- */

nav {
  background: var(--menu);
  font-family: system-ui, sans-serif;
  font-size: 1.25rem;     /* taille des caractères du menu ; au-delà, le menu ne tient plus sur une ligne sur un écran portable courant (1536 px) */
  position: sticky;
  top: 0;
  z-index: 10;
}
nav > ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 auto;
  padding: 0 0.5rem;
  list-style: none;
}
nav > ul > li { position: relative; }
nav a, nav summary {
  display: block;
  padding: 1.1rem 0.6rem;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
nav summary { list-style: none; }
nav summary::-webkit-details-marker { display: none; }
/* Flèche à droite du titre d'une rubrique ; elle devient une croix au survol ou quand la rubrique est ouverte */
nav summary::after {
  content: "▾";
  display: inline-block;
  width: 1em;
  margin-left: 0.2em;
  text-align: center;
  font-size: 0.8em;
}
nav details:hover > summary::after,
nav details[open] > summary::after { content: "✕"; }
nav > ul > li > a:hover, nav summary:hover, nav details[open] > summary { background: rgba(0, 0, 0, 0.15); }

nav details ul {
  position: absolute;
  left: 0;
  min-width: 15rem;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: var(--papier);
  border: 1px solid var(--bord);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
nav details a { color: var(--texte); padding: 0.4rem 1rem; }
nav details a:hover { background: var(--fond); color: var(--menu); }
nav details li.sous a { padding-left: 2rem; font-size: 0.9em; }
nav a[aria-current="page"] { font-weight: bold; }
nav details a[aria-current="page"] { color: var(--menu); }

/* ---------- Contenu ---------- */

main {
  /* Largeur du contenu : jusqu'à 95 % de la fenêtre, sans dépasser 90rem (1440 px) */
  width: 95%;
  max-width: 90rem;
  margin: 1.5rem auto;
  padding: 1.5rem 2rem 2rem;
  background: var(--papier);
  border: 1px solid var(--bord);
  border-radius: 6px;
}
main::after { content: ""; display: block; clear: both; }

h1, h2, h3 { line-height: 1.25; clear: both; }
/* Titre qui peut se placer à côté d'une photo flottante, sans espace blanc */
h2.sans-saut { clear: none; }
h1 { color: var(--rouge); text-align: center; font-size: 1.9rem; margin: 0.5rem 0 1.5rem; }
h2 { color: var(--vert); font-size: 1.45rem; margin-top: 2rem; }
h3 { color: var(--vert); font-size: 1.15rem; margin-top: 1.5rem; }

p { text-align: justify; }
.centre { text-align: center; }
p > img:only-child:not(.droite):not(.gauche) { display: block; margin: 0 auto; }

img.droite { float: right; margin: 0.3rem 0 1rem 1.5rem; max-width: 50%; }
/* Photos à droite empilées les unes sous les autres contre le bord */
img.droite.empilee { clear: right; }
img.gauche { float: left; margin: 0.3rem 1.5rem 1rem 0; max-width: 50%; }
/* Photo avec légende, à droite du texte */
figure.droite { float: right; margin: 0.3rem 0 1rem 1.5rem; max-width: 50%; }
/* Photo ronde en tête de page */
img.medaillon {
  width: 12rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--papier);
  box-shadow: 0 0 0 2px var(--bord), 0 4px 12px rgba(0, 0, 0, 0.15);
}
/* Photo et texte associés : le bloc suivant commence sous la photo */
.bloc { display: flow-root; clear: both; }
/* Texte qui reste en colonne à côté de la photo, sans passer dessous */
.bloc .colonne { display: flow-root; }

blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1.5rem;
  border-left: 4px solid var(--bord);
  font-style: italic;
}

table { border-collapse: collapse; margin: 1rem auto; }
td, th { border: 1px solid var(--bord); padding: 0.3rem 0.7rem; vertical-align: top; }
th { background: var(--fond); }
td > p:first-child { margin-top: 0; }
td > p:last-child { margin-bottom: 0; }

/* Galerie de photos */
.galerie {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  clear: both;
}
/* Galerie de 3 images par ligne (une seule colonne sur téléphone) */
.galerie.trois { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 40rem) { .galerie.trois { grid-template-columns: 1fr; } }
/* Galerie centrée : les colonnes vides ne restent pas à droite */
.galerie.centree {
  grid-template-columns: repeat(auto-fit, minmax(14rem, 18rem));
  justify-content: center;
}
/* Images côte à côte, centrées, qui passent à la ligne si la place manque */
.en-ligne {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem;
  margin: 1.5rem 0;
  clear: both;
}
/* Titre placé entre deux photos, centré verticalement */
.entre-photos { align-items: center; justify-content: space-around; }
.entre-photos { flex-wrap: nowrap; }
.entre-photos .milieu { flex: 1; }
.entre-photos h1 { margin-top: 0; }
figure { margin: 0; text-align: center; }
main > figure { margin: 1.5rem 0; }
figure img { display: block; margin: 0 auto; }
figcaption { font-size: 0.9rem; color: var(--discret); margin-top: 0.3rem; }

/* ---------- Accueil ---------- */

/* Grande photo « Bienvenue à Durlinsdorf » en haut de l'accueil */
.bienvenue { margin: 0 0 1.5rem; }
.bienvenue img { display: block; width: 100%; border-radius: 4px; }

.colonnes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem;
  align-items: start;
  margin: 1.5rem 0;
}
.colonnes h2 { margin-top: 0; text-align: center; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0; }
dt { font-weight: bold; color: var(--rouge); }
dd { margin: 0; }

/* Vignettes : toujours 3 par ligne (2 sur tablette, 1 sur téléphone) */
.tuiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}
.tuiles a {
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: 6px;
  overflow: hidden;
}
.tuiles img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.tuiles span { display: block; padding: 0.5rem; font-weight: bold; font-size: 1.1rem; }
.tuiles a:hover span { color: var(--rouge); }

/* ---------- Formulaire de contact ---------- */

.formulaire { max-width: 36rem; margin: 0 auto; }
.formulaire label { display: block; margin: 1rem 0 0.3rem; font-weight: bold; }
.formulaire input, .formulaire textarea {
  width: 100%;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid var(--bord);
  border-radius: 4px;
  background: #fff;
}
.formulaire input:focus, .formulaire textarea:focus { outline: 2px solid var(--rouge); border-color: transparent; }
.formulaire label.case { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: normal; font-size: 0.95rem; }
.formulaire label.case input { width: auto; margin-top: 0.3rem; }
.formulaire button {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.6rem 2.5rem;
  font: inherit;
  font-weight: bold;
  color: #fff;
  background: var(--rouge);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.formulaire button:hover { background: #962b20; }
.piege { position: absolute; left: -9999px; }

/* Messages de retour : affichés seulement quand l'adresse se termine par #merci ou #erreur */
.avis { display: none; padding: 1rem; border-radius: 4px; text-align: center; background: #e3f1e8; color: #1f5a3a; }
.avis.erreur { background: #f8e1de; color: #8a2a20; }
.avis:target { display: block; }
#merci:target ~ .formulaire { display: none; }

/* ---------- Diaporama (page Photos, avec diaporama.js) ---------- */

/* Toutes les photos occupent un cadre de même hauteur, quel que soit leur format */
.diaporama { --hauteur-photo: min(65vh, 32rem); display: grid; position: relative; margin: 1.5rem 0; }
.diaporama figure { grid-area: 1 / 1; margin-bottom: 1rem; }
.diaporama img { width: 100%; height: var(--hauteur-photo); object-fit: contain; }
/* Les photos ne sont masquées que si le script fonctionne */
.diaporama.actif figure { opacity: 0; visibility: hidden; transition: opacity 1.5s, visibility 1.5s; }
.diaporama.actif figure.visible { opacity: 1; visibility: visible; }
.diaporama button {
  position: absolute;
  top: calc(var(--hauteur-photo) / 2 - 1.3rem); /* au milieu de la photo */
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}
.diaporama button:hover { background: var(--rouge); }
.diaporama .precedente { left: 0.5rem; }
.diaporama .suivante { right: 0.5rem; }

/* ---------- Animations ---------- */

@keyframes depuis-le-haut   { from { opacity: 0; transform: translateY(-40px); } }
@keyframes depuis-la-gauche { from { opacity: 0; transform: translateX(-60px); } }
@keyframes depuis-la-droite { from { opacity: 0; transform: translateX(60px); } }
@keyframes rebond {
  0%   { opacity: 0; transform: translateY(80px); }
  60%  { opacity: 1; transform: translateY(-12px); }
  80%  { transform: translateY(5px); }
  100% { transform: none; }
}

/* Petits effets au survol, sur toutes les pages */
.tuiles a { transition: transform 0.3s, box-shadow 0.3s; }
.tuiles a:hover { transform: translateY(-4px); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15); }
/* Le sous-menu se déroule vers le bas à l'ouverture */
@keyframes deroule {
  from { clip-path: inset(0 0 100% 0); opacity: 0.6; }
  to   { clip-path: inset(0 0 0 0); opacity: 1; }
}
nav details[open] ul { animation: deroule 0.35s ease-out; }

/* Accueil : apparition des blocs comme sur l'ancien site.
   Désactivé si le visiteur a demandé à réduire les animations. */
@media (prefers-reduced-motion: no-preference) {
  .accueil header img,
  .accueil .bienvenue img            { animation: depuis-le-haut 1s ease-out both; }
  .accueil .colonnes > :nth-child(1) { animation: depuis-la-gauche 1s ease-out both; }
  .accueil .colonnes > :nth-child(2) { animation: rebond 1s ease-out both; }
  .accueil .colonnes > :nth-child(3) { animation: depuis-la-droite 1s ease-out both; }
  /* Vignettes : les 3 premières viennent de la gauche, les 3 suivantes de la droite */
  .accueil .tuiles a:nth-child(-n+3) { animation: depuis-la-gauche 1s ease-out both; }
  .accueil .tuiles a:nth-child(n+4)  { animation: depuis-la-droite 1s ease-out both; }
}

@media (prefers-reduced-motion: reduce) {
  .diaporama.actif figure, .tuiles a { transition: none; }
}

/* ---------- Bouton « retour en haut » (créé par menu.js) ---------- */

.retour-haut {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  width: 2.8rem;
  height: 2.8rem;
  border: 0;
  border-radius: 50%;
  background: var(--menu);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, background 0.2s;
  z-index: 50;
}
.retour-haut.visible { opacity: 1; visibility: visible; }
.retour-haut:hover, .retour-haut:focus-visible { background: var(--rouge); }

/* ---------- Pied de page ---------- */

footer {
  text-align: center;
  padding: 1rem;
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--discret);
}
footer a { color: var(--discret); }

/* ---------- Petits écrans ---------- */

@media (max-width: 60rem) {
  .tuiles { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 40rem) {
  main { width: auto; margin: 0; padding: 1rem; border: 0; border-radius: 0; }
  .tuiles { grid-template-columns: 1fr; }
  nav { position: static; }
  nav details ul { position: static; min-width: 0; box-shadow: none; }
  img.droite, img.gauche { float: none; display: block; margin: 1rem auto; max-width: 100%; }
  figure.droite { float: none; margin: 1rem auto; max-width: 100%; }
  .diaporama { --hauteur-photo: calc((100vw - 2rem) * 2 / 3); } /* cadre au format 3/2 sur toute la largeur */
  .entre-photos { flex-wrap: wrap; }
  .entre-photos .milieu { flex-basis: 100%; order: -1; }
  p { text-align: left; }
}
