@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --night: #0b1d2e;
  --night-2: #10283b;
  --pine: #0f3b2e;
  --red: #d7263d;
  --red-dark: #a61b2e;
  --gold: #f2c14e;
  --gold-soft: #f7dc94;
  --snow: #fffaf3;
  --ink: #1d2a33;
  --muted: #64707a;
  --line: #ece4d8;
  --green: #1d7a55;
  --radius: 22px;
  --shadow: 0 20px 50px -20px rgb(0 0 0 / 55%), 0 2px 6px rgb(0 0 0 / 12%);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--snow);
  background: var(--night);
  overflow-x: hidden;
}
body::before {
  /* fond fixe (plus fiable que background-attachment: fixed sur mobile) */
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgb(242 193 78 / 16%), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgb(215 38 61 / 22%), transparent 60%),
    linear-gradient(180deg, var(--night) 0%, var(--night-2) 55%, var(--pine) 100%);
}

/* ---------- Neige ---------- */
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
main, header.top, footer { position: relative; z-index: 1; }

/* ---------- En-tête et guirlande ---------- */
header.top {
  display: flex;
  justify-content: center;
  padding: 26px 20px 8px;
}
header.top a {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  color: var(--snow);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgb(255 255 255 / 6%);
  border: 1px solid rgb(255 255 255 / 12%);
  backdrop-filter: blur(8px);
}
.garland {
  position: relative;
  z-index: 1;
  height: 34px;
  margin: 0 auto;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  background: radial-gradient(120% 60px at 50% -20px, transparent 70%, rgb(255 255 255 / 25%) 71%, transparent 73%);
}
.garland i {
  width: 10px;
  height: 14px;
  border-radius: 50% 50% 45% 45%;
  margin-top: 12px;
  background: var(--c, var(--gold));
  box-shadow: 0 0 12px 3px var(--c, var(--gold));
  animation: twinkle 1.6s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
.garland i:nth-child(4n+1) { --c: #ff4d5e; }
.garland i:nth-child(4n+2) { --c: #f2c14e; --d: .4s; }
.garland i:nth-child(4n+3) { --c: #4fd69c; --d: .8s; }
.garland i:nth-child(4n)   { --c: #6ab8ff; --d: 1.2s; }
.garland i:nth-child(odd) { margin-top: 18px; }
@keyframes twinkle { 50% { opacity: .35; box-shadow: 0 0 4px 1px var(--c, var(--gold)); } }

/* ---------- Mise en page ---------- */
main { max-width: 780px; margin: 0 auto; padding: 18px 18px 72px; }

h1, h2, .display { font-family: 'Fraunces', Georgia, serif; }
h1 {
  margin: 10px 0 6px;
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.1;
  font-weight: 800;
  color: var(--snow);
}
h2 { margin: 0 0 12px; font-size: 1.3rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
p.lead { color: rgb(255 250 243 / 75%); margin-top: 0; font-size: 1.05rem; line-height: 1.6; }

.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 3.8rem); }
.hero h1 em { font-style: normal; color: var(--gold); }
.hero .lead { max-width: 560px; margin: 14px auto 0; }
.features { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 22px 0 30px; }
.features span {
  font-size: .9rem; padding: 7px 14px; border-radius: 999px;
  background: rgb(255 255 255 / 8%); border: 1px solid rgb(255 255 255 / 14%);
  color: rgb(255 250 243 / 88%);
}

/* ---------- Cartes ---------- */
.card {
  position: relative;
  color: var(--ink);
  /* liseré « sucre d'orge » : dessiné dans le fond de la carte, il suit donc exactement ses coins arrondis */
  background:
    repeating-linear-gradient(-45deg, var(--red) 0 12px, var(--snow) 12px 24px) top / 100% 7px no-repeat,
    var(--snow);
  border-radius: var(--radius);
  padding: 30px 26px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  animation: rise .5s ease both;
}
.card h2 .icon {
  width: 36px; height: 36px; border-radius: 12px; display: inline-grid; place-items: center;
  font-size: 1.1rem; background: #fbeee6;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin: 14px 0 6px; color: #3a4750; }
input, textarea, select {
  width: 100%;
  font: inherit;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgb(215 38 61 / 14%);
}
input:disabled { background: #f6f1ea; color: #5a6670; }
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .card { padding: 22px 18px; } }

/* ---------- Boutons ---------- */
button, .btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #e8344b, var(--red-dark));
  box-shadow: 0 8px 20px -8px rgb(215 38 61 / 70%), inset 0 1px 0 rgb(255 255 255 / 25%);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s, box-shadow .12s, filter .12s;
}
button:hover, .btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
button:active { transform: translateY(0); }
button.secondary {
  background: #fff; color: var(--red-dark);
  border: 1.5px solid rgb(215 38 61 / 35%); box-shadow: none;
}
button.secondary:hover { background: #fff3f3; }
button.ghost { background: transparent; color: var(--muted); padding: 8px 12px; box-shadow: none; }
button.ghost:hover { background: #f3ece2; color: var(--ink); }
button.green {
  background: linear-gradient(180deg, #24935f, #16603f);
  box-shadow: 0 8px 20px -8px rgb(29 122 85 / 80%), inset 0 1px 0 rgb(255 255 255 / 25%);
}
button.gold {
  color: #3b2a00;
  background: linear-gradient(180deg, #ffd978, #e6a92a);
  box-shadow: 0 10px 26px -8px rgb(242 193 78 / 80%), inset 0 1px 0 rgb(255 255 255 / 50%);
}
button.big { padding: 15px 30px; font-size: 1.08rem; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }

/* ---------- Listes ---------- */
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.row input { flex: 1; min-width: 0; }
.row .avatar { flex: none; }
@media (max-width: 560px) { .row { flex-wrap: wrap; } .row input { flex-basis: 40%; } }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-weight: 700; color: #fff; font-size: .95rem;
  background: hsl(var(--hue, 350) 60% 45%);
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 15%);
}
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap;
}
.list li:last-child { border-bottom: 0; }
.list .who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.pill { font-size: .78rem; padding: 3px 10px; border-radius: 999px; background: #f3ece2; color: var(--muted); font-weight: 500; }
.pill.ok { background: #dff3e9; color: var(--green); }
h2 .pill { font-family: 'Inter', sans-serif; background: var(--red); color: #fff; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 14px; border-radius: 999px; background: #fbeee6; font-weight: 500;
}
.chip.oneway { background: #eef2f6; }

.notice { padding: 13px 16px; border-radius: 14px; background: #fff6dc; border: 1px solid #f3dd9a; font-size: .93rem; color: #6b5300; }
.notice.error { background: #fdecee; border-color: #f4b8c0; color: var(--red-dark); }
.notice.success { background: #e3f4ea; border-color: #b6dcc7; color: #155c3f; }
main > .notice { margin-top: 20px; }

.copybox { display: flex; gap: 8px; }
.copybox input { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: .82rem; background: #f8f3ec; }

.checkbox { display: flex !important; gap: 10px; align-items: center; font-weight: 500 !important; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--red); }

/* ---------- Barre d'enregistrement ---------- */
#saveBar {
  position: sticky; bottom: 16px; z-index: 5;
  background: var(--night); color: var(--snow);
  border: 1px solid rgb(242 193 78 / 40%);
  padding: 14px 18px;
}

/* ---------- Page tirage ---------- */
.reveal { text-align: center; padding: 40px 22px 34px; overflow: hidden; }
.reveal .name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(2.6rem, 9vw, 4rem);
  font-weight: 800;
  line-height: 1.05;
  margin: 8px 0 10px;
  word-break: break-word;
  background: linear-gradient(90deg, var(--red-dark), var(--red), #e85d3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pop .7s cubic-bezier(.2, 1.6, .4, 1) both .25s;
}
.reveal .kicker { text-transform: uppercase; letter-spacing: .16em; font-size: .78rem; font-weight: 700; color: var(--muted); }
.reveal .gift { font-size: 4rem; line-height: 1; }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }

/* Cadeau en CSS */
.present {
  --w: 150px;
  position: relative;
  width: var(--w);
  height: calc(var(--w) * .95);
  margin: 6px auto 26px;
  cursor: pointer;
  animation: wobble 2.4s ease-in-out infinite;
  filter: drop-shadow(0 18px 18px rgb(0 0 0 / 25%));
}
.present .box, .present .lid { position: absolute; left: 50%; transform: translateX(-50%); }
.present .box {
  bottom: 0; width: 86%; height: 68%;
  border-radius: 6px 6px 12px 12px;
  background:
    linear-gradient(90deg, transparent 42%, var(--gold) 42% 58%, transparent 58%),
    linear-gradient(180deg, #e8344b, var(--red-dark));
}
.present .lid {
  top: 14%; width: 100%; height: 22%;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 42%, var(--gold-soft) 42% 58%, transparent 58%),
    linear-gradient(180deg, #f04c61, #c41f35);
  transition: transform .6s cubic-bezier(.3, 1.4, .5, 1), opacity .6s;
  z-index: 2;
}
.present .lid::before, .present .lid::after {
  /* nœud */
  content: ''; position: absolute; bottom: 92%; width: 38%; height: 70%;
  border: 9px solid var(--gold); border-radius: 50% 50% 0 50%;
}
.present .lid::before { right: 50%; transform: rotate(-12deg); }
.present .lid::after { left: 50%; border-radius: 50% 50% 50% 0; transform: rotate(12deg); }
.present.open { animation: none; }
.present.open .lid { transform: translate(-50%, -140%) rotate(-24deg); opacity: 0; }
@keyframes wobble {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); }
  85% { transform: rotate(-3deg); } 90% { transform: rotate(2deg); }
}

.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 50; pointer-events: none; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.hidden { display: none !important; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: var(--night); color: var(--snow);
  border: 1px solid rgb(242 193 78 / 45%);
  padding: 11px 20px; border-radius: 999px; z-index: 60;
  font-size: .92rem; font-weight: 500; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { text-align: center; color: rgb(255 250 243 / 55%); font-size: .85rem; padding: 0 16px 34px; }

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