/* Palette : givre, encre, ruban, sapin, ficelle, papier */
:root {
  --givre: #EAF0F1;
  --papier: #FBFAF5;
  --encre: #17303F;
  --muted: #4E6472;
  --ligne: #C5D2D6;
  --ruban: #A61E2E;
  --ruban-fonce: #861823;
  --sapin: #1F5140;
  --ficelle: #B08A45;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--givre); color: var(--encre); font: 1rem/1.55 var(--sans); }
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 2.07rem; }
h2 { font-size: 1.44rem; }
p { margin: 0 0 1rem; max-width: 68ch; }
a { color: var(--sapin); }
:focus-visible { outline: 3px solid var(--sapin); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.muted { color: var(--muted); }

/* Boutons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--ruban); color: #fff; border: 2px solid var(--ruban);
  border-radius: 6px; padding: .65rem 1.2rem; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--ruban-fonce); border-color: var(--ruban-fonce); }
.btn.ghost { background: transparent; color: var(--encre); border-color: var(--encre); }
.btn.ghost:hover { background: var(--encre); color: #fff; }
.btn.small { padding: .3rem .8rem; font-size: .9rem; }
.btn.danger-btn { background: transparent; color: var(--ruban); }
.btn.danger-btn:hover { background: var(--ruban); color: #fff; }
.btn:disabled, .link:disabled { opacity: .45; cursor: not-allowed; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--sapin); text-decoration: underline; cursor: pointer; }
.link.danger { color: var(--ruban); }

/* Formulaires */
.stack { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
label { font-weight: 600; }
input[type=password], input[type=text], textarea, .link-field {
  font: inherit; color: inherit; background: var(--papier);
  border: 1.5px solid var(--ligne); border-radius: 6px; padding: .55rem .7rem; width: 100%; max-width: 26rem;
}
textarea { resize: vertical; }

/* Messages */
.notices { max-width: 62rem; margin: 1rem auto 0; padding: 0 1.25rem; }
.notice { margin: 0 0 .5rem; padding: .7rem 1rem; background: var(--papier); border-left: 5px solid var(--sapin); }
.notice.error { border-left-color: var(--ruban); }
.notice.warn { border-left-color: var(--ficelle); }

/* Pages simples */
.plain-main { max-width: 26rem; margin: 18vh auto 0; padding: 0 1.25rem; }
.plain-main h1 { margin-bottom: 1rem; }

/* ------- Page participant : nuit d'hiver, cadeau, étiquette ------- */
:root { --ficelle-clair: #DDBB70; --ruban-clair: #C8323F; }
.scene-page {
  min-height: 100vh; color: var(--givre);
  background: radial-gradient(120% 70% at 50% 0%, #2B566F 0%, #17303F 50%, #0E202B 100%) fixed;
}
.scene-page :focus-visible { outline-color: var(--ficelle-clair); }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.scene { position: relative; z-index: 1; max-width: 28rem; margin: 0 auto; padding: 2rem 1.25rem 3rem; text-align: center; }
.stage { display: flex; flex-direction: column; align-items: center; }
.above { position: relative; z-index: 1; width: 100%; min-height: 27rem; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center; }
.above.text { padding-bottom: 3.8rem; }
.eyebrow { margin: 0 0 .4rem; font-size: .9rem; letter-spacing: .05em; color: var(--ficelle-clair); }
.scene h1 { font-size: 2.07rem; color: #fff; margin-bottom: .6rem; }
.scene .lead { margin: 0 auto 1rem; max-width: 24rem; color: #C9D8DD; }
.pill { display: inline-block; margin: 0 0 1rem; padding: .2rem .95rem; border: 1.5px solid var(--ficelle-clair);
  border-radius: 999px; color: var(--ficelle-clair); }
.pill strong { color: #fff; }

/* Le cadeau */
.gift { position: relative; z-index: 2; width: 12rem; margin-top: -3.6rem; }
.gift svg { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 100%; }
.gift .lid { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .75s cubic-bezier(.3, 1.2, .5, 1), opacity .5s .25s; }
.gift .mouth { opacity: 0; transition: opacity .4s .2s; }
.gift.opening .lid, .gift.open .lid { transform: translate(60px, -95px) rotate(24deg); opacity: 0; }
.gift.opening .mouth, .gift.open .mouth { opacity: 1; }
.gift.open .lid, .gift.open .mouth { transition: none; }
.gift.closed svg { animation: wiggle 4s ease-in-out infinite; }
.gift.opening svg { animation: shake .45s ease-in-out; }
@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-3deg); } 88% { transform: rotate(3deg); }
  92% { transform: rotate(-2deg); } 96% { transform: rotate(1deg); }
}
@keyframes shake {
  0%, 100% { transform: rotate(0); } 20% { transform: rotate(-5deg); } 40% { transform: rotate(5deg); }
  60% { transform: rotate(-4deg); } 80% { transform: rotate(3deg); }
}

/* L'étiquette qui sort du cadeau */
.tag-wrap { position: relative; width: min(21rem, 100%); padding-top: 80px; color: var(--ficelle-clair);
  animation: rise 1.1s cubic-bezier(.2, .9, .3, 1.15) both; }
@keyframes rise {
  from { transform: translateY(11rem) scale(.8) rotate(-4deg); opacity: 0; }
  25% { opacity: 1; }
  to { transform: none; opacity: 1; }
}
.twine { position: absolute; top: 0; left: 50%; transform: translateX(-50%); overflow: visible; z-index: 1; }
.tag {
  position: relative; color: var(--encre); background: var(--papier); text-align: left;
  padding: 4.2rem 1.6rem 2.2rem;
  clip-path: polygon(14% 0, 86% 0, 100% 9%, 100% 100%, 0 100%, 0 9%);
  -webkit-mask: radial-gradient(circle at 50% 28px, transparent 12.5px, #000 13px);
  mask: radial-gradient(circle at 50% 28px, transparent 12.5px, #000 13px);
}
.tag dl { margin: 0; display: flex; flex-direction: column; gap: 1.4rem; }
.tag dt { font-size: .9rem; color: var(--muted); }
.tag dd { margin: 0; font-family: var(--serif); font-style: italic; overflow-wrap: anywhere;
  border-bottom: 1.5px dashed var(--ligne); padding-bottom: .2rem; }
.tag .from { font-size: 1.44rem; }
.tag .to { font-size: 2.49rem; line-height: 1.15; color: var(--ruban); }
.tag .budget { font-size: 1.44rem; }
.to.is-revealed { animation: unveil 900ms 700ms ease-out both; }
@keyframes unveil { from { filter: blur(12px); opacity: .1; } to { filter: blur(0); opacity: 1; } }

.scene-actions { margin-top: 1.25rem; }
.hint { color: #B4C6CD; font-size: .95rem; margin: 1rem auto 0; }
.scene-actions .hint:first-child { margin: 0 auto 1rem; }
.btn.gold { background: var(--ficelle-clair); border-color: var(--ficelle-clair); color: #17303F; }
.btn.gold:hover { background: #ECD08A; border-color: #ECD08A; }
.scene .btn.ghost { color: #fff; border-color: #C9D8DD; }
.scene .btn.ghost:hover { background: #fff; color: var(--encre); }

/* ------- Administration ------- */
.page { max-width: 62rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.status { margin: .5rem 0 0; color: var(--muted); }
.page section { border-top: 2px solid var(--encre); padding-top: 1.25rem; margin-top: 2.5rem; }
.page section > h2 { margin-bottom: .6rem; }
.help { color: var(--muted); }
.scroll { overflow-x: auto; }

.people { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
.people th, .people td { text-align: left; padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
.people thead th { font-size: .9rem; color: var(--muted); font-weight: 500; }
.people tbody th { font-weight: 600; white-space: nowrap; }
.linkcell { display: flex; gap: .5rem; align-items: center; min-width: 18rem; }
.linkcell .link-field { max-width: 20rem; font-size: .85rem; padding: .3rem .5rem; }
.add { margin-top: 1.5rem; }
.add textarea { max-width: 22rem; }

.brushes { display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0 .4rem; }
.brush { font: inherit; font-weight: 700; width: 2.4rem; height: 2.4rem; padding: 0; cursor: pointer;
  border: 2px solid var(--ligne); border-radius: 6px; color: var(--encre); }
.brush[aria-pressed="true"] { border-color: var(--encre); box-shadow: 0 0 0 2px var(--encre); }
.scale-legend { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.pair { border: 1.5px solid var(--ligne); border-radius: 6px; padding: .75rem 1rem 1rem; margin: 0 0 1.25rem; max-width: 46rem; }
.pair legend { font-weight: 600; padding: 0 .4rem; }
.pair-row { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; margin-top: .5rem; }
.pair select, .pair input[type=number] { font: inherit; color: inherit; background: var(--papier);
  border: 1.5px solid var(--ligne); border-radius: 6px; padding: .35rem .5rem; }
.pair input[type=number] { width: 5.5rem; }
.pair label { font-weight: 400; display: inline-flex; gap: .4rem; align-items: center; }
.options { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.check { font-weight: 400; display: flex; gap: .5rem; align-items: center; }

.matrix { border-collapse: separate; border-spacing: 2px; }
.matrix thead th { vertical-align: bottom; padding: 0; }
.matrix tbody th { text-align: right; padding-right: .5rem; position: sticky; left: 0; background: var(--givre); z-index: 1; }
.hd { font: inherit; font-size: .9rem; background: none; border: 0; color: var(--encre); cursor: pointer; padding: .25rem; }
.hd:hover:not(:disabled) { text-decoration: underline; }
.hd-col { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.hd-row { white-space: nowrap; }
.cell { width: 2.9rem; height: 2.7rem; border: 1px solid var(--ligne); border-radius: 4px; cursor: pointer;
  font: inherit; color: var(--encre); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; user-select: none; }
.cell:disabled { cursor: default; }
.cell .sym { font-weight: 700; line-height: 1; }
.pct { display: none; font-size: .7rem; line-height: 1.1; }
.with-pct .pct { display: block; }
.diag { background: repeating-linear-gradient(135deg, transparent 0 4px, var(--ligne) 4px 5px); }

/* Notes : 0 interdit, 1 à 4 moins de chances, 5 neutre, 6 à 9 plus de chances, 10 certain */
.n0 { background: #CBD3D6; }
.cell.n0 { background: repeating-linear-gradient(135deg, #CBD3D6 0 5px, #B7C2C6 5px 6px); }
.n1 { background: #EEBFC4; } .n2 { background: #F1CDD1; } .n3 { background: #F4DBDD; } .n4 { background: #F8EAEB; }
.n5 { background: var(--papier); }
.n6 { background: #E4F0E9; } .n7 { background: #D3E7DC; } .n8 { background: #C0DDCC; }
.n9 { background: #8FC1A8; }
.n10 { background: #E6CF93; font-weight: 700; }
.cell.masked { opacity: .35; }

.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
#draw-form { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--encre); color: #fff;
  padding: .7rem 1.1rem; border-radius: 6px; opacity: 0; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.error { background: var(--ruban); }

@media (max-width: 40rem) {
  h1 { font-size: 1.728rem; }
  .bar { flex-direction: column; }
  .tag .to { font-size: 2.07rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tag-wrap, .to.is-revealed, .gift svg, .gift.opening svg { animation: none !important; }
  .gift .lid, .gift .mouth { transition: none !important; }
  #fx { display: none; }
}

.couples { margin: 0 0 1rem; }
.inline { display: flex; gap: .5rem; flex-wrap: wrap; width: 100%; }
.inline input { flex: 1 1 14rem; }
.inline-label { font-weight: 400; }
.inline input[type=number] { flex: 0 0 5rem; width: 5rem; font: inherit; color: inherit; background: var(--papier);
  border: 1.5px solid var(--ligne); border-radius: 6px; padding: .55rem .6rem; }
.inline { align-items: center; }
.small-help { font-size: .9rem; margin: 0; }
.budget-form input { max-width: 16rem; }
.check input[type=number] { width: 4rem; font: inherit; color: inherit; background: var(--papier); border: 1.5px solid var(--ligne); border-radius: 6px; padding: .25rem .4rem; }
