/* Saudáveis da Lu — identidade do Cardápio Marmitas dela: verde-limão, amarelo e título manuscrito. */
@layer base, layout, componentes, utilidades;

@font-face {
  font-family: "Caveat";
  src: url("/fontes/caveat-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Caveat";
  src: url("/fontes/caveat-500-latin-ext.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Figtree";
  src: url("/fontes/figtree-latin.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}

@layer base {
  :root {
    --limao: #b9cf2f;
    --limao-claro: #eef4c4;
    --limao-fundo: #f7f9e6;
    --folha: #3f5212;
    --folha-escura: #26330a;
    --amarelo: #f6c344;
    --laranja: #e9851f;
    --papel: #fffdf6;
    --texto: #24300b;
    --texto-suave: #5b6640;
    --linha: #dfe6b8;
    --whats: #178244;          /* 4,87:1 com texto branco (AA) */
    --linha-campo: #848f5a;    /* borda de campo: 3,4:1 no branco e no papel */
    --foco: var(--folha-escura);
    --erro: #b3261e;

    --raio: 14px;
    --raio-peq: 10px;
    --sombra: 0 1px 2px rgb(38 51 10 / 8%), 0 4px 14px rgb(38 51 10 / 8%);
    --espaco: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    --largura: 70rem;

    --fonte-texto: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --fonte-titulo: "Caveat", "Segoe Script", cursive;
    color-scheme: light;
  }

  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
  body {
    margin: 0;
    font-family: var(--fonte-texto);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--texto);
    background: var(--papel);
  }
  body.com-barra { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  img { display: block; max-width: 100%; height: auto; } /* height do atributo não pode vencer o aspect-ratio */
  h1, h2, h3, p { margin: 0; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  :focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
  html:has(dialog[open]) { overflow: hidden; }
  [hidden] { display: none !important; }
}

@layer layout {
  .topo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    padding: calc(var(--espaco) + env(safe-area-inset-top)) var(--espaco) var(--espaco);
    background:
      radial-gradient(circle at 85% 20%, rgb(246 195 68 / 45%), transparent 40%),
      var(--limao);
  }
  .topo__logo {
    width: clamp(4rem, 3rem + 5vw, 5.5rem);
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--papel);
    box-shadow: var(--sombra);
  }
  .topo__nome {
    font-family: var(--fonte-titulo);
    font-weight: 500;
    font-size: clamp(2.6rem, 2rem + 4vw, 4rem);
    line-height: 1;
    color: var(--folha-escura);
  }

  .atalhos {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.7rem var(--espaco);
    background: rgb(255 253 246 / 92%);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--linha);
    scrollbar-width: none;
  }
  .atalhos::-webkit-scrollbar { display: none; }

  .cardapio {
    max-width: var(--largura);
    margin-inline: auto;
    padding: var(--espaco);
    display: grid;
    gap: calc(var(--espaco) * 2);
  }

  .secao { display: grid; gap: 1rem; }
  .secao__lista {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  }
}

@layer componentes {
  .atalhos__item {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    background: var(--limao-claro);
    color: var(--folha-escura);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    white-space: nowrap;
  }
  .atalhos__item:hover { background: var(--limao); }

  .secao__titulo {
    font-family: var(--fonte-titulo);
    font-weight: 500;
    font-size: clamp(2.2rem, 1.8rem + 2vw, 3rem);
    line-height: 1.05;
    color: var(--folha);
  }
  .secao__texto {
    display: grid;
    gap: 0.6rem;
    max-width: 60ch;
    padding: 0.9rem 1rem;
    border-left: 4px solid var(--amarelo);
    border-radius: 0 var(--raio-peq) var(--raio-peq) 0;
    background: var(--limao-fundo);
    color: var(--texto-suave);
    white-space: pre-line;
  }

  .cartao {
    display: grid;
    grid-template-columns: 6.5rem 1fr;
    gap: 0.9rem;
    padding: 0.75rem;
    border-radius: var(--raio);
    background: #fff;
    border: 1px solid var(--linha);
    box-shadow: var(--sombra);
  }
  .cartao__foto {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--raio-peq);
    background: var(--limao-claro);
  }
  .cartao__foto--vazia {
    background:
      radial-gradient(circle at 30% 30%, rgb(246 195 68 / 55%), transparent 55%),
      var(--limao-claro);
  }
  .cartao__info { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
  .cartao__nome { font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
  .cartao__desc { font-size: 0.92rem; color: var(--texto-suave); }
  .cartao__preco { font-weight: 800; font-size: 1.1rem; color: var(--folha); }
  .cartao__unidade { font-weight: 600; font-size: 0.9rem; color: var(--texto-suave); }
  .cartao__acoes { margin-top: auto; padding-top: 0.25rem; }

  .opcoes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; border: 0; }
  .opcoes__item { position: relative; }
  .opcoes__item input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
  .opcoes__item span {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1.5px solid var(--linha-campo);
    font-size: 0.88rem;
    font-weight: 600;
  }
  .opcoes__item input:checked + span { border-color: var(--folha); background: var(--limao-claro); }
  .opcoes__item input:focus-visible + span { outline: 3px solid var(--foco); outline-offset: 2px; }

  .botao-adicionar {
    min-height: 2.75rem;
    padding: 0.5rem 1.2rem;
    border: 0;
    border-radius: 999px;
    background: var(--folha);
    color: #fff;
    font-weight: 700;
  }
  .botao-adicionar:hover { background: var(--folha-escura); }

  .passo {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    border-radius: 999px;
    background: var(--limao-claro);
    padding: 0.2rem;
  }
  .passo__botao {
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--folha-escura);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: var(--sombra);
  }
  .passo__qtd { min-width: 3.2rem; text-align: center; font-weight: 800; }

  .barra-pedido {
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    padding: 0.75rem var(--espaco) calc(0.75rem + env(safe-area-inset-bottom));
    background: linear-gradient(transparent, var(--papel) 35%);
  }
  .barra-pedido__botao {
    display: flex;
    width: min(100%, 32rem);
    margin-inline: auto;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 3.4rem;
    padding: 0.6rem 1.3rem;
    border: 0;
    border-radius: 999px;
    background: var(--folha-escura);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 6px 20px rgb(38 51 10 / 30%);
  }

  .pedido {
    width: min(100% - 1rem, 34rem);
    max-inline-size: none;           /* o navegador corta 38 px no dialog:modal */
    max-height: min(92dvh, 52rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: auto auto calc(0.5rem + env(safe-area-inset-bottom));
    padding: 0;
    border: 0;
    border-radius: var(--raio) var(--raio) var(--raio) var(--raio);
    background: var(--papel);
    color: var(--texto);
    box-shadow: 0 10px 40px rgb(0 0 0 / 25%);
  }
  .pedido::backdrop { background: rgb(38 51 10 / 45%); }
  .pedido__corpo { display: grid; gap: 1rem; padding: var(--espaco); }
  .pedido__topo { display: flex; align-items: center; justify-content: space-between; }
  .pedido__topo h2 { font-family: var(--fonte-titulo); font-weight: 500; font-size: 2.2rem; color: var(--folha); }
  .pedido__itens { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
  .pedido__total {
    display: flex;
    justify-content: space-between;
    padding-top: 0.6rem;
    border-top: 2px dashed var(--linha);
    font-size: 1.15rem;
  }
  .pedido__total strong { font-size: 1.3rem; color: var(--folha); }

  .item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.4rem 0.8rem;
    align-items: center;
    padding: 0.6rem 0.7rem;
    border-radius: var(--raio-peq);
    background: #fff;
    border: 1px solid var(--linha);
  }
  .item__texto { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 0.6rem; }
  .item__nome { font-weight: 700; }
  .item__preco { color: var(--texto-suave); font-size: 0.9rem; white-space: nowrap; }
  .item .passo { justify-self: start; }
  .item__subtotal { justify-self: end; }

  .campos { display: grid; gap: 0.8rem; }
  .campo { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.95rem; }
  .campo :where(input:not([type="radio"], [type="checkbox"], [type="file"]), textarea, select) {
    width: 100%;
    min-height: 2.9rem;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--linha-campo);
    border-radius: var(--raio-peq);
    background: #fff;
    font-weight: 400;
    font-size: 1rem; /* 16px: o iPhone não dá zoom ao tocar no campo */
  }
  .campo textarea { resize: vertical; }
  .escolha { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
  .escolha legend { padding: 0; margin-bottom: 0.3rem; width: 100%; }
  .escolha__item { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; min-height: 2.75rem; }
  .escolha__item input { width: 1.25rem; height: 1.25rem; accent-color: var(--folha); }

  .botao-whats {
    min-height: 3.4rem;
    border: 0;
    border-radius: 999px;
    background: var(--whats);
    color: #fff;
    font-weight: 800;
    font-size: 1.08rem;
  }
  .botao-whats:hover { filter: brightness(0.94); }
  .botao-texto {
    justify-self: center;
    border: 0;
    background: none;
    color: var(--texto-suave);
    text-decoration: underline;
    min-height: 2.75rem;
    padding: 0.5rem 1rem;
  }
  .botao-icone {
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: var(--limao-claro);
    font-size: 1.6rem;
    line-height: 1;
  }

  .rodape { display: grid; justify-items: center; gap: 0.1rem; padding: 1rem var(--espaco) 2rem; }
  .rodape__link {
    display: inline-block;
    padding: 0.6rem 1rem;          /* alvo de toque confortável sem chamar atenção */
    color: var(--texto-suave);
    font-size: 0.9rem;
  }
  .rodape__credito { font-size: 0.8rem; text-decoration: none; }
  .aviso-erro { color: var(--erro); font-weight: 600; }
  .aviso-erro:empty { position: absolute; } /* fora do fluxo, mas na árvore: o leitor anuncia quando o texto entra */
  main + .aviso-erro { max-width: var(--largura); margin: 0 auto; padding: var(--espaco); }
}

@layer utilidades {
  .so-leitor {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@layer componentes {
  @media (min-width: 48rem) {
    .cartao { grid-template-columns: 8rem 1fr; }
    .pedido { margin: auto; }
  }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
