/* ============================================================================
   Carta Viva — carta publica
   Estetica do Instagram, mecanica de pagina web.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

/* O atributo hidden tem de ganhar sempre.
   Qualquer componente que declare `display` (e .card declara flex) derrota o
   [hidden] do browser, porque uma regra de autor vence a do agente. O resultado
   e um bloco que se manda esconder e fica visivel — foi o que aconteceu com o
   "carrinho vazio" a aparecer por cima da lista. O projecto vinha a remendar
   isto elemento a elemento; resolve-se aqui, uma vez. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

img, video { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

button {
  font: inherit; color: inherit;
  background: none; border: 0; padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- cabecalho */

.header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.header__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; flex: none;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px; color: var(--text-2);
}

.header__name {
  font-size: 17px; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header__actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text);
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* seletor de idioma */
.lang { position: relative; }
.lang__current {
  height: 30px; padding: 0 10px;
  display: flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 15px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.lang__current svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.lang__menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 150px; padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.lang__menu[hidden] { display: none; }
.lang__menu a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px; border-radius: 6px; font-size: 14px;
}
.lang__menu a:hover { background: var(--surface-2); }
.lang__menu a[aria-current="true"] { font-weight: 600; color: var(--accent); }

/* ---------------------------------------------------------------- categorias */

.stories {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.stories::-webkit-scrollbar { display: none; }

.stories__track {
  display: flex; gap: 16px;
  padding: 0 16px;
  width: max-content;
  margin: 0 auto;
  min-width: 100%;
}

.story { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 68px; flex: none; }

/* Estas bolas tem de ser redondas em qualquer motor, por isso nao dependem de
   nada que precise de ser resolvido: sem percentagens, sem aspect-ratio, sem
   contar com a grelha para nao esticar o item. So pixeis.

   A versao anterior encadeava tres coisas — width:100%, aspect-ratio:1 e
   place-items:center — e bastava uma delas resolver de outra maneira para sair
   uma elipse. Alem disso o anel nao tinha flex:none: sendo filho de um flex em
   coluna, o seu eixo principal e o vertical e podia ser espremido em altura
   mantendo os 62px de largura, dando uma bola mais larga do que alta.

   O aspect-ratio continua certo onde a moldura tem mesmo de acompanhar a
   largura, como no carrossel. Aqui o tamanho e fixo e conhecido — escreve-se. */
.story__ring {
  width: 62px; height: 62px;
  flex: none;
  border-radius: 50%;
  padding: 2.5px;
  background: var(--surface-2);
  display: grid; place-items: center;
}
/* O anel do Instagram. Aqui marca a categoria activa — nao e decoracao,
   e o indicador de "estas a ver esta". */
.story--active .story__ring {
  background: linear-gradient(45deg, #F09433 0%, #E6683C 25%, #DC2743 50%, #CC2366 75%, #BC1888 100%);
}
.story__img,
.story__all {
  width: 57px; height: 57px;   /* 62 menos os 2x2.5 do padding do anel */
  flex: none;
  border-radius: 50%;
  border: 2.5px solid var(--surface);
  background: var(--surface-2);
}
.story__img {
  object-fit: cover;
}
.story__all {
  display: grid; place-items: center;
  color: var(--text-2);
}
.story__all svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.story__label {
  font-size: 11px; line-height: 1.2; text-align: center;
  max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.story--active .story__label { font-weight: 600; }

/* ---------------------------------------------------------------- feed */

.feed { max-width: var(--feed-width); margin: 0 auto; }

.post {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
@media (min-width: 500px) {
  .post { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
  .feed { padding-top: 20px; }
}

.post__head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}
.post__cat {
  font-size: 13px; font-weight: 600;
}
/* O preco nao compete com o nome do prato: fica ao tamanho da descricao, so
   que a negrito, e encostado a direita — onde o olho o procura numa carta. */
.post__price {
  margin: 2px 0 0;
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.post__sold {
  margin-left: auto;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--like);
  border: 1px solid var(--like); border-radius: 4px;
  padding: 2px 7px;
}

/* ---------------------------------------------------------------- carrossel */

.carousel { position: relative; background: var(--surface-2); }

.carousel__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;

  /* 4:5 — o formato retrato para que as fotografias foram enquadradas, e o que
     o Instagram passou a privilegiar. Em 1:1 cortavam-se 20% de cada uma. */
  aspect-ratio: 4 / 5;
}
.carousel__track::-webkit-scrollbar { display: none; }

.carousel__slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  position: relative;
}
/* O <picture> tem de receber a caixa, e nao so o <img> lá dentro.
   O <picture> e inline e de altura automatica: sem isto, o height:100% do
   <img> nao tem contra o que medir, o browser cai na proporcao natural do
   ficheiro, e o object-fit fica sem caixa definida para recortar. Uma foto
   que nao seja 4:5 aparecia deformada. */
.carousel__slide picture {
  display: block;
  width: 100%; height: 100%;
}
.carousel__slide img,
.carousel__slide video {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}

.carousel__dots {
  position: absolute; left: 0; right: 0; bottom: 10px;
  display: flex; justify-content: center; gap: 4px;
  pointer-events: none;
}
.carousel__dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.55);
  transition: background .2s ease, transform .2s ease;
}
.carousel__dots span.is-active { background: #FFFFFF; transform: scale(1.15); }

.carousel__count {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,.6); color: #FFF;
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.carousel__arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,.9);
  display: none; place-items: center;
  color: #262626;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.carousel__arrow svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.carousel__arrow--prev { left: 10px; }
