/* ==================================================================
   Carnet de Pairi Daiza — feuille de style
   Palette : forêt profonde, or de laiton, terracotta, parchemin
   ================================================================== */

:root {
  --forest: #1f3a2e;
  --forest-dark: #142720;
  --parchment: #f3ecd9;
  --parchment-2: #eae0c6;
  --gold: #c89b3c;
  --gold-light: #e4c878;
  --terracotta: #b5563c;
  --ink: #23201b;
  --ink-soft: #57503f;
  --sage: #8fa88a;
  --white-soft: #fffdf7;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Work Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;

  --radius-s: 6px;
  --radius-m: 12px;
  --shadow-card: 0 6px 18px rgba(31, 58, 46, 0.14);
  --shadow-lift: 0 14px 34px rgba(31, 58, 46, 0.22);
  --compact-hero-height: 96px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper grain, purely decorative, ignored by screen readers */
.paper-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(
      circle at 20% 20%,
      rgba(31, 58, 46, 0.035) 0,
      transparent 45%
    ),
    radial-gradient(
      circle at 80% 60%,
      rgba(181, 86, 60, 0.035) 0,
      transparent 45%
    );
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

a {
  color: inherit;
}

/* ---------------------------------------------------------------
   Hero
   --------------------------------------------------------------- */
.hero {
  position: relative;
  background: linear-gradient(
    180deg,
    var(--forest) 0%,
    var(--forest-dark) 100%
  );
  color: var(--parchment);
  padding: 4.5rem 1.5rem 4rem;
  text-align: center;
  overflow: hidden;
  transition: padding 0.25s ease, min-height 0.25s ease;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
    rgba(228, 200, 120, 0.09) 1px,
    transparent 1px
  );
  background-size: 22px 22px;
  opacity: 0.6;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  transition: max-width 0.25s ease;
}

.hero-logo {
  display: block;
  height: 160px;
  width: auto;
  margin: 0 auto 1.5rem;
  filter: brightness(0) invert(1);
  opacity: 0.95;
  transition: height 0.25s ease, margin 0.25s ease;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--gold-light);
  margin: 0 0 1rem;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
  transition: font-size 0.25s ease, margin 0.25s ease;
}

.hero-title span {
  font-style: italic;
  font-weight: 500;
  color: var(--gold-light);
}

.hero-subtitle {
  font-size: 1.05rem;
  color: rgba(243, 236, 217, 0.8);
  max-width: 480px;
  margin: 0 auto 2.2rem;
}

.hero-stats {
  display: inline-flex;
  align-items: center;
  gap: 1.1rem;
  background: rgba(243, 236, 217, 0.08);
  border: 1px solid rgba(228, 200, 120, 0.35);
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--gold-light);
}

.stat-label {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(243, 236, 217, 0.65);
}

.stat-sep {
  color: rgba(228, 200, 120, 0.5);
}

/* Version compacte indépendante : elle ne modifie jamais la hauteur de page. */
.compact-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  height: var(--compact-hero-height);
  max-height: 150px;
  padding: 0.65rem 1.5rem;
  overflow: hidden;
  color: var(--parchment);
  background: linear-gradient(180deg, var(--forest) 0%, var(--forest-dark) 100%);
  transform: translateY(-100%);
  transition: transform 0.25s ease;
}

.compact-header.is-visible {
  transform: translateY(0);
}

.compact-header-inner {
  max-width: 980px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.compact-header-logo {
  height: 72px;
  margin: 0;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.compact-header-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.05;
  text-align: left;
}

.compact-header-title span {
  font-style: italic;
  font-weight: 500;
  color: var(--gold-light);
}

@media (max-width: 640px) {
  .compact-header {
    height: 74px;
    padding: 0.5rem 1rem;
  }

  .compact-header-inner {
    gap: 0.7rem;
  }

  .compact-header-logo {
    height: 54px;
  }

  .compact-header-title {
    font-size: 1.25rem;
  }
}

/* ---------------------------------------------------------------
   Main / toolbar
   --------------------------------------------------------------- */
.main {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0;
  margin-bottom: 2rem;
  padding: 0.8rem 0;
  background: var(--parchment);
}

/* La barre ne devient fixe qu'avec l'en-tête compact. */
body.has-compact-header .toolbar {
  position: sticky;
  top: var(--compact-hero-height);
  z-index: 9;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--white-soft);
  border: 1px solid var(--parchment-2);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
}

