/* Écriture de lumière — ambiance « galerie » : fond sombre, accent jaune.
   La classe « cadre-blanc » sur <body> (réglage de l'administration) ajoute une marge blanche à la photo du jour. */
:root {
  --fond: #161514;
  --fond-2: #211f1d;
  --texte: #e9e4dc;
  --doux: #a39b90;
  --accent: #d9a85b;
  --sur-accent: #1b1712;
  --ligne: #36322e;
  --ombre: 0 8px 36px rgba(0, 0, 0, .6);
  --cadre: none;
  --titre: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --corps: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --legende: var(--corps);
  --casse-titre: none;
  --espace-titre: .02em;
  --graisse-titre: 500;
  --danger: #d76a5a;
  --ok: #7fb77e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 17px/1.6 var(--corps); min-height: 100vh; display: flex; flex-direction: column;
  transition: background-color .3s, color .3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: var(--titre); font-weight: var(--graisse-titre); line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 .6em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 .5em; }
small { color: var(--doux); font-size: .8em; font-weight: 400; }

/* En-tête */
.entete {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1.1rem max(1.2rem, env(safe-area-inset-left)) .9rem; border-bottom: 1px solid var(--ligne);
}
.marque { display: flex; flex-direction: column; color: var(--texte); line-height: 1.15; }
.marque:hover { text-decoration: none; }
.marque strong {
  font-family: var(--titre); font-weight: var(--graisse-titre); font-size: 1.7rem;
  text-transform: var(--casse-titre); letter-spacing: var(--espace-titre);
}
.marque strong span { color: var(--accent); font-style: italic; }
.marque em { font-family: var(--titre); font-size: .9rem; color: var(--doux); margin-top: .25rem; }
.menu { display: flex; gap: 1.2rem; margin-left: auto; flex-wrap: wrap; font-size: .95rem; }
.menu a { color: var(--doux); }
.menu a:hover { color: var(--texte); text-decoration: none; }
.menu .admin { color: var(--accent); }
.burger { display: none; margin-left: auto; background: none; border: 0; color: var(--texte); font-size: 1.5rem; cursor: pointer; }
@media (max-width: 760px) {
  .marque strong { font-size: 1.35rem; }
  .marque em { font-size: .78rem; }
  .burger { display: block; }
  .menu { display: none; width: 100%; flex-direction: column; gap: .2rem; margin: 0; }
  .menu.ouvert { display: flex; }
  .menu a { padding: .45rem 0; font-size: 1.05rem; }
}

main { flex: 1; width: 100%; margin: 0 auto; padding: 1.4rem 1rem 2rem; }
main.etroit { max-width: 46rem; }
main.large { max-width: 80rem; }
.pied { text-align: center; color: var(--doux); font-size: .85rem; padding: 1.5rem 1rem; border-top: 1px solid var(--ligne); }
.pied a { color: var(--doux); text-decoration: underline; }

/* Navigation entre jours / mois */
.jours { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1.2rem; }
.jours h1 { margin: 0; text-align: center; font-size: 1.35rem; }
.jours h1::first-letter { text-transform: uppercase; }
.fleche {
  flex: 0 0 2.6rem; height: 2.6rem; display: grid; place-items: center; border-radius: 50%;
  font-size: 2rem; line-height: 1; color: var(--texte); border: 1px solid var(--ligne);
}
a.fleche:hover { background: var(--fond-2); text-decoration: none; }
span.fleche { border-color: transparent; }

/* Photo du jour */
.photo { margin: 0 0 2.5rem; }
.photo img {
  display: block; margin: 0 auto; max-width: 100%; height: auto;
  /* Un portrait doit tenir dans l'écran sous l'en-tête et la date, sans faire défiler. */
  max-height: 70vh; max-height: 70svh; width: auto; object-fit: contain;
  box-shadow: var(--ombre); border: var(--cadre);
}
.photo figcaption {
  max-width: 40rem; margin: 1.5rem auto 0; font-family: var(--legende);
  font-size: 1.08rem; line-height: 1.75;
}
.sans-image { display: grid; place-items: center; aspect-ratio: 4 / 3; max-width: 36rem; margin: 0 auto; background: var(--fond-2); color: var(--doux); }
.avis { text-align: center; color: var(--accent); }
.vide { color: var(--doux); text-align: center; }
.liens-bas { text-align: center; }
.outils { font-size: .9rem; color: var(--doux); }

