/* Styles spécifiques à encyclopedie.php.
   Externalisés depuis la balise <style> de la page pour faciliter la maintenance. */

* { box-sizing: border-box; }
:root {
  --wood: #7c3f19; --panel: #efe7c8; --accent: #c5522b;
  --green: #1f8f45; --text: #24160d; --bg-card: #f5f0dc;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: #d7b07a;
  background-image:
    linear-gradient(rgba(215, 176, 122, 0.18), rgba(215, 176, 122, 0.18)),
    url("../images/fond-bovins.webp");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  min-height: 100vh;
}
.app { max-width: 1280px; margin: 0 auto; padding: 18px; }


.photo-contribution-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 14px;
  padding: 11px 14px;
  border: 2px solid rgba(47, 107, 53, .62);
  border-radius: 10px;
  background: rgba(239, 247, 222, .95);
  box-shadow: 0 3px 0 rgba(47, 107, 53, .18);
}
.photo-contribution-banner div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.photo-contribution-banner strong {
  color: #245c2c;
  font-size: .96rem;
  line-height: 1.2;
}
.photo-contribution-banner span {
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.3;
  opacity: .82;
}
.photo-contribution-banner a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 8px 13px;
  border: 2px solid #2f7d38;
  border-radius: 8px;
  background: linear-gradient(180deg, #4aa74e, #34863d);
  color: #fff;
  font-size: .88rem;
  font-weight: 900;
  line-height: 1.1;
  text-decoration: none;
  box-shadow: inset 0 -2px 0 rgba(24, 84, 31, .24);
}
.photo-contribution-banner a:hover,
.photo-contribution-banner a:focus-visible {
  background: linear-gradient(180deg, #55b35a, #3d9346);
  outline: none;
}

/* Filtres */
.filters {
  background: rgba(239,231,200,.95);
  border: 4px solid var(--wood);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.filters label { font-weight: 800; font-size: .88rem; display: flex; flex-direction: column; gap: 4px; }
.filters select, .filters input {
  padding: 7px 10px;
  border: 2px solid var(--wood);
  border-radius: 6px;
  font-size: .9rem;
  background: white;
  min-width: 160px;
}
.filters-footer {
  flex: 1 1 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}
.filters-note {
  margin: 0;
  max-width: 900px;
  font-size: .82rem;
  line-height: 1.35;
  font-weight: 700;
  opacity: .78;
}
.filter-count {
  font-weight: 700;
  font-size: .9rem;
  margin-left: auto;
  opacity: .7;
  white-space: nowrap;
  text-align: right;
}
.reset-btn {
  padding: 8px 14px;
  border: 2px solid var(--accent);
  background: #e3de93;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: .85rem;
}
.reset-btn:hover { background: #d5d17f; }

/* Grille de cartes */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.card {
  background: var(--bg-card);
  border: 3px solid var(--wood);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 7px 0 rgba(0,0,0,.15); }
.hidden { display: none !important; }
.card.hidden { display: none; }
.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: linear-gradient(135deg, #dfc178, #c9a85c);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  background: linear-gradient(135deg, #dfc178, #c9a85c);
}
.card-img-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #dfc178, #c9a85c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}
.card-photo-credit {
  position: absolute;
  left: 7px;
  bottom: 7px;
  max-width: calc(100% - 14px);
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: .68rem;
  line-height: 1.15;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}
.card-photo-credit a { color: #fff; text-decoration: underline; }
.card-body { padding: 8px 10px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.card-name {
  font-weight: 900;
  font-size: .95rem;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.validation-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px 4px;
  border-radius: 999px;
  border: 1px solid rgba(124,63,25,.35);
  font-size: .64rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 1px 1px rgba(0,0,0,.08);
}
.validation-label-photo {
  background: #dfe8cf;
  color: #35572d;
  border-color: #9fb27f;
}
.validation-label-text {
  background: #ead9cf;
  color: #7a3f30;
  border-color: #c49a86;
}
.validation-label-full {
  background: #f3e3ad;
  color: #6b4a00;
  border-color: #d0ad58;
}
.card-pays { font-size: .75rem; opacity: .75; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flag-icon {
  width: 1.25em;
  height: .88em;
  object-fit: cover;
  display: inline-block;
  vertical-align: -0.1em;
  margin-right: .35em;
  border: 1px solid rgba(36,22,13,.22);
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.16);
}
.card-pays .flag-icon { width: 1.15em; height: .82em; }
.origin-location .flag-icon { width: 1.3em; height: .92em; }

.card-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: .68rem;
  font-weight: 700;
}
.tag-aptitude { background: #d4edda; color: #155724; }
.tag-niveau   { background: #fff3cd; color: #856404; }
.tag-format   { background: #e2e8f0; color: #2d3748; }
.fiche-approval {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 2px solid rgba(215,169,0,.75);
  border-radius: 10px;
  background: rgba(255,241,184,.55);
  color: #5a2a12;
  font-size: .9rem;
  line-height: 1.35;
}
.fiche-approval-title { font-weight: 1000; color: #7a4c00; margin-bottom: 2px; }
.fiche-approval-meta { font-size: .82rem; opacity: .88; }
.fiche-approval a { color: var(--accent); font-weight: 900; }

/* Aucun résultat */
.no-result { text-align: center; padding: 60px 20px; font-size: 1.2rem; opacity: .6; grid-column: 1/-1; }

/* Dialog fiche */
dialog {
  --fiche-photo-h: min(46vh, 360px);
  border: 4px solid var(--wood);
  border-radius: 12px;
  padding: 0;
  max-width: 880px;
  width: min(96vw, 880px);
  max-height: 92vh;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.fiche-header { position: relative; overflow: hidden; isolation: isolate; }
.fiche-gallery {
  position: relative;
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  background: linear-gradient(135deg, #dfc178, #c9a85c);
  scrollbar-width: none;
  z-index: 1;
}
.fiche-gallery::-webkit-scrollbar { display: none; }
.fiche-photo-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: var(--fiche-photo-h);
  scroll-snap-align: start;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #dfc178, #c9a85c);
}
.fiche-photo-backdrop {
  position: absolute;
  inset: -18px;
  width: calc(100% + 36px);
  height: calc(100% + 36px);
  object-fit: cover;
  object-position: center center;
  filter: blur(16px);
  transform: scale(1.05);
  opacity: .42;
  z-index: 0;
}
.fiche-photo-main {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  background: transparent;
}
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.45);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
.gallery-nav.is-disabled,
.gallery-nav:disabled {
  opacity: .38;
  cursor: default;
}
.gallery-nav.prev { left: 8px; }
.gallery-nav.next { right: 8px; }
.gallery-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 90;
  pointer-events: none;
  box-shadow: 0 1px 5px rgba(0,0,0,.22);
}
.fiche-credit {
  position: absolute;
  bottom: 8px;
  left: 12px;
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 5px 10px;
  border-radius: 999px;
  max-width: calc(100% - 110px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 90;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  text-shadow: 0 1px 1px rgba(0,0,0,.65);
}
.fiche-credit a {
  color: #fff;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}
.fiche-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  max-height: calc(92vh - var(--fiche-photo-h));
  background: var(--panel);
}
.fiche-title { margin: 0 0 4px; font-size: 1.5rem; }
.fiche-origin {
  font-size: .9rem;
  opacity: .9;
  margin: 0 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.origin-category-inline {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #d4edda;
  color: #155724;
  font-weight: 800;
  font-size: .76rem;
  line-height: 1.2;
}
.origin-location {
  opacity: .78;
}
.fiche-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.fiche-info {
  background: rgba(255,255,255,.5);
  border: 1px solid rgba(124,63,25,.25);
  border-radius: 6px;
  padding: 8px 10px;
}
.fiche-info-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; opacity: .6; }
.fiche-info-value { font-weight: 700; margin-top: 2px; font-size: .9rem; }
.fiche-desc { font-size: .95rem; line-height: 1.55; }
.fiche-desc p { margin: 0 0 10px; }
.fiche-photo-credits {
  margin-top: 14px;
  padding: 12px 14px;
  border: 2px dashed rgba(124,63,25,.55);
  border-radius: 10px;
  background: rgba(255,255,255,.45);
}
.fiche-photo-credits h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--accent);
}
.photo-credit-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .9rem;
}
.photo-credit-list li {
  padding: 7px 9px;
  border-radius: 7px;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(124,63,25,.22);
}
.photo-credit-list a { color: var(--accent); font-weight: 900; }
.fiche-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,.5);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
.fiche-niveaux { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }

.site-footer {
  margin: 24px auto 4px;
  padding: 12px 0;
  text-align: center;
  font-size: .84rem;
  font-weight: 800;
  opacity: .82;
}
.site-footer a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-footer a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .app { padding: 12px; }
.filters-footer { flex-direction: column; gap: 6px; }
  .filter-count { margin-left: 0; text-align: left; }
  dialog { --fiche-photo-h: 220px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
  .card-body { padding: 7px 8px; }
  .card-name { font-size: .88rem; }
  .validation-label { font-size: .58rem; padding: 3px 7px 4px; }
}

/* Fond illustré bovin : version téléphone portrait */
@media (max-width: 700px) and (orientation: portrait) {
  body {
    background-image:
      linear-gradient(rgba(215, 176, 122, 0.18), rgba(215, 176, 122, 0.18)),
      url("../images/fond-bovins-mobile.webp");
    background-position: center top;
    background-attachment: scroll;
  }
}

/* Téléphone paysage : même fond large que l’accueil, sans fixed pour éviter les saccades */
@media (max-width: 950px) and (max-height: 620px) and (orientation: landscape) {
  body {
    background-color: #d7b07a;
    background-image:
      linear-gradient(rgba(215, 176, 122, 0.14), rgba(215, 176, 122, 0.14)),
      url("../images/fond-bovins.webp");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: scroll;
  }
}

  

/* v galerie stable — boutons précédent / suivant centrés sur la photo
   Correctif ajouté sans modifier la logique JS : les flèches restent
   ancrées au milieu de la zone image, même si le contenu de la fiche varie. */
.fiche-header {
  height: var(--fiche-photo-h);
  min-height: var(--fiche-photo-h);
  max-height: var(--fiche-photo-h);
  overflow: hidden;
}

.fiche-gallery {
  height: 100%;
  min-height: 100%;
}

.fiche-photo-slide {
  height: 100%;
  min-height: 100%;
}

.gallery-nav {
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 40px;
  height: 40px;
  font-size: 1.25rem;
  line-height: 1;
  z-index: 95;
}

.gallery-nav.prev { left: 10px; }
.gallery-nav.next { right: 10px; }

.gallery-nav:focus-visible {
  outline: 3px solid rgba(255,255,255,.92);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .gallery-nav {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  .gallery-nav.prev { left: 8px; }
  .gallery-nav.next { right: 8px; }
}


/* Mise en évidence d'une fiche ouverte depuis le mode Défi. */
.card.is-direct-target {
  outline: 4px solid rgba(31,143,69,.75);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px rgba(31,143,69,.18), 0 7px 0 rgba(0,0,0,.15);
}


@media (max-width: 700px) {
  .photo-contribution-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
  }
  .photo-contribution-banner a {
    width: 100%;
    min-height: 43px;
  }
}