#search-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.85rem 1.2rem 0.85rem 2.7rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  border-radius: 999px;
  outline-offset: 2px;
}

#search-input::placeholder {
  color: var(--ink-soft);
  opacity: 0.7;
}

.filter-selects {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  justify-content: center;
  gap: 0.7rem;
}

.filter-select {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--forest);
}

.filter-select select {
  min-width: 180px;
  padding: 0.7rem 2.2rem 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  color: var(--forest);
  background: var(--white-soft);
  border: 1px solid var(--parchment-2);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

.filter-select select:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

.comments-page-link {
  align-self: end;
  padding: 0.72rem 0.95rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--parchment);
  background: var(--forest);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-card);
  text-decoration: none;
}

.comments-page-link:hover { background: var(--terracotta); }

/* Page de tous les commentaires */
.comments-page { padding-top: 3rem; }
.comments-back { font-family: var(--font-mono); color: var(--forest); text-decoration: none; }
.comments-page-heading { margin: 1.5rem 0; }
.comments-page-heading h1 { margin: 0; font-family: var(--font-display); color: var(--forest); }
.comments-page-heading p, .comment-page-photo, .comment-page-card time { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-soft); }
.comments-page-list { display: grid; gap: 1rem; }
.comment-page-card { display: flex; gap: 1rem; padding: 1rem; background: var(--white-soft); border-radius: var(--radius-m); box-shadow: var(--shadow-card); }
.comment-page-thumb-button { width: 120px; height: 90px; flex: 0 0 auto; padding: 0; border: 0; border-radius: var(--radius-s); background: none; cursor: zoom-in; overflow: hidden; }
.comment-page-thumb-button:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; }
.comment-page-thumb { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-s); transition: transform 0.2s ease; }
.comment-page-thumb-button:hover .comment-page-thumb { transform: scale(1.06); }
.comment-page-content { min-width: 0; flex: 1; }
.comment-page-photo, .comment-page-author, .comment-page-text { margin: 0 0 0.45rem; }
.comment-page-author { font-family: var(--font-display); font-weight: 600; color: var(--forest); }
.comment-page-text { line-height: 1.5; }
.comments-notice { padding: 0.75rem 1rem; border-radius: var(--radius-s); }
.comments-notice.success { background: #e2f0df; color: #285b2b; }
.comments-notice.error { background: #f8e0da; color: #842d1f; }
.comment-edit-form { display: grid; gap: 0.6rem; margin-bottom: 0.6rem; }
.comment-edit-form label { display: grid; gap: 0.25rem; font-family: var(--font-mono); font-size: 0.75rem; color: var(--forest); }
.comment-edit-form input, .comment-edit-form textarea { width: 100%; box-sizing: border-box; padding: 0.55rem 0.65rem; font: inherit; border: 1px solid var(--sage); border-radius: var(--radius-s); }
.comment-edit-form textarea { min-height: 90px; resize: vertical; }
.comment-page-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.comment-page-actions button { padding: 0.6rem 0.9rem; border: 1px solid transparent; border-radius: 999px; font-family: var(--font-mono); font-size: 0.78rem; cursor: pointer; transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease; }
.comment-page-actions button:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.comment-page-actions button[name="action"][value="update"] { color: var(--parchment); background: var(--forest); }
.comment-page-actions button[name="action"][value="update"]:hover { background: var(--terracotta); }
.comment-delete { color: #fff; background: #9f3426; }
.comment-delete:hover { background: #7e241a; }

@media (max-width: 640px) {
  :root {
    --compact-hero-height: 74px;
  }

  .comments-page-link { align-self: auto; }
  .comment-page-thumb-button { width: 82px; height: 62px; }
}

/* ---------------------------------------------------------------
   Category "stamps"
   --------------------------------------------------------------- */
.stamp-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  overflow-x: hidden;
  padding: 0.4rem 0.2rem 1.6rem;
  margin-bottom: 0.5rem;
  scrollbar-width: none;
}

.stamp {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--forest);
  background: var(--white-soft);
  border: 1.5px dashed var(--sage);
  border-radius: 999px;
  padding: 0.55rem 1.05rem;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
}

.stamp .stamp-count {
  font-size: 0.72rem;
  opacity: 0.6;
}

.stamp:hover {
  transform: rotate(-1deg) translateY(-2px);
  border-color: var(--terracotta);
}

.stamp:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

.stamp.active {
  background: var(--forest);
  border-color: var(--gold);
  border-style: solid;
  color: var(--parchment);
  transform: rotate(-1deg);
}

.stamp-icon {
  font-size: 1rem;
}

/* ---------------------------------------------------------------
   Gallery grid — scrapbook cards
   --------------------------------------------------------------- */
.gallery-wrap {
  min-height: 40vh;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.6rem;
}

.photo-card {
  position: relative;
  background: var(--white-soft);
  border-radius: var(--radius-m);
  padding: 0.6rem 0.6rem 0.9rem;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transform: rotate(var(--tilt, 0deg));
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  animation: rise 0.4s ease both;
}

.photo-card:hover {
  transform: rotate(0deg) translateY(-4px) scale(1.015);
  box-shadow: var(--shadow-lift);
  z-index: 2;
}

.photo-card:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
}

.photo-card .tape {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 64px;
  height: 22px;
  background: rgba(228, 200, 120, 0.55);
  border: 1px solid rgba(200, 155, 60, 0.4);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  background: var(--parchment-2);
}

.photo-card .card-meta {
  padding: 0.65rem 0.35rem 0.1rem;
}

.card-category {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--terracotta);
  display: block;
  margin-bottom: 0.2rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.2rem;
  color: var(--ink);
}

