/* Aiuta la mamma a Natale — grafica calda in stile cover illustrata:
   pergamena crema, cuciture tratteggiate, rosso ricco, verde agrifoglio, oro. */
:root {
  --bg-top: #f9ecd2;
  --bg-bottom: #f2ddb4;
  --cream: #fffaf0;
  --cream-deep: #f8ecd6;
  --red-600: #b3222b;
  --red-700: #8f161e;
  --green-700: #1f6b3a;
  --green-800: #14502b;
  --gold-500: #d99a2b;
  --gold-300: #f2c56b;
  --ink: #3a2a1a;
  --ink-soft: #7c6650;
  --stitch: rgba(179, 34, 43, 0.5);
  --shadow: 0 6px 16px rgba(110, 70, 20, 0.18);
  --radius: 18px;
  --font: "Baloo 2", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --script: "Lobster", "Baloo 2", cursive;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(60vw 40vh at 85% 0%, rgba(242, 197, 107, 0.35), transparent 70%),
    radial-gradient(50vw 35vh at 10% 100%, rgba(179, 34, 43, 0.12), transparent 70%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%) fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* ---------- Neve ---------- */
.snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.snow i {
  position: absolute;
  top: -8vh;
  color: #fff;
  text-shadow: 0 1px 3px rgba(110, 70, 20, 0.35);
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(115vh) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .snow { display: none; }
}

/* ---------- Chi sei? ---------- */
.who {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px 28px;
  background: inherit;
}
.who-card {
  width: 100%;
  max-width: 440px;
  text-align: center;
}
.who-cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 22px;
  border: 4px solid var(--cream);
  outline: 2px dashed var(--stitch);
  outline-offset: -10px;
  box-shadow: 0 10px 28px rgba(110, 70, 20, 0.3);
}
.who-ask {
  font-family: var(--script);
  font-weight: 400;
  font-size: 34px;
  color: var(--red-600);
  margin: 18px 0 14px;
  text-shadow: 0 1px 0 #fff;
}
.who-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.who-buttons button {
  font-family: var(--font);
  font-size: 19px;
  font-weight: 700;
  color: var(--green-800);
  background: var(--cream);
  border: 2px dashed var(--stitch);
  border-radius: var(--radius);
  padding: 16px 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}
.who-buttons button:active { transform: scale(0.96); }
.who-buttons .emoji {
  display: block;
  font-size: 40px;
  margin-bottom: 6px;
}

/* ---------- Header ---------- */
.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 140px;
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  background: var(--cream);
  border: 2px dashed var(--stitch);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.header h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}
.header .t-top {
  display: block;
  font-weight: 800;
  color: var(--green-700);
}
.header .t-script {
  font-family: var(--script);
  font-weight: 400;
  font-size: 24px;
  color: var(--red-600);
}
.me-badge {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  color: var(--cream);
  background: var(--red-600);
  border: 2px solid var(--gold-300);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ---------- Tabs persone ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.tabs button {
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  color: var(--green-800);
  background: rgba(255, 250, 240, 0.7);
  border: 2px solid rgba(217, 154, 43, 0.4);
  border-radius: 14px;
  padding: 10px 2px 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tabs button .emoji {
  display: block;
  font-size: 26px;
  margin-bottom: 2px;
}
.tabs button .count {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  font-size: 12px;
  color: var(--cream);
  background: var(--green-700);
  border-radius: 999px;
  padding: 0 5px;
}
.tabs button.active {
  background: var(--red-600);
  color: var(--cream);
  border-color: var(--gold-300);
  box-shadow: var(--shadow);
}
.tabs button.active .count {
  background: var(--gold-300);
  color: var(--red-700);
}

/* ---------- Lista ---------- */
.list-title {
  margin: 0 0 10px;
  font-family: var(--script);
  font-weight: 400;
  font-size: 24px;
  color: var(--green-700);
  text-shadow: 0 1px 0 #fff;
}
.gift-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gift-card {
  background: var(--cream);
  color: var(--ink);
  border: 2px dashed var(--stitch);
  border-left: 6px solid var(--red-600);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.gift-card:nth-child(even) {
  border-color: rgba(31, 107, 58, 0.45);
  border-left-color: var(--green-700);
}
.gift-body { flex: 1; min-width: 0; }
.gift-title {
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: break-word;
}
.gift-note {
  margin-top: 2px;
  font-size: 14px;
  color: var(--ink-soft);
  overflow-wrap: break-word;
}
.gift-note a { color: var(--red-700); }
.gift-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}
.gift-delete {
  flex-shrink: 0;
  font-size: 18px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.55;
}
.gift-delete:active { opacity: 1; }

/* ---------- Stato vuoto ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  font-size: 17px;
}
.empty-gift {
  font-size: 56px;
  animation: bounce 2.4s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- Form aggiunta ---------- */
.add-form {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(242, 221, 180, 0), var(--bg-bottom) 35%);
}
.add-row {
  display: flex;
  gap: 8px;
}
.add-form input {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  background: var(--cream);
  border: 2px dashed var(--stitch);
  border-radius: 999px;
  padding: 12px 18px;
  outline: none;
}
.add-form input:focus { border-style: solid; border-color: var(--gold-500); }
.add-form input::placeholder { color: var(--ink-soft); }
.add-row input { flex: 1; }
.add-row button {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  font-size: 24px;
  background: var(--red-600);
  border: 2px solid var(--gold-300);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}
.add-row button:active { transform: scale(0.92); }
#add-note {
  margin-top: 8px;
  font-size: 14px;
  padding: 9px 18px;
  border-color: rgba(217, 154, 43, 0.5);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 130px;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--green-700);
  color: var(--cream);
  font-weight: 700;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}

/* ---------- Link anteprima mobile (solo desktop) ---------- */
.preview-link {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  font-weight: 700;
  font-size: 14px;
  color: var(--cream);
  background: var(--green-700);
  border: 2px solid var(--gold-300);
  border-radius: 999px;
  padding: 9px 16px;
  text-decoration: none;
  box-shadow: var(--shadow);
}
@media (min-width: 900px) {
  .preview-link { display: inline-block; }
}

@media (min-width: 480px) {
  .header h1 { font-size: 19px; }
  .header .t-script { font-size: 27px; }
  .tabs button { font-size: 15px; }
}
