/* Cadeaux de Noël : habillage « enveloppe dessinée » (kitsch assumé).
   Les dessins (s-*.webp) sont découpés dans la photo de l'enveloppe ; ils se posent en « multiply » sur le papier blanc. */

:root {
  --pen: #1b1b1b;
  --blue: #1f9bd1;
  --pink: #ef7f95;
  --lime: #9cc41a;
  --red: #e3414f;
  --green: #3a9a3a;
  --tan: #f0c9a0;
  --hand: "Bradley Hand", "Segoe Print", "Marker Felt", "Chalkboard SE", "Comic Sans MS", "Comic Sans", cursive;
  --wobble: 14px 4px 12px 5px / 5px 12px 4px 14px;
  --wobble2: 5px 13px 4px 14px / 13px 4px 14px 5px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

body {
  margin: 0;
  color: var(--pen);
  font: 19px/1.45 var(--hand);
}

/* ------------------------------------------------ Fonds de page (au choix de chacun, mémorisé sur l'appareil)
   Chaque thème s'applique à <body> (attribut data-fond sur <html>) et aux pastilles du sélecteur (.sw-*, échelle réduite par --k). */
html:not([data-fond]) body, html[data-fond="nuit"] body, .sw-nuit {
  background: #122860 url("fond-nuit.webp") repeat;
  background-size: calc(640px * var(--k, 1)) auto;
}
html[data-fond="douce"] body, .sw-douce {
  background-color: #0b1b40;
  background-image: url("fond-flocons.webp"), url("fond-etoiles.webp"), radial-gradient(ellipse at 50% 0%, #1f3d86 0%, #10244f 55%, #09152f 100%);
  background-size: calc(900px * var(--k, 1)) auto, calc(640px * var(--k, 1)) auto, 100% 100%;
  background-attachment: scroll, scroll, fixed;
  background-repeat: repeat, repeat, no-repeat;
}
html[data-fond="cadeau"] body, .sw-cadeau {
  background: #fff7e0 url("fond-cadeau.webp") repeat;
  background-size: calc(720px * var(--k, 1)) auto;
}
html[data-fond="kraft"] body, .sw-kraft {
  background: #cba470 url("fond-kraft.webp") repeat;
  background-size: calc(760px * var(--k, 1)) auto;
}
html[data-fond="sapin"] body, .sw-sapin {
  background-color: #1b3f31;
  background-image: url("fond-grain.webp"), radial-gradient(ellipse at 50% 15%, #2b6049 0%, #1b3f31 62%, #122a21 100%);
  background-size: 128px auto, 100% 100%;
  background-attachment: scroll, fixed;
  background-repeat: repeat, no-repeat;
}
html[data-fond="bordeaux"] body, .sw-bordeaux {
  background-color: #5e1a29;
  background-image: url("fond-grain.webp"), radial-gradient(ellipse at 50% 15%, #8c2b3d 0%, #5e1a29 62%, #3d101b 100%);
  background-size: 128px auto, 100% 100%;
  background-attachment: scroll, fixed;
  background-repeat: repeat, no-repeat;
}
html[data-fond="ivoire"] body, .sw-ivoire {
  background-color: #efe8da;
  background-image: repeating-linear-gradient(0deg, rgba(110, 90, 60, .08) 0 1px, transparent 1px 4px),
                    repeating-linear-gradient(90deg, rgba(110, 90, 60, .08) 0 1px, transparent 1px 4px);
}

/* ------------------------------------------------ Barre sous l'en-tête : prénom + choix du fond */
.bar { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 6px 18px; margin: -4px 4px 4px; }
.bar:empty { display: none; }
.bar .whoami { margin: 0; }
.fond { position: relative; }
.foot { margin-top: 34px; display: flex; justify-content: flex-end; }
.fond-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 400; color: #8a8a8a;
  background: none; border: 0; box-shadow: none; padding: 2px 4px; min-height: 0; border-radius: 4px; opacity: .85;
}
.fond-btn:hover:not(:disabled) { transform: none; box-shadow: none; color: var(--blue); opacity: 1; text-decoration: underline wavy; text-underline-offset: 4px; }
.swatch {
  --k: .34; display: inline-block; flex: none; width: 24px; height: 24px; border: 2px solid var(--pen);
  border-radius: 50%; background-attachment: scroll !important;
}
.fond-btn .swatch { width: 15px; height: 15px; border-width: 1.5px; border-color: #999;
}
.fond-pop {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 30; width: min(360px, calc(100vw - 32px));
  background: #fff; border: 3px solid var(--blue); border-radius: var(--wobble); padding: 12px 14px 14px;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .3);
}
.fond-title { margin: 0 0 8px; font-weight: 700; color: var(--blue); }
.fond-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; }
.fond-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px 5px; min-height: 0; font-size: .85rem; line-height: 1.1; box-shadow: 2px 2px 0 var(--pen); }
.fond-opt .swatch { width: 52px; height: 52px; border-radius: 10px 4px 10px 4px / 4px 10px 4px 10px; --k: .34; }
.fond-opt[aria-pressed="true"] { background: #fffbd6; border-color: var(--red); box-shadow: 2px 2px 0 var(--red); }

/* ------------------------------------------------ La feuille (papier posé sur le bois) */
.sheet {
  max-width: 1040px;
  margin: 26px auto 48px;
  padding: 14px 22px 40px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5), inset 0 0 50px rgba(0, 0, 0, .05);
}

/* ------------------------------------------------ En-tête : la composition de l'enveloppe */
.envelope { margin-bottom: 6px; }
.art {
  display: block; position: relative; width: 100%;
  aspect-ratio: 1880 / 610;
  container-type: inline-size;
  text-decoration: none;
}
.art .sp { position: absolute; height: auto; mix-blend-mode: multiply; user-select: none; -webkit-user-drag: none; }
.art img.sp { display: block; }
.burst > img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }
.burst { container-type: inline-size; }
.burst-name {
  position: absolute; left: 61.7%; top: 49.8%;
  transform: translate(-50%, -50%) rotate(-4deg);
  font: 700 15cqw/1 var(--hand); color: var(--pen);
  white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 6px #fff, 0 0 3px #fff;
}
.whoami { display: flex; justify-content: flex-end; align-items: baseline; gap: 12px; font-size: .95rem; }
.whoami b { font-weight: 700; color: var(--red); }
.link { background: none; border: 0; padding: 0; min-height: 0; font: inherit; color: var(--blue); text-decoration: underline wavy; text-underline-offset: 4px; cursor: pointer; }