.card-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) rotate(var(--tilt, 0deg));
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--tilt, 0deg));
  }
}

/* ---------------------------------------------------------------
   States: empty / loader / load more
   --------------------------------------------------------------- */
.empty-state {
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-soft);
  padding: 3rem 1rem;
}

.loader {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 2rem 0;
}

.load-more {
  display: block;
  margin: 2.4rem auto 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--forest);
  color: var(--parchment);
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.8rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.load-more[hidden] {
  display: none !important;
}

.load-more:hover {
  background: var(--terracotta);
  transform: translateY(-2px);
}

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 2.5rem 1.5rem 3rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  border-top: 1px dashed var(--parchment-2);
}

.admin-link {
  display: inline-block;
  margin-top: 0.6rem;
  color: var(--terracotta);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.admin-link:hover {
  border-color: var(--terracotta);
}

/* ---------------------------------------------------------------
   Lightbox
   --------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 39, 32, 0.92);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 50;
  padding: 2rem;
  overflow-y: auto;
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox-content {
  max-width: 1000px;
  width: 100%;
  max-height: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: auto 0;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 55vh;
  border-radius: var(--radius-s);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.lightbox-info {
  text-align: center;
  color: var(--parchment);
  max-width: 620px;
}

.lightbox-category {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-light);
}

.lightbox-info h2 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0.3rem 0;
  font-size: 1.4rem;
}

.lightbox-info p {
  color: rgba(243, 236, 217, 0.85);
  margin: 0.3rem 0;
}

.lightbox-date {
  display: inline-block;
  margin-top: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--sage);
}

.lightbox-close,
.lightbox-nav {
  position: fixed;
  background: rgba(243, 236, 217, 0.1);
  border: 1px solid rgba(228, 200, 120, 0.4);
  color: var(--parchment);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(228, 200, 120, 0.25);
}

.lightbox-close {
  top: 1.5rem;
  right: 1.5rem;
  z-index: 51;
}
.lightbox-prev {
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-next {
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
}

@media (max-width: 640px) {
  .lightbox-nav {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
  .lightbox {
    padding: 1rem;
  }
}

/* ---------------------------------------------------------------
   Commentaires (lightbox)
   --------------------------------------------------------------- */
.lightbox-comments {
  /* width: 100%; */
  width: 480px;
  margin: 1rem auto 0;
  text-align: left;
}

.lightbox-comments h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold-light);
  margin: 0 0 0.8rem;
  text-align: center;
}

.photo-comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.2rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.comment {
  background: rgba(243, 236, 217, 0.08);
  border: 1px solid rgba(228, 200, 120, 0.25);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.8rem;
}

.comment strong {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--gold-light);
}

.comment .comment-date {
  float: right;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--sage);
}

.comment p {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: rgba(243, 236, 217, 0.9);
  clear: both;
}

.no-comments {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--sage);
  text-align: center;
}

.photo-comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.photo-comment-form input,
.photo-comment-form textarea {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(228, 200, 120, 0.35);
  border-radius: var(--radius-s);
  background: rgba(243, 236, 217, 0.08);
  color: var(--parchment);
}

