/* The customers' menu: the BASE look, and the agreement every template builds on (docs/templates.md, docs/template-contract.json).
   A template (web/templates/<id>/template.css) is loaded after this file and changes the look by (1) setting the tokens below and (2) adding rules under .menu and .m-scope. Nothing here
   is written for one look: colours, shapes, depth and type all come from the tokens, so a template that only changes tokens already looks different, and one that wants more adds rules.

   THE RESTAURANT'S OWN COLOUR (written on .menu and on the sheets by the page: js/menu.js, or the server's own HTML; a template reads them, never sets them):
     --m-accent  the colour       --m-on     the text colour that reads on it          --m-at-l / --m-at-d  the colour as TEXT on a light / a dark surface
     --m-as-l / --m-as-d  the colour as a SOFT background that --m-at-* reads on (4.5:1, checked in tests/front.test.mjs)
   --m-at and --m-as are the two of those that belong to the scheme (light or dark) that is on now.

   TOKENS (set by a template; the values here are the base look):
     --m-bg --m-surface --m-surface-2 --m-line --m-border --m-text --m-muted      colours of the page, of cards and controls, of quiet areas inside them, of lines, of text
     --m-r-card --m-r-ctl --m-r-photo --m-r-sheet                                  corner radii: cards, controls (pills), photos, sheets
     --m-shadow --m-float                                                          depth: of a card, of a bar that floats over the page
     --m-font --m-h1 --m-h2 --m-name                                               type: the family and the sizes of the restaurant's name, of a section's title, of a dish's name

   iPhone Safari rule that no template may break: the sticky section bar is a pill at most 87% wide, 10px from the edge, and nothing fixed or sticky runs edge to edge: that is what
   keeps the top and bottom strips of Safari see-through (website-creator). */
.menu, .m-scope {
  --m-at: var(--m-at-l, var(--accent)); --m-as: var(--m-as-l, var(--accent-soft)); --m-accent: var(--accent); --m-on: var(--accent-contrast);
  --m-bg: var(--bg); --m-surface: var(--surface); --m-surface-2: var(--surface-2); --m-line: var(--line); --m-border: var(--border); --m-text: var(--text); --m-muted: var(--muted);
  --m-r-card: var(--r-l); --m-r-ctl: var(--r-pill); --m-r-photo: var(--r-m); --m-r-sheet: var(--r-xl);
  --m-shadow: none; --m-float: 0 4px 16px rgba(0, 0, 0, .12);
  --m-font: var(--font); --m-h1: 28px; --m-h2: 22px; --m-name: 17px;
}
:root[data-theme="dark"] .menu, :root[data-theme="dark"] .m-scope { --m-at: var(--m-at-d, var(--accent)); --m-as: var(--m-as-d, var(--accent-soft)); }
.menu { background: var(--m-bg); color: var(--m-text); font-family: var(--m-font); }
.menu .scroll { background: var(--m-bg); }
/* The sheets (a dish, the filters) are not inside .menu: they live in #layer, above the page. js/menu.js gives them the class m-scope and the same colour variables, so that a badge or a
   pressed chip in a sheet is the same colour as on the page; a template styles them as .m-scope.sheet. */
.m-scope .chip[aria-pressed="true"] { background: var(--m-accent); border-color: var(--m-accent); color: var(--m-on); }
.m-scope .btn.primary { background: var(--m-accent); color: var(--m-on); }
.menu-page { padding-bottom: calc(var(--s8) + var(--sab)); }
.narrow { width: 100%; max-width: 720px; margin-inline: auto; padding-inline: calc(var(--sal) + var(--s4)) calc(var(--sar) + var(--s4)); }

