/*
 * Celular e tablet (até 991px), no padrão do Caliope: o botão do cardápio sempre à mão no topo,
 * o cardápio em lista compacta e o pedido a um toque (sacola flutuante + gaveta de js/pedido.js).
 * Carregado depois de style.css e pedido.css; o comportamento do topo fica em js/mobile-nav.js.
 */

/* Botão "Cardápio" do topo: só existe no celular. */
.m-menu-cta {
  display: none;
}

@media (max-width: 991.98px) {
  :root {
    --m-header: 70px;
    --m-line: rgba(26, 26, 26, 0.1);
    /* Sem o "voltar ao topo" no celular, a sacola desce para o canto. */
    --pd-floating-bottom: 16px;
  }

  #btt {
    display: none !important;
  }

  /* ================= topo ================= */
  #nav {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  #nav > .container {
    flex-wrap: nowrap;
  }

  #nav .navbar-brand {
    margin-right: auto;
    padding: 0;
  }

  .bico {
    width: 42px;
    height: 42px;
    font-size: 1.15rem;
  }

  .m-menu-cta {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: 44px;
    margin-right: 8px;
    padding: 0 18px;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-family: var(--pd-font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 6px 16px rgba(232, 40, 26, 0.3);
    transition: background-color 0.2s ease, scale 0.15s ease;
  }

  .m-menu-cta:hover,
  .m-menu-cta:focus {
    background: #c01e12;
    color: #ffffff;
  }

  .m-menu-cta:active {
    scale: 0.96;
  }

  /* Hambúrguer redondo com duas linhas que viram um X. */
  #nav .navbar-toggler {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--m-line);
    border-radius: 50%;
    background: #ffffff;
    box-shadow: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
  }

  #nav .navbar-toggler:focus-visible {
    outline: 3px solid rgba(232, 40, 26, 0.35);
    outline-offset: 2px;
  }

  #nav .navbar-toggler[aria-expanded='true'] {
    border-color: var(--dark);
    background: var(--dark);
  }

  #nav .navbar-toggler span {
    grid-area: 1 / 1;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--dark);
    transition: translate 0.25s ease, rotate 0.25s ease, background-color 0.2s ease;
  }

  #nav .navbar-toggler span:first-child { translate: 0 -3px; }
  #nav .navbar-toggler span:last-child { translate: 0 3px; }

  #nav .navbar-toggler[aria-expanded='true'] span {
    translate: 0;
    background: #ffffff;
  }

  #nav .navbar-toggler[aria-expanded='true'] span:first-child { rotate: 45deg; }
  #nav .navbar-toggler[aria-expanded='true'] span:last-child { rotate: -45deg; }

  /* ================= painel do menu ================= */
  /* Sem a animação de altura do Bootstrap: o painel aparece como um cartão flutuante. */
  #navmenu.collapsing {
    transition: none !important;
  }

  #navmenu {
    position: fixed;
    z-index: 2;
    top: calc(var(--m-header) + 8px);
    right: 12px;
    left: 12px;
    max-height: calc(100dvh - var(--m-header) - 24px);
    overflow-y: auto;
    padding: 18px 20px 20px;
    border-radius: 24px;
    background: #fffdf9;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  }

  #navmenu.show {
    animation: m-panel-in 0.22s cubic-bezier(0.32, 0.72, 0, 1) both;
  }

  #navmenu .navbar-nav {
    margin: 0 !important;
  }

  #navmenu .navbar-nav::before {
    content: 'Navegação';
    padding-bottom: 12px;
    color: #8a7466;
    font-family: var(--pd-font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  #navmenu .nav-item {
    border-top: 1px solid var(--m-line);
  }

  #navmenu .navbar-nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 2px !important;
    font-size: 1rem;
    font-weight: 600;
  }

  /* No lugar do sublinhado do desktop, uma seta. */
  #navmenu .navbar-nav .nav-link::after,
  #navmenu .navbar-nav .nav-link:hover::after,
  #navmenu .navbar-nav .nav-link.active::after {
    position: static;
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    border-radius: 0;
    background: none;
    opacity: 0.4;
    transform: rotate(45deg);
  }

  #navmenu .navbar-nav .nav-link.active {
    color: var(--primary) !important;
  }

  #navmenu .navbar-nav + .d-flex {
    gap: 10px !important;
    margin-top: 16px;
  }

  #navSearchBtn {
    flex: none;
    width: 50px;
    height: 50px;
    border: 1px solid var(--m-line);
    border-radius: 50%;
  }

  #navmenu .nav-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 50px;
    margin-left: 0;
    border-radius: 999px;
    font-size: 0.95rem !important;
  }

  body.m-nav-open::before {
    content: '';
    position: fixed;
    z-index: 989;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: m-fade-in 0.2s ease both;
  }

  .m-nav-open .pd-floating {
    display: none;
  }

  /* ================= cardápio ================= */
  /* Categorias numa fileira que rola para o lado e gruda embaixo do topo. */
  .m-filters {
    position: -webkit-sticky;
    position: sticky;
    z-index: 5;
    top: var(--m-header);
    display: flex;
    gap: 8px;
    margin: 0 calc(var(--bs-gutter-x, 1.5rem) * -0.5) 12px !important;
    padding: 10px calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    overflow-x: auto;
    border-bottom: 1px solid var(--m-line);
    background: rgba(249, 245, 240, 0.96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    text-align: left !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .m-filters::-webkit-scrollbar {
    display: none;
  }

  .m-filters .filtbtn {
    flex: none;
    margin: 0;
    padding: 8px 18px;
    border-width: 1px;
    white-space: nowrap;
  }

  .m-filters .filtbtn:hover:not(.active) {
    border-color: #e5e5e5;
    background: #ffffff;
    color: #666;
    box-shadow: none;
  }

  #menu .mb-5 {
    margin-bottom: 1.5rem !important;
  }
}

