/* Valori di base: i colori di ogni ristorante arrivano da /api/theme/<id> (src/tenant.ts). */
:root {
  --bg: #111827;
  --header: #1f2937;
  --card: #1d2430;
  --line: rgba(245, 158, 11, 0.2);
  --accent: #f59e0b;
  --accent-soft: #f7bd5c;
  --text: #f9fafb;
  --muted: #b3b6bb;
  --bar-bg: rgba(17, 24, 39, 0.96);
  --print-accent: #1f2937;
  --red: #e2735f;
  --green: #7ccf9a;
  --bar-h: 150px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent-soft); }

/* ---------------------------------------------------------------- header */
.hero {
  position: relative;
  background: var(--header);
  text-align: center;
  padding: 28px 16px 18px;
  padding-top: calc(28px + env(safe-area-inset-top));
}
.brand { margin: 0; line-height: 0; }
.logo { height: 140px; width: auto; max-width: min(260px, 70vw); object-fit: contain; display: block; margin: 0 auto; }
.logo-text { margin: 24px 0 8px; font-size: 30px; line-height: 1.15; font-weight: 700; color: var(--accent); }
.lang {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  text-decoration: none;
  color: var(--accent);
}
.charges { margin: 14px 0 0; color: var(--muted); font-size: 14px; display: flex; gap: 18px; justify-content: center; }
.charges b { color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- barra sticky */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 0;
}
.seg {
  display: flex;
  background: var(--card);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 8px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 6px;
  border-radius: 9px;
}
.seg button[aria-selected="true"] { background: var(--accent); color: var(--bg); }
html:not(.js) .seg, html:not(.js) .tools { display: none; }

.tools { display: flex; gap: 8px; }
.tools input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
.tools input::placeholder { color: var(--muted); }
.fbtn {
  font: inherit;
  font-size: 15px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 0 12px;
  white-space: nowrap;
}
.fbtn.active { background: var(--accent); color: var(--bg); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
}
.chip.active { color: var(--bg); background: var(--accent-soft); border-color: var(--accent-soft); }

/* ---------------------------------------------------------------- menu */
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 24px; }