/* ------------------------------------------------ Contenu */
main { padding: 4px 0 0; }
h1 {
  font: 700 2.2rem/1.1 var(--hand); color: var(--blue); margin: 10px 0 14px;
  transform: rotate(-1.2deg); display: inline-block;
  text-decoration: underline wavy var(--pink) 3px; text-underline-offset: 8px;
}
h2 { font: 700 1.6rem/1.1 var(--hand); margin: 0 0 10px; }
.muted { color: #555; }

button, input, textarea { font: inherit; }
button {
  cursor: pointer; border: 2.5px solid var(--pen); border-radius: var(--wobble);
  padding: 7px 16px; min-height: 42px; background: #fff; color: var(--pen);
  font-weight: 700; box-shadow: 3px 3px 0 var(--pen);
  transition: transform .08s;
}
button:hover:not(:disabled) { transform: translate(1px, 1px) rotate(-1deg); box-shadow: 2px 2px 0 var(--pen); }
button:disabled { opacity: .55; cursor: wait; }
button.primary { background: var(--lime); }
button.ghost { background: #fff; border-style: dashed; border-color: var(--pink); box-shadow: 3px 3px 0 var(--pink); }
button.danger { color: var(--red); border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
button.link { box-shadow: none; border: 0; min-height: 0; padding: 0; background: none; }
button.link:hover:not(:disabled) { transform: none; box-shadow: none; }

input, textarea {
  width: 100%; padding: 9px 12px; border: 2.5px solid var(--blue); border-radius: var(--wobble2);
  background: #fffef2; color: var(--pen);
}
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px dashed var(--red); outline-offset: 2px; }
label { display: block; font-weight: 700; margin-bottom: 12px; }
label input, label textarea { margin-top: 4px; font-weight: 400; }

.card, .panel {
  background: #fff; border: 3px solid var(--blue); border-radius: var(--wobble);
  padding: 16px; box-shadow: 4px 4px 0 rgba(0, 0, 0, .18);
}
.panel { max-width: 560px; margin: 18px auto; overflow: hidden; }
.panel .hero { float: right; height: 150px; width: auto; mix-blend-mode: multiply; margin: 0 0 8px 12px; transform: rotate(3deg); }
.panel h1 { display: block; margin-top: 4px; }

/* « Qui es-tu ? » */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; clear: both; }
.choice { padding: 12px; font-size: 1.15rem; border-color: var(--pen); }
.choice:nth-child(5n+1) { background: #bfe6f6; }
.choice:nth-child(5n+2) { background: #fbc9d3; }
.choice:nth-child(5n+3) { background: #e3f0a6; }
.choice:nth-child(5n+4) { background: #fbd0d4; }
.choice:nth-child(5n+5) { background: #c8e8c4; }
.choice:nth-child(odd) { transform: rotate(-1.2deg); }
.choice:nth-child(even) { transform: rotate(1deg); }

.newname { clear: both; margin-top: 22px; padding-top: 16px; border-top: 3px dashed var(--pink); }
.newname-row { display: flex; gap: 12px; align-items: stretch; margin-top: 6px; }
.newname-row input { margin-top: 0; flex: 1 1 auto; min-width: 0; }
.newname-row button { flex: 0 0 auto; }

/* ------------------------------------------------ Accueil */
main.wide { max-width: none; }

.person.mine {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
  background: #fffbd6; border: 3px dashed var(--red); border-radius: var(--wobble2);
  padding: 10px 16px; box-shadow: 4px 4px 0 rgba(0, 0, 0, .18);
}
.person.mine .gift-ico { height: 62px; width: auto; mix-blend-mode: multiply; transform: rotate(-6deg); }
.person-name { display: block; font: 700 1.6rem/1.1 var(--hand); color: var(--red); }
.person.mine:hover { transform: rotate(-.4deg); }

.summary { display: flex; align-items: center; gap: 12px; margin: 18px 0 8px; font-size: 1.2rem; font-weight: 700; color: #666; min-height: 56px; }
.summary .oh { height: 56px; width: auto; mix-blend-mode: multiply; }
.summary.has-new { color: var(--red); }
.summary.none .birds-ico { height: 46px; width: auto; mix-blend-mode: multiply; }


.lists-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 28px; align-items: start; margin-top: 14px; }
.person-list {
  position: relative; --c: var(--blue);
  background: #fff; border: 3.5px solid var(--c); border-radius: var(--wobble);
  padding: 14px 14px 10px; box-shadow: 5px 5px 0 rgba(0, 0, 0, .18); scroll-margin-top: 70px;
}
.person-list:nth-child(5n+1) { --c: var(--blue); }
.person-list:nth-child(5n+2) { --c: var(--pink); transform: rotate(.5deg); }
.person-list:nth-child(5n+3) { --c: var(--lime); transform: rotate(-.5deg); }
.person-list:nth-child(5n+4) { --c: var(--red); }
.person-list:nth-child(5n+5) { --c: var(--green); transform: rotate(.4deg); }
.person-list h2 { color: var(--c); display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-right: 100px; min-height: 64px;
  text-decoration: underline wavy var(--c) 2px; text-underline-offset: 7px; }
.person-list h2 .name { text-shadow: 1px 1px 0 var(--pen); }
.person-list .sticker { position: absolute; top: 6px; right: 12px; height: 86px; max-width: 90px; object-fit: contain; width: auto; mix-blend-mode: multiply; }
.person-list:nth-child(5n+1) .sticker { transform: rotate(6deg); }
.person-list:nth-child(5n+2) .sticker { transform: rotate(-8deg); }
.person-list:nth-child(5n+3) .sticker { transform: rotate(10deg); }
.person-list:nth-child(5n+4) .sticker { transform: rotate(-5deg); }
.person-list:nth-child(5n+5) .sticker { transform: rotate(7deg); }

.back { display: block; width: fit-content; margin: 8px 0 6px; color: var(--blue); font-weight: 700; }

.add-form { display: grid; gap: 10px; margin: 16px 0 24px; border-color: var(--lime); }
.add-form .primary { justify-self: start; }

.gifts { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
.gift {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #fff; border: 2.5px solid var(--pen); border-radius: var(--wobble2);
  padding: 10px 14px; box-shadow: 3px 3px 0 rgba(0, 0, 0, .2);
}
.gift:nth-child(odd) { transform: rotate(-.4deg); }
.gift:nth-child(even) { transform: rotate(.35deg); }
.gift.fresh { background: #fff6c8; border-color: var(--red); }
.gift.taken:not(.fresh) { background: #f3f3f0; }
.gift-main { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.gift-title { font-weight: 700; font-size: 1.2rem; }
.gift-link { display: inline-block; color: var(--blue); font-size: 1rem; }
.gift-note { margin: 2px 0 0; color: #444; white-space: pre-wrap; }
.gift-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.claimed { font-weight: 700; color: #555; display: inline-flex; align-items: center; gap: 6px; }
.claimed.mine { color: var(--green); }
.claimed .gift-ico { height: 26px; width: auto; mix-blend-mode: multiply; }
.empty { display: flex; align-items: center; gap: 12px; padding: 12px; color: #555; border: 2px dashed #aaa; border-radius: var(--wobble2); margin: 0; }
.empty .empty-ico { height: 60px; width: auto; mix-blend-mode: multiply; flex: none; }

/* Étiquette « Nouveau » : étoile hérissée dessinée au crayon */
.tag-new {
  display: inline-block; vertical-align: middle; margin-left: 8px; padding: 13px 20px 12px;
  font: 700 1rem/1 var(--hand); color: var(--red); transform: rotate(-7deg);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 60' preserveAspectRatio='none'><polygon points='50,2 58,15 72,3 74,18 92,9 86,26 99,30 86,38 95,53 76,46 72,58 58,47 48,58 40,46 22,56 26,42 4,45 16,32 2,22 22,22 16,6 36,17' fill='%23f6a5b4' stroke='%231b1b1b' stroke-width='1.6' stroke-linejoin='round' vector-effect='non-scaling-stroke'/></svg>") center / 100% 100% no-repeat;
}

.form-error { color: var(--red); font-weight: 700; margin: 8px 0; }

/* ------------------------------------------------ Boîte de dialogue et message */
dialog { border: 4px solid var(--lime); border-radius: var(--wobble); padding: 20px; width: min(480px, calc(100vw - 32px)); box-shadow: 8px 8px 0 rgba(0, 0, 0, .3); font-family: var(--hand); font-size: 19px; }
dialog::backdrop { background: rgba(60, 35, 10, .55); }
dialog .row { display: flex; justify-content: flex-end; gap: 12px; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) rotate(-1.5deg); z-index: 10;
  max-width: calc(100vw - 32px); padding: 10px 20px; background: #fff59d; color: var(--pen);
  border: 2px solid var(--pen); box-shadow: 4px 4px 0 rgba(0, 0, 0, .3); font-weight: 700;
}
.toast.error { background: #ffb3ba; }

/* ------------------------------------------------ Tablette / téléphone */
@media (max-width: 900px) {
  .sheet { margin: 12px 10px 30px; padding: 10px 12px 30px; }
}
@media (max-width: 700px) {
  body { font-size: 18px; }
  .lists-grid { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.9rem; }
  .panel .hero { height: 110px; }
}

/* ---- composition de l'en-tête : positions de la photo (ordinateur) ---- */
.art .s-pere { left: 0.53%; top: 1.97%; width: 23.94%; }
.art .s-merry { left: 4.68%; top: 21.31%; width: 29.89%; }
.art .s-birds { left: 34.15%; top: 8.20%; width: 9.36%; }
.art .s-joyeux { left: 43.72%; top: 14.75%; width: 19.47%; }
.art .s-jingle { left: 66.22%; top: 14.75%; width: 27.02%; }
.art .s-sun { left: 93.24%; top: 4.59%; width: 5.90%; }
.art .s-stamp { left: 91.70%; top: 31.15%; width: 5.21%; }
.art .s-tree { left: 23.62%; top: 48.20%; width: 5.85%; }
.art .s-burst { left: 30.32%; top: 47.21%; width: 25.00%; }
.art .s-lutin { left: 55.32%; top: 50.49%; width: 7.13%; }
.art .s-lutinlbl { left: 61.91%; top: 84.59%; width: 8.51%; }
.art .s-oh { left: 59.57%; top: 47.54%; width: 32.77%; }
.art .s-flake { left: 89.26%; top: 65.90%; width: 9.26%; }
@media (max-width: 700px) {
  .art { aspect-ratio: 100 / 84; }
  .art .s-pere { left: 1%; top: 1.19%; width: 34%; }
  .art .s-merry { left: 34%; top: 3.57%; width: 52%; }
  .art .s-birds { left: 86%; top: 0.00%; width: 12%; }
  .art .s-joyeux { left: 2%; top: 32.14%; width: 40%; }
  .art .s-jingle { left: 44%; top: 44.05%; width: 46%; }
  .art .s-sun { left: 90%; top: 38.10%; width: 8%; }
  .art .s-stamp { display: none !important; }
  .art .s-tree { left: 2%; top: 61.90%; width: 12%; }
  .art .s-burst { left: 16%; top: 61.90%; width: 50%; }
  .art .s-lutin { left: 70%; top: 61.90%; width: 14%; }
  .art .s-lutinlbl { left: 84%; top: 84.52%; width: 14%; }
  .art .s-oh { display: none !important; }
  .art .s-flake { display: none !important; }
}

