/* Gestion du consentement aux cookies — solution maison (remplace Tarteaucitron).
   Markup : PageView/Partials/Consent.html — Logique : JavaScript/consent.js
   S'appuie sur les variables de root.css (--rouge, --bleu, --round, --shadow). */

:root {
  --consent-ink: #111111;
  --consent-muted: #555555;
  --consent-line: rgba(0, 0, 0, 0.08);
  --consent-surface: #ffffff;
  --consent-z: 1999;
}

/* ---------- Boutons ---------- */
.gip-consent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--consent-ink);
  background: var(--consent-surface);
  color: var(--consent-ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.gip-consent-btn:hover { background: #f4f4f4; }
.gip-consent-btn:focus-visible { outline: 3px solid var(--bleu-sombre, #accacf); outline-offset: 2px; }
.gip-consent-btn--primary { background: var(--consent-ink); color: #ffffff; }
.gip-consent-btn--primary:hover { background: #333333; }
.gip-consent-btn--accent { background: var(--rouge, #ed1c24); border-color: var(--rouge, #ed1c24); color: #ffffff; }
.gip-consent-btn--accent:hover { background: #d0141b; border-color: #d0141b; }
.gip-consent-btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--consent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding-left: 12px;
  padding-right: 12px;
}
.gip-consent-btn--ghost:hover { background: transparent; color: var(--rouge, #ed1c24); }

/* ---------- Bandeau ---------- */
.gip-consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: var(--consent-z);
  box-sizing: border-box;
  width: auto;
  max-width: 560px;
  margin: 0;
  padding: 24px;
  border-radius: var(--round, 20px);
  border: 1px solid var(--consent-line);
  background: var(--consent-surface);
  color: var(--consent-ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gip-consent-banner.is-visible { opacity: 1; transform: translateY(0); }
.gip-consent-banner[hidden] { display: none; }

.gip-consent-banner__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.gip-consent-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bleu, #e1eaec);
  color: var(--consent-ink);
}
.gip-consent-banner__title,
.gip-consent-dialog__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
}
.gip-consent-banner__text { margin: 0 0 18px; color: var(--consent-muted); }
.gip-consent-banner__text a,
.gip-consent-dialog a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.gip-consent-banner__text a:hover,
.gip-consent-dialog a:hover { color: var(--rouge, #ed1c24); }

.gip-consent-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.gip-consent-banner__actions .gip-consent-btn { flex: 1 1 auto; }
.gip-consent-banner__actions .gip-consent-btn--ghost { flex: 1 1 100%; justify-content: center; }

@media (min-width: 640px) {
  .gip-consent-banner { left: 24px; right: auto; bottom: 24px; padding: 28px; }
  .gip-consent-banner__actions .gip-consent-btn { flex: 0 1 auto; }
  .gip-consent-banner__actions .gip-consent-btn--ghost { flex: 0 1 auto; margin-left: auto; }
}

/* ---------- Panneau de préférences (dialog natif) ---------- */
.gip-consent-dialog {
  box-sizing: border-box;
  width: min(680px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--round, 20px);
  background: var(--consent-surface);
  color: var(--consent-ink);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow: hidden;
}
.gip-consent-dialog::backdrop { background: rgba(17, 17, 17, 0.55); backdrop-filter: blur(2px); }
.gip-consent-dialog[open] { display: flex; flex-direction: column; }
.gip-consent-dialog__form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }

.gip-consent-dialog__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--consent-line);
}
.gip-consent-dialog__head .gip-consent-dialog__title { flex: 1 1 auto; }
.gip-consent-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--consent-ink);
  cursor: pointer;
}
.gip-consent-close:hover { background: var(--bleu, #e1eaec); }
.gip-consent-close:focus-visible { outline: 3px solid var(--bleu-sombre, #accacf); outline-offset: 2px; }

.gip-consent-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}
.gip-consent-dialog__intro { margin: 0 0 18px; color: var(--consent-muted); }

.gip-consent-cat {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 16px;
  row-gap: 6px;
  padding: 16px 18px;
  margin: 0 0 12px;
  border: 1px solid var(--consent-line);
  border-radius: 14px;
  background: #fafafa;
}
.gip-consent-cat[hidden] { display: none; }
.gip-consent-cat__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  grid-column: 1;
}
.gip-consent-cat__desc { margin: 0; color: var(--consent-muted); grid-column: 1; }
.gip-consent-cat__meta {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.gip-consent-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bleu, #e1eaec);
  font-size: 0.75rem;
  font-weight: 600;
}
.gip-consent-cat__details { grid-column: 1 / -1; margin-top: 6px; font-size: 0.82rem; color: var(--consent-muted); }
.gip-consent-cat__details summary { cursor: pointer; font-weight: 600; color: var(--consent-ink); }
.gip-consent-cat__details summary:hover { color: var(--rouge, #ed1c24); }
.gip-consent-cat__details ul { margin: 8px 0 0; padding-left: 18px; }
.gip-consent-cat__details li { margin: 2px 0; }
.gip-consent-cat__always {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1d7a3f;
  white-space: nowrap;
}

/* Interrupteur */
.gip-consent-switch {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}
.gip-consent-switch input {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 999px;
  border: 0;
  background: #c9c9c9;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.gip-consent-switch input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gip-consent-switch input:checked { background: var(--rouge, #ed1c24); }
.gip-consent-switch input:checked::before { transform: translateX(20px); }
.gip-consent-switch input:focus-visible { outline: 3px solid var(--bleu-sombre, #accacf); outline-offset: 2px; }

.gip-consent-dialog__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--consent-line);
  background: var(--consent-surface);
}
.gip-consent-dialog__foot .gip-consent-btn { flex: 1 1 auto; }
@media (min-width: 640px) {
  .gip-consent-dialog__foot .gip-consent-btn { flex: 0 1 auto; }
  .gip-consent-dialog__foot .gip-consent-btn--primary { margin-left: auto; }
}

/* ---------- Bouton flottant de réouverture ---------- */
.gip-consent-fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: var(--consent-z);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--consent-line);
  border-radius: 50%;
  background: var(--consent-surface);
  color: var(--consent-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.gip-consent-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2); }
.gip-consent-fab:focus-visible { outline: 3px solid var(--bleu-sombre, #accacf); outline-offset: 2px; }
.gip-consent-fab[hidden] { display: none; }
@media (min-width: 640px) { .gip-consent-fab { left: 24px; bottom: 24px; } }

/* ---------- Médias en attente de consentement ---------- */
.gip-consent-embed {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 24px;
  border-radius: 12px;
  background: var(--bleu, #e1eaec);
  color: var(--consent-ink);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
}
.gip-consent-embed p { margin: 0; max-width: 42ch; }
.gip-consent-embed .gip-consent-icon { width: 48px; height: 48px; background: #ffffff; }
.ce-slider__youtube .gip-consent-embed { position: absolute; inset: 0; height: 100%; aspect-ratio: auto; border-radius: 0; }
iframe[data-consent-src][hidden] { display: none; }

/* ---------- Accessibilité / confort ---------- */
@media (prefers-reduced-motion: reduce) {
  .gip-consent-banner,
  .gip-consent-btn,
  .gip-consent-fab,
  .gip-consent-switch input,
  .gip-consent-switch input::before { transition: none; }
}
