/* Desideri di Natale: notte d'abete, luci calde, biglietti di carta regalo.
   Palette: notte #0b2a22 · pino #14573b · agrifoglio #c8202f · oro #f3c552 · carta #fff6e5 · inchiostro #1f332b */

@font-face { font-family: 'Mountains of Christmas'; src: url(/fonts/mountains-of-christmas-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(/fonts/nunito-var.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  --night: #0b2a22;
  --pine: #14573b;
  --berry: #c8202f;
  --gold: #f3c552;
  --gold-dk: #b8841a;
  --paper: #fff6e5;
  --ink: #1f332b;
  --ink-soft: #5a6e63;
  --line: #dccfae;
  --display: 'Mountains of Christmas', 'Marker Felt', 'Segoe Print', cursive;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; position: relative; overflow-x: hidden;
  min-height: 100vh; min-height: 100dvh;
  background: var(--night); color: var(--paper);
  font: 500 1rem/1.5 var(--body);
}
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button { font-family: inherit; }

/* ---------- cielo e luci ---------- */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(46, 140, 100, .55), transparent 70%),
    radial-gradient(700px 420px at 100% 100%, rgba(22, 76, 96, .45), transparent 70%),
    linear-gradient(180deg, #0d2f26, #081c16);
}
.sky::after {
  content: ""; position: absolute; inset: 0; opacity: .6;
  background-image:
    radial-gradient(1.3px 1.3px at 12% 22%, #fff, transparent 60%),
    radial-gradient(1px 1px at 38% 64%, #fff, transparent 60%),
    radial-gradient(1.5px 1.5px at 63% 12%, #fff, transparent 60%),
    radial-gradient(1px 1px at 82% 48%, #fff, transparent 60%),
    radial-gradient(1.2px 1.2px at 91% 86%, #fff, transparent 60%),
    radial-gradient(1px 1px at 24% 90%, #fff, transparent 60%);
  background-size: 320px 320px;
}
.lights { position: absolute; top: 0; left: 0; right: 0; height: 48px; z-index: 4; overflow: hidden; pointer-events: none; }
.lights i { position: absolute; inset: 0; background-repeat: repeat-x; background-size: 120px 48px; }
.lights .wire { background-image: url(/img/wire.svg); }
.lights .a { background-image: url(/img/bulbs-a.svg); animation: twinkle 2.4s ease-in-out infinite; }
.lights .b { background-image: url(/img/bulbs-b.svg); animation: twinkle 2.4s ease-in-out -1.2s infinite; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .28; } }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 50; pointer-events: none; }

/* ---------- tipografia e bottoni ---------- */
.title {
  margin: 0; padding: 0 .1em .08em;
  font: 700 clamp(2.7rem, 10.5vw, 5.2rem)/.95 var(--display);
  background: linear-gradient(180deg, #fff3c4 8%, var(--gold) 55%, #d9962a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .28));
}
.btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 14px 22px; border-radius: 999px;
  font: 800 1rem/1 var(--body);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
}
.btn.gold {
  color: #3a2705;
  background: linear-gradient(180deg, #ffe595, var(--gold) 55%, #e6ac2e);
  box-shadow: 0 4px 0 var(--gold-dk), 0 10px 18px rgba(0, 0, 0, .28);
}
.btn.gold:hover { filter: brightness(1.06); }
.btn.gold:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-dk), 0 4px 10px rgba(0, 0, 0, .25); }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.btn.ghost:hover { background: rgba(255, 255, 255, .08); }
.btn.small { padding: 9px 16px; font-size: .9rem; }
.btn:disabled { opacity: .6; cursor: progress; }

/* striscia bastoncino di zucchero in cima a carte, biglietti e finestre */
.cane { position: relative; }
.cane::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 8px; border-radius: 18px 18px 0 0;
  background: repeating-linear-gradient(-45deg, var(--berry) 0 10px, #fff 10px 20px);
}

/* ---------- caricamento e accesso ---------- */
.boot { margin: 38vh 0 0; text-align: center; font: 700 1.7rem var(--display); color: var(--gold); }
.login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 72px 18px 40px; text-align: center;
}
.tree { width: 128px; height: auto; margin-bottom: 4px; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45)); }
.login .title { margin-bottom: 18px; font-size: clamp(2.5rem, 12vw, 4.2rem); }
.gifttag {
  width: min(380px, 100%); padding: 30px 22px 20px; text-align: left;
  background: var(--paper); color: var(--ink); border-radius: 18px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
}
.gifttag label { display: block; margin-bottom: 8px; font-weight: 800; }
.gifttag input { text-align: center; text-transform: uppercase; letter-spacing: .14em; font-weight: 800; font-size: 1.2rem; }
.gifttag .btn { width: 100%; margin-top: 14px; }
.hint { margin: 14px 0 0; text-align: center; color: var(--ink-soft); font-size: .92rem; font-weight: 600; }

input, textarea {
  width: 100%; padding: 11px 13px;
  font: 600 1rem/1.4 var(--body); color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9aa79f; font-weight: 500; letter-spacing: normal; }
input:focus, textarea:focus { outline: 3px solid rgba(243, 197, 82, .7); border-color: var(--gold-dk); }
.msg { margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; background: #fde4e4; color: #8f1320; font-weight: 700; font-size: .92rem; }

/* ---------- testata ---------- */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto; padding: 60px 16px 4px;
}
.hello { color: var(--gold); font-weight: 800; font-size: 1.05rem; }
.hero { max-width: 1180px; margin: 0 auto; padding: 4px 16px 0; text-align: center; }
.sub { margin: 12px 0 0; color: #cfe3d8; font-weight: 700; font-size: clamp(1rem, 3.6vw, 1.2rem); }
.countdown {
  display: inline-flex; align-items: center; gap: 10px; margin: 16px 0 0; padding: 7px 16px;
  border-radius: 999px; border: 1px solid rgba(243, 197, 82, .4); background: rgba(243, 197, 82, .12);
  color: var(--gold); font-weight: 800;
}
.countdown:empty { display: none; }
.countdown::before, .countdown::after { content: "✦"; font-size: .8em; }

/* ---------- le palline appese: il menu delle 8 liste ---------- */
.ornaments { max-width: 960px; margin: 28px auto 0; padding: 0 12px 6px; }
.rail { display: flex; flex-wrap: wrap; justify-content: center; row-gap: 20px; } /* su telefono: 2 file da 4, si vedono tutte */
.orn {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer; font: inherit;
  position: relative; width: 80px; color: var(--paper); -webkit-tap-highlight-color: transparent;
}
.orn::before { /* un tratto di filo dorato per cella: così il filo segue le righe quando vanno a capo */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(180deg, #ffe9a6, #d9a72b); box-shadow: 0 0 12px rgba(243, 197, 82, .5);
}
.pend { position: relative; display: flex; flex-direction: column; align-items: center; transform-origin: 50% 0; animation: sway 4.6s ease-in-out var(--d, 0s) infinite; }
.pend::before { /* gancetto dorato */
  content: ""; position: absolute; top: -3px; left: 50%; width: 8px; height: 8px; border-radius: 50%; transform: translateX(-50%);
  background: radial-gradient(circle at 35% 30%, #fff3c4, var(--gold) 55%, var(--gold-dk));
}
.string { width: 1.5px; height: var(--len, 16px); background: linear-gradient(#e8d6a0, #b89a4a); }
.nm { margin-top: 9px; font: 800 .8rem/1.1 var(--body); letter-spacing: .02em; }
.orn:hover .pend, .orn:focus-visible .pend { animation: swing 1.1s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-2.4deg); } 50% { transform: rotate(2.4deg); } }
@keyframes swing { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

/* la pallina: colore e simbolo diversi per ognuno (le iniziali non bastano: 5 nomi su 8 iniziano per G) */
.ball {
  --s: 58px;
  position: relative; flex: none; display: grid; place-items: center;
  width: var(--s); height: var(--s); border-radius: 50%;
  font-size: calc(var(--s) * .42); line-height: 1;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .9) 0 5%, rgba(255, 255, 255, 0) 17%),
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 60%),
    radial-gradient(circle at 50% 58%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, .38) 100%),
    var(--c);
  box-shadow: inset -4px -7px 12px rgba(0, 0, 0, .22), 0 7px 14px rgba(0, 0, 0, .35);
}
.ball::before { /* cappuccio dorato */
  content: ""; position: absolute; top: calc(var(--s) * -.1); left: 50%; transform: translateX(-50%);
  width: calc(var(--s) * .3); height: calc(var(--s) * .18); border-radius: 3px 3px 1px 1px;
  background: linear-gradient(90deg, #b8841a, #ffe08a 45%, #b8841a);
}
.ball::after { /* anellino */
  content: ""; position: absolute; top: calc(var(--s) * -.21); left: 50%; transform: translateX(-50%);
  width: calc(var(--s) * .15); height: calc(var(--s) * .15); border: 2px solid #d9a72b; border-bottom-color: transparent; border-radius: 50%;
}

/* ---------- la bacheca: una carta per persona ---------- */
.board { max-width: 1180px; margin: 0 auto; padding: 34px 16px 0; column-width: 320px; column-gap: 22px; }
.card {
  position: relative; display: inline-block; width: 100%; margin: 0 0 24px; break-inside: avoid; scroll-margin-top: 20px;
  background: var(--paper); color: var(--ink); text-align: left; border-radius: 18px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .38);
}
.card.me { background: #fff1cc; box-shadow: 0 0 0 3px var(--gold), 0 0 40px rgba(243, 197, 82, .35), 0 14px 34px rgba(0, 0, 0, .38); }
.enter .card { animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
.card.flash { animation: flash 1.4s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(243, 197, 82, .95), 0 14px 34px rgba(0, 0, 0, .38); } 100% { box-shadow: 0 0 0 26px rgba(243, 197, 82, 0), 0 14px 34px rgba(0, 0, 0, .38); } }

.badge {
  position: absolute; top: -13px; right: 18px; z-index: 2; padding: 4px 12px; border-radius: 999px;
  background: var(--berry); color: #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .3);
  font: 800 .74rem/1.3 var(--body); letter-spacing: .05em; text-transform: uppercase;
}
.card-head { display: flex; align-items: center; gap: 16px; padding: 30px 18px 10px; }
.card-head .ball { --s: 54px; margin-top: 8px; }
.card-head h2 { margin: 0; font: 700 2.05rem/1 var(--display); color: var(--pine); overflow-wrap: anywhere; }
.count { margin: 5px 0 0; color: var(--ink-soft); font-weight: 700; font-size: .88rem; }

.add { padding: 4px 18px 12px; }
.add .btn { width: 100%; }

.wishes { margin: 0; padding: 4px 0 10px; list-style: none; }
.wish { display: grid; grid-template-columns: 26px 1fr auto; column-gap: 10px; align-items: start; padding: 12px 14px 12px 18px; border-top: 1.5px dashed var(--line); }
.gift { font-size: 1.15rem; line-height: 1.35; }
.wish h3 { margin: 0; font: 800 1rem/1.35 var(--body); overflow-wrap: anywhere; }
.wish h3 a { color: var(--pine); text-decoration: underline; text-decoration-color: rgba(20, 87, 59, .35); text-underline-offset: 3px; }
.wish h3 a:hover { text-decoration-color: currentColor; }
.note { margin: 3px 0 0; color: var(--ink-soft); font-size: .92rem; white-space: pre-line; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 999px; font: 800 .78rem/1 var(--body); text-decoration: none; }
.chip.price { background: #f6e3b0; color: #6a4a07; }
.chip.link { background: #dcefe5; color: #0f5035; }
.chip.link:hover { background: #c9e6d8; }
.wact { display: flex; gap: 2px; margin: -4px -4px 0 0; }
.icon {
  appearance: none; border: 0; background: transparent; cursor: pointer; color: var(--ink);
  min-width: 40px; height: 40px; border-radius: 12px; font-size: 1.05rem;
}
.icon:hover { background: rgba(0, 0, 0, .07); }
.icon.armed { background: var(--berry); color: #fff; padding: 0 10px; font: 800 .8rem var(--body); }
.empty { margin: 4px 18px 20px; padding: 18px 14px; border: 2px dashed var(--line); border-radius: 14px; text-align: center; color: var(--ink-soft); font-weight: 700; }
.empty b { display: block; margin-bottom: 4px; font-size: 1.8rem; font-weight: 400; }

/* ---------- finestra per aggiungere/modificare ---------- */
.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  padding: 0; border: 0; border-radius: 22px; overflow: auto;
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.sheet[open] { animation: pop .22s ease-out; }
.sheet::backdrop { background: rgba(3, 16, 12, .72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.sheet form { display: grid; gap: 14px; padding: 34px 22px 22px; border-radius: 22px; }
.sheet .cane::before { border-radius: 22px 22px 0 0; }
.sheet h2 { margin: 0; font: 700 2.1rem/1 var(--display); color: var(--pine); }
.sheet label { display: grid; gap: 6px; font-weight: 800; }
.sheet label small { font-weight: 600; color: var(--ink-soft); }
.sheet .msg { margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.sheet .btn.ghost { color: var(--ink); }
.sheet .btn.ghost:hover { background: rgba(0, 0, 0, .06); }

/* ---------- avviso e piede di pagina ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px; text-align: center;
  background: var(--night); color: var(--gold); border: 1px solid rgba(243, 197, 82, .5);
  font-weight: 800; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  opacity: 0; transform: translate(-50%, 24px); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.drift {
  margin-top: 36px; padding: 96px 16px calc(34px + env(safe-area-inset-bottom)); text-align: center;
  background: url(/img/drift.svg) bottom center / 100% 100% no-repeat;
  color: var(--pine); font: 700 1.7rem var(--display);
}
.drift p { margin: 0; }

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