/* Sunday in Lisbon: the menu page (/ementa, /en/menu). Owner: page-ementa.
   Markup from site/src/_partes/ementa.mjs. Uses the shell's tokens and components (.caixa, .selo, .etiqueta,
   .onda, .foto, .selo-anel); defines no token. On the phone the section index is a bar that sticks to the top
   and opens a panel; from 64em it is a sticky sidebar. Food sections are the house's rule boxes, drinks take the
   filled label, as on the printed menu. */

.ementa { --ementa-barra-h: 52px; }

/* ---------- opening ---------- */

.ementa-abertura__grelha { display: grid; gap: var(--space-l); align-items: center; }
.ementa-abertura__texto { display: grid; gap: var(--space-m); max-width: 40rem; }
.ementa-abertura__texto .acoes { margin-top: calc(-1 * var(--space-2xs)); }
.ementa-abertura__encomendar { max-width: 34em; font-size: var(--step--1); line-height: 1.5; color: var(--color-text-muted); }
.ementa-abertura__encomendar .ligacao { color: var(--color-text); min-height: 0; }
.ementa-abertura__selo { display: none; --selo-anel: clamp(160px, 9vw + 60px, 210px); }
@media (min-width: 48em) {
  .ementa-abertura__grelha { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-2xl); }
  .ementa-abertura__selo { display: block; }
}

/* ---------- the menu: index beside or above the moments ---------- */

.ementa { display: grid; grid-template-columns: minmax(0, 1fr); }
.ementa-corpo { min-width: 0; container-type: inline-size; }
@media (min-width: 64em) {
  .ementa { grid-template-columns: 16rem minmax(0, 1fr); column-gap: var(--space-2xl); align-items: start; }
}

/* ---------- section index: the bar on the phone ---------- */

.ementa-indice {
  position: sticky; top: 0; z-index: 5;
  margin-inline: calc(-1 * var(--space-gutter)); padding-inline: var(--space-gutter);
  background: var(--color-surface);
  border-bottom: var(--rule) solid var(--color-rule);
}
.ementa-indice__botao {
  display: flex; align-items: center; gap: var(--space-xs); width: 100%; min-height: var(--ementa-barra-h);
  padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
  font: var(--weight-label) var(--step--1) / 1.2 var(--font-text); letter-spacing: var(--tracking-label); text-transform: uppercase;
}
.ementa-indice__atual {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: var(--weight-text); font-size: var(--step-0); letter-spacing: 0; text-transform: none; color: var(--color-text-muted);
}
.ementa-indice__seta { margin-left: auto; display: inline-flex; transition: transform var(--dur-micro) var(--ease-out); }
.ementa-indice__botao[aria-expanded="true"] .ementa-indice__seta { transform: rotate(180deg); }
.ementa-indice__botao:active .ementa-indice__rotulo { opacity: .72; }

.js .ementa-indice__painel {
  display: none; position: absolute; left: 0; right: 0; top: 100%;
  max-height: calc(100dvh - var(--ementa-barra-h) - var(--barra-h) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-m) var(--space-gutter) var(--space-l);
  background: var(--color-surface); border-bottom: var(--rule) solid var(--color-rule);
}
.js .ementa-indice.is-aberto .ementa-indice__painel { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .js .ementa-indice.is-aberto .ementa-indice__painel {
    clip-path: inset(0); transition: clip-path var(--dur-micro) var(--ease-out);
    @starting-style { clip-path: inset(0 0 100% 0); }
  }
}

/* without JavaScript the index is a plain list above the menu, and the filter stays out */
.no-js .ementa-indice { position: static; border-bottom: 0; }
.no-js .ementa-indice__botao, .no-js .ementa-filtro { display: none; }
.no-js .ementa-indice__painel { padding-bottom: var(--space-l); }

/* ---------- filter by moment of the day ---------- */

.ementa-filtro { margin: 0 0 var(--space-l); padding: 0; border: 0; min-width: 0; }
.ementa-filtro__legenda { padding: 0; margin-bottom: var(--space-xs); font: var(--weight-label) var(--step--1) / 1.3 var(--font-text); color: var(--color-text-muted); }
.ementa-filtro__opcoes { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.ementa-filtro__opcao {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-s);
  border: var(--rule) solid var(--color-rule); border-radius: var(--radius);
  font: var(--weight-ui) var(--step--1) / 1.1 var(--font-text); cursor: pointer;
  -webkit-user-select: none; user-select: none;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-hover) ease, color var(--dur-hover) ease;
}
.ementa-filtro__opcao:active { transform: scale(.97); }
.ementa-filtro input:checked + .ementa-filtro__opcao { background: var(--color-action); border-color: var(--color-action); color: var(--color-action-text); }
.ementa-filtro input:focus-visible + .ementa-filtro__opcao { outline: var(--rule-strong) solid var(--color-focus); outline-offset: var(--focus-offset); }

/* ---------- the index list ---------- */

.ementa-indice__grupos { display: grid; gap: var(--space-m); list-style: none; }
.ementa-indice__momento {
  display: inline-flex; align-items: center; min-height: var(--tap);
  font: var(--weight-strong) var(--step-0) / 1.25 var(--font-text); text-decoration: none;
}
.ementa-indice__seccoes { display: flex; flex-wrap: wrap; gap: 0 var(--space-2xs); list-style: none; margin-left: calc(-1 * var(--space-2xs)); }
.ementa-indice__ligacao {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-2xs);
  font-size: var(--step-0); line-height: 1.25; text-decoration: underline; text-decoration-color: transparent;
  transition: text-decoration-color var(--dur-hover) ease;
}
.ementa-indice__ligacao:active, .ementa-indice__momento:active { opacity: .72; }
.ementa-indice__ligacao[aria-current="location"] { font-weight: var(--weight-strong); text-decoration-color: currentColor; text-decoration-thickness: var(--rule-strong); }
.ementa-indice__grupo[hidden] { display: none; }

/* ---------- section index: the sidebar from 64em ---------- */

@media (min-width: 64em) {
  .ementa-indice {
    position: sticky; top: var(--space-l); margin: 0; padding: 0; border: 0; background: none;
    max-height: calc(100vh - 2 * var(--space-l) - var(--barra-h));
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  }
  .ementa-indice__botao { display: none; }
  .js .ementa-indice__painel, .no-js .ementa-indice__painel {
    display: block; position: static; max-height: none; overflow: visible; padding: 0 0 var(--space-xs); border: 0; clip-path: none;
  }
  .ementa-filtro { margin-bottom: var(--space-m); }
  .ementa-filtro__opcao { min-height: 2.25rem; padding-inline: var(--space-xs); }
  .ementa-indice__grupos { gap: var(--space-xs); }
  .ementa-indice__momento, .ementa-indice__ligacao { min-height: 1.75rem; }
  .ementa-indice__ligacao { font-size: var(--step--1); }
  .ementa-indice__momento { font-size: var(--step--1); }
}
@media (min-width: 75em) {
  .ementa-indice { max-height: calc(100vh - 2 * var(--space-l)); }
}
@media (hover: hover) and (pointer: fine) {
  .ementa-filtro__opcao:hover { background: var(--color-ghost-hover); }
  .ementa-filtro input:checked + .ementa-filtro__opcao:hover { background: var(--color-action-hover); border-color: var(--color-action-hover); }
  .ementa-indice__ligacao:hover, .ementa-indice__momento:hover { text-decoration: underline; text-decoration-color: currentColor; }
}

/* ---------- notes, moments, sections ---------- */

.ementa-notas { display: grid; gap: var(--space-3xs); padding-top: var(--space-l); font-size: var(--step--1); line-height: 1.5; color: var(--color-text-muted); }
.ementa-notas__alergenios { display: flex; gap: var(--space-2xs); align-items: flex-start; color: var(--color-text); font-weight: var(--weight-ui); }
.ementa-notas__alergenios .ico { margin-top: .05em; }
.ementa-notas__iva { padding-left: calc(20px + var(--space-2xs)); }
@media (min-width: 64em) { .ementa-notas { padding-top: 0; } }