/* Plein écran */
img[data-zoom] { cursor: zoom-in; }
.visionneuse {
  position: fixed; inset: 0; z-index: 100; background: #000; cursor: zoom-out;
  display: grid; place-items: center; animation: apparition .2s ease-out;
}
/* L'image occupe tout l'écran (agrandie si besoin), sans être déformée ni rognée. */
.visionneuse img { width: 100vw; height: 100vh; max-width: none; max-height: none; object-fit: contain; }
.visionneuse .fermer {
  position: absolute; top: max(.6rem, env(safe-area-inset-top)); right: .8rem; width: 2.6rem; height: 2.6rem;
  padding: 0; border-radius: 50%; font-size: 1.8rem; line-height: 1; color: #fff;
  background: rgba(0, 0, 0, .45); border: 1px solid rgba(255, 255, 255, .3);
}
.sans-defilement { overflow: hidden; }
@keyframes apparition { from { opacity: 0; } to { opacity: 1; } }

/* Barre d'actions de l'administration : toujours visible en haut */
.barre-actions {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin: 0 -1rem 1rem; padding: .6rem 1rem; background: var(--fond); border-bottom: 1px solid var(--ligne);
}
.barre-actions .titre-barre { font-family: var(--titre); font-size: 1.1rem; margin-right: auto; }
.barre-actions h1.titre-barre { font-size: 2.2rem; line-height: 1.1; color: var(--accent); margin: 0; }
.barre-actions span.titre-barre { color: var(--accent); flex-basis: 100%; }
.barre-actions a:not(.bouton) { padding: .6rem .4rem; }

/* Bande des derniers jours (accueil) */
/* Discrète : la photo du jour reste la vedette. */
.derniers { margin: 1.5rem auto 2rem; max-width: 40rem; }
.bande { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.bande a { display: block; color: var(--doux); font-size: .75rem; text-align: center; }
.bande img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; margin-bottom: .25rem; background: var(--fond-2); opacity: .8; transition: opacity .2s; }
.bande a:hover img { opacity: 1; outline: 2px solid var(--accent); }
@media (max-width: 480px) { .bande { gap: .3rem; } .bande a { font-size: .62rem; } }

/* Option « marge blanche » autour de la photo du jour (comme un tirage). */
.cadre-blanc .photo img { border: clamp(8px, 1.6vw, 18px) solid #fff; box-shadow: 0 8px 36px rgba(0, 0, 0, .7); }

/* Archives : années et mois */
.chapeau { color: var(--doux); }
.annee h2 { border-bottom: 1px solid var(--ligne); padding-bottom: .3rem; }
.mois { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.mois a { display: block; color: var(--texte); font-size: .85rem; text-align: center; }
.mois a:hover { text-decoration: none; color: var(--accent); }
.mois img, .mois .vignette-vide { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--fond-2); margin-bottom: .3rem; }
.mois small { display: block; }
@media (max-width: 480px) { .mois { grid-template-columns: repeat(3, 1fr); gap: .4rem; } }

/* Calendrier d'un mois */
.calendrier { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.calendrier th { font-weight: 400; font-size: .75rem; color: var(--doux); text-transform: uppercase; letter-spacing: .1em; padding-bottom: .2rem; }
.calendrier td { vertical-align: top; padding: 0; }
.calendrier .case { position: relative; display: block; aspect-ratio: 1; background: var(--fond-2); overflow: hidden; }
.calendrier .case img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.calendrier a.case:hover img { transform: scale(1.06); }
.calendrier .num {
  position: absolute; left: 4px; top: 3px; font-size: .75rem; color: #fff;
  text-shadow: 0 0 4px rgba(0, 0, 0, .9);
}
.calendrier .case.sans .num { color: var(--doux); text-shadow: none; }
@media (max-width: 480px) { .calendrier { border-spacing: 2px; } .calendrier .num { font-size: .62rem; } }

/* Grille (recherche) */
.grille { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grille a { display: block; color: var(--doux); font-size: .85rem; text-align: center; }
.grille img, .grille .sans-image { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--fond-2); margin-bottom: .3rem; }
.grille a:hover img { outline: 2px solid var(--accent); }
@media (max-width: 480px) { .grille { grid-template-columns: repeat(3, 1fr); gap: .35rem; } .grille span { font-size: .7rem; } }

/* Formulaires */
.recherche { display: flex; gap: .5rem; margin: 0 0 1.2rem; }
input, textarea, button, .bouton { font: inherit; }
input[type=search], input[type=date], input[name=login], input[name=titre], input[type=password], input[name=nom], input[name=ville], textarea {
  width: 100%; padding: .6rem .7rem; background: var(--fond-2); color: var(--texte);
  border: 1px solid var(--ligne); border-radius: 6px;
}
textarea { resize: vertical; line-height: 1.5; }
button, .bouton {
  display: inline-block; padding: .6rem 1.1rem; border-radius: 6px; cursor: pointer;
  background: var(--fond-2); color: var(--texte); border: 1px solid var(--ligne);
}
button.principal, .bouton.principal { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); font-weight: 600; }
.bouton:hover { text-decoration: none; }
button.danger { color: var(--danger); border-color: var(--danger); background: none; }
button:disabled { opacity: .6; cursor: wait; }
.formulaire { display: flex; flex-direction: column; gap: 1rem; }
.formulaire label { display: flex; flex-direction: column; gap: .3rem; }
.formulaire label.case { flex-direction: row; align-items: center; gap: .5rem; }
.formulaire input[type=file] { color: var(--doux); }
.apercu { max-width: 100%; max-height: 50vh; align-self: center; }
.supprimer { margin-top: 2.5rem; }
.erreur { color: var(--danger); }
.succes { color: var(--ok); }

/* Calendrier de publication (administration) */
.alerte { color: var(--danger); font-weight: 600; }
.titre-mois { margin: 0; text-align: center; }
.titre-mois::first-letter { text-transform: uppercase; }
.planning { width: 100%; border-collapse: separate; border-spacing: 5px; table-layout: fixed; }
.planning th { font-weight: 400; font-size: .75rem; color: var(--doux); text-transform: uppercase; letter-spacing: .08em; }
.planning td.jour {
  position: relative; vertical-align: top; height: 9.5rem; padding: 1.4rem .3rem .3rem;
  background: var(--fond-2); border: 2px dashed transparent; border-radius: 6px;
}
.planning td.passe { opacity: .55; }
.planning td.aujourdhui { border-color: var(--accent); border-style: solid; }
.planning td.survol { border-color: var(--accent); background: var(--ligne); opacity: 1; }
.planning .num { position: absolute; top: .25rem; left: .45rem; font-size: .85rem; color: var(--doux); }
.planning .vignette { position: relative; display: block; margin-bottom: .25rem; cursor: grab; }
.planning .vignette img { display: block; width: 100%; height: 7.6rem; object-fit: cover; border-radius: 3px; }
.planning .vignette.sans-texte img { outline: 3px solid var(--danger); outline-offset: -3px; }
.planning .badge {
  position: absolute; left: 3px; bottom: 3px; padding: 0 .3rem; border-radius: 3px;
  font-size: .62rem; background: var(--danger); color: #fff;
}
.planning .masquee .badge { background: #555; }
.planning .ajouter {
  display: grid; place-items: center; height: 7.6rem; border-radius: 3px; cursor: pointer;
  font-size: 2rem; color: var(--doux); border: 1px dashed var(--ligne);
}
.planning .ajouter:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) {
  .planning { border-spacing: 2px; }
  .planning th { font-size: .55rem; letter-spacing: 0; }
  .planning td.jour { height: 4.6rem; padding: 1rem 1px 1px; }
  .planning .vignette img, .planning .ajouter { height: 3.4rem; font-size: 1.3rem; }
  .planning .badge { font-size: 0; width: .7rem; height: .7rem; padding: 0; border-radius: 50%; }
  .planning .num { font-size: .7rem; top: .1rem; left: .25rem; }
}
.fenetre {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .65);
  display: flex; justify-content: center; align-items: flex-start; padding: 2vh 1rem; overflow-y: auto;
}
.fenetre[hidden] { display: none; }
.fenetre-boite {
  width: 100%; max-width: 52rem; background: var(--fond); border: 1px solid var(--ligne);
  border-radius: 8px; padding: 0 1rem 1rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.fenetre-boite .barre-actions { margin: 0 -1rem 1rem; border-radius: 8px 8px 0 0; }
.a-programmer { list-style: none; margin: 0; padding: 0; }
.a-programmer li { display: flex; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--ligne); }
.a-programmer img { width: 11rem; height: 11rem; object-fit: cover; flex: none; border-radius: 4px; }
.a-programmer .champs { flex: 1; display: flex; flex-direction: column; gap: .4rem; }
.a-programmer label { display: flex; flex-direction: column; gap: .2rem; }
.a-programmer .date-longue { color: var(--accent); }
.a-programmer .discret { align-self: flex-start; background: none; border: 0; padding: 0; color: var(--doux); text-decoration: underline; font-size: .85rem; }
@media (max-width: 600px) {
  .a-programmer li { flex-direction: column; }
  .a-programmer img { width: 100%; height: auto; max-height: 40vh; object-fit: contain; }
}
.progression {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 50;
  padding: .7rem 1.2rem; border-radius: 2rem; background: var(--accent); color: var(--sur-accent);
  font-weight: 600; box-shadow: 0 4px 20px rgba(0, 0, 0, .4); max-width: 90vw;
}

