/* ── Lexic-O frontend ─────────────────────────────────────────── */

/* Terme détecté dans le contenu */
.lexico-term {
  position: relative;
  cursor: help;
  border-bottom: 1.5px dotted var(--lexico-term-underline-color, currentColor);
  color: var(--lexico-term-color, inherit);
}
.lexico-term:focus {
  outline: 2px solid var(--lexico-term-underline-color, currentColor);
  outline-offset: 2px;
}

/* Tooltip */
.lexico-tooltip[hidden] { display: none; }
.lexico-tooltip {
  position: absolute;
  z-index: 99998;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(320px, 86vw);
  padding: 12px 14px;
  background: var(--lexico-tooltip-bg, #2f2c29);
  color: var(--lexico-tooltip-color, #fff);
  font-size: 14px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.55;
  text-align: left;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
  cursor: auto;
}
.lexico-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--lexico-tooltip-bg, #2f2c29);
}
/* Pont invisible : comble l'écart de 10px entre le terme et la bulle pour
   que le curseur puisse la rejoindre sans déclencher mouseleave */
.lexico-tooltip::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 12px;
}
.lexico-tooltip.is-below::before {
  top: auto;
  bottom: 100%;
}
/* Ouvert sous le terme (pas de place au-dessus) */
.lexico-tooltip.is-below {
  bottom: auto;
  top: calc(100% + 10px);
}
.lexico-tooltip.is-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--lexico-tooltip-bg, #2f2c29);
}
.lexico-tooltip:not(.is-below)::before { top: 100%; bottom: auto; }
/* Recalé horizontalement par le JS quand il déborde du viewport */
.lexico-tooltip.is-shifted { transform: translateX(var(--lexico-shift, -50%)); }
.lexico-tooltip.is-shifted::after { left: var(--lexico-arrow-left, 50%); }

.lexico-tooltip strong, .lexico-tooltip b { font-weight: 700; }
.lexico-tooltip em, .lexico-tooltip i { font-style: italic; }

/* Lien « définition complète » (affiché quand l'extrait est tronqué) */
.lexico-tooltip__more {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lexico-tooltip-link-color, #d7ae6a);
  text-decoration: none;
  border-bottom: none;
}
.lexico-tooltip__more:hover,
.lexico-tooltip__more:focus {
  text-decoration: underline;
  color: var(--lexico-tooltip-link-color, #d7ae6a);
}

/* ── Glossaire (widget / shortcode) ───────────────────────────── */
.lexico-glossary {
  --lexico-columns: 2;
  color: var(--lexico-def-color, inherit);
}

/* Barre de filtre A–Z */
.lexico-glossary__letters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}
.lexico-glossary__letter {
  min-width: 34px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid var(--lexico-letter-border, rgba(0, 0, 0, .16));
  border-radius: 8px;
  background: var(--lexico-letter-bg, transparent);
  color: var(--lexico-letter-color, inherit);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.lexico-glossary__letter:hover:not(.is-empty),
.lexico-glossary__letter.is-active {
  background: var(--lexico-letter-active-bg, #2f2c29);
  color: var(--lexico-letter-active-color, #fff);
  border-color: var(--lexico-letter-active-bg, #2f2c29);
}
.lexico-glossary__letter.is-empty {
  opacity: .35;
  cursor: default;
  pointer-events: none;
}

/* Groupes par lettre */
.lexico-glossary__group[hidden] { display: none; }
.lexico-glossary__group { margin: 0 0 28px; }
.lexico-glossary__group-letter {
  margin: 0 0 14px;
  font-size: 26px;
  font-weight: 700;
  color: var(--lexico-letter-heading-color, inherit);
  border-bottom: 2px solid var(--lexico-letter-border, rgba(0, 0, 0, .16));
  padding-bottom: 6px;
}
.lexico-glossary__list {
  display: grid;
  grid-template-columns: repeat(var(--lexico-columns, 2), minmax(0, 1fr));
  gap: 18px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lexico-glossary__item { min-width: 0; scroll-margin-top: 90px; }
/* Surlignage bref à l'arrivée depuis un tooltip */
.lexico-glossary__item.is-highlighted {
  animation: lexico-highlight 2.4s ease-out;
  border-radius: 8px;
}
@keyframes lexico-highlight {
  0%, 55% { background: var(--lexico-highlight-bg, rgba(215, 174, 106, .28)); box-shadow: 0 0 0 6px var(--lexico-highlight-bg, rgba(215, 174, 106, .28)); }
  100% { background: transparent; box-shadow: none; }
}
.lexico-glossary__term {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--lexico-term-color, inherit);
}
.lexico-glossary__synonyms {
  margin: 0 0 6px;
  font-size: 13px;
  font-style: italic;
  opacity: .7;
}
.lexico-glossary__definition {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}
.lexico-glossary__definition p { margin: 0 0 8px; }
.lexico-glossary__definition p:last-child { margin-bottom: 0; }

@media (max-width: 680px) {
  .lexico-glossary { --lexico-columns: 1 !important; }
  .lexico-glossary__letter { min-width: 30px; min-height: 30px; font-size: 13px; }
}