.momento { padding-top: var(--space-2xl); }
.momento[hidden] { display: none; }
/* after a filter change the moments that come back fade in; never on the first paint */
@media (prefers-reduced-motion: no-preference) {
  .ementa.is-filtrada .momento { transition: opacity var(--dur-enter) var(--ease-out); @starting-style { opacity: 0; } }
}
.momento__cabeca { display: grid; justify-items: start; gap: var(--space-xs); margin-bottom: var(--space-xl); }
.momento__cabeca .onda { margin-bottom: var(--space-s); }
.momento__horas { display: inline-flex; align-items: center; gap: var(--space-2xs); color: var(--color-text-muted); font-variant-numeric: var(--numeric); }

.momento__seccoes { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); }
.seccao { scroll-margin-top: calc(var(--ementa-barra-h) + var(--space-s)); }
.momento { scroll-margin-top: var(--ementa-barra-h); }
@media (min-width: 64em) { .seccao, .momento { scroll-margin-top: var(--space-s); } }

/* two columns of boxes when the column has room; break-inside keeps a box whole */
@container (min-width: 42rem) {
  /* each box is one line of the column; orphans and widows at 1 let a moment of two boxes (Almoço) split across
     the columns instead of stacking both in the first */
  .momento__seccoes { display: block; columns: 2; column-gap: var(--space-xl); orphans: 1; widows: 1; }
  /* inline-block keeps the space above each box at the top of a column, where the seal and the title stick out */
  .momento__seccoes > .seccao { display: inline-block; width: 100%; vertical-align: top; break-inside: avoid; margin: 0 0 var(--space-xl); }
  .momento__seccoes > .caixa { margin-top: calc(var(--seal) * .4); }
  /* a moment with one box: the box takes the width, the photo goes beside the dishes */
  .momento__seccoes:has(> .seccao:only-child) { columns: auto; }
  .momento__seccoes > .caixa:only-child:has(> .seccao__foto) {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); column-gap: var(--space-xl); align-items: start;
  }
  .momento__seccoes > .caixa:only-child:has(> .seccao__foto) > * { grid-column: 1; }
  .momento__seccoes > .caixa:only-child > .seccao__foto { grid-column: 2; grid-row: 2 / span 6; margin-top: 0; }
  .momento__seccoes > .seccao:only-child:not(:has(> .seccao__foto)) { max-width: 40rem; }
}

/* the rule box: the title cuts the top rule and may take two lines on a phone */
.ementa .caixa { padding: var(--space-l) var(--space-m) var(--space-m); }
.ementa .caixa__titulo {
  position: relative; top: auto; left: auto; transform: none;
  width: fit-content; max-width: 100%;
  margin: calc(-1 * var(--space-l) - .6em) 0 var(--space-m) calc(-1 * var(--space-2xs));
  margin-top: calc(-1 * var(--space-l) - .5lh);
  padding: 0; background: none; line-height: 1.15;
}
/* the background sits behind the words only, so the rule shows again after the first line */
.ementa .caixa__titulo > span {
  padding: 0 var(--space-2xs); background: var(--color-surface);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.ementa .seccao--selo .caixa__titulo { max-width: calc(100% - var(--seal) * .6 - var(--space-s)); }

.seccao__nota { margin-bottom: var(--space-s); font-size: var(--step--1); line-height: 1.5; color: var(--color-text-muted); }
.seccao__so-pt { margin-top: var(--space-s); font-size: var(--step--1); line-height: 1.5; color: var(--color-text-muted); }
.seccao__foto { margin-top: var(--space-m); width: 100%; max-width: 360px; }
.ementa .caixa .seccao__foto--larga { max-width: 100%; }

/* ---------- dishes ---------- */

.pratos { list-style: none; }
.prato { padding-block: var(--space-s); border-top: var(--rule) solid var(--color-rule-soft); }
.prato:first-child { border-top: 0; padding-top: 0; }
.prato:last-child { padding-bottom: 0; }
/* the prices sit beside the name; when a row of variant prices does not fit, it drops under the name, to the right */
.prato__linha { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--space-3xs) var(--space-m); }
.prato__nome { flex: 1 1 8rem; min-width: 0; font: var(--weight-label) var(--step-1) / var(--leading-ui) var(--font-text); overflow-wrap: break-word; }
.prato--longo .prato__nome { flex-basis: 15rem; }
.prato__qtd { font-weight: var(--weight-text); font-size: var(--step--1); color: var(--color-text-muted); white-space: nowrap; }
.prato__preco {
  flex: none; margin-left: auto; font: var(--weight-text-light) var(--step-1) / var(--leading-ui) var(--font-text);
  font-variant-numeric: var(--numeric); white-space: nowrap; text-align: right;
}
.prato__sem-preco { font-size: var(--step--1); font-weight: var(--weight-text); color: var(--color-text-muted); }
/* break-ui: three sizes with four-figure prices, or three «Preço sob consulta», are wider than a phone; the sizes
   wrap onto a second row, still flush right, instead of running past the box */