.carousel__arrow--next { right: 10px; }
.carousel__arrow[hidden] { display: none !important; }
@media (hover: hover) and (min-width: 500px) {
  .carousel:hover .carousel__arrow:not([hidden]) { display: grid; }
}

/* coracao do duplo-toque */
.carousel__burst {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  opacity: 0;
}
.carousel__burst svg { width: 96px; height: 96px; fill: #FFFFFF; filter: drop-shadow(0 2px 12px rgba(0,0,0,.4)); }
.carousel__burst.is-bursting { animation: burst .95s ease-out; }
@keyframes burst {
  0%   { opacity: 0; transform: scale(.2); }
  15%  { opacity: .95; transform: scale(1.2); }
  30%  { transform: scale(.95); }
  45%  { transform: scale(1); }
  80%  { opacity: .9; }
  100% { opacity: 0; transform: scale(1); }
}

/* ---------------------------------------------------------------- accoes */

.post__actions {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px 2px;
}
.post__actions .icon-btn svg { width: 24px; height: 24px; }
.post__actions .spacer { margin-left: auto; }

.like-btn.is-liked { color: var(--like); }
.like-btn.is-liked svg { fill: var(--like); stroke: var(--like); }
.like-btn.is-liked svg { animation: pop .3s ease; }
@keyframes pop {
  0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); }
}

.post__body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 10px; }

/* Nome, descricao e preco sao a mesma unidade de leitura — colados.
   O espaco fica entre grupos, nao dentro deles. */
.post__dish { display: flex; flex-direction: column; gap: 3px; }

.post__likes { font-size: 14px; font-weight: 600; }

.post__title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.25; }

.post__desc { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.4; }

.post__comments { font-size: 14px; color: var(--text-2); text-align: left; }
.post__comments:hover { color: var(--text); }

/* ---------------------------------------------------------------- alergenios */

.allergens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.allergen {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: 14px;
  font-size: 12px; font-weight: 500; line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
}
.allergen svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* "pode conter vestigios" a traco interrompido — a distincao que a cozinha
   precisa de fazer e que se perde na carta em papel */
.allergen--traces { background: transparent !important; border-style: dashed; }

.allergen--cereais  { background: var(--fam-cereais-bg);  color: var(--fam-cereais);  border-color: var(--fam-cereais); }
.allergen--mar      { background: var(--fam-mar-bg);      color: var(--fam-mar);      border-color: var(--fam-mar); }
.allergen--animal   { background: var(--fam-animal-bg);   color: var(--fam-animal);   border-color: var(--fam-animal); }
.allergen--frutos   { background: var(--fam-frutos-bg);   color: var(--fam-frutos);   border-color: var(--fam-frutos); }
.allergen--aditivos { background: var(--fam-aditivos-bg); color: var(--fam-aditivos); border-color: var(--fam-aditivos); }

/* ---------------------------------------------------------------- explorar */

.grid {
  max-width: calc(var(--feed-width) * 2);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
}
@media (min-width: 700px) { .grid { gap: 4px; padding: 16px; } }

/* A grelha fica quadrada mesmo com fotografias 4:5 — é o que o Instagram faz.
   Um mosaico com proporções diferentes deixa de ser um mosaico. */
.grid__item { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); overflow: hidden; }
/* A grelha e 1:1 e as fotografias sao 4:5 — aqui o recorte nao e um extra,
   e o que impede que todas aparecam esmagadas. Mesmo motivo do carrossel. */
.grid__item picture { display: block; width: 100%; height: 100%; }
.grid__item img { display: block; width: 100%; height: 100%; object-fit: cover; }

.grid__overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; gap: 16px;
  color: #FFF; font-weight: 600; font-size: 14px;
  opacity: 0; transition: opacity .15s ease;
}
.grid__overlay span { display: inline-flex; align-items: center; gap: 5px; }
.grid__overlay svg { width: 17px; height: 17px; fill: #FFF; }
@media (hover: hover) { .grid__item:hover .grid__overlay { opacity: 1; } }

.grid__multi { position: absolute; top: 7px; right: 7px; color: #FFF; filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); }
.grid__multi svg { width: 17px; height: 17px; fill: #FFF; }

/* ---------------------------------------------------------------- estados */

.state {
  max-width: var(--feed-width);
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.state h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); }
.state p { margin: 0; font-size: 14px; }
.state svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.3; }

.sentinel { height: 1px; }

.spinner {
  width: 26px; height: 26px; margin: 24px auto;
  border: 2px solid var(--border);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.feed-end {
  text-align: center;
  padding: 28px 16px 40px;
  color: var(--text-3);
  font-size: 13px;
}

/* ---------------------------------------------------------------- navegacao */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2);
  font-size: 10px;
}
.nav__item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav__item[aria-current="page"] { color: var(--text); }
.nav__item[aria-current="page"] svg { stroke-width: 2.2; }

@media (min-width: 700px) {
  body { padding-bottom: 0; }
  .nav {
    position: sticky; top: var(--header-h); bottom: auto;
    height: 46px; padding: 0;
    border-top: 0; border-bottom: 1px solid var(--border);
    justify-content: center; gap: 8px;
  }
  .nav__item { flex: 0 0 auto; flex-direction: row; gap: 7px; padding: 0 18px; font-size: 13px; font-weight: 500; }
  .nav__item svg { width: 19px; height: 19px; }
}

/* ---------------------------------------------------------------- movimento */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- cartão sem foto

   Setenta e sete pratos entraram sem fotografia — a carta de origem também não as
   tem. Um rectângulo cinzento repetido 77 vezes mataria o feed, por isso o prato
   desenha-se a si próprio: o mesmo quadrado 1:1, tipografia grande, cor da família
   da categoria. Quando a fotografia chegar, substitui isto sem migração.          */

/* O cartão sem foto acompanha o 4:5, senão os pratos com e sem fotografia teriam
   alturas diferentes e o feed andaria aos saltos. */
.dishcard {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 30px 28px;
  background: var(--dc-bg, var(--surface-2));
  color: var(--dc-ink, var(--text));
  position: relative;
  overflow: hidden;
}

/* Marca de água: a inicial do prato, grande e quase invisível. Dá peso visual
   ao quadrado sem competir com o texto. */
.dishcard::after {
  content: "";
  position: absolute; right: -30px; bottom: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: currentColor; opacity: .05;
}

