/* Nuit de fête : mur de polaroïds qui défile, mots sur papiers de couleur scotchés par-dessus. */
:root {
  --nuit: #16132a;
  --texte: #f6f0e4;
  --texte-doux: #cfc6dc;
  --or: #f4c25b;
  --rose: #f39fb1;
  --creme: #fbf7ef;
  --encre: #2a2333;
  --p1: #fff3c4;
  --p2: #ffd8de;
  --p3: #d6f0df;
  --p4: #dce6ff;
  --f-titre: "Gloock", Georgia, serif;
  --f-texte: "Figtree", system-ui, -apple-system, sans-serif;
  --f-main: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--nuit);
  color: var(--texte);
  font: 16px/1.5 var(--f-texte);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--or); outline-offset: 3px; }

/* ---------- Mur de photos ---------- */
/* Cadre aux dimensions exactes de l'écran : le mur penché qui déborde à l'intérieur n'élargit jamais la page sur téléphone. */
.wall {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}
.wall-inner {
  position: absolute;
  inset: -12vh -12vw;
  display: flex;
  gap: 22px;
  transform: rotate(-6deg);
}

/* Les couches de contenu laissent passer les clics jusqu'aux photos du mur ;
   seuls les éléments utiles les captent. */
.intro, .intro-inner, .drop, .app, .app > section, .notes, .guesses, .diapo, .top, .page-form { pointer-events: none; }
.intro-inner > *, .drop .polaroid, .note, .guess, .diapo-photo, .diapo-text, .top > *, .empty, .card { pointer-events: auto; }

[data-photo] { cursor: zoom-in; }
/* L'assombrissement du mur est porté par chaque photo, pour qu'une photo survolée retrouve toute sa lumière. */
.wall .polaroid {
  position: relative;
  filter: brightness(.42) saturate(.8);
  transition: scale .4s cubic-bezier(.2, .8, .3, 1), filter .4s, box-shadow .4s;
}
@media (hover: hover) {
  .wall-col:hover { position: relative; z-index: 1; }
  .wall .polaroid:hover {
    z-index: 2;
    scale: 1.35;
    filter: brightness(1.08) saturate(1.15);
    box-shadow: 0 0 0 2px rgba(244, 194, 91, .7), 0 0 70px rgba(244, 194, 91, .5), 0 30px 60px rgba(0, 0, 0, .6);
  }
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding-block: 24px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  background: rgba(10, 8, 20, .9);
  backdrop-filter: blur(8px);
}
.viewer-photo { margin: 0; padding: 10px 10px 42px; max-width: min(100%, 760px); transform: rotate(-1.5deg); cursor: default; }
.viewer-photo.in { animation: pose .35s ease-out both; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.wall-col { flex: 1; min-width: 0; }
.wall-track {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 22px;
  animation: defile var(--dur, 80s) linear infinite;
}
.wall-col.down .wall-track { animation-direction: reverse; }
@keyframes defile { to { transform: translateY(-50%); } }

.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(22, 19, 42, .2) 0%, rgba(22, 19, 42, .35) 65%, rgba(22, 19, 42, .6) 100%);
}