.prato__precos {
  flex: 0 1 auto; max-width: 100%; margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end;
  gap: var(--space-2xs) var(--space-m); list-style: none;
}
.prato__precos .prato__preco { display: flex; flex-direction: column-reverse; align-items: flex-end; min-width: 0; max-width: 100%; margin-left: 0; }
.prato__precos .prato__var { text-align: right; white-space: normal; }
.prato__var { display: block; font-size: var(--step--1); line-height: 1.3; font-weight: var(--weight-text); color: var(--color-text-muted); }
.prato__desc, .prato__perfil, .seccao__nota, .prato__extras { overflow-wrap: break-word; }
.prato__desc, .prato__perfil { margin-top: var(--space-3xs); max-width: 60ch; font-size: var(--step--1); line-height: 1.5; color: var(--color-text-muted); }
.prato__extras { margin-top: var(--space-2xs); list-style: none; font-size: var(--step--1); line-height: 1.5; color: var(--color-text-muted); }
.prato__extras li { display: flex; flex-wrap: wrap; column-gap: var(--space-2xs); }
.extra__preco { white-space: nowrap; }
.prato__esgotado { display: inline-flex; align-items: center; gap: var(--space-3xs); margin-top: var(--space-2xs); font: var(--weight-label) var(--step--1) / 1.3 var(--font-text); }
.is-esgotado .prato__nome, .is-esgotado .prato__preco { color: var(--color-text-muted); }

.seccao__extras { margin-top: var(--space-m); padding-top: var(--space-s); border-top: var(--rule) solid var(--color-rule-soft); }
.seccao__extras-titulo { margin-bottom: var(--space-2xs); font: var(--weight-strong) var(--step--1) / 1.3 var(--font-text); }
.seccao__extras-lista { list-style: none; font-size: var(--step--1); line-height: 1.5; }
.seccao__extras-lista li { display: flex; justify-content: space-between; gap: var(--space-s); padding-block: 2px; }
.seccao__extras-lista .extra__preco { color: var(--color-text-muted); }

/* drinks: the filled label instead of the box, and a tighter list */
.seccao--etiqueta .seccao__etiqueta { margin-bottom: var(--space-s); font-size: var(--step-0); }
.momento--etiqueta .prato { padding-block: var(--space-xs); }
.momento--etiqueta .prato:first-child { padding-top: 0; }
.momento--etiqueta .prato__nome, .momento--etiqueta .prato__preco { font-size: var(--step-0); }

/* ---------- end of the menu ---------- */

.ementa-fim {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-xs) var(--space-l);
  margin-top: var(--space-2xl); padding-top: var(--space-m); border-top: var(--rule) solid var(--color-rule);
  font-size: var(--step--1); color: var(--color-text-muted);
}
.ementa-fim__topo { color: var(--color-text); }

@media print {
  .ementa-indice, .ementa-abertura__selo, .ementa-fim__topo, .seccao__foto, .momento__cabeca .onda { display: none !important; }
  .momento[hidden] { display: block !important; }
  .ementa { display: block; }
}
