@font-face {
  font-family: 'Clash Display';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/clash-display-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter-latin-var.woff2') format('woff2');
}

:root {
  --muro: #f3ead9;
  --muro-riga: #ece0ca;
  --legno: #8f5730;
  --legno-fronte: #b97a47;
  --inchiostro: #2a1d12;
  --tenue: #6b5847;
  --carta: #fffaf0;
  --cartellino: #fff3b0;
  --rosso: #c8372d;
  --verde: #1f5a43;
  --nastro: #f2c14e;
  --ombra: rgba(42, 29, 18, .25);
  --foto-blend: multiply;
  --foto-fondo: transparent;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --muro: #1d1712;
    --muro-riga: #221b15;
    --legno: #5c3a20;
    --legno-fronte: #7d5130;
    --inchiostro: #f3ead9;
    --tenue: #bba892;
    --carta: #2a221b;
    --verde: #2f7a5d;
    --ombra: rgba(0, 0, 0, .5);
    /* multiply su fondo scuro spegnerebbe le foto: meglio un fondo bianco */
    --foto-blend: normal;
    --foto-fondo: #fff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 Inter, system-ui, sans-serif;
  color: var(--inchiostro);
  background: repeating-linear-gradient(90deg, var(--muro) 0 28px, var(--muro-riga) 28px 56px);
  padding-bottom: 120px;
}
h1, h2 { font-family: 'Clash Display', system-ui, sans-serif; font-weight: 600; line-height: 1.1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid var(--nastro); outline-offset: 2px; }

