/* =========================================================
   Bethléem — Notes d'article avec pop-up au survol / toucher
   Fichier : assets/css/beth-footnotes.css
   ========================================================= */

:root {
  --beth-note-text: #2F2A26;
  --beth-note-bg: #FFFDF8;
  --beth-note-bg-soft: #FAF8F3;
  --beth-note-gold: #B08D57;
  --beth-note-gold-dark: #8F6F3F;
  --beth-note-border: rgba(176, 141, 87, 0.42);
  --beth-note-shadow: rgba(47, 42, 38, 0.18);
}

/* =========================================================
   Sécurité Divi : éviter que les pop-ups soient coupés
   ========================================================= */

.et_pb_text_inner,
.et_pb_module,
.et_pb_column {
  overflow: visible;
}

/* =========================================================
   Appel de note dans le texte
   ========================================================= */

.beth-footnote-call {
  position: relative;
  display: inline-block;
  line-height: 1;
  overflow: visible;
  vertical-align: baseline;
}

.beth-footnote-ref {
  display: inline-block;
  color: var(--beth-note-gold);
  text-decoration: none;
  font-weight: 600;
  margin-left: 0.08em;
  line-height: 1;
  cursor: pointer;
}

.beth-footnote-ref sup,
.et_pb_text_inner .beth-footnote-ref sup,
.entry-content .beth-footnote-ref sup {
  font-size: 0.66em !important;
  line-height: 0 !important;
  vertical-align: super !important;
  position: relative;
  top: -0.12em;
}

.beth-footnote-ref:hover,
.beth-footnote-ref:focus {
  color: var(--beth-note-gold-dark);
  text-decoration: none;
  outline: none;
}

/* Surbrillance douce quand on revient depuis la note finale */

.beth-footnote-call:target .beth-footnote-ref {
  background: rgba(176, 141, 87, 0.14);
  border-radius: 999px;
  padding: 0.05em 0.28em;
}

/* =========================================================
   Pop-up de note — desktop
   ========================================================= */

.beth-footnote-popover {
  position: absolute;
  left: 50%;
  bottom: 1.8em;
  z-index: 999999;

  width: 28rem;
  max-width: min(28rem, calc(100vw - 2rem));

  color: var(--beth-note-text);
  background: var(--beth-note-bg);

  border: 1px solid var(--beth-note-border);
  border-radius: 12px;
  box-shadow: 0 10px 28px var(--beth-note-shadow);

  font-size: 0.9rem;
  line-height: 1.45;
  font-weight: 400;
  text-align: left;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transform: translateX(-50%) translateY(6px);
  transition:
    opacity 0.18s ease,
    visibility 0.18s ease,
    transform 0.18s ease;
}

.beth-footnote-popover-inner {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--beth-note-bg);
  color: var(--beth-note-text);
  border-radius: 12px;
}

/* Petite pointe du pop-up */

.beth-footnote-popover::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;

  width: 12px;
  height: 12px;

  background: var(--beth-note-bg);
  border-right: 1px solid var(--beth-note-border);
  border-bottom: 1px solid var(--beth-note-border);

  transform: translateX(-50%) rotate(45deg);
}

/* Affichage au survol et au focus clavier */

.beth-footnote-call:hover .beth-footnote-popover,
.beth-footnote-call:focus-within .beth-footnote-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Contenu du pop-up */

.beth-footnote-popover p {
  margin: 0 0 0.65em 0;
}

.beth-footnote-popover p:last-child {
  margin-bottom: 0;
}

.beth-footnote-popover a {
  color: var(--beth-note-gold-dark);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.beth-footnote-popover em,
.beth-footnote-popover cite {
  font-style: italic;
}

.beth-footnote-popover strong {
  font-weight: 600;
}

/* =========================================================
   Bloc final des notes
   ========================================================= */

.beth-notes {
  margin-top: 3.5rem;
  padding-top: 1.35rem;

  border-top: 1px solid rgba(176, 141, 87, 0.45);

  color: var(--beth-note-text);
  font-size: 0.92em;
  line-height: 1.55;

  overflow: visible;
}

.beth-notes-title {
  margin: 0 0 1rem 0;

  font-family: "Spectral", serif;
  font-size: 20px !important;
  font-weight: 500;
  line-height: 1.25;

  color: var(--beth-note-text);
}

.beth-notes-list {
  margin: 0;
  padding-left: 1.45rem;
}

.beth-note-item {
  margin-bottom: 0.75rem;
  padding-left: 0.2rem;
  color: var(--beth-note-text);
}

.beth-note-content {
  display: inline;
}

.beth-note-content p {
  margin: 0 0 0.65em 0;
}

.beth-note-content p:last-child {
  margin-bottom: 0;
}

.beth-note-content a {
  color: var(--beth-note-gold-dark);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.beth-note-content em,
.beth-note-content cite {
  font-style: italic;
}

.beth-note-content strong {
  font-weight: 600;
}

/* Lien retour */

.beth-note-back {
  color: var(--beth-note-gold);
  text-decoration: none;
  font-weight: 600;
  margin-left: 0.35em;
}

.beth-note-back:hover,
.beth-note-back:focus {
  color: var(--beth-note-gold-dark);
  text-decoration: none;
  outline: none;
}

/* Surbrillance de la note ciblée */

.beth-note-item:target {
  background: rgba(176, 141, 87, 0.11);
  border-left: 3px solid var(--beth-note-gold);
  border-radius: 8px;

  margin-left: -0.8rem;
  padding: 0.45rem 0.65rem 0.45rem 0.8rem;
}

/* =========================================================
   Mobile : pop-up au toucher
   ========================================================= */

@media (max-width: 767px) {
  .beth-footnote-ref sup,
  .et_pb_text_inner .beth-footnote-ref sup,
  .entry-content .beth-footnote-ref sup {
    font-size: 0.72em !important;
    top: -0.1em;
  }

  .beth-footnote-popover {
    display: block !important;

    position: fixed !important;
    left: 1rem !important;
    right: 1rem !important;
    bottom: 1rem !important;
    z-index: 999999 !important;

    width: auto !important;
    max-width: none !important;

    color: var(--beth-note-text) !important;
    background: #FFFDF8 !important;

    border: 1px solid var(--beth-note-border) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 28px var(--beth-note-shadow) !important;

    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    font-weight: 400 !important;
    text-align: left !important;

    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;

    transform: translateY(8px) !important;
    transition:
      opacity 0.18s ease,
      visibility 0.18s ease,
      transform 0.18s ease !important;
  }

  .beth-footnote-popover::after {
    display: none !important;
  }

  /*
   * Sur mobile, on neutralise le hover/focus.
   * Seule la classe .is-open, ajoutée par le JS, affiche la note.
   */

  .beth-footnote-call:hover .beth-footnote-popover,
  .beth-footnote-call:focus-within .beth-footnote-popover {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(8px) !important;
  }

  .beth-footnote-call.is-open .beth-footnote-popover,
  .beth-footnote-call.is-open:hover .beth-footnote-popover,
  .beth-footnote-call.is-open:focus-within .beth-footnote-popover {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
    background: #FFFDF8 !important;
    color: var(--beth-note-text) !important;
  }

  .beth-footnote-popover-inner {
    display: block !important;
    max-height: 45vh;
    overflow-y: auto;
    padding: 0.95rem 1rem;
    background: #FFFDF8 !important;
    color: var(--beth-note-text) !important;
    border-radius: 12px;
  }

  .beth-footnote-popover-inner,
  .beth-footnote-popover-inner p,
  .beth-footnote-popover-inner span,
  .beth-footnote-popover-inner em,
  .beth-footnote-popover-inner strong,
  .beth-footnote-popover-inner cite {
    opacity: 1 !important;
    color: inherit;
  }

  .beth-notes {
    margin-top: 2.75rem;
    font-size: 0.95em;
  }

  .beth-notes-title {
    font-size: 20px !important;
  }

  .beth-note-item {
    margin-bottom: 0.85rem;
  }
}

/* =========================================================
   Impression
   ========================================================= */

@media print {
  .beth-footnote-popover {
    display: none !important;
  }

  .beth-footnote-ref {
    color: #000;
  }

  .beth-note-back {
    display: none;
  }

  .beth-notes {
    border-top: 1px solid #999;
  }
}

/* =========================================================
   Correctif Divi mobile : empêcher le pop-up de passer derrière
   les modules / colonnes / sections suivants
   ========================================================= */

@media (max-width: 980px), (hover: none), (pointer: coarse) {
  .beth-footnote-zlift {
    position: relative !important;
    z-index: 2147483000 !important;
    overflow: visible !important;
  }

  .beth-footnote-call.is-open {
    position: relative !important;
    z-index: 2147483600 !important;
    isolation: isolate !important;
  }

  .beth-footnote-call.is-open .beth-footnote-popover {
    z-index: 2147483647 !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: #FFFDF8 !important;
    color: var(--beth-note-text) !important;
    filter: none !important;
    backdrop-filter: none !important;
    mix-blend-mode: normal !important;
  }

  .beth-footnote-call.is-open .beth-footnote-popover-inner {
    background: #FFFDF8 !important;
    color: var(--beth-note-text) !important;
    opacity: 1 !important;
  }
}