/**
 * Bandeau de consentement aux témoins (Loi 25) — habillage.
 *
 * Les couleurs passent par les variables de la palette du thème
 * (`theme.json` : bleu nuit, orange voyage) avec un repli littéral : le
 * plugin doit rester présentable avec un thème qui n'en déclare aucune.
 *
 * Le bandeau est masqué tant que le script ne l'a pas ouvert : sans
 * JavaScript, il n'occupe aucune place et ne décale rien.
 */

/* Cible tactile minimale, partagée par le bandeau et le bouton du pied de
   page — ces deux-là ne sont pas dans le même arbre. */
:root {
  --ved-consent-touch: 44px;
}

ved-cookie-consent {
  display: none;
}

ved-cookie-consent.-open {
  display: block;
}

.c-cookie-consent {
  --ved-consent-bg: var(--wp--preset--color--night-blue, #083d91);
  --ved-consent-accent: var(--wp--preset--color--travel-orange, #ff8a00);
  --ved-consent-ink: var(--wp--preset--color--white, #fff);
  --ved-consent-radius: 999px;

  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 9999;
  padding: 1rem 1.25rem;
  background: var(--ved-consent-bg);
  border-top: 1px solid rgb(255 255 255 / 15%);
  color: var(--ved-consent-ink);
  font-family: inherit;

  /* Ouverture : le bandeau monte en place une fois la page lue. */
  opacity: 0;
  transform: translateY(1.25rem);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.c-cookie-consent.-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.c-cookie-consent__inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 75rem;
  margin-inline: auto;
}

.c-cookie-consent__text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

.c-cookie-consent__link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--ved-consent-ink);
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.c-cookie-consent__link:hover,
.c-cookie-consent__link:focus-visible {
  color: var(--ved-consent-accent);
}

.c-cookie-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.c-cookie-consent__button {
  flex: 1 1 auto;
  min-height: var(--ved-consent-touch);
  padding: 0.625rem 1.5rem;
  border-radius: var(--ved-consent-radius);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.c-cookie-consent__button.-accept {
  background: var(--ved-consent-accent);
  border: 1px solid var(--ved-consent-accent);
  color: var(--wp--preset--color--ink, #1f2937);
  font-weight: 700;
}

.c-cookie-consent__button.-accept:hover {
  filter: brightness(0.94);
}

.c-cookie-consent__button.-refuse {
  background: transparent;
  border: 1px solid rgb(255 255 255 / 55%);
  color: var(--ved-consent-ink);
  font-weight: 500;
}

.c-cookie-consent__button.-refuse:hover {
  background: rgb(255 255 255 / 12%);
  border-color: var(--ved-consent-ink);
}

.c-cookie-consent__button:focus-visible,
.c-cookie-consent__link:focus-visible {
  outline: 2px solid var(--ved-consent-ink);
  outline-offset: 2px;
}

/* Bouton « Gérer les témoins » du pied de page : un lien, pas un bouton.

   Il doit offrir la même cible de 44 px que les boutons du bandeau sans
   épaissir la ligne légale où il s'aligne sur un lien texte : le surplus,
   vertical comme horizontal, est repris en marge négative. */
.c-footer__link.-consent {
  display: inline-flex;
  align-items: center;
  min-height: var(--ved-consent-touch, 44px);
  padding-inline: 0.5rem;
  margin-block: calc((var(--ved-consent-touch, 44px) - 1.5em) / -2);
  margin-inline: -0.5rem;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.c-footer__link.-consent:focus-visible {
  outline: 2px solid currentcolor;
  outline-offset: 0;
}

@media (min-width: 48rem) {
  .c-cookie-consent__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.875rem;
  }

  .c-cookie-consent__body {
    max-width: 48rem;
  }

  .c-cookie-consent__actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .c-cookie-consent__button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* Mouvement réduit demandé par le système : le bandeau paraît, sans glisser. */
@media (prefers-reduced-motion: reduce) {
  .c-cookie-consent {
    transform: none;
    transition: none;
  }

  .c-cookie-consent.-visible {
    transform: none;
  }

  .c-cookie-consent__button,
  .c-cookie-consent__link {
    transition: none;
  }
}