/* Éditeur visuel des pages */
.outils-editeur { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.outils-editeur button { padding: .35rem .7rem; font-size: .9rem; }
.outils-editeur .separateur { width: 1px; align-self: stretch; background: var(--ligne); margin: 0 .2rem; }
.editeur {
  min-height: 50vh; padding: .8rem 1rem; background: var(--fond-2); border: 1px solid var(--ligne);
  border-radius: 6px; outline: none; line-height: 1.6;
}
.editeur:focus { border-color: var(--accent); }
.editeur h2 { margin-top: 1rem; }

/* Administration */
.liste-admin { list-style: none; padding: 0; margin: 0; }
.liste-admin li { display: flex; gap: .8rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--ligne); font-size: .92rem; }
.liste-admin img, .vignette-vide { width: 72px; height: 72px; object-fit: cover; flex: none; display: block; background: var(--fond-2); }
.cartes-admin { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 1rem .8rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.cartes-admin li { font-size: .85rem; min-width: 0; }
.cartes-admin a { display: block; color: var(--accent); }
.cartes-admin img, .cartes-admin .vignette-vide { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; background: var(--fond-2); margin-bottom: .35rem; border-radius: 3px; }
.cartes-admin a:hover img { outline: 2px solid var(--accent); }
.cartes-admin small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--doux); margin-top: .15rem; }
@media (max-width: 480px) { .cartes-admin { grid-template-columns: repeat(3, 1fr); gap: .6rem .4rem; } }
.images-expo { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.images-expo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.images-expo .actions { display: flex; gap: .3rem; margin-top: .3rem; }
.images-expo button { padding: .25rem .6rem; font-size: .85rem; }

/* Pages de texte et expositions */
.texte h2 { color: var(--accent); }
.expo { margin-bottom: 3rem; }
.expo img { display: block; max-width: 100%; margin: 0 auto 1rem; box-shadow: var(--ombre); border: var(--cadre); }
.expo p { font-family: var(--legende); }

/* Statistiques (administration) */
.stats { width: 100%; border-collapse: collapse; margin: .5rem 0 1.5rem; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: .35rem .6rem; border-bottom: 1px solid var(--ligne); text-align: right; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats th { font-weight: normal; opacity: .7; }
.stats .barre-col { width: 40%; text-align: left; }
.stats .barre { display: block; height: .7rem; min-width: 1px; background: var(--accent); border-radius: 2px; }
.stats-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 2rem; }
.stats-top h3 { margin: .5rem 0; }

/* Livre d'or */
.livre-ecrire { margin: 1rem 0 1.5rem; }
.livre-ecrire > summary { display: inline-block; list-style: none; cursor: pointer; }
.livre-ecrire > summary::-webkit-details-marker { display: none; }
.livre-ecrire[open] > summary { opacity: .6; }
.livre-ecrire[open] > form { margin-top: 1rem; padding: 1rem 0; border-top: 1px solid var(--ligne); border-bottom: 1px solid var(--ligne); }
.livre-ligne { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; }
.piege { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.livre { list-style: none; margin: 0; padding: 0; }
.livre > li { padding: 1rem 1.2rem; margin-bottom: 1rem; background: var(--fond-2); border: 1px solid var(--ligne); border-left: 3px solid var(--accent); border-radius: 4px; }
.livre-auteur small { opacity: .65; margin-left: .4rem; }
.livre p { margin: .4rem 0; }
.livre-reponse { margin: .5rem 0 0 1rem; padding-left: .8rem; border-left: 2px solid var(--accent); opacity: .9; }
.livre-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.livre-actions form { margin: 0; }

/* Accueil sans photo du jour */
.pas-de-photo { text-align: center; color: var(--doux); padding: 3rem 1rem 4rem; }
.pas-de-photo .cadre-vide {
  width: min(420px, 80%); aspect-ratio: 3 / 2; margin: 0 auto 1.5rem;
  display: grid; place-items: center; font-size: 3rem; opacity: .35;
  border: 2px dashed var(--ligne); border-radius: 6px; background: var(--fond-2);
}
.pas-de-photo .titre { font-size: 1.5rem; color: var(--texte); margin-bottom: .5rem; }
.pas-de-photo p { max-width: 34rem; margin-left: auto; margin-right: auto; }

/* Statistiques : graphiques SVG */
.graphique { width: 100%; height: auto; display: block; margin: .3rem 0 1.5rem; }
.graphique .grille { stroke: var(--ligne); stroke-width: 1; }
.graphique .axe { fill: var(--doux); font-size: 11px; }
.graphique .fond-col { fill: transparent; }
.graphique g:hover .fond-col { fill: var(--fond-2); }
.graphique .vis { fill: var(--accent); }
.graphique .pages { fill: none; stroke: var(--doux); stroke-width: 2; stroke-linejoin: round; }
.legende-graphe { color: var(--doux); font-size: .9rem; margin: 0; }
.pastille { display: inline-block; width: .8rem; height: .8rem; vertical-align: -.05rem; margin: 0 .2rem 0 .8rem; border-radius: 2px; }
.pastille.vis { background: var(--accent); margin-left: 0; }
.pastille.pages { height: 3px; vertical-align: .2rem; background: var(--doux); }

/* Statistiques : cartes des visiteurs */
.cartes { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; align-items: end; margin: .5rem 0 1rem; }
@media (max-width: 700px) { .cartes { grid-template-columns: 1fr; } }
.cartes figure { margin: 0; }
.cartes figcaption { color: var(--doux); font-size: .85rem; text-align: center; margin-top: .3rem; }
.carte { width: 100%; height: auto; display: block; background: #2a3138; border: 1px solid var(--ligne); border-radius: 4px; }
.carte .terres { fill: #8a8178; stroke: #b3aa9f; stroke-width: .6; }
.carte .voisins { fill: #5d5750; stroke: #7d756b; stroke-width: .6; }
.carte circle { fill: #f2b84b; fill-opacity: .75; stroke: #fff3d6; stroke-width: 1; }
.carte circle:hover { fill-opacity: .9; }