/* Celular: cada prato numa linha — foto, nome, descrição curta, preço e o botão do pedido.
   Tocar no card continua abrindo os detalhes (js/main.js). */
@media (max-width: 575.98px) {
  #mgrid {
    --bs-gutter-y: 12px;
  }

  /* A lista aparece pronta: sem esperar a animação de rolagem (AOS) card a card. */
  #mgrid .mwrap[data-aos] {
    opacity: 1 !important;
    transform: none !important;
  }

  .mcard {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    grid-template-areas:
      'img cat'
      'img title'
      'img desc'
      'img foot'
      'add add';
    grid-template-rows: auto auto auto 1fr auto;
    column-gap: 14px;
    padding: 12px;
    border: 1px solid var(--m-line);
    border-radius: 22px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .mcard:hover {
    transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .mcard:hover .mimg img {
    transform: none;
  }

  .mimg {
    grid-area: img;
    width: 104px;
    height: 104px;
    border-radius: 16px;
  }

  .mbdg {
    top: 6px;
    left: 6px;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.56rem;
  }

  .mhrt,
  .madd {
    display: none;
  }

  .mbody {
    display: contents;
  }

  .mcat {
    grid-area: cat;
    margin: 2px 0 2px;
    font-size: 0.62rem;
  }

  .mtit {
    grid-area: title;
    margin-bottom: 3px;
    font-size: 1rem;
    line-height: 1.25;
  }

  .mdesc {
    grid-area: desc;
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: #8f8f8f;
    font-size: 0.76rem;
    line-height: 1.4;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .mfoot {
    grid-area: foot;
    align-self: end;
    margin-top: 6px;
  }

  /* Na Playfair a vírgula de "14,99" parece ponto. */
  .mprice {
    font-family: 'Poppins', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
  }

  .mcard .pd-add {
    grid-area: add;
    margin-top: 12px;
  }

  .mcard .pd-add__stepper {
    height: 44px;
  }

  .bsub {
    display: none;
  }

  /* Detalhes do prato: sobe de baixo como a sacola, com o "Adicionar" sempre visível. */
  #menuPop {
    align-items: flex-end;
    padding: 8px;
  }

  .mpbox {
    max-height: calc(100dvh - 16px);
    border-radius: 28px;
    animation: m-sheet-in 0.3s cubic-bezier(0.32, 0.72, 0, 1) both;
  }

  .mpbox .mpimg {
    height: 200px;
    min-height: 0;
    border-radius: 28px 28px 0 0;
  }

  .mpbox .mpbody {
    padding: 20px 18px 0;
  }

  #mpTitle {
    font-size: 1.5rem;
  }

  .mpmeta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .mpm {
    padding: 9px 6px;
  }

  .mpaddcart {
    position: sticky;
    bottom: 0;
    margin: 0 -18px;
    width: calc(100% + 36px);
    border-radius: 0;
    padding: 18px;
    box-shadow: 0 -12px 24px rgba(255, 255, 255, 0.9);
  }
}

@keyframes m-sheet-in {
  from { opacity: 0; transform: translateY(2.5rem); }
}

/* Na sacola, nomes longos quebram em duas linhas em vez de virar "Smash Burger …". */
@media (max-width: 575.98px) {
  .pd-sheet .pd-row__name {
    display: -webkit-box;
    white-space: normal;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

@keyframes m-panel-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
}

@keyframes m-fade-in {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #navmenu.show,
  body.m-nav-open::before {
    animation: none;
  }
}