/* Insegna con tenda a righe */
.insegna {
  position: relative;
  background: var(--verde);
  color: #fdf6e3;
  text-align: center;
  padding: 64px 16px 20px;
}
.insegna::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 40px;
  background: repeating-linear-gradient(90deg, var(--rosso) 0 36px, #fdf6e3 36px 72px);
  -webkit-mask: radial-gradient(18px at 18px 22px, #000 98%, transparent) 0 0 / 36px 40px repeat-x, linear-gradient(#000 0 0) 0 0 / 100% 22px no-repeat;
  mask: radial-gradient(18px at 18px 22px, #000 98%, transparent) 0 0 / 36px 40px repeat-x, linear-gradient(#000 0 0) 0 0 / 100% 22px no-repeat;
}
.insegna h1 { font-size: clamp(2rem, 7vw, 3.4rem); margin: 0 0 8px; letter-spacing: .01em; }
.insegna p { margin: 0 auto 16px; max-width: 34em; opacity: .9; }
#corsie { display: flex; gap: 8px; overflow-x: auto; justify-content: safe center; padding: 4px 0; scrollbar-width: none; }
#corsie a {
  flex: none;
  color: var(--inchiostro);
  background: var(--carta);
  text-decoration: none;
  font-size: .9rem;
  padding: 6px 12px;
  border-radius: 999px;
}
#corsie a:hover { background: var(--nastro); color: #2a1d12; }

/* Corsie e mensole */
main { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.vuoto { text-align: center; color: var(--tenue); padding: 48px 0; }
.corsia { padding-top: 40px; scroll-margin-top: 8px; }
.corsia h2 {
  display: inline-flex;
  flex-direction: column;
  margin: 0 0 12px;
  padding: 8px 16px;
  font-size: 1.4rem;
  background: var(--verde);
  color: #fdf6e3;
  border-radius: 6px;
  box-shadow: 0 4px 0 var(--ombra);
}
.corsia h2 small { font-family: Inter, sans-serif; font-size: .7rem; letter-spacing: .15em; text-transform: uppercase; opacity: .75; }

/* La mensola è lo sfondo: una tavola ogni --riga, così va a capo da sola */
.mensola {
  --riga: 252px;
  --tavola: 62px;
  list-style: none;
  margin: 0;
  padding: 0 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  grid-auto-rows: var(--riga);
  column-gap: 12px;
  background: linear-gradient(transparent calc(var(--riga) - var(--tavola)),
    var(--legno) 0 calc(var(--riga) - var(--tavola) + 6px), var(--legno-fronte) 0) 0 0 / 100% var(--riga) repeat-y;
  border-radius: 4px;
  filter: drop-shadow(0 8px 6px var(--ombra));
}
@media (max-width: 640px) {
  .mensola {
    grid-auto-flow: column;
    grid-auto-columns: 132px;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -16px;
    padding: 0 16px;
    border-radius: 0;
  }
  .mensola li { scroll-snap-align: start; }
}

.prodotto {
  position: relative;
  display: grid;
  grid-template-rows: 1fr var(--tavola);
  width: 100%;
  height: 100%;
  padding: 12px 0 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.foto {
  align-self: end;
  justify-self: center;
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
  mix-blend-mode: var(--foto-blend);
  background: var(--foto-fondo);
  border-radius: 6px;
  transition: transform .2s ease;
}
.segnaposto {
  display: grid;
  place-items: center;
  width: 110px;
  height: 120px;
  font-size: 3.4rem;
  background: var(--carta);
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--muro-riga);
}
.prodotto:hover .foto, .prodotto:focus-visible .foto { transform: translateY(-6px) rotate(-2deg); }
.cartellino {
  align-self: center;
  justify-self: center;
  max-width: 100%;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.25;
  color: #2a1d12;
  background: var(--cartellino);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  display: grid;
}
.cartellino .nome {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cartellino small { font-size: .68rem; font-weight: 500; opacity: .8; white-space: nowrap; }
.bollino:empty { display: none; }
.bollino {
  position: absolute;
  top: 36%;
  left: 50%;
  translate: -50% 0;
  rotate: -10deg;
  max-width: 96%;
  padding: 3px 8px;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff;
  background: var(--rosso);
  border: 2px dashed rgba(255, 255, 255, .7);
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preso .foto, .preso .segnaposto { filter: grayscale(.85); opacity: .45; }

/* Il pacco */
.pacco {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 80px;
  height: 76px;
  z-index: 40;
  filter: drop-shadow(0 6px 8px var(--ombra));
}
.pacco.salta { animation: salta .55s ease; }
@keyframes salta {
  30% { transform: scale(1.18, .82); }
  60% { transform: scale(.94, 1.08) translateY(-8px); }
}
.scatola, .coperchio {
  position: absolute;
  background: linear-gradient(90deg, transparent 43%, var(--nastro) 43% 57%, transparent 57%), var(--rosso);
  border-radius: 4px;
}
.scatola { inset: 26px 6px 0; }
.coperchio {
  left: 0;
  right: 0;
  top: 12px;
  height: 18px;
  z-index: 1;
  transform-origin: 8% 100%;
  transition: transform .25s ease;
}
.coperchio::before, .coperchio::after {
  content: '';
  position: absolute;
  bottom: 100%;
  width: 18px;
  height: 14px;
  border: 4px solid var(--nastro);
  border-radius: 50% 50% 0 50%;
}
.coperchio::before { right: 50%; rotate: 20deg; }
.coperchio::after { left: 50%; rotate: 70deg; }
.pacco.aperto .coperchio { transform: translateY(-16px) rotate(-30deg); }
.conta {
  position: absolute;
  top: 0;
  left: -8px;
  z-index: 2;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .9rem;
  color: var(--verde);
  background: #fdf6e3;
  border: 2px solid var(--verde);
  border-radius: 999px;
}
.in-volo {
  position: fixed;
  margin: 0;
  z-index: 50;
  pointer-events: none;
  mix-blend-mode: normal;
}

/* Scheda prodotto */
dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 0;
  border-radius: 16px;
  color: var(--inchiostro);
  background: var(--carta);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  text-align: center;
}
dialog::backdrop { background: rgba(20, 14, 8, .55); }
dialog h2 { margin: 8px 0 4px; font-size: 1.5rem; }
.chiudi { position: absolute; top: 8px; right: 8px; }
.chiudi button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: inherit; font-size: 1.2rem; cursor: pointer; }
.grande { display: block; margin: 28px auto 0; max-width: 100%; max-height: 220px; object-fit: contain; background: #fff; border-radius: 8px; }
.grande.segnaposto { width: 160px; height: 160px; font-size: 5rem; }
.cat { margin: 0 0 16px; color: var(--tenue); font-size: .9rem; }
.prezzo {
  display: inline-grid;
  margin: -4px 0 16px;
  padding: 8px 20px;
  color: #2a1d12;
  background: var(--cartellino);
  border-radius: 4px;
  rotate: -2deg;
  box-shadow: 0 2px 4px var(--ombra);
}
.prezzo small { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }
.prezzo strong { font-family: 'Clash Display', system-ui, sans-serif; font-size: 1.8rem; line-height: 1.1; }
.prezzo span { font-size: .85rem; font-weight: 600; }

/* Festa del GRAZIE */
.festa {
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  overflow: hidden;
  pointer-events: none;
}
.festa i {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 10px;
  height: 14px;
  border-radius: 2px;
}
.festa i:nth-child(3n) { width: 8px; height: 8px; border-radius: 50%; }
.festa .emoji { width: auto; height: auto; font-size: 1.8rem; font-style: normal; }
.grazie {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-family: 'Clash Display', system-ui, sans-serif;
  font-size: clamp(4rem, 18vw, 11rem);
  font-weight: 600;
  color: var(--nastro);
  -webkit-text-stroke: 3px var(--rosso);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--rosso), 0 12px 30px rgba(0, 0, 0, .4);
  animation: svanisci 2.6s ease forwards;
}
.grazie span { display: inline-block; animation: lettera .6s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes lettera {
  from { transform: translateY(60px) scale(.2) rotate(-20deg); opacity: 0; }
}
@keyframes svanisci {
  0%, 70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.2); }
}
.azioni { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--inchiostro);
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: wait; }
.primario { background: var(--rosso); border-color: var(--rosso); color: #fff; width: 100%; }
.whatsapp { background: #25d366; border-color: #25d366; color: #0b3b1e; }
.tenue { border-color: transparent; color: var(--tenue); font-weight: 400; }
.firma, .nota { margin-top: 20px; padding-top: 16px; border-top: 2px dashed var(--muro-riga); display: grid; gap: 10px; }
.firma label { display: grid; gap: 6px; text-align: left; font-weight: 600; }
.firma input {
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--tenue);
  border-radius: 10px;
  background: var(--muro);
  color: inherit;
  font: inherit;
}
.nota p { margin: 0; }
.avviso {
  margin: 16px 0 0;
  padding: 10px 12px;
  font-size: .9rem;
  text-align: left;
  color: #2a1d12;
  background: var(--nastro);
  border-radius: 10px;
}
.errore { margin: 0; color: var(--rosso); font-size: .9rem; }
.errore:empty { display: none; }
.evviva { font-size: 3.5rem; margin: 0; animation: salta .6s ease; }

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

/* Countdown, filtro budget, piè di pagina */
.countdown {
  display: inline-block;
  margin: 0 0 12px !important;
  padding: 4px 14px;
  font-weight: 700;
  color: #2a1d12;
  background: var(--nastro);
  border-radius: 999px;
  opacity: 1 !important;
}
.budget { display: flex; gap: 6px; overflow-x: auto; justify-content: safe center; align-items: center; padding: 8px 0 0; scrollbar-width: none; }
.budget span { flex: none; font-size: .85rem; opacity: .85; }
.budget button {
  flex: none;
  min-height: 36px;
  padding: 4px 12px;
  border: 2px solid rgba(253, 246, 227, .5);
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.budget button[aria-pressed="true"] { background: #fdf6e3; border-color: #fdf6e3; color: #2a1d12; font-weight: 600; }
.piede { max-width: 1100px; margin: 48px auto 0; padding: 0 16px; text-align: center; font-size: .85rem; color: var(--tenue); }

/* Stato sulla mensola: bollino "preso" o barra della colletta */
.stato { display: contents; }
.barra {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: calc(var(--tavola) + 4px);
  height: 18px;
  overflow: hidden;
  font-size: .65rem;
  font-weight: 700;
  line-height: 18px;
  color: #2a1d12;
  background: linear-gradient(90deg, var(--nastro) var(--p), rgba(255, 250, 240, .9) var(--p));
  border: 1px solid #2a1d12;
  border-radius: 999px;
}
.barra span { position: relative; white-space: nowrap; }
.colletta { display: grid; gap: 6px; margin: -4px 0 16px; }
.colletta .barra { position: relative; inset: auto; height: 24px; line-height: 24px; font-size: .8rem; }
.colletta p, .spiega { margin: 0; font-size: .9rem; color: var(--tenue); }
.firma fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 6px; text-align: left; }
.firma legend { padding: 0 0 6px; font-weight: 600; }
.firma .scelta {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  font-weight: 400;
  border: 2px solid var(--muro-riga);
  border-radius: 10px;
  cursor: pointer;
}
.firma .scelta:has(:checked) { border-color: var(--rosso); }
.firma .scelta input { accent-color: var(--rosso); width: 18px; height: 18px; }