.polaroid {
  margin: 0;
  background: var(--creme);
  padding: 8px 8px 30px;
  border-radius: 2px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  transform: rotate(var(--r, 0deg));
}
.polaroid img, .polaroid .ph {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}
.viewer-photo img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 72svh;
  aspect-ratio: auto;
  object-fit: contain;
}
.ph0 { background: linear-gradient(160deg, #f6c1a0, #b8607a); }
.ph1 { background: linear-gradient(160deg, #a6c8e8, #5a5f9e); }
.ph2 { background: linear-gradient(160deg, #f3dc8c, #d07c4c); }
.ph3 { background: linear-gradient(160deg, #b9e0c4, #4f8a7a); }

/* ---------- Cadeau d'ouverture : le toucher obligatoire pour le son devient le geste d'ouvrir ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  background: radial-gradient(circle at 50% 50%, #2b2450 0%, var(--nuit) 70%);
  transition: opacity .8s ease, transform .8s ease;
}
.gate::before, .gate::after {
  content: "";
  position: absolute;
  background: linear-gradient(90deg, #d9a23f, var(--or), #d9a23f);
  box-shadow: 0 0 30px rgba(244, 194, 91, .35);
}
.gate::before { top: 0; bottom: 0; left: 50%; width: 56px; transform: translateX(-50%); }
.gate::after { left: 0; right: 0; top: 50%; height: 56px; transform: translateY(-50%); background: linear-gradient(180deg, #d9a23f, var(--or), #d9a23f); }
.gate-inner {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
  padding: 40px 32px;
  max-width: 420px;
  background: var(--nuit);
  border: 2px solid var(--or);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: respire 3s ease-in-out infinite;
}
@keyframes respire { 50% { scale: 1.03; } }
.gate-title { margin: 0; font: 700 clamp(2.4rem, 9vw, 3.4rem)/1 var(--f-main); color: var(--texte); }
.gate.opening { opacity: 0; transform: scale(1.15); pointer-events: none; }

/* ---------- Ouverture ---------- */
.intro {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding-block: 56px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  overflow: hidden;
}
.intro-inner {
  position: relative;
  z-index: 2;
  max-width: 780px;
  display: grid;
  gap: 22px;
  justify-items: center;
}
.eyebrow {
  margin: 0;
  font: 600 .8rem/1 var(--f-texte);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--or);
}
h1 {
  margin: 0;
  font: 400 clamp(2.4rem, 8vw, 5.6rem)/.95 var(--f-titre);
  text-wrap: balance;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .6);
}
h1 .prenom {
  display: block;
  margin-top: .1em;
  font-family: var(--f-main);
  font-weight: 700;
  font-size: 1.55em;
  color: var(--or);
  transform: rotate(-3deg);
}
.sub {
  margin: 0;
  max-width: 34ch;
  font-size: 1.1rem;
  color: var(--texte-doux);
  text-wrap: balance;
}
.btn {
  border: 0;
  border-radius: 999px;
  padding: 15px 30px;
  background: var(--or);
  color: var(--encre);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(244, 194, 91, .3);
  transition: transform .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(244, 194, 91, .45); }
.btn:disabled { opacity: .6; cursor: wait; transform: none; }

.drop { position: absolute; inset: 0; z-index: 1; }
.drop .polaroid {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(92px, 15vw, 190px);
  animation: tombe 1.1s cubic-bezier(.2, .9, .3, 1.15) both;
  animation-delay: var(--delay);
}
@keyframes tombe {
  from { transform: translateY(-130vh) rotate(calc(var(--r) * -4)); }
  to { transform: translateY(0) rotate(var(--r)); }
}
@media (max-width: 640px) {
  .drop .polaroid:nth-child(n + 4) { display: none; }
  .drop .polaroid { opacity: .85; }
}

/* ---------- Application ---------- */
.app {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  padding-top: 28px;
  padding-bottom: 120px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.top {
  max-width: 1200px;
  margin: 0 auto 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  align-items: baseline;
}
.back {
  flex-basis: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--texte-doux);
  font-weight: 600;
  cursor: pointer;
}
.back:hover { color: var(--or); }
.top h2 { margin: 0; font: 400 clamp(1.7rem, 4vw, 2.5rem)/1.1 var(--f-titre); }
.top h2 span { font-family: var(--f-main); color: var(--or); font-size: 1.3em; }
.count { color: var(--texte-doux); font-size: .95rem; }

.empty {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  color: var(--texte-doux);
  font: 500 1.8rem/1.2 var(--f-main);
}

/* Papiers */
.p1 { --paper: var(--p1); }
.p2 { --paper: var(--p2); }
.p3 { --paper: var(--p3); }
.p4 { --paper: var(--p4); }

/* Mode Constellation */
.notes {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 34px 28px;
  align-items: start;
}
.note {
  position: relative;
  border: 0;
  text-align: left;
  cursor: pointer;
  padding: 26px 22px 28px;
  background: var(--paper);
  color: var(--encre);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .4);
  transform: rotate(var(--r));
  animation: flotte 6s ease-in-out infinite;
  animation-delay: calc(var(--d) * -1);
  transition: transform .25s;
}
.note::before, .zoom-note::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 78px;
  height: 22px;
  background: rgba(255, 255, 255, .5);
  transform: translateX(-50%) rotate(-3deg);
}
.note:hover, .note:focus-visible { transform: rotate(0deg) scale(1.04); z-index: 3; }
@keyframes flotte { 0%, 100% { translate: 0 0; } 50% { translate: 0 -9px; } }
.note-text {
  margin: 0;
  font: 500 1.6rem/1.15 var(--f-main);
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.zoom {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding-block: 24px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  background: rgba(10, 8, 20, .72);
  backdrop-filter: blur(6px);
}
.zoom-note {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 85svh;
  overflow: auto;
  padding: 40px 34px 30px;
  background: var(--paper);
  color: var(--encre);
  transform: rotate(-1deg);
  box-shadow: 0 30px 60px rgba(0, 0, 0, .5);
  animation: pose .35s ease-out both;
}
@keyframes pose { from { transform: rotate(-6deg) scale(.85); opacity: 0; } }
.zoom-note p { margin: 0; font: 500 clamp(1.7rem, 4.4vw, 2.3rem)/1.2 var(--f-main); white-space: pre-wrap; }
.zoom-close {
  margin-top: 24px;
  border: 0;
  background: transparent;
  color: var(--encre);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* Mode Diaporama */
.diapo {
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100svh - 230px);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 48px;
  align-items: center;
}
.diapo-photo { margin: 0; max-width: 460px; justify-self: center; width: 100%; transform: rotate(-3deg); padding-bottom: 44px; }
.diapo-photo .frame { overflow: hidden; aspect-ratio: 4 / 5; }
.diapo-photo .frame img, .diapo-photo .frame .ph { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: auto; }
.diapo-photo .frame .kb { animation: kenburns 11s ease-out both; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.14) translate(-2%, -3%); } }
.diapo-text { min-width: 0; display: grid; gap: 28px; }
.diapo-text p {
  margin: 0;
  font: 500 clamp(1.9rem, 4.2vw, 3.3rem)/1.12 var(--f-main);
  white-space: pre-wrap;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .5);
}
.diapo-text p.long { font-size: clamp(1.5rem, 2.8vw, 2.3rem); }
.diapo-text .in { animation: apparait .9s ease-out both; }
@keyframes apparait { from { opacity: 0; transform: translateY(14px); } }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ctrl {
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .08);
  color: var(--texte);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}
.ctrl:hover { background: rgba(255, 255, 255, .16); }
.progress { color: var(--texte-doux); font-variant-numeric: tabular-nums; margin-left: 6px; }
@media (max-width: 760px) {
  .diapo { grid-template-columns: minmax(0, 1fr); gap: 20px; min-height: 0; }
  .diapo-photo { max-width: 220px; padding-bottom: 32px; }
  .diapo-text p { font-size: 1.75rem; }
  .diapo-text p.long { font-size: 1.4rem; }
  .face { min-height: 0; }
  .app { padding-top: 16px; }
}

/* Mode Devine qui */
.guesses {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px;
}
.guess { perspective: 1200px; }
.guess-inner {
  display: grid;
  transition: transform .8s cubic-bezier(.3, .8, .3, 1);
  transform-style: preserve-3d;
}
.guess.flipped .guess-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 26px 22px 22px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .4);
  display: grid;
  gap: 18px;
  align-content: space-between;
  min-height: 230px;
}
.face.front { background: var(--paper); color: var(--encre); }
.face.front p { margin: 0; font: 500 1.5rem/1.15 var(--f-main); }
.face.back {
  transform: rotateY(180deg);
  background: var(--encre);
  color: var(--texte);
  text-align: center;
  place-items: center;
  align-content: center;
}
.face.back .label { font-size: .8rem; letter-spacing: .18em; text-transform: uppercase; color: var(--or); }
.face.back .who { font: 400 clamp(1.8rem, 3vw, 2.4rem)/1.1 var(--f-titre); margin: 0; }
.face.back .who.secret { font-family: var(--f-main); font-size: 2rem; color: var(--rose); }
.flip {
  justify-self: start;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: var(--encre);
  color: var(--texte);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
}
.face.back .flip { justify-self: center; background: transparent; border: 1px solid rgba(255, 255, 255, .3); }

