/* ---------------- The letter to Santa: 38 px ruled paper ---------------- */
.stage { position: relative; perspective: 1600px; min-width: 0; }
/* --tilt and --sheet shrink as the letter grows (letter.js), so a long letter never sticks out of the page */
.letter-wrap { position: relative; transform: rotate(var(--tilt, 1.2deg)); }
.letter-wrap.arrive { transform: translateY(120px) rotate(6deg); opacity: 0; animation: letterIn 1.1s .6s cubic-bezier(.2,.9,.25,1.05) forwards; transform-origin: 50% 100%; }
.letter-wrap.tilt-l { transform: rotate(var(--tilt, -.8deg)); }
@keyframes letterIn { to { transform: rotate(var(--tilt, 1.2deg)); opacity: 1; } }
.letter-wrap::before { content: ""; position: absolute; inset: 10px -8px -10px 8px; background: #efe0c2; transform: rotate(var(--sheet, -3deg)); box-shadow: 0 20px 40px rgba(40,5,8,.45); border-radius: 2px; }
.letter { position: relative; color: var(--ink); padding: var(--line) 44px calc(var(--line) * 1.5) 78px; margin: 0; min-width: 0;
  --deckle: polygon(0 0,100% 0,100% calc(100% - 14px),97% calc(100% - 6px),93% calc(100% - 13px),89% calc(100% - 4px),84% calc(100% - 12px),79% calc(100% - 3px),74% calc(100% - 11px),69% calc(100% - 4px),63% calc(100% - 13px),58% calc(100% - 5px),52% calc(100% - 12px),47% calc(100% - 3px),41% calc(100% - 12px),36% calc(100% - 5px),30% calc(100% - 11px),25% calc(100% - 2px),19% calc(100% - 12px),14% calc(100% - 5px),8% calc(100% - 12px),3% calc(100% - 4px),0 calc(100% - 13px));
  clip-path: var(--deckle);
  background:
    linear-gradient(90deg, transparent 58px, rgba(154,42,44,.45) 58px, rgba(154,42,44,.45) 60px, transparent 60px),
    repeating-linear-gradient(180deg, transparent 0 calc(var(--line) - 1px), rgba(29,74,55,.17) calc(var(--line) - 1px) var(--line)),
    radial-gradient(ellipse at 30% 10%, #fffaf0, #f6ead2 70%, #eedcba);
  filter: drop-shadow(0 24px 30px rgba(40,5,8,.5)); }
.letter::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .42 0 0 0 0 .28 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* every line-level element is exactly one ruling tall, text sits on the rule */
.ln { height: var(--line); display: flex; align-items: flex-end; padding-bottom: 6px; position: relative; z-index: 1; min-width: 0; }
.dear { font-family: Caveat, cursive; font-size: 32px; color: var(--red-700); padding-bottom: 2px; }
.prose { font-family: Fraunces, serif; font-style: italic; font-size: 17px; }
.field { border: 0; background: transparent; outline: none; color: var(--ink); padding: 0 2px; min-width: 0; border-radius: 3px; transition: background .2s; }
.field::placeholder { color: #bba585; font-style: italic; font-weight: 400; }
.field:focus, .field:focus-visible { background: rgba(231,183,95,.16); outline: none; }
.field.title { font-family: Fraunces, serif; font-weight: 600; font-size: 17px; font-style: normal; border-bottom: 2px solid var(--gold-2); width: 230px; margin: 0 6px; }

/* text that may wrap: one ruling per line; --shift puts the glyphs on the rule like .ln lines */
.flow { line-height: var(--line); position: relative; top: var(--shift, 0px); z-index: 1; margin: 0; }
.flow.fr { font-family: Fraunces, serif; font-size: 16.5px; --shift: 2.5px; }
.flow.fr.it { font-style: italic; font-size: 17px; }
.flow.cv { font-family: Caveat, cursive; font-size: 22px; --shift: -1px; }

.rows { list-style: none; margin: 0; padding: 0; counter-reset: l; }
.row { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) 24px; gap: 14px; height: var(--line); align-items: end; padding-bottom: 5px; position: relative; counter-increment: l; z-index: 1; }
.row::before { content: counter(l) "."; position: absolute; left: -66px; width: 44px; text-align: right; bottom: 3px; font-family: Caveat, cursive; font-size: 24px; color: var(--red-600); }
.row .nm { font-family: Fraunces, serif; font-size: 20px; font-weight: 600; }
.row .ml { font-size: 14.5px; color: var(--ink-soft); text-overflow: ellipsis; padding-bottom: 2px; }
.row .rm { border: 0; background: none; color: rgba(154,42,44,.45); font-size: 18px; cursor: pointer; padding: 0; line-height: 1; opacity: 0; transition: opacity .2s, color .2s; }
.row:hover .rm, .row:focus-within .rm, .row .rm:focus-visible { opacity: 1; }
.row .rm:hover { color: var(--red-600); }
.row.invalid .ml { color: var(--red-600); text-decoration: underline wavy rgba(154,42,44,.55); }
/* ink writing in */
.row.enter { animation: rowIn .55s cubic-bezier(.2,.8,.2,1); }
.row.enter::before { animation: numPop .5s .1s both cubic-bezier(.3,1.6,.5,1); }
@keyframes rowIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes numPop { from { transform: scale(0) rotate(-20deg); } }
/* crossed out then gone */
.row.leave::after { content: ""; position: absolute; left: -4px; right: 30px; top: 55%; height: 2px; background: var(--red-600); transform-origin: left; animation: strike .3s forwards; border-radius: 2px; }
@keyframes strike { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.row.collapse { height: 0; opacity: 0; padding: 0; overflow: hidden; transition: height .3s, opacity .3s; }

.add { font-family: Caveat, cursive; font-size: 24px; color: var(--pine-500); background: none; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
.add:hover { color: var(--pine-700); }
.add[disabled] { color: #a48c70; cursor: default; }
.add kbd { font-family: Inter, sans-serif; font-size: 11px; color: #b49a78; border: 1px solid #d8c4a2; border-radius: 4px; padding: 1px 5px; margin-left: 8px; vertical-align: 3px; }
.sm { display: none; }
.ps { font-family: Caveat, cursive; font-size: 22px; color: #8a6f55; gap: 6px; white-space: nowrap; }
.ps .field { font-family: Caveat, cursive; font-size: 22px; color: var(--pine-700); font-weight: 700; border-bottom: 1.5px dotted #b49a78; width: 120px; }
.opt { font-family: Caveat, cursive; font-size: 20px; color: #8a6f55; border: 0; background: none; padding: 0; border-bottom: 1.5px dotted #b49a78; cursor: pointer; white-space: nowrap; }
.opt:hover { color: var(--ink); }
.sign { font-family: Caveat, cursive; font-size: 22px; color: #8a6f55; gap: 8px; }
.sign .field { font-family: Caveat, cursive; font-size: 24px; color: var(--ink); border-bottom: 1.5px dotted #b49a78; }
.sign .who { width: 130px; flex: none; }
.sign .mail { flex: 1; width: 0; font-family: Inter, sans-serif; font-size: 14px; text-overflow: ellipsis; }

/* "+ un petit mot" unfolded: written right on the ruling, grows one ruling at a time */
.opt-head { justify-content: space-between; gap: 10px; }
.undo { font-family: Caveat, cursive; font-size: 19px; color: #a48c70; border: 0; background: none; padding: 0; cursor: pointer; white-space: nowrap; font-style: normal; }
.undo:hover { color: var(--red-600); }
.mot { display: block; width: 100%; height: calc(var(--line) * 2); margin: 0; padding: 0 2px; border: 0; outline: none; resize: none; overflow: hidden; background: transparent;
  font-family: Caveat, cursive; font-weight: 600; font-size: 23px; line-height: var(--line); color: var(--pine-700);
  position: relative; top: -1.5px; z-index: 1; border-radius: 3px; }
.mot::placeholder { color: #bba585; font-weight: 500; }
.mot:focus, .mot:focus-visible { background: rgba(231,183,95,.13); outline: none; }
.tally { justify-content: flex-end; gap: 8px; font-family: "Special Elite", monospace; font-size: 12px; color: var(--ink-soft); padding-bottom: 9px; }
.tally .q { font-size: 15px; color: var(--ink); }
.tally.full .q { color: var(--red-600); }
.mot-block[hidden], .opt-line[hidden] { display: none; }

/* "je participe aussi": hand-drawn box, a real checkbox underneath */
.me { gap: 10px; font-family: Caveat, cursive; font-size: 22px; color: #8a6f55; cursor: pointer; user-select: none; }
.me input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.me .box { width: 24px; height: 24px; flex: none; margin-bottom: 1px; }
.me .box svg { width: 100%; height: 100%; overflow: visible; }
.me .sq { fill: rgba(255,250,240,.6); stroke: #8a6f55; stroke-width: 1.6; }
.me .tick { fill: none; stroke: var(--red-700); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset .35s cubic-bezier(.6,0,.4,1); }
.me input:checked + .box .tick { stroke-dashoffset: 0; }
.me input:checked ~ .lbl { color: var(--ink); }
.me input:focus-visible + .box .sq { stroke: var(--gold-2); stroke-width: 2.4; }
.me .aside { margin-left: auto; font-family: Inter, sans-serif; font-size: 13px; color: #a48c70; white-space: nowrap; padding-bottom: 3px; }
.me input:not(:checked) ~ .aside { visibility: hidden; }

/* the wax seal is the submit button */
.seal-row { height: calc(var(--line) * 3); display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.seal-btn { border: 0; background: none; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 16px; text-align: left; color: inherit; }
.seal { width: 84px; height: 84px; flex: none; filter: drop-shadow(0 6px 8px rgba(60,5,8,.45)); transition: transform .25s cubic-bezier(.3,1.6,.5,1); }
.seal-btn:hover .seal { transform: rotate(-8deg) scale(1.06); }
.seal-btn:active .seal { transform: scale(.92); }
.seal-btn .go { font-family: Fraunces, serif; font-weight: 600; font-size: 21px; color: var(--red-700); line-height: 1.15; }
.seal-btn .go small { display: block; font-family: Inter, sans-serif; font-weight: 400; font-size: 13px; color: #8a7058; margin-top: 4px; }
.seal-btn[disabled] { cursor: not-allowed; }
.seal-btn[disabled] .seal { filter: grayscale(.7) drop-shadow(0 6px 8px rgba(60,5,8,.25)); opacity: .55; transform: none; }
.seal-btn[disabled] .go { color: #a08a72; }
.seal-btn.pressing { cursor: progress; }
.seal-btn.pressing .seal { animation: press 1s ease-in-out infinite; }
@keyframes press { 0%,100% { transform: scale(.94) rotate(-4deg); } 50% { transform: scale(1) rotate(4deg); } }
.hintmsg { position: absolute; left: 100px; bottom: -4px; font-family: Caveat, cursive; color: var(--red-600); font-size: 19px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.hintmsg.show { opacity: 1; }
.shake { animation: shake .45s; }
@keyframes shake { 20%,60% { transform: translateX(-6px) rotate(1.2deg); } 40%,80% { transform: translateX(6px) rotate(1.2deg); } }

/* stamp (the budget) + postmark */
.stamp { position: absolute; top: 24px; right: 30px; width: 86px; height: 104px; padding: 7px; z-index: 2;
  background: radial-gradient(circle at 5px 5px, transparent 3.2px, #fffaf0 3.8px) -5px -5px / 10px 10px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); transform: rotate(4deg); }
.stamp.arrive { transform: rotate(4deg) scale(0); animation: stampIn .5s 1.5s cubic-bezier(.3,1.6,.5,1) forwards; }
@keyframes stampIn { to { transform: rotate(4deg) scale(1); } }
.stamp .in { height: 100%; outline: 3px solid #fffaf0; background: linear-gradient(180deg,#1d4a37,#0f2a20); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 6px 4px; color: var(--cream); }
.stamp small { font-size: 7px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .8; }
.stamp input { width: 70px; text-align: center; background: transparent; border: 0; outline: none; font-family: Fraunces, serif; font-weight: 800; font-size: 20px; color: var(--gold); padding: 0; border-radius: 2px; }
.stamp input::placeholder { color: rgba(231,183,95,.55); }
.stamp input:focus, .stamp input:focus-visible { background: rgba(255,255,255,.08); outline: none; }
.stamp .stamp-v { font-family: Fraunces, serif; font-weight: 800; font-size: 18px; color: var(--gold); }
.postmark { position: absolute; top: 92px; right: 76px; width: 78px; height: 78px; border: 2px solid rgba(125,30,34,.45); border-radius: 50%; z-index: 3; pointer-events: none;
  display: grid; place-items: center; text-align: center; font-family: "Special Elite", monospace; font-size: 8px; color: rgba(125,30,34,.65); line-height: 1.5; transform: rotate(-14deg); }
.postmark.arrive { opacity: 0; transform: rotate(-14deg) scale(1.6); animation: pm .35s 1.9s ease-in forwards; }
@keyframes pm { to { opacity: 1; transform: rotate(-14deg) scale(1); } }

/* ---- errors: Santa's red pencil ---- */
.oops { color: var(--red-600); counter-increment: none !important; }
.oops.flow.cv { font-size: 21px; --shift: 0px; }
.oops::before { content: "!"; position: absolute; left: -66px; width: 44px; text-align: right; top: calc(-1 * var(--shift, 0px)); line-height: var(--line); font-family: Caveat, cursive; font-weight: 700; font-size: 26px; color: var(--red-600); }
.oops.write { animation: rowIn .5s cubic-bezier(.2,.8,.2,1); }
.rows li.oops { list-style: none; }
.wavy { text-decoration: underline wavy rgba(154,42,44,.6) !important; text-decoration-thickness: 1.5px !important; text-underline-offset: 4px; color: var(--red-600) !important; }
.missing { border-bottom: 2px dashed rgba(154,42,44,.55) !important; }
.missing::placeholder { color: #c98a80 !important; }
/* on the dark stamp, the red pencil needs a lighter red */
.stamp input.wavy, .stamp input.missing { color: #ffb0a4 !important; text-decoration-color: #ffb0a4 !important; border-bottom-color: #ffb0a4 !important; }
/* a red pencil ring around the margin number of a faulty line */
.row.bad::after { content: ""; position: absolute; left: -48px; bottom: 2px; width: 34px; height: 28px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='28'%3E%3Cpath d='M30 9 C27 2 10 1 5 8 C0 15 6 25 17 25 C27 25 33 18 29 10 C27 6 22 4 18 4' fill='none' stroke='%239a2a2c' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat; }
/* letter-level refusal: a post-office rubber stamp over the seal */
.closed-stamp { position: absolute; left: 112px; top: 50%; transform: translateY(-50%) rotate(-7deg); z-index: 3; pointer-events: none;
  font-family: "Special Elite", monospace; color: rgba(154,42,44,.85); text-align: center; line-height: 1.25;
  border: 2.5px solid rgba(154,42,44,.75); outline: 1.5px solid rgba(154,42,44,.55); outline-offset: 3px; border-radius: 4px; padding: 6px 12px; background: rgba(251,244,230,.35);
  mix-blend-mode: multiply; animation: thump .35s ease-in both; }
.closed-stamp b { display: block; font-weight: 400; font-size: 17px; letter-spacing: 2px; }
.closed-stamp small { font-size: 10px; letter-spacing: 1.5px; }
@keyframes thump { from { opacity: 0; transform: translateY(-50%) rotate(-7deg) scale(1.6); } }

/* ---------------- Send sequence: letter → envelope → away ---------------- */
.envelope { position: absolute; left: 50%; top: 120px; width: 420px; height: 270px; margin-left: -210px; z-index: 6; opacity: 0; pointer-events: none; }
.envelope .back { position: absolute; inset: 0; background: #e9d3ad; border-radius: 6px; box-shadow: 0 30px 50px rgba(40,5,8,.5); }
.envelope .paper { position: absolute; left: 22px; right: 22px; top: 18px; height: 230px; border-radius: 3px; background: repeating-linear-gradient(180deg, #fffaf0 0 21px, #d9e2d8 21px 22px); transition: transform .7s cubic-bezier(.5,0,.3,1); }
.envelope .front { position: absolute; inset: 0; border-radius: 6px; background: #f1dfbd; clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%); }
.envelope .front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, transparent 60%, rgba(0,0,0,.06)); }
.envelope .flap { position: absolute; left: 0; right: 0; top: 0; height: 160px; background: #e4caa0; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transform: rotateX(180deg); transition: transform .5s ease-in; z-index: 3; }
.envelope .wax { position: absolute; left: 50%; top: 116px; width: 70px; height: 70px; margin-left: -35px; z-index: 4; transform: scale(2.4); opacity: 0; }
.envelope .addr { position: absolute; left: 0; right: 0; bottom: 36px; text-align: center; font-family: Caveat, cursive; font-size: 30px; color: var(--ink); z-index: 2; }
.envelope .addr small { display: block; font-family: "Special Elite", monospace; font-size: 11px; letter-spacing: 2px; color: var(--ink-soft); }

.letter-wrap.fold { animation: none; opacity: 1; transform: rotate(var(--tilt, 1.2deg)); transition: transform .7s cubic-bezier(.6,0,.4,1), opacity .5s .3s; }
.letter-wrap.fold.go { transform: translateY(40px) scale(.55) rotateX(60deg); opacity: 0; }

.trail { position: fixed; pointer-events: none; z-index: 20; width: 6px; height: 6px; border-radius: 50%; background: #ffe7a6; box-shadow: 0 0 10px 3px rgba(255,214,120,.8); animation: trail 1s forwards; }
@keyframes trail { to { opacity: 0; transform: scale(.2) translateY(20px); } }

@media (max-width: 980px) {
  .letter { padding-left: 64px; padding-right: 22px; }
  .stamp { transform: rotate(4deg) scale(.8); }
  .stamp.arrive { animation-name: stampInSm; }
  @keyframes stampInSm { to { transform: rotate(4deg) scale(.8); } }
}
@media (max-width: 560px) {
  .row { grid-template-columns: minmax(0, 1fr) 20px; height: calc(var(--line) * 2); grid-template-rows: var(--line) var(--line); row-gap: 0; }
  .row .nm { grid-column: 1; grid-row: 1; align-self: end; padding-bottom: 5px; }
  .row .ml { grid-column: 1; grid-row: 2; align-self: end; padding-bottom: 7px; }
  .row .rm { grid-row: 1; opacity: 1; }
  .row::before { bottom: auto; top: 4px; }
  .row.bad::after { bottom: auto; top: 6px; }
  .field.title { width: 100%; margin: 0; }
  /* event line: "pour le" on one ruling, the name on the next */
  .prose.event { height: calc(var(--line) * 2); display: grid; grid-template-columns: minmax(0, 1fr) auto 56px; grid-template-rows: var(--line) var(--line); align-items: end; padding-bottom: 0; }
  .prose.event > span:first-child { grid-column: 1 / -1; padding-bottom: 6px; }
  .prose.event .title { grid-row: 2; grid-column: 1; margin-bottom: 6px; }
  .prose.event .comma { grid-row: 2; grid-column: 2; padding-bottom: 6px; }
  .lg { display: none; } .sm { display: inline; }
  .ps .field { width: 104px; }
  .sign .who { width: 112px; } /* « votre prénom » fits, and « votre e-mail » still does at 375 px */
  .me .aside { display: none; }
  .letter { padding-right: 16px; }
  .letter-wrap::before { inset: 10px -4px -10px 4px; }
  .stamp, .stamp.arrive { top: 14px; right: 10px; transform-origin: top right; }
  .stamp { transform: rotate(4deg) scale(.72); }
  .stamp.arrive { animation-name: stampInXs; }
  @keyframes stampInXs { to { transform: rotate(4deg) scale(.72); } }
  .postmark { top: 40px; right: 64px; transform: rotate(-14deg) scale(.8); }
  .postmark.arrive { animation-name: pmXs; }
  @keyframes pmXs { to { opacity: 1; transform: rotate(-14deg) scale(.8); } }
  .closed-stamp { left: 88px; }
  .closed-stamp b { font-size: 14px; letter-spacing: 1px; }
  .seal { width: 70px; height: 70px; }
  .seal-btn { gap: 12px; }
  .seal-btn .go { font-size: 18px; } /* « Cacheter et envoyer » stays on one line down to 375 px */
  .hintmsg { left: 82px; }
  .envelope { width: 320px; margin-left: -160px; height: 210px; }
  .envelope .paper { height: 175px; }
  .envelope .flap { height: 125px; }
  .envelope .wax { top: 88px; width: 56px; height: 56px; margin-left: -28px; }
  .envelope .addr { font-size: 25px; bottom: 22px; }
}

/* headings written on the paper keep the hand of the letter */
.letter h1, .letter h2, .letter h3 { font-weight: 400; margin: 0; }