.photo-comment-form input::placeholder,
.photo-comment-form textarea::placeholder {
  color: rgba(243, 236, 217, 0.5);
}

.photo-comment-form input:focus,
.photo-comment-form textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(243, 236, 217, 0.14);
}

.photo-comment-form textarea {
  min-height: 70px;
  resize: vertical;
}

.photo-comment-form button {
  align-self: flex-end;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--gold);
  color: var(--forest-dark);
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.photo-comment-form button:hover {
  background: var(--gold-light);
}

/* Honeypot : invisible pour les humains, visible pour les bots */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none;
}

/* ---------------------------------------------------------------
   Admin page
   --------------------------------------------------------------- */
.admin-page {
  background: var(--parchment);
  min-height: 100vh;
}

.admin-wrap {
  max-width: 75%;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.admin-back {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.admin-back:hover {
  color: var(--terracotta);
}

.admin-card {
  background: var(--white-soft);
  border-radius: var(--radius-m);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.admin-card h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 0.4rem;
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.admin-hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 1.4rem;
}

.admin-error {
  background: rgba(181, 86, 60, 0.1);
  color: var(--terracotta);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-s);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-form label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-top: 0.7rem;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--parchment-2);
  border-radius: var(--radius-s);
  background: var(--parchment);
  color: var(--ink);
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  outline: 2px solid var(--terracotta);
  outline-offset: 1px;
}

.admin-form button {
  margin-top: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: var(--forest);
  color: var(--parchment);
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.admin-form button:hover {
  background: var(--terracotta);
}

.admin-logout {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--terracotta);
  text-decoration: none;
}

.admin-status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin-top: 0.8rem;
  min-height: 1.2em;
}

.admin-status.success {
  color: var(--forest);
}
.admin-status.error {
  color: var(--terracotta);
}

/* ---------------------------------------------------------------
   Gestion des catégories — tableau interactif
   --------------------------------------------------------------- */
.categories-list {
  margin-bottom: 2rem;
  overflow-x: auto;
}

.categories-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  background: var(--white-soft);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.categories-table thead {
  background: var(--forest);
  color: var(--parchment);
}

.categories-table th {
  text-align: left;
  padding: 0.9rem 1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.categories-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--parchment-2);
}

.categories-table tbody tr:last-child td {
  border-bottom: none;
}

.categories-table tbody tr:hover {
  background: rgba(31, 58, 46, 0.03);
}

.categories-table .editable {
  cursor: pointer;
  position: relative;
  padding: 0.7rem 1rem;
}

.categories-table .editable:hover:not(.editing) {
  background: rgba(196, 155, 60, 0.1);
  border-radius: 4px;
}

.categories-table .editable.editing {
  padding: 0.4rem 0.7rem;
}

.categories-table .edit-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.categories-table .edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(196, 155, 60, 0.3);
}

.categories-table .sort-input {
  width: 50px;
  padding: 0.5rem;
  border: 1px solid var(--sage);
  border-radius: 4px;
  font-family: var(--font-mono);
  text-align: center;
}

.categories-table .sort-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(196, 155, 60, 0.2);
}

.categories-table .actions {
  text-align: right;
  white-space: nowrap;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.categories-table .btn-edit,
.categories-table .btn-delete {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--sage);
  color: var(--forest);
  border-radius: 4px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.categories-table .btn-edit:hover {
  background: var(--forest);
  color: var(--parchment);
  border-color: var(--forest);
}

.categories-table .btn-delete:hover {
  background: var(--terracotta);
  color: var(--parchment);
  border-color: var(--terracotta);
}

.btn-add-category {
  background: var(--forest);
  color: var(--parchment);
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-add-category:hover {
  background: var(--terracotta);
}

.slug-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.categories-list .error {
  color: var(--terracotta);
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------
   Panneau d'administration
   --------------------------------------------------------------- */
.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.admin-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--forest);
}

.admin-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  background: var(--white-soft);
  border: 2px solid var(--sage);
  border-radius: var(--radius-m);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  cursor: pointer;
  text-align: center;
}

.admin-panel:hover {
  background: var(--parchment-2);
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.admin-panel .panel-icon {
  font-size: 3rem;
}

.admin-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--forest);
}

.admin-panel .panel-count {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0;
}

.admin-panel .panel-description {
  font-size: 0.9rem;
  color: var(--ink);
  margin: 0;
  line-height: 1.4;
}