/* Sélecteur de mode */
.modes {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 4px;
  padding: 6px;
  max-width: calc(100% - 32px);
  background: rgba(22, 19, 42, .82);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
}
.modes button {
  border: 0;
  background: transparent;
  color: var(--texte-doux);
  font-weight: 600;
  font-size: .92rem;
  padding: 10px 16px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--or); color: var(--encre); }
@media (max-width: 420px) { .modes button { padding: 9px 11px; font-size: .85rem; } }

.music-bar {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 15;
  display: flex;
  gap: 6px;
}
.music-toggle {
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(22, 19, 42, .8);
  backdrop-filter: blur(10px);
  color: var(--or);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
}
.music-toggle[aria-pressed="false"] { color: var(--texte-doux); }

.demo {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--rose);
  color: var(--encre);
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Formulaire ---------- */
.page-form {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding-block: 48px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.card {
  position: relative;
  width: 100%;
  max-width: 560px;
  padding: 36px 30px 30px;
  background: var(--creme);
  color: var(--encre);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
  transform: rotate(-.6deg);
  display: grid;
  gap: 22px;
  color-scheme: light;
}
.card h1 { font-size: clamp(2rem, 6vw, 2.8rem); text-shadow: none; }
.card h1 .prenom { color: #c4862a; font-size: 1.4em; }
.card .intro-text { margin: 0; color: #5a5064; }
.field { display: grid; gap: 8px; }
.field label { font-weight: 700; font-size: .95rem; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid #d8cfc0;
  border-radius: 8px;
  background: #fff;
  color: var(--encre);
  padding: 12px 14px;
  font: inherit;
}
.field textarea {
  min-height: 190px;
  resize: vertical;
  font: 500 1.55rem/1.2 var(--f-main);
  background: var(--p1) repeating-linear-gradient(transparent 0 35px, rgba(42, 35, 51, .1) 35px 36px);
  background-attachment: local;
}
.hint { font-size: .85rem; color: #6d6378; display: flex; justify-content: space-between; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: #c4862a; }
.error { margin: 0; color: #b3263e; font-weight: 600; }
.merci { text-align: center; display: grid; gap: 16px; justify-items: center; }
.merci p { margin: 0; }
.merci .big { font: 700 2.6rem/1 var(--f-main); color: #c4862a; }
.link-btn { border: 0; background: none; color: var(--encre); text-decoration: underline; font-weight: 600; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
