/* Page « Merci » : un café qui se remplit, puis les téléchargements.
   Chronologie (s) : 0 la coulée tombe · 0,35 le café monte · 2,9 il se pose · 3,1 la vapeur s'élève. */

.thanks {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(24px, 5vh, 56px) var(--gutter) 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.thanks h1 {
  font-size: clamp(44px, 7vw, 84px);
  line-height: 0.98;
}

/* Textes : ils arrivent pendant que le café coule, sans attendre la fin. */
.thanks > :not(.brew) {
  animation: rise 800ms var(--spring-smooth) both;
}

.thanks > :nth-child(2) {
  animation-delay: 250ms;
}
.thanks > :nth-child(3) {
  animation-delay: 330ms;
}
.thanks > :nth-child(4) {
  animation-delay: 410ms;
}
.thanks > :nth-child(n + 5) {
  animation-delay: 520ms;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ─── Le café ──────────────────────────────────────────────────────── */

.brew {
  width: min(250px, 62vw);
  aspect-ratio: 240 / 280;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.brew svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.brew:focus-visible {
  outline: 2px solid var(--crema);
  outline-offset: 6px;
  border-radius: 24px;
}

.shadow {
  fill: var(--ink);
  opacity: 0.07;
}

.saucer,
.glass,
.handle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glass-fill {
  fill: #fff;
  opacity: 0.55;
}

.shine {
  fill: none;
  stroke: #fff;
  stroke-width: 6;
  stroke-linecap: round;
  opacity: 0.5;
}

/* La coulée tombe du haut (origine en haut), puis sa queue tombe dans la tasse (origine en bas). */
.pour,
.stream {
  transform-box: fill-box;
}

.pour {
  transform-origin: 50% 0;
  animation: pour-in 380ms cubic-bezier(0.5, 0, 0.9, 0.6) both;
}

.stream {
  fill: #3d2213;
  transform-origin: 50% 100%;
  transform: scaleY(0); /* état final : plus de coulée */
  animation: pour-out 320ms cubic-bezier(0.4, 0, 1, 1) 2.75s backwards;
}

@keyframes pour-in {
  from {
    transform: scaleY(0);
  }
}

@keyframes pour-out {
  from {
    transform: scaleY(1);
  }
  to {
    transform: scaleY(0);
  }
}

/* Le niveau monte vite puis ralentit, dépasse d'un cheveu et se pose. */
.level {
  transform: translateY(6px); /* plein, à un doigt du bord */
  animation: fill 2.6s cubic-bezier(0.3, 0.1, 0.25, 1) 0.35s both;
}

@keyframes fill {
  from {
    transform: translateY(150px);
  }
  88% {
    transform: translateY(2px);
  }
  to {
    transform: translateY(6px);
  }
}

/* Deux vagues en sens contraire : la crème derrière, le café devant. Leur motif se répète tous les 120 px. */
.wave-back {
  fill: url(#crema);
  animation: drift 3.4s linear infinite;
}

.wave-front {
  fill: url(#coffee);
  animation: drift-back 2.5s linear infinite;
}

@keyframes drift {
  to {
    transform: translateX(-120px);
  }
}

@keyframes drift-back {
  from {
    transform: translateX(-120px);
  }
}

.bubble {
  fill: #f4dcbc;
  opacity: 0;
  animation: bubble 1.6s ease-out 3 both;
}

.b2 {
  animation-delay: 0.5s;
}
.b3 {
  animation-delay: 0.9s;
}
.b4 {
  animation-delay: 1.3s;
}

@keyframes bubble {
  0% {
    opacity: 0;
    transform: translateY(0);
  }
  30% {
    opacity: 0.7;
  }
  100% {
    opacity: 0;
    transform: translateY(-70px);
  }
}

/* Quand le café est servi, la tasse se tasse un instant, comme posée sur la soucoupe. */
.vessel {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: settle 700ms var(--spring-bouncy) 2.9s both;
}

@keyframes settle {
  from {
    transform: scale(1);
  }
  25% {
    transform: scale(1.025, 0.975);
  }
  to {
    transform: scale(1);
  }
}

.steam path {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 3.5;
  stroke-linecap: round;
  opacity: 0.4; /* état fixe si les animations sont coupées */
  animation: steam 2.6s ease-in-out 3.1s infinite backwards;
}

.steam .s2 {
  animation-delay: 3.5s;
}
.steam .s3 {
  animation-delay: 3.9s;
}

@keyframes steam {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  40% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
    transform: translateY(-16px);
  }
}

.brew:hover .vessel {
  filter: drop-shadow(0 10px 18px rgba(60, 35, 20, 0.12));
}

/* ─── Téléchargements et étapes ────────────────────────────────────── */

.downloads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.steps {
  list-style: none;
  padding: 0;
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: min(900px, calc(100vw - 2 * var(--gutter))); /* plus large que le texte : trois étapes côte à côte */
  text-align: left;
}

.steps li {
  display: flex;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 15px;
  color: var(--ink-2);
}

.steps b {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--cream);
  font: 600 13px/1 var(--sans);
}

.help {
  margin-top: 18px;
  font-size: 14.5px;
  color: var(--ink-3);
}

@media (max-width: 640px) {
  .steps {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Animations réduites : le café se remplit quand même, mais sans vagues, sans rebond ni vapeur mobile.
   (styles.css coupe toutes les animations : celles-ci, plus douces, sont rétablies.) */
@media (prefers-reduced-motion: reduce) {
  .brew .pour {
    animation: pour-in 380ms ease-in both !important;
  }
  .brew .stream {
    animation: pour-out 320ms ease-in 2.75s backwards !important;
  }
  .brew .level {
    animation: fill-calm 2.6s ease-in-out 0.35s both !important;
  }
  .brew .steam path {
    animation: steam-calm 2.6s ease-in-out 3.1s infinite backwards !important;
  }
}

@keyframes fill-calm {
  from {
    transform: translateY(150px);
  }
  to {
    transform: translateY(6px);
  }
}

@keyframes steam-calm {
  0%,
  100% {
    opacity: 0.15;
  }
  50% {
    opacity: 0.5;
  }
}

.thanks-foot {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 0 var(--gutter) 40px;
  font-size: 13px;
  color: var(--ink-3);
}

.thanks-foot a {
  text-decoration: none;
}

.thanks-foot a:hover {
  color: var(--ink);
}

/* ─── Clé de licence et clé perdue ─────────────────────────────────── */

/* Blocs affichés seulement une fois la commande vérifiée (leur display ne doit pas l'emporter sur hidden). */
.thanks [hidden] {
  display: none !important;
}

.status {
  font-size: 15px;
  color: var(--ink-3);
}

.status.problem {
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--cream);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
}

.license {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(620px, 100%);
  margin-top: 8px;
  padding: 22px;
  border-radius: 22px;
  background: var(--cream);
  box-shadow: inset 0 0 0 1px var(--line);
}

.key {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  font: 500 13px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink);
  text-align: left;
  word-break: break-all;
  user-select: all;
}

.license-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.after-purchase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.recover {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(560px, 100%);
  margin-top: 30px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.recover h2 {
  font: 400 32px/1.1 var(--serif);
}

.recover p {
  font-size: 15px;
  color: var(--ink-2);
}

#recover-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

#recover-form input {
  flex: 1 1 200px;
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--cream);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

#recover-form input:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 60%, transparent);
  outline-offset: 1px;
}

#recover-form input#rec-receipt {
  flex: 0 1 140px;
}

.rec-message {
  min-height: 1.4em;
}

/* Arrivée par « Retrouver ma clé » : le formulaire d'abord, le café attendra la clé. */
body.recovering .brew {
  display: none;
}

body.recovering .recover {
  margin-top: 6px;
  padding-top: 0;
  border-top: 0;
}

body.recovering .recover h2 {
  display: none;
}