.admin-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--sage);
}

/* Layout principal avec 75% de largeur */
.admin-main {
  margin: 0 auto;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.admin-card-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}
.btn-open-modal {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  background: #2f7d4f;
  color: #fff;
  font-weight: 600;
}
.btn-open-modal:hover {
  background: #256640;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.is-open {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
}
.modal-close:hover {
  color: #000;
}

.categories-table .thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

/* ---------------------------------------------------------------
   Gallery grid — cartes photo (classes générées par app.js)
   --------------------------------------------------------------- */
.gallery-item {
  position: relative;
  background: var(--white-soft);
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  animation: rise 0.4s ease both;
}

.gallery-item:hover {
  transform: translateY(-4px) scale(1.015);
  box-shadow: var(--shadow-lift);
  z-index: 2;
}

.gallery-item:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
}

.gallery-image {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--parchment-2);
}

.gallery-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.2rem 0.9rem 0.8rem;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(20, 39, 32, 0.75) 100%
  );
  color: var(--parchment);
}

.gallery-category {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold-light);
  margin: 0 0 0.2rem;
}

.gallery-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--white-soft);
}
.thumb-clickable {
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.thumb-clickable:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-card);
}

.modal-box-image {
  max-width: 90vw;
  max-height: 90vh;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  box-shadow: none;
}

.modal-box-image img {
  max-width: 100%;
  max-height: 85vh;
  display: block;
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-lift);
}

.modal-box-image .modal-close {
  background: var(--forest);
  color: var(--parchment);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  top: 0.5rem;
  right: 0.5rem;
}

.modal-box-image .modal-close:hover {
  background: var(--terracotta);
}

/* ---------------------------------------------------------------
   Responsive — tablette et mobile
   --------------------------------------------------------------- */
img,
svg {
  max-width: 100%;
}

.lightbox-comments {
  width: min(480px, 100%);
}

@media (max-width: 900px) {
  .main {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
    gap: 1rem;
  }

  .admin-wrap {
    max-width: 100%;
    padding: 2rem 1rem;
  }

  .lightbox {
    padding: 1rem;
  }

  .lightbox-content img {
    max-height: 48vh;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 3rem 1rem 2.5rem;
  }

  .hero-logo {
    height: 120px;
    margin-bottom: 1rem;
  }

  .hero-title {
    font-size: clamp(2rem, 10vw, 2.8rem);
  }

  .hero-stats {
    gap: 0.8rem;
    padding: 0.6rem 1.1rem;
  }

  .toolbar {
    gap: 0.65rem;
    margin-bottom: 1.25rem;
  }

  .search-box {
    max-width: none;
  }

  .filter-selects {
    gap: 0.55rem;
  }

  .filter-select select {
    min-width: 0;
    width: 100%;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
    gap: 0.8rem;
  }

  .lightbox {
    padding: 0.75rem;
  }

  .lightbox-content {
    gap: 0.75rem;
  }

  .lightbox-content img {
    max-height: 42vh;
  }

  .lightbox-close {
    top: 0.6rem;
    right: 0.6rem;
  }

  .lightbox-prev { left: 0.4rem; }
  .lightbox-next { right: 0.4rem; }

  .lightbox-comments {
    margin-top: 0.75rem;
  }

  .comment-page-card {
    align-items: flex-start;
  }

  .admin-card {
    padding: 1.25rem;
  }

  .admin-header,
  .admin-card-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .admin-card-header .header-actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }

  .admin-panels {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .modal-overlay {
    padding: 0.75rem;
  }

  .modal-box {
    padding: 1.25rem;
  }
}

@media (max-width: 420px) {
  .main {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-logo {
    height: 100px;
  }

  .filter-selects {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-select,
  .comments-page-link {
    width: 100%;
  }

  .comments-page-link {
    text-align: center;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .comment-page-card {
    flex-direction: column;
  }

  .comment-page-thumb-button {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .comment .comment-date {
    display: block;
    float: none;
    margin-top: 0.2rem;
  }

  .admin-wrap {
    padding: 1.25rem 0.75rem;
  }

  .admin-card {
    padding: 1rem;
  }

  .admin-header h1 {
    font-size: 1.65rem;
  }

  .admin-card-header .header-actions,
  .btn-open-modal {
    width: 100%;
  }

  .categories-table th,
  .categories-table td {
    padding: 0.65rem 0.7rem;
  }
}