/* ---- the top: cover, logo, name */
.m-hero { position: relative; }
.m-cover { display: block; width: 100%; height: clamp(150px, 42vw, 260px); object-fit: cover; background: var(--m-surface-2); }
.m-cover.plain { background: linear-gradient(135deg, var(--m-accent), color-mix(in srgb, var(--m-accent) 55%, #000)); }
.m-back { position: absolute; z-index: 3; top: calc(10px + var(--sat)); left: calc(10px + var(--sal)); width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--m-surface); color: var(--m-text); box-shadow: var(--m-float); }
.m-id { position: relative; max-width: 720px; margin: 0 auto; padding: 0 calc(var(--sar) + var(--s4)) 0 calc(var(--sal) + var(--s4)); }
.m-logo { display: block; width: 72px; height: 72px; margin-top: -36px; border-radius: 20px; object-fit: cover; background: var(--m-surface); border: 3px solid var(--m-bg); box-shadow: var(--m-float); }
.m-id-text { display: grid; gap: 4px; padding-top: var(--s3); }
.m-id:not(:has(.m-logo)) .m-id-text { padding-top: var(--s4); }
.m-id h1 { font-size: var(--m-h1); line-height: 1.15; overflow-wrap: anywhere; }
.m-id p { color: var(--m-muted); overflow-wrap: anywhere; }
.m-actions { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s4) 0 var(--s1); scrollbar-width: none; }
.m-actions::-webkit-scrollbar { display: none; }
.m-action { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: var(--m-r-ctl); background: var(--m-as); color: var(--m-at); font-size: var(--t-sm); font-weight: 600; text-decoration: none; }
.m-note { display: flex; align-items: flex-start; gap: 10px; margin: var(--s3) 0 0; padding: 12px 14px; border-radius: var(--m-r-photo); background: var(--m-surface-2); font-size: var(--t-sm); overflow-wrap: anywhere; white-space: pre-line; }
.m-note svg { margin-top: 2px; flex: none; color: var(--m-muted); }

/* ---- search and filters */
.m-tools { display: flex; gap: var(--s2); margin-top: var(--s4); }
.m-search-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s2); padding: 0 14px; min-height: 48px; border-radius: var(--m-r-ctl); background: var(--m-surface); border: 1px solid var(--m-border); color: var(--m-muted); }
.m-search-wrap:focus-within { border-color: var(--m-at); box-shadow: 0 0 0 1px var(--m-at); }
.m-search { flex: 1; min-width: 0; padding: 12px 0; border: 0; background: none; outline: none; font-size: var(--t-body); color: var(--m-text); }
.m-filter-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: var(--m-r-ctl); background: var(--m-surface); border: 1px solid var(--m-border); font-size: var(--t-sm); font-weight: 600; color: var(--m-text); }
.m-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--m-accent); color: var(--m-on); font-size: var(--t-cap); }

/* The server writes the first screen with empty places where the search and the section bar will be (the page's script fills them in): they take the room the real ones take, so that nothing moves
   when the script takes over. A template whose search or bar is taller or shorter says so here, under .menu. */
.m-tools[aria-hidden="true"] { min-height: 48px; }
.m-tabs[aria-hidden="true"] { min-height: 52px; visibility: hidden; }

/* ---- the sticky section bar: a pill, never edge to edge */
.m-tabs { position: sticky; top: calc(10px + var(--sat)); z-index: 6; width: min(560px, calc(100% - 2 * var(--pill-edge))); margin: var(--s3) auto 0; border-radius: var(--m-r-ctl);
  background: var(--m-surface); border: 1px solid var(--m-line); box-shadow: var(--m-float); }
.m-tabs-scroll { position: relative; display: flex; gap: 6px; padding: 5px; overflow-x: auto; scrollbar-width: none; border-radius: var(--m-r-ctl); }
.m-tabs-scroll::-webkit-scrollbar { display: none; }
:root[data-theme="dark"] .m-tabs { background: var(--m-surface-2); border-color: var(--m-border); }
.m-tab { flex: none; min-height: 40px; padding: 0 16px; border-radius: var(--m-r-ctl); font-size: var(--t-sm); font-weight: 600; color: var(--m-muted); white-space: nowrap; }
.m-tab[aria-selected="true"] { background: var(--m-accent); color: var(--m-on); }

