:root {
  --bg: #d9d6cc;
  --paper: #fdfcf8;
  --ink: #1a1a1a;
  --muted: #666;
  --faint: #aaa;
  --hl: #fde047;
  --w: 400px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  background-image: radial-gradient(rgba(0,0,0,.06) 1px, transparent 1.2px);
  background-size: 5px 5px;
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.receipt {
  width: min(var(--w), 100% - 24px);
  margin: 0 auto;
  padding: 0 0 80px;
}

.paper {
  background: var(--paper);
  padding: 28px 18px 40px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  position: relative;
  transform-origin: top center;
}
.paper::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -9px;
  height: 9px;
  background: radial-gradient(circle at 8px 9px, transparent 8px, var(--paper) 8.5px) 0 0 / 16px 9px repeat-x;
}

/* stampa: si srotola dall'alto */
@keyframes print {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 -20px 0); }
}
.paper.printing { animation: print 2.4s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) {
  .paper.printing { animation: none; }
}

h1, h2, p { margin: 0; }

h1 { font-size: 20px; font-weight: 700; letter-spacing: 3px; text-align: center; }
h2 { font-size: 13px; font-weight: 700; margin: 4px 0 8px; letter-spacing: 1px; }

.c { text-align: center; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; color: var(--faint); margin-top: 8px; }

.meta {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px;
  margin-top: 14px; font-size: 11.5px; color: var(--muted);
}
.meta b { color: var(--ink); font-weight: 500; }

hr { border: 0; border-top: 1px dashed #333; margin: 12px 0; }

/* ---------- voci ---------- */
.item { border: 0; margin: 0 -18px; }
.item summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 0 10px;
  align-items: start;
  padding: 8px 18px;
  -webkit-tap-highlight-color: transparent;
}
.item summary::-webkit-details-marker { display: none; }
.item summary:hover { background: rgba(0,0,0,.025); }
.item[open] summary { background: #f4f2ea; }

.logo {
  width: 36px; height: 36px; border-radius: 8px; object-fit: contain; padding: 2px;
  background: #fff;
}

.body { display: block; min-width: 0; }
.t { display: block; font-weight: 700; font-size: 13px; line-height: 1.25; letter-spacing: .3px; }
.t::after {
  content: ""; display: inline-block;
  width: 5px; height: 5px; margin-left: 9px;
  border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint);
  transform: translateY(-3px) rotate(45deg);
  transition: transform .2s ease;
}
.item[open] .t::after { transform: translateY(0) rotate(-135deg); }
.r { display: block; font-size: 11.5px; line-height: 1.35; }
.r small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 10px; }
.d { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

.num { display: block; text-align: right; font-weight: 700; font-size: 13.5px; white-space: nowrap; line-height: 1.25; }
.num b { display: block; }
.num small { display: block; font-weight: 400; font-size: 10.5px; color: var(--muted); margin-bottom: 4px; }
.hl { background: var(--hl); padding: 0 3px; }

/* descrizione aperta */
.x { padding: 6px 18px 14px 64px; background: #f4f2ea; }
.x p { font-size: 13.5px; line-height: 1.6; margin-top: 8px; }
.x .links, .foot .links { font-size: 13px; }
.x a, .foot a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; margin-right: 10px; }

/* animazione apertura */
.item .x { animation: open .25s ease-out; }
@keyframes open { from { opacity: 0; transform: translateY(-4px); } }

.prose { font-size: 13px; color: var(--muted); line-height: 1.6; }

.bullets { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.bullets li { padding-left: 16px; position: relative; margin-bottom: 4px; line-height: 1.5; }
.bullets li::before { content: "-"; position: absolute; left: 2px; color: var(--ink); }

/* ---------- footer ---------- */
.foot p + p { margin-top: 8px; }
.barcode {
  height: 34px; margin-top: 18px;
  background: repeating-linear-gradient(90deg,
    #111 0 2px, transparent 2px 4px,
    #111 4px 5px, transparent 5px 8px,
    #111 8px 11px, transparent 11px 13px,
    #111 13px 14px, transparent 14px 18px,
    #111 18px 20px, transparent 20px 21px);
}

@media (min-width: 600px) {
  body { font-size: 14.5px; }
  .receipt { padding-top: 24px; }
  .paper { transform: rotate(-.4deg); }
}
