/* ===================================================
   TOASTS — système de notification partagé
   API JS : gfToast(message, type, durée) — voir toast.js
   Types : success · error · warning · info
   =================================================== */

.gf-toast-stack {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 11000;
  pointer-events: none;
}

.gf-toast {
  --gf-toast-accent: #83F379;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 560px);
  padding: 13px 24px;
  border-radius: 999px;
  background: rgba(0, 0, 38, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--gf-toast-accent) 35%, transparent);
  box-shadow: 0 14px 40px rgba(0, 0, 38, 0.45);
  color: #fff;
  font-family: 'Roboto Flex', system-ui, sans-serif;
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(-14px) scale(.96);
  transition: opacity .4s ease,
              transform .5s cubic-bezier(.22, 1, .36, 1);
}

.gf-toast--error   { --gf-toast-accent: #EF5CA1; }
.gf-toast--warning { --gf-toast-accent: #FEC00E; }
.gf-toast--info    { --gf-toast-accent: #FFDE00; }

/* Persistant : reste affiché jusqu'à fermeture manuelle */
.gf-toast--sticky {
  pointer-events: auto;
}

.gf-toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  font-size: .65rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, color .2s;
}

.gf-toast-close:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.gf-toast-close:focus-visible {
  outline: 2px solid var(--gf-toast-accent);
  outline-offset: 2px;
}

.gf-toast--show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.gf-toast svg {
  width: 19px;
  height: 19px;
  color: var(--gf-toast-accent);
  flex-shrink: 0;
}

/* L'icône se dessine à l'apparition : contour puis symbole */
.gf-toast svg .gf-toast-outline,
.gf-toast svg .gf-toast-mark {
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
}

.gf-toast--show svg .gf-toast-outline {
  animation: gfToastDraw .5s .1s ease forwards;
}

.gf-toast--show svg .gf-toast-mark {
  animation: gfToastDraw .35s .45s ease forwards;
}

@keyframes gfToastDraw {
  to { stroke-dashoffset: 0; }
}

/* ── Mode mascotte (gfToast.mascot) : la mascotte surgit, puis « parle » —
      la notification se déroule en bulle de dialogue depuis elle ── */
.gf-toast--mascot {
  padding: 0;
  gap: 0;
  background: none;
  border: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.gf-toast-mascot {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 38, 0.45));
  transform: scale(0) rotate(-20deg);
}

.gf-toast--show .gf-toast-mascot {
  animation: gfMascotPop .55s cubic-bezier(.34, 1.56, .64, 1) forwards;
}

@keyframes gfMascotPop {
  to { transform: scale(1) rotate(0deg); }
}

/* La vache frétille pendant qu'elle parle (forwards : reste à scale 1 ensuite) */
.gf-toast--unrolled .gf-toast-mascot {
  animation: gfMascotTalk .9s ease .05s forwards;
}

@keyframes gfMascotTalk {
  0%, 100% { transform: scale(1) rotate(0deg); }
  20%      { transform: scale(1.05) rotate(-5deg); }
  45%      { transform: scale(1) rotate(3deg); }
  70%      { transform: scale(1.02) rotate(-2deg); }
}

/* Queue de la bulle, pointée vers la vache */
.gf-toast-tail {
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-right: 9px solid rgba(0, 0, 38, 0.88);
  border-left: none;
  margin-right: -1px;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .3s ease .12s,
              transform .45s cubic-bezier(.22, 1, .36, 1) .1s;
}

.gf-toast--unrolled .gf-toast-tail {
  opacity: 1;
  transform: none;
}

/* La bulle : reprend le verre navy de la pilule */
.gf-toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(-8px);
  border-radius: 999px;
  background: rgba(0, 0, 38, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--gf-toast-accent) 35%, transparent);
  box-shadow: 0 14px 40px rgba(0, 0, 38, 0.45);
  transition: max-width .7s cubic-bezier(.22, 1, .36, 1),
              padding .7s cubic-bezier(.22, 1, .36, 1),
              opacity .45s ease .1s,
              transform .7s cubic-bezier(.22, 1, .36, 1);
}

.gf-toast--unrolled .gf-toast-body {
  max-width: min(70vw, 460px);
  padding: 12px 22px;
  opacity: 1;
  transform: none;
}

/* Mobile : le message peut passer sur deux lignes une fois déroulé */
@media (max-width: 480px) {
  .gf-toast--unrolled .gf-toast-body {
    white-space: normal;
    line-height: 1.5;
  }
}

/* L'icône se dessine une fois la notification déroulée */
.gf-toast--mascot.gf-toast--show svg .gf-toast-outline {
  animation-delay: .6s;
}

.gf-toast--mascot.gf-toast--show svg .gf-toast-mark {
  animation-delay: .95s;
}

/* ── Mode hero (opts.hero) : grande carte centrée façon Apple Pay,
      puis rétraction vers le haut où la pilule prend le relais ── */
.gf-toast-hero {
  --gf-toast-accent: #83F379;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  max-width: min(92vw, 480px);
  padding: 48px 56px;
  border-radius: 28px;
  background: rgba(0, 0, 38, 0.9);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--gf-toast-accent) 35%, transparent);
  box-shadow: 0 30px 80px rgba(0, 0, 38, 0.55);
  color: #fff;
  font-family: 'Roboto Flex', system-ui, sans-serif;
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.7;
  opacity: 0;
  z-index: 11000;
  pointer-events: none;
  transition: opacity .4s ease,
              transform .55s cubic-bezier(.22, 1, .36, 1);
}

.gf-toast-hero--show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Rétraction : file vers la position de la pilule en rapetissant */
.gf-toast-hero--out {
  opacity: 0;
  transform: translate(-50%, calc(-50vh + 100px)) scale(.18);
  transition: opacity .45s ease,
              transform .45s cubic-bezier(.5, 0, .8, .4);
}

.gf-toast-hero svg {
  width: 88px;
  height: 88px;
  color: var(--gf-toast-accent);
}

.gf-toast-hero svg .gf-toast-outline,
.gf-toast-hero svg .gf-toast-mark {
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
}

/* Tracé plus lent qu'en pilule : c'est le moment spectacle */
.gf-toast-hero--show svg .gf-toast-outline {
  animation: gfToastDraw .8s .15s ease-in-out forwards;
}

.gf-toast-hero--show svg .gf-toast-mark {
  animation: gfToastDraw .45s .95s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  .gf-toast {
    transition: opacity .3s ease;
    transform: none;
  }

  .gf-toast svg .gf-toast-outline,
  .gf-toast svg .gf-toast-mark {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    animation: none !important;
  }

  .gf-toast-mascot {
    animation: none !important;
    transform: none;
  }

  .gf-toast-body,
  .gf-toast-tail {
    transition: none;
  }

  .gf-toast-tail {
    opacity: 1;
    transform: none;
  }
}