/* ---- sections and dishes */
.m-cat { margin-top: var(--s7); scroll-margin-top: calc(72px + var(--sat)); }
.m-cat[hidden] { display: none; }
.m-cat h2 { font-size: var(--m-h2); line-height: 1.2; overflow-wrap: anywhere; }
.m-cat > .m-muted { margin-top: 4px; }
.m-items { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: 10px; }
.m-item { border-radius: var(--m-r-card); background: var(--m-surface); border: 1px solid var(--m-line); box-shadow: var(--m-shadow); }
.m-item[hidden] { display: none; }
.m-item-btn { display: flex; align-items: flex-start; gap: var(--s3); width: 100%; padding: 14px; text-align: left; border-radius: var(--m-r-card); }
.m-item-text { flex: 1; min-width: 0; display: grid; gap: 5px; }
.m-name { font-size: var(--m-name); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.m-soldout { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: var(--m-r-ctl); background: var(--warn-soft); color: var(--warn); font-size: var(--t-cap); font-weight: 700; vertical-align: 2px; }
.m-desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; color: var(--m-muted); font-size: 14.5px; line-height: 1.4; overflow-wrap: anywhere; }
.m-prices { display: flex; flex-wrap: wrap; gap: 2px 16px; }
.m-price { display: inline-flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.m-price b { color: var(--m-at); font-size: var(--t-body); }
.m-price small { color: var(--m-muted); font-size: var(--t-meta); }
.m-photo { flex: none; width: 96px; height: 96px; border-radius: var(--m-r-photo); object-fit: cover; background: var(--m-surface-2); }
.m-item.soldout .m-photo { opacity: .5; filter: grayscale(.7); }
.m-item.soldout .m-name, .m-item.soldout .m-price b { color: var(--m-muted); }
.m-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.m-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--m-r-ctl); background: var(--m-as, var(--accent-soft)); color: var(--m-at, var(--accent)); font-size: var(--t-cap); font-weight: 600; }
.m-allergens { font-size: var(--t-cap); color: var(--m-muted); overflow-wrap: anywhere; }
.m-muted { color: var(--m-muted); font-size: var(--t-meta); }
.m-foot { display: grid; gap: var(--s4); margin-top: var(--s8); padding-top: var(--s5); border-top: 1px solid var(--m-line); text-align: center; justify-items: center; }
.m-info { display: grid; gap: var(--s2); justify-items: center; max-width: 520px; }
.m-info p { display: flex; gap: 8px; align-items: flex-start; justify-content: center; text-align: left; overflow-wrap: anywhere; white-space: pre-line; }
.m-info svg { flex: none; margin-top: 3px; color: var(--m-muted); }
.m-about { color: var(--m-muted); text-align: center !important; }
.m-lang { width: 200px; }
.m-brand { font-size: var(--t-cap); color: var(--m-muted); }
.menu .notice { padding-top: var(--s8); }

/* ---- the sheets of a dish and of the filters */
.dish { display: grid; gap: var(--s3); }
.dish-photo { width: 100%; aspect-ratio: 4 / 3; max-height: 340px; border-radius: var(--m-r-card); object-fit: cover; background: var(--m-surface-2); }
.dish-text { white-space: pre-line; overflow-wrap: anywhere; }
.dish-prices { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dish-prices li { display: flex; justify-content: space-between; gap: var(--s3); padding: 10px 14px; border-radius: var(--m-r-photo); background: var(--m-surface-2); font-variant-numeric: tabular-nums; }
.dish-soldout { display: flex; align-items: center; gap: var(--s2); padding: 10px 14px; border-radius: var(--m-r-photo); background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.dish-allergens h3 { margin-bottom: 6px; font-size: var(--t-sm); color: var(--m-muted); }
.dish-allergens ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.dish-allergens li { padding: 4px 12px; border-radius: var(--m-r-ctl); background: var(--m-surface-2); font-size: var(--t-sm); font-weight: 600; }