.dishcard__name {
  margin: 0;
  font-size: clamp(26px, 8vw, 42px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -.02em;
  text-wrap: balance;
}



/* Na grelha de Explorar o mesmo cartão aparece em miniatura, só com o nome. */
.grid__item .dishcard { padding: 12px 10px; justify-content: center; text-align: center; }
.grid__item .dishcard__name { font-size: clamp(11px, 3.2vw, 15px); -webkit-line-clamp: 3; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }

/* ================================================================ formulários,
   contas e comentários — tudo em tokens, para os dois temas saírem de graça. */

.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 18px;
  border-radius: 8px; border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; line-height: 1;
  transition: opacity .15s ease, background .15s ease;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn--full { width: 100%; }
.btn--primary { background: var(--accent); color: #FFFFFF; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--ghost { border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label {
  font-size: 12px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-2);
}
.field__hint { font-size: 12.5px; color: var(--text-3); }
.field input,
.comment-form input,
.copyrow input {
  width: 100%; padding: 11px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 15px;   /* 15px+ evita o zoom automático do iOS */
}
.field input:focus,
.comment-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form__error {
  margin: 0; padding: 10px 12px;
  background: var(--berry-soft, rgba(255,48,64,.1));
  border-radius: 6px;
  font-size: 13.5px; color: var(--like);
}
.form__error[hidden] { display: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs__btn {
  flex: 1; padding: 12px 8px;
  font-size: 14px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__btn.is-active { color: var(--text); border-bottom-color: var(--text); }

/* ---------------------------------------------------------------- conta */

.account { max-width: var(--feed-width); margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 20px;
}

.account__head { display: flex; align-items: center; gap: 14px; }
.account__head h1 { margin: 0; font-size: 19px; font-weight: 600; }
.account__avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: var(--surface-2); color: var(--text-2);
  display: grid; place-items: center;
  font-size: 21px; font-weight: 600;
}
.muted { color: var(--text-2); margin: 2px 0 0; }
.small { font-size: 13px; }

.stars-box {
  display: flex; align-items: baseline; gap: 8px;
  padding: 16px; border-radius: 8px;
  background: var(--surface-2);
}
.stars-box__icon { width: 22px; height: 22px; fill: var(--star); stroke: none; align-self: center; }
.stars-box__n { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stars-box__label { font-size: 14px; color: var(--text-2); }

.account__stats { display: flex; gap: 28px; margin: 0; flex-wrap: wrap; }
.account__stats div { display: flex; flex-direction: column; gap: 2px; }
.account__stats dt { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.account__stats dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.account__share { display: flex; flex-direction: column; gap: 6px; }
.copyrow { display: flex; gap: 8px; margin-top: 4px; }
.copyrow input { font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.copyrow .btn { flex: none; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.notice svg { width: 20px; height: 20px; flex: none; fill: var(--star); stroke: none; margin-top: 1px; }
.notice strong { display: block; font-size: 14.5px; }
.notice p { margin: 3px 0 0; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.notice--good { border-color: var(--star); }
.notice--warn { border-color: var(--star); }
.notice--bad  { border-color: var(--like); }

/* ---------------------------------------------------------------- bottom sheet */

.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet[hidden] { display: none; }

.sheet__backdrop { position: absolute; inset: 0; background: var(--overlay); }

.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 82vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-sheet);
  animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (min-width: 700px) {
  .sheet__panel {
    left: 50%; bottom: 50%; right: auto;
    transform: translate(-50%, 50%);
    width: min(480px, 92vw);
    max-height: 76vh;
    border-radius: 14px;
    animation: none;
  }
}

.sheet__grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 8px auto 0;
}
@media (min-width: 700px) { .sheet__grip { display: none; } }

.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.sheet__head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet__head svg { width: 20px; height: 20px; }

.sheet__body { flex: 1; overflow-y: auto; padding: 8px 16px; -webkit-overflow-scrolling: touch; }
.sheet__empty { text-align: center; color: var(--text-3); padding: 32px 0; font-size: 14px; }
.sheet__notice { margin: 0; padding: 14px 0; font-size: 14px; color: var(--text-2); text-align: center; }

.sheet__foot {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

/* A folha de comentarios passou a ter identidade (nome, e-mail) por cima da
   linha de escrita. Deixa de ser uma linha e passa a ser uma coluna. */
.comment-form { display: flex; flex-direction: column; gap: 8px; }

.comment-form__row { display: flex; gap: 8px; align-items: center; }
.comment-form__row input { flex: 1; min-width: 0; }
.comment-form__row .btn { flex: none; }

/* Nome e e-mail lado a lado onde cabe; empilhados no telemovel estreito. */
.comment-form__id { display: flex; gap: 8px; }
.comment-form__id input { flex: 1; min-width: 0; }
@media (max-width: 380px) {
  .comment-form__id { flex-direction: column; }
}

/* Dizer que o e-mail nao aparece na carta e o que faz a diferenca entre
   escreve-lo e desistir a meio. Vale os 11px que ocupa. */
.comment-form__note {
  margin: 0;
  font-size: 11px; line-height: 1.4;
  color: var(--text-2);
}
.comment-form__as {
  margin: 0;
  font-size: 12px;
  color: var(--text-2);
}
.comment-form__as strong { color: var(--text); }

/* O "Sair" e uma saida, nao uma accao a convidar. Fica discreto e centrado,
   longe de se confundir com o botao principal. */
.account__logout {
  display: block;
  margin: 4px auto 0;
  padding: 8px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.account__logout:hover { color: var(--text); }

.comment { display: flex; gap: 11px; padding: 11px 0; }
.comment__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--surface-2); color: var(--text-2);
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.comment__body { min-width: 0; }
.comment__body p { margin: 0; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.comment__meta { display: block; margin-top: 3px; font-size: 12px; color: var(--text-3); }

/* O comentário do próprio, ainda por aprovar: a traço interrompido, para se
   perceber que já foi enviado mas ainda não está publicado. */
.comment--pending {
  padding: 11px 12px; margin: 8px 0;
  border: 1px dashed var(--border); border-radius: 8px;
}
.comment--pending .comment__meta { color: var(--star); font-weight: 600; }

/* ============================================================================
   Encomendas — carrinho, finalizacao e estado
   ========================================================================= */

/* O botao de juntar encosta-se a direita da fila de accoes: e a unica que custa
   dinheiro e nao deve confundir-se com gostar ou partilhar. */
.post__add { margin-left: auto; }
.post__add.is-added { background: var(--good, #2E7D32); }

.btn--sm { padding: 7px 14px; font-size: 13px; }

/* contador no icone do carrinho */
.nav__icon { position: relative; display: inline-grid; place-items: center; }
.nav__badge {
  position: absolute; top: -5px; right: -9px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--like); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  border-radius: 9px;
}

.cart, .order { max-width: var(--feed-width); margin: 0 auto; padding: 16px; }
.page-title h1 { margin: 4px 0 14px; font-size: 22px; letter-spacing: -.02em; }

/* ---- lista do carrinho ---- */

.cartlist { list-style: none; margin: 0 0 4px; padding: 0; }
.cartline {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.cartline:last-child { border-bottom: 0; }
.cartline__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cartline__info strong { font-weight: 600; }
.cartline__note { font-size: 12px; color: var(--text-2); }
.cartline__total { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Alvos de 32px: isto e mexido com o polegar, muitas vezes de pe. */
.qty { display: flex; align-items: center; gap: 2px; flex: none; }
.qty button {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 17px; line-height: 1; color: var(--text);
}
.qty button:hover { background: var(--surface-2); }
.qty span { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- contas ---- */

.totals { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.totals > div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals dt { color: var(--text-2); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals__grand { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.totals__grand dt, .totals__grand dd { font-size: 17px; font-weight: 700; color: var(--text); }

/* ---- escolha entre entrega e balcao ---- */

.seg { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seg legend { padding: 0; }
.seg__opt {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer;
}
.seg__opt input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.seg__opt:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

/* ---- estado da encomenda ---- */

.order__ref { margin: 0 0 14px; font-size: 15px; }
.order__ref strong { font-size: 19px; letter-spacing: .06em; }
.order__eta { margin: 0 0 16px; color: var(--text-2); }

/* Quatro passos em linha. O que ja passou fica cheio, o actual fica marcado —
   e a resposta a unica pergunta que o cliente tem enquanto espera. */
.steps { list-style: none; display: flex; margin: 0 0 18px; padding: 0; }
.steps li {
  flex: 1; position: relative;
  text-align: center; font-size: 11px; color: var(--text-2);
}
.steps li span {
  display: block; width: 14px; height: 14px; margin: 0 auto 6px;
  border: 2px solid var(--border); border-radius: 50%;
  background: var(--surface);
  position: relative; z-index: 1;
}
/* a linha que liga os passos passa por tras das bolas */
.steps li::before {
  content: ''; position: absolute; top: 7px; left: -50%; width: 100%; height: 2px;
  background: var(--border);
}
.steps li:first-child::before { display: none; }
.steps li.is-done span { border-color: var(--accent); background: var(--accent); }
.steps li.is-done::before { background: var(--accent); }
.steps li.is-now { color: var(--text); font-weight: 700; }

.cartlist--read .cartline { padding: 9px 0; }

/* Atalho da carta para a app de entregas. Discreto de proposito: a carta serve
   quem esta a mesa, e a essa pessoa o botao de encomendar nao interessa. */
.header__order {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 16px;
  background: var(--surface-2);
  font-size: 13px; font-weight: 600;
}
.header__order svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.header__order:hover { background: var(--border); }
.header__badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--like); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  border-radius: 9px;
}
@media (max-width: 420px) { .header__order span:not(.header__badge) { display: none; } }

/* ============================================================================
   AS TRÊS FORMAS DE VER A CARTA

   Em baixo escolhe-se onde se está no site; aqui escolhe-se como se vê a carta.
   Eram duas coisas a partilhar a mesma barra, e nenhuma ficava clara.
   ========================================================================= */

.vistas {
  position: sticky; top: var(--header-h); z-index: 40;
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.vistas__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  /* Alvo de 52px: escolhe-se isto com o polegar, muitas vezes em andamento. */
  min-height: 52px;
  color: var(--text-3);
  font-size: 10.5px; letter-spacing: .02em;
  /* A marca do activo cresce de dentro para fora e não empurra nada. */
  box-shadow: inset 0 -2px 0 transparent;
  transition: color .15s ease, box-shadow .15s ease;
}
.vistas__item svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.vistas__item.is-active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.vistas__item.is-active svg { stroke-width: 2.2; }

/* O nome por baixo do ícone não é decoração: um quadrado, uns quadradinhos e
   umas linhas são três coisas parecidas a 20px, e sem a palavra ninguém sabe o
   que está a escolher da primeira vez. Fica, em todas as larguras. */

/* O contador do carrinho mudou-se para a barra de baixo, e precisa de âncora. */
.nav__item { position: relative; }
.nav__item .nav__badge { top: 6px; right: calc(50% - 20px); }

/* ---------------------------------------------------------- a carta em lista

   Prefixo `.cl-` de propósito: a app de entregas tem uma listagem parecida em
   `shop.css`, com nomes de classe iguais. As duas folhas nunca se carregam ao
   mesmo tempo, mas bastava um dia carregarem-se para uma comer a outra. */

.cl { padding-bottom: 8px; }

.cl__search {
  position: relative;
  margin: 12px var(--gutter, 14px);
}
.cl__search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px;
  fill: none; stroke: var(--text-3); stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}
.cl__search input {
  width: 100%; padding: 11px 12px 11px 38px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 15px;
}

.cl__tabs {
  position: sticky; top: calc(var(--header-h) + 53px); z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cl__tabs::-webkit-scrollbar { display: none; }
.cl__tabs-track { display: flex; gap: 6px; padding: 9px var(--gutter, 14px); width: max-content; }
.cl__tabs a {
  padding: 7px 13px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.cl__tabs a.is-active { background: var(--accent); color: #FFFFFF; }

.cl__cat { padding-top: 6px; }
.cl__cat-title {
  margin: 16px 0 4px; padding: 0 var(--gutter, 14px);
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-3);
}

.cl__rows { list-style: none; margin: 0; padding: 0; }
.cl__row + .cl__row { border-top: 1px solid var(--border); }

.cl__link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px var(--gutter, 14px);
  color: inherit;
}
.cl__link:active { background: var(--surface-2); }

.cl__thumb { flex: none; width: 62px; height: 62px; border-radius: 10px; overflow: hidden; }
.cl__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Sem fotografia, o mesmo par de cores que a grelha e o feed usam para esta
   categoria. As classes `.dishcard--{categoria}` só declaram as variáveis; quem
   as pinta é cada sítio onde aparecem. Sem estas duas linhas ficava a inicial
   preta sobre nada, que é pior do que um quadrado cinzento. */
.cl__noimg {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: var(--dc-bg, var(--surface-2));
  color: var(--dc-ink, var(--text-2));
  font-size: 24px; font-weight: 700;
}

.cl__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl__name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.cl__desc {
  font-size: 13px; color: var(--text-2); line-height: 1.4;
  /* Duas linhas e corta: uma descrição de cinco linhas transforma a lista numa
     parede de texto e acaba com a razão de ela existir. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.cl__price { margin-top: 2px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

.cl__go { flex: none; color: var(--text-3); }
.cl__go svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.cl__none { padding: 40px var(--gutter, 14px); text-align: center; color: var(--text-2); }

@media (min-width: 700px) {
  /* Com a barra de baixo a virar barra de cima, o selector desce para debaixo
     dela — senão ficavam dois cabeçalhos colados e nenhum se lia. */
  .vistas { top: calc(var(--header-h) + 46px); }
  .cl__tabs { top: calc(var(--header-h) + 46px + 53px); }
}

/* ------------------------------------------------------------------ voltar

   Na ficha de um prato, aberta a partir de qualquer uma das três vistas.
   Antes não havia saída nenhuma: o cartão ocupava o ecrã e a única forma de
   regressar era o separador «Carta» da barra de baixo, que perdia o sítio onde
   se estava a ler. */

.voltar {
  display: inline-flex; align-items: center; gap: 4px;
  /* Alvo de 44px de altura, contado com o padding: toca-se com o polegar. */
  padding: 12px var(--gutter, 14px);
  color: var(--text-2);
  font-size: 14px; font-weight: 600;
}
.voltar svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}
.voltar:active { color: var(--text); }