.sec { scroll-margin-top: calc(var(--bar-h) + 8px); padding-top: 18px; }
.sec h2 {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.note { margin: 0 0 6px; color: var(--muted); font-size: 14px; font-style: italic; }

.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.thumb { flex: none; width: 88px; height: 88px; border-radius: 10px; object-fit: cover; background: var(--card); }
.body { flex: 1; min-width: 0; }
.row { display: flex; align-items: baseline; gap: 12px; }
.name { flex: 1; margin: 0; font-size: 17px; font-weight: 650; }
.price { color: var(--accent); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.desc { margin: 3px 0 0; color: var(--muted); font-size: 15px; }
.dlist { padding-left: 18px; }
.dlist li { margin: 2px 0; }
.price small { font-size: 12px; font-weight: 500; color: var(--muted); }
.pnote { margin: 1px 0 0; font-size: 13px; color: var(--accent-soft); text-align: right; }
.item.addon { padding: 4px 0 10px; border-bottom: 0; }
.item.addon .name { font-size: 14px; font-weight: 500; color: var(--muted); }
.item.addon .price { font-size: 14px; }

/* sezione in evidenza (es. Special del giorno) */
.sec.featured {
  margin-top: 16px;
  padding: 14px 14px 4px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: var(--card);
}
.chip.featured { color: var(--accent); border-color: var(--accent); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.badge {
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 7px;
  border: 1px solid currentColor;
}
.badge.sold { color: var(--red); }
.badge.new { color: var(--accent); }
.badge.rec { color: var(--accent-soft); }
.badge.veg { color: var(--green); }
.badge.hot { color: var(--red); }
.unavailable .name, .unavailable .desc, .unavailable .price { opacity: 0.45; }
.unavailable .price { text-decoration: line-through; }
.warn { margin: 6px 0 0; font-size: 13px; color: var(--accent-soft); }

.algs { display: inline-flex; gap: 4px; }
.alg {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  cursor: help;
}

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------------------------------------------------------------- filtro allergeni */
dialog {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--header);
  color: var(--text);
  padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 12px; font-size: 17px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.fchk { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 15px; }
.fchk input { width: 20px; height: 20px; accent-color: var(--accent); }
.small { font-size: 13px; color: var(--muted); }
.factions { display: flex; gap: 10px; justify-content: flex-end; }
.factions button {
  font: inherit;
  border-radius: 10px;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
}
.factions .primary { background: var(--accent); color: var(--bg); font-weight: 600; }

/* ---------------------------------------------------------------- footer */
.foot {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--line);
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text); }
.foot summary { cursor: pointer; color: var(--accent); margin: 10px 0; }
.legend-list { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.contacts { display: flex; gap: 14px; align-items: center; margin-top: 18px; }
.contacts img { width: 64px; height: 64px; flex: none; object-fit: contain; }
.footnotes p { margin: 6px 0; }
.contacts p { margin: 2px 0; }
.contacts strong { color: var(--text); }

@media (min-width: 700px) {
  .logo { height: 170px; }
}

/* ---------------------------------------------------------------- pagina della piattaforma */
.landing main { max-width: 720px; padding: 48px 20px 40px; text-align: center; }
.pf-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.pf-head img { width: clamp(48px, 13vw, 64px); height: auto; }
.pf-head h1 { margin: 0; font-size: clamp(28px, 8vw, 38px); letter-spacing: -1px; color: var(--text); }
.pf-head h1 span { color: var(--accent); }
.pf-sub { color: var(--muted); max-width: 460px; margin: 14px auto 34px; line-height: 1.5; }
.pf-h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 14px; }
/* Card tutte della stessa misura: due colonne sul telefono, colonne fisse e centrate sullo schermo largo. */
.rlist { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 12px; }
.rlist li { display: flex; min-width: 0; }
@media (min-width: 560px) {
  .rlist { grid-template-columns: repeat(auto-fit, 170px); justify-content: center; gap: 14px; }
}
.rlist a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.rlist a:hover, .rlist a:focus-visible { border-color: var(--accent); }
.rlogo { height: 88px; width: 100%; display: flex; align-items: center; justify-content: center; }
.rlist img { max-height: 88px; width: auto; max-width: 100%; object-fit: contain; }
.rname { flex: 1; display: flex; align-items: center; line-height: 1.3; }
.pf-admin {
  display: inline-block;
  margin-top: 36px;
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}
.pf-admin:hover, .pf-admin:focus-visible { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- stampa (PDF dal menu) */
@media print {
  /* html:root vince sulle variabili del tema (/api/theme), caricato dopo questo file */
  html:root {
    --bg: #fff;
    --card: #fff;
    --text: #111;
    --muted: #444;
    --accent: var(--print-accent);
    --accent-soft: var(--print-accent);
    --line: #ddd;
  }
  body { background: #fff; font-size: 11pt; }
  .bar, .lang, dialog, .warn, .foot details, .thumb { display: none !important; }
  /* la fascia del logo resta del colore del locale, così i loghi chiari restano leggibili */
  .hero { padding: 10pt 0 8pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hero .charges, .hero .charges b { color: #eee; }
  .logo { height: 90px; }
  .sec.featured { padding: 6pt 8pt 2pt; }
  main { max-width: none; columns: 2; column-gap: 28pt; padding: 0; }
  .sec { padding-top: 10pt; }
  .sec h2, .sec .note { break-after: avoid; }
  .sec[hidden], .item[hidden] { display: block !important; }
  .item { break-inside: avoid; padding: 4pt 0; }
  .name { font-size: 11pt; }
  .desc { font-size: 9.5pt; }
  .foot { max-width: none; }
  .contacts img { display: none; }
}
