/* Il blocchetto degli ordini: carta bianca, righe azzurre, inchiostro blu.
   Un solo elemento forte: il timbro con lo stato della lista. */

@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ground: #f2f5fa;
  --ink: #1f3a93;
  --ink-soft: #4a5d9c;
  --text: #16213e;
  --muted: #5b6478;
  --rule: #d6dce8;
  --open: #2e7d4f;
  --closed: #c2332b;
  --draft: #8a6d1f;
  --focus: #f2b705;
  --radius: 10px;
  --tap: 48px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
img, input, select, textarea { max-width: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 17px/1.5 'Atkinson Hyperlegible', system-ui, sans-serif;
}

h1, h2, h3 { line-height: 1.2; margin: 0; color: var(--ink); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 120px;
}

/* Il foglio del blocchetto */
.sheet {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.sheet > h2 { margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.row { display: flex; align-items: center; gap: 12px; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* Righe del blocchetto */
.lines { list-style: none; margin: 0; padding: 0; }
.lines > li {
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
  min-height: var(--tap);
}
.lines > li:last-child { border-bottom: 0; }
.line-name { font-weight: 700; }
.line-meta { color: var(--muted); font-size: 0.92rem; }
.qty { font-variant-numeric: tabular-nums; }

/* Il timbro */
.stamp {
  display: inline-block;
  border: 3px solid currentColor;
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transform: rotate(-2deg);
  line-height: 1.25;
  margin: 6px 0 10px;
  max-width: 100%;
}
.stamp.open { color: var(--open); }
.stamp.closed { color: var(--closed); }
.stamp.draft { color: var(--draft); }
@media (prefers-reduced-motion: no-preference) {
  .stamp.fresh { animation: stamp 260ms ease-out; }
  @keyframes stamp {
    from { transform: scale(1.4) rotate(-6deg); opacity: 0; }
    to { transform: rotate(-2deg); opacity: 1; }
  }
}

/* Moduli */
label { display: block; font-weight: 700; margin-bottom: 4px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.9rem; }
input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--paper);
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(31, 58, 147, 0.15); }
textarea { min-height: 80px; resize: vertical; }
.field + .field { margin-top: 14px; }

/* Pulsanti */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: 700 1rem 'Atkinson Hyperlegible', system-ui, sans-serif;
  cursor: pointer;
  text-decoration: none;
}
button.primary, .button.primary { background: var(--ink); color: #fff; }
button.danger { border-color: var(--closed); color: var(--closed); }
button.quiet { border-color: transparent; background: transparent; padding: 0 8px; }
button.wide { width: 100%; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Selettore di quantità */
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: var(--tap); padding: 0; font-size: 1.4rem; }
.stepper output { min-width: 5.2em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Scelte a pulsante (fasce di ritiro) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choices label {
  margin: 0;
  font-weight: 700;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.choices input:checked + label { border-color: var(--ink); background: var(--ink); color: #fff; }
.choices input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Barra fissa in basso */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bottom-bar .inner { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.total { font-size: 1.2rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Barra delle sezioni del produttore */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabs button {
  flex: 1;
  max-width: 140px;
  border: 0;
  border-radius: 0;
  border-top: 3px solid transparent;
  min-height: 56px;
  font-weight: 400;
  color: var(--muted);
}
.tabs button[aria-selected='true'] { color: var(--ink); font-weight: 700; border-top-color: var(--ink); }

/* Avvisi */
.notice { border-left: 4px solid var(--ink); background: var(--ground); padding: 10px 12px; border-radius: 4px; }
.notice.error { border-left-color: var(--closed); }
.notice.ok { border-left-color: var(--open); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  max-width: calc(100% - 32px);
  z-index: 20;
}

.badge { display: inline-block; font-size: 0.85rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--ground); color: var(--ink-soft); }
.badge.yes { background: #e3f1e8; color: var(--open); }

.copybox { display: flex; gap: 8px; }
.copybox input { font-size: 0.9rem; }

.big-number { font-size: 1.6rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

details > summary { cursor: pointer; font-weight: 700; color: var(--ink); min-height: var(--tap); display: flex; align-items: center; }
