@font-face { font-family: "Fraunces"; src: url("fonts/fraunces-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("fonts/fraunces-latin-wght-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }

:root {
  --pine: #14382f;
  --pine-2: #1d4a3e;
  --paper: #f4f1ea;
  --paper-2: #e6e0d3;
  --paper-3: #d8d0be;
  --wax: #a61e2b;
  --wax-deep: #861723;
  --ink: #14382f;
  --gutter: 12px;
  --scallop: 16px;
  --display: "Fraunces", Georgia, serif;
  --text: "Figtree", system-ui, -apple-system, sans-serif;
  --step-small: 0.875rem;
  --step-body: 1.0625rem;
  --step-lead: 1.25rem;
  --step-head: 2.25rem;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 400 var(--step-body)/1.5 var(--text); color: var(--ink); -webkit-tap-highlight-color: transparent; }
body.ground { background: var(--pine); color: var(--paper); }
body.desk { background: var(--paper); }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--wax); outline-offset: 2px; }
.ground :focus-visible { outline-color: currentColor; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.trap { position: absolute; left: -9999px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.015em; line-height: 1.05; }

/* Barra */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
.mark { display: block; width: 46px; height: 46px; }
.mark svg { display: block; width: 100%; height: 100%; }
.hello { font: italic 500 var(--step-lead) var(--display); }

/* Ceralacca */
.wax { fill: var(--wax); }
.wax-deep { fill: var(--wax-deep); }
.wax-mark { fill: var(--paper); font: italic 700 30px var(--display); }

/* Bottoni */
.btn { display: inline-block; min-height: 48px; padding: 11px 20px; border: 0; border-radius: 0; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; transition: transform .16s var(--ease), background-color .16s; }
.btn:active { transform: scale(.97); }
.btn-wax { background: var(--wax); color: #fff; }
.btn-wax:hover { background: var(--wax-deep); }
.btn-paper { background: var(--paper); color: var(--ink); }
.btn-ink { background: var(--pine); color: var(--paper); }
.btn-ink:hover { background: var(--pine-2); }
.btn-quiet { background: var(--paper-2); color: var(--ink); }
.btn-bad { background: var(--paper); color: var(--wax-deep); text-decoration: underline; }
.btn-wide { display: block; width: 100%; }
.btn-link { background: none; border: 0; padding: 10px 0; min-height: 44px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn-link-bad { color: var(--wax-deep); }

/* Biglietto: angoli a smerlo intagliati nel foglio */
.card {
  position: relative;
  margin: 0 var(--gutter);
  padding: 32px 22px;
  background: var(--paper);
  color: var(--ink);
  -webkit-mask: radial-gradient(circle var(--scallop) at 0 0, #0000 97%, #000) top left / 51% 51% no-repeat, radial-gradient(circle var(--scallop) at 100% 0, #0000 97%, #000) top right / 51% 51% no-repeat, radial-gradient(circle var(--scallop) at 0 100%, #0000 97%, #000) bottom left / 51% 51% no-repeat, radial-gradient(circle var(--scallop) at 100% 100%, #0000 97%, #000) bottom right / 51% 51% no-repeat;
  mask: radial-gradient(circle var(--scallop) at 0 0, #0000 97%, #000) top left / 51% 51% no-repeat, radial-gradient(circle var(--scallop) at 100% 0, #0000 97%, #000) top right / 51% 51% no-repeat, radial-gradient(circle var(--scallop) at 0 100%, #0000 97%, #000) bottom left / 51% 51% no-repeat, radial-gradient(circle var(--scallop) at 100% 100%, #0000 97%, #000) bottom right / 51% 51% no-repeat;
}
.lead { font-size: var(--step-lead); line-height: 1.35; }
.details { margin-top: 22px; font-size: var(--step-body); font-weight: 600; }
.details li + li { margin-top: 4px; }
.details li + li::before { content: ""; display: block; width: 9px; height: 9px; margin: 10px auto; background: var(--wax); transform: rotate(45deg); }
.plain-card { margin-top: 12vh; padding: 36px 24px 40px; }
.title { font-size: var(--step-head); margin-bottom: 14px; font-style: italic; font-weight: 500; }
.plain-card form, .plain-card p + p { margin-top: 20px; }
.flash { margin: 0 var(--gutter) 12px; padding: 12px 16px; background: var(--paper-2); color: var(--ink); font-weight: 600; }
.flash-bad { background: var(--wax); color: #fff; }

/* Neve: pochi fiocchi piatti, solo sul verde */
.flake { position: fixed; top: -12px; width: var(--s, 6px); height: var(--s, 6px); border-radius: 50%; background: var(--paper); opacity: .5; pointer-events: none; animation: fall var(--d, 14s) linear var(--w, 0s) infinite; z-index: 0; }
.bar, main { position: relative; z-index: 1; }
@keyframes fall { to { transform: translate3d(var(--x, 20px), 106vh, 0); } }

/* Tagliando: il bordo a puntini è il foglio che si strappa */
.coupon { margin: 48px var(--gutter) 0; padding: 32px 20px 36px; background: var(--paper); color: var(--ink); border-top: 6px dotted var(--pine); scroll-margin-top: 16px; }
.coupon h2 { font-size: var(--step-head); margin-bottom: 10px; }
.coupon .lead + form { margin-top: 22px; }
.coupon details > p { margin: 8px 0 18px; }
.coupon summary { cursor: pointer; list-style: none; }
.coupon summary::-webkit-details-marker { display: none; }
.coupon summary h2 { display: inline; margin: 0; }
.coupon summary::after { content: "+"; float: right; font: 500 2rem/1 var(--display); color: var(--wax); }
.coupon details[open] summary::after { content: "–"; }
.coupon details[open] summary { margin-bottom: 10px; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; }
input:not([type=hidden]), textarea, select { display: block; width: 100%; min-height: 48px; padding: 11px 12px; font-size: 1.0625rem; color: var(--ink); background: var(--paper-2); border: 0; border-bottom: 2px solid var(--pine); border-radius: 0; -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; line-height: 1.4; }
::placeholder { color: #55695f; opacity: 1; }
.has-error input { border-bottom-color: var(--wax); }
.error { margin-top: 6px; color: var(--wax-deep); font-weight: 600; }
.small { margin-top: 16px; font-size: var(--step-small); line-height: 1.4; }

/* Busta */
.stage { padding: 12px 16px 28px; text-align: center; }
.stage-title { font-size: var(--step-head); font-style: italic; font-weight: 500; margin: 8px 0 26px; }
.stage-hint { max-width: 22em; margin: 26px auto 0; }
.env { position: relative; width: 100%; max-width: 420px; aspect-ratio: 7 / 5; margin: 0 auto; perspective: 900px; transition: transform .7s var(--ease), opacity .4s; }
.env-back, .env-front, .env-flap { position: absolute; inset: 0; }
.env-back { background: var(--paper-3); }
.env-front { z-index: 3; background: var(--paper-2); clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); }
.env-flap { z-index: 4; background: var(--paper); clip-path: polygon(0 0, 100% 0, 50% 60%); transform-origin: top center; transition: transform .6s var(--ease); }
.slip { position: absolute; z-index: 2; left: 6%; right: 6%; top: 8%; bottom: 6%; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 10px; background: #fbf9f4; color: var(--ink); transition: transform .9s var(--ease); }
.slip span { font-size: var(--step-small); }
.slip strong { font: italic 600 clamp(1.5rem, 8vw, 2.25rem)/1.05 var(--display); }
.seal { position: absolute; z-index: 5; left: 50%; top: 60%; width: 96px; height: 96px; margin: -48px 0 0 -48px; padding: 0; background: none; border: 0; border-radius: 50%; cursor: pointer; animation: pulse 2.6s ease-in-out infinite; }
.half { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform .5s var(--ease), opacity .5s; }
.half-a { clip-path: polygon(0 0, 56% 0, 46% 22%, 58% 40%, 44% 60%, 56% 80%, 48% 100%, 0 100%); }
.half-b { clip-path: polygon(56% 0, 100% 0, 100% 100%, 48% 100%, 56% 80%, 44% 60%, 58% 40%, 46% 22%); }
@keyframes pulse { 50% { transform: scale(1.06); } }

.env.s1 .seal { animation: none; pointer-events: none; }
.env.s1 .half-a { transform: translate(-46px, 90px) rotate(-38deg); opacity: 0; }
.env.s1 .half-b { transform: translate(46px, 100px) rotate(42deg); opacity: 0; }
.env.s2 .env-flap { transform: rotateX(180deg); }
.env.s3 .env-flap { z-index: 1; }
.env.s3 .slip { transform: translateY(-62%); }
.env.s4 { opacity: 0; transform: translateY(30px); }
.stage.opened .stage-hint, .stage.opened .stage-title { opacity: 0; transition: opacity .3s; }
.confetto { position: fixed; top: 34vh; width: 7px; height: 7px; border-radius: 50%; background: var(--paper); pointer-events: none; z-index: 20; animation: burst var(--d, 1.4s) var(--ease) forwards; }
.confetto.red { background: var(--wax); border-radius: 0; transform: rotate(45deg); }
@keyframes burst { to { transform: translate3d(var(--x, 0), var(--y, 60vh), 0) rotate(160deg); opacity: 0; } }

.js .locked { display: none; }
.result { margin-bottom: 8px; padding: 34px 22px 26px; text-align: center; animation: rise .55s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
.result-to { font-size: var(--step-body); }
.result-name { font-size: clamp(3rem, 15vw, 5rem); font-style: italic; font-weight: 500; line-height: .98; letter-spacing: -.03em; margin: 8px 0 4px; overflow-wrap: anywhere; }
.wishes { margin-top: 28px; text-align: left; }
.wishes dt { margin-top: 20px; font: italic 600 1.25rem var(--display); color: var(--wax-deep); }
.wishes dd { margin-top: 2px; }
.result > p:not(.result-to) { margin-top: 24px; }
.result .btn-link { margin-top: 20px; }

/* Elenco chat */
.chats { margin-top: 36px; padding: 0 var(--gutter); }
.chats h2 { font-size: var(--step-head); padding: 0 4px 14px; }
.chat-entry { position: relative; display: block; padding: 18px 56px 18px 18px; margin-bottom: 8px; background: var(--pine-2); text-decoration: none; transition: transform .16s var(--ease); }
.chat-entry:active { transform: scale(.985); }
.chat-entry strong { display: block; font: 600 1.25rem/1.2 var(--display); margin-bottom: 4px; }
.chat-entry span { display: block; }
.badge { position: absolute; top: 16px; right: 14px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--wax); color: #fff; font-weight: 700; line-height: 28px; text-align: center; }

/* Conversazione a schermo intero */
.chat { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; height: var(--app-h, 100dvh); background: var(--paper); color: var(--ink); }
.chat-head { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--pine); color: var(--paper); }
.chat-back { flex: none; padding: 6px 2px; min-height: 44px; }
.chat-head h2 { font-size: 1.375rem; font-style: italic; font-weight: 500; line-height: 1.15; }
.chat-head p { font-size: var(--step-small); line-height: 1.3; margin-top: 3px; }
.chat-list { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.chat-day { align-self: center; margin: 10px 0 4px; font-size: var(--step-small); }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 14px; background: var(--paper-2); white-space: pre-wrap; overflow-wrap: anywhere; align-self: flex-start; border-bottom-left-radius: 3px; animation: pop .2s var(--ease) both; }
.bubble.mine { align-self: flex-end; background: var(--pine); color: var(--paper); border-radius: 14px; border-bottom-right-radius: 3px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.chat-empty { margin: auto 12px; text-align: center; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--paper-2); }
.chat-form textarea { flex: 1; max-height: 120px; background: var(--paper); border-bottom: 0; resize: none; }
.chat-error { position: absolute; left: 12px; right: 12px; bottom: 76px; padding: 10px 12px; background: var(--wax); color: #fff; }

/* Pannello */
.desk-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--pine); color: var(--paper); }
.desk-bar .btn-link { color: var(--paper); }
.desk-name { flex: 1; font: italic 500 1.25rem var(--display); }
.desk-main { max-width: 680px; margin: 0 auto; padding: 0 16px 56px; }
.desk-main > section { padding-top: 36px; }
.desk-main h1 { font-size: var(--step-head); margin-bottom: 8px; }
.desk-main h2 { font-size: 1.625rem; margin-bottom: 8px; }
.desk-main .flash { margin: 16px 0 0; }
.next { margin: 16px -16px 0; padding: 24px 16px !important; background: var(--paper-2); }
.next p { margin-bottom: 12px; }
.next-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.people li { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; align-items: center; padding: 12px 0; }
.people li + li { border-top: 2px solid var(--paper-2); }
.who { min-width: 0; flex: 1 1 200px; }
.who strong, .who span { display: block; overflow-wrap: anywhere; }
.who .mail { font-size: var(--step-small); }
.status { font-size: var(--step-small); font-weight: 600; color: var(--pine-2); }
.status-wait { color: var(--wax-deep); }
.row-actions { display: flex; gap: 16px; }
.stack { margin-top: 14px; }
.danger .stack { margin-top: 18px; }
.danger .btn-bad { padding-left: 0; background: none; }

@media (min-width: 720px) {
  :root { --step-head: 3rem; --gutter: auto; }
  .bar { padding: 22px 28px; }
  .card, .coupon { margin-left: auto; margin-right: auto; max-width: 560px; }
  .chats { max-width: 560px; margin-left: auto; margin-right: auto; }
  .chat { max-width: 560px; left: 50%; transform: translateX(-50%); }
  .flash { max-width: 560px; margin-left: auto; margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .flake, .confetto { display: none; }
}
