:root {
  --bg: #0b0b0b;
  --fg: #f4f1ea;
  --red: #e0261d;
  --carton: #c9a46c;
  --carton-dark: #9c7a45;
  --ink: #141414;
  --ink-blue: #1f3fa6;
  --slide-ms: 5000ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Archivo", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#stage { position: fixed; inset: 0; touch-action: none; overflow: hidden; }

.slide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 600ms ease, transform 380ms cubic-bezier(.2, .8, .2, 1);
  will-change: transform, opacity;
}
.slide.in { opacity: 1; }

/* Navigation par swipe : la diapo entre par le côté */
.slide.from-right { opacity: 1; transform: translateX(100%); }
.slide.from-left { opacity: 1; transform: translateX(-100%); }
.slide.from-right.in, .slide.from-left.in { transform: none; }
.slide.to-left { transform: translateX(-35%); opacity: 0; }
.slide.to-right { transform: translateX(35%); opacity: 0; }

/* Photo : version floue en fond pour remplir l'écran, photo entière par-dessus */
.slide .blur {
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(30px) brightness(0.45);
}
.slide img {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.slide.in img { animation: zoom var(--slide-ms) linear forwards; }
@keyframes zoom { from { transform: scale(1); } to { transform: scale(1.04); } }

/* ---------- Pancarte d'ouverture ---------- */
.seed {
  background:
    radial-gradient(circle at 50% 35%, #2a2a2a 0%, var(--bg) 70%);
  grid-template-rows: auto auto;
  align-content: center;
}
.pancarte {
  position: relative;
  --w: min(86vw, 52vh);
  width: var(--w);
  aspect-ratio: 3 / 4;
  container-type: inline-size;
  /* % de padding = % du parent : on part de la largeur du carton */
  padding: calc(var(--w) * .08) calc(var(--w) * .08) calc(var(--w) * .09);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(170deg, #d4b07a 0%, var(--carton) 45%, var(--carton-dark) 100%);
  box-shadow:
    inset 0 0 40px rgba(80, 50, 15, .45),
    0 30px 60px rgba(0, 0, 0, .6);
  border-radius: 3px 6px 4px 2px;
  transform: rotate(-2.5deg);
  font-family: "Permanent Marker", "Marker Felt", cursive;
  color: var(--ink);
}
.seed.in .pancarte { animation: brandish 2.4s ease-in-out infinite alternate; }
@keyframes brandish {
  from { transform: rotate(-2.5deg) translateY(0); }
  to   { transform: rotate(1.5deg) translateY(-6px); }
}

.tries {
  list-style: none;
  display: grid;
  gap: .2em;
  font-size: 7.4cqi;
  color: var(--ink-blue);
  opacity: .9;
}
.tries li {
  position: relative;
  width: fit-content;
  transform: rotate(-1deg);
}
.tries li:nth-child(2) { margin-left: 18%; transform: rotate(1.5deg); }
.tries li:nth-child(3) { margin-left: 6%; }
/* Rature au feutre noir : la pancarte cherche ses mots */
.tries li::after {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  top: 50%;
  height: .55em;
  transform: translateY(-50%) scaleX(0);
  transform-origin: left;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M2 12 C 30 4, 50 16, 80 9 S 130 3, 160 11 S 190 14, 198 6 M6 15 C 40 8, 90 17, 140 8 S 185 10, 196 12' fill='none' stroke='%23141414' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.seed.in .tries li::after { animation: rature 350ms ease-out forwards; }
.seed.in .tries li:nth-child(1)::after { animation-delay: 300ms; }
.seed.in .tries li:nth-child(2)::after { animation-delay: 750ms; }
.seed.in .tries li:nth-child(3)::after { animation-delay: 1200ms; }
@keyframes rature { to { transform: translateY(-50%) scaleX(1); } }

.main {
  font-size: 13cqi;
  line-height: 1.08;
  transform: rotate(-1.5deg);
  text-wrap: balance;
}
.main em {
  font-style: normal;
  color: var(--red);
  position: relative;
  white-space: nowrap;
}
.main em::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: -.12em;
  height: .22em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M3 9 C 50 3, 120 13, 197 5' fill='none' stroke='%23e0261d' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

.baton {
  width: min(4vw, 3vh);
  height: 12vh;
  margin-top: -1px;
  background: linear-gradient(90deg, #6b4a26, #a27a4a 45%, #6b4a26);
  transform: rotate(-2.5deg);
  transform-origin: top;
}
.seed.in .baton { animation: brandish 2.4s ease-in-out infinite alternate; }

/* ---------- Habillage ---------- */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: max(10px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.progress {
  display: flex;
  gap: 3px;
  height: 3px;
}
.progress span {
  flex: 1;
  background: rgba(255, 255, 255, .28);
  border-radius: 2px;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--fg);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  margin-bottom: auto;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
}
.live { display: inline-flex; align-items: center; gap: 8px; }
.live i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

.bottom {
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
  min-height: 1.4em;
}
.bottom { display: grid; gap: 10px; justify-items: start; }
#caption { min-height: 1.4em; }
/* Seul élément cliquable du HUD : le reste laisse passer les gestes vers le diaporama */
.send {
  pointer-events: auto;
  display: inline-block;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  border: 1px solid rgba(255, 255, 255, .25);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-shadow: none;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.send strong { font-weight: 800; }
.send:active { transform: scale(.97); }
.bottom .new {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 3px;
}
.paused .progress i { opacity: .5; }

@media (prefers-reduced-motion: reduce) {
  .slide.in img, .seed.in .pancarte, .seed.in .baton { animation: none; }
  .seed .tries li::after { transform: translateY(-50%) scaleX(1); animation: none; }
}
