/* Fundacao responsiva - Mobile V15, Etapa 1.
   Breakpoint unico: 767/768. Fonte dos valores: docs/mobile/BREAKPOINTS.md.
   var() nao funciona dentro de @media, por isso o 767 aqui e literal.
   Cor e tipografia somente por token de base.html. Nenhum hex novo.
   Fora da @media so existe o estado desktop da barra e da folha: display:none. */

/* --fab-base: quanto o rodape ocupa. O botao de feedback e qualquer
   acao flutuante futura se apoiam nisso, nunca em bottom literal. */
:root { --fab-base: 24px; }

.barra-inferior { display: none; }
.folha-fundo { display: none; }
.folha-mais { display: none; }

@media (max-width: 767px) {
  :root {
    --fab-base: calc(56px + env(safe-area-inset-bottom) + 16px);
  }


  /* 1. main ganha largura propria, independente da sidebar */
  .sidebar { display: none; }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 1.5rem 1.15rem calc(56px + env(safe-area-inset-bottom) + 1.25rem);
  }

  /* 2. barra inferior */
  .barra-inferior {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    min-height: 56px;
    background: white;
    border-top: 1px solid var(--br);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: var(--sh2);
  }

  .barra-item {
    flex: 1;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    padding: .4rem .25rem;
    font-family: var(--fb);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--ts);
    background: transparent;
    border: none;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .18s var(--ease);
  }

  .barra-item.on { color: var(--l600); }

  .barra-ico {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .barra-ico svg { width: 18px; height: 18px; }

  /* 3. folha "Mais". Regra do hidden aprendida na v14.1:
     nunca declarar display na classe base, senao vence [hidden]. */
  .folha-fundo:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 210;
    background: rgba(42, 34, 64, .4);
  }

  .folha-mais:not([hidden]) {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 211;
    max-height: 82%;
    overflow-y: auto;
    background: white;
    border-radius: var(--rlg) var(--rlg) 0 0;
    padding: 1rem 1.1rem calc(1rem + env(safe-area-inset-bottom));
    box-shadow: var(--sh3);
  }

  .folha-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .35rem;
  }

  .folha-titulo {
    font-family: var(--fd);
    font-size: 1.2rem;
    color: var(--tp);
  }

  .folha-mais .nav-a { min-height: 44px; }
  .folha-mais .nav-lbl { margin-top: .7rem; }

  /* ---- D-P1 (Etapa 3a): grades de conteudo viram uma coluna ----
     Causa raiz de 6 das 8 telas que estouravam na Etapa 2. `1fr` sozinho
     e minmax(auto,1fr): a trilha guarda o minimo do conteudo, entao um
     filho largo (tabela, palavra longa, pre) estica a coluna e a pagina
     rola de lado. minmax(0,1fr) no track mais min-width:0 no filho e o
     par que segura de verdade - foi assim que a Etapa 2 corrigiu tela a
     tela. Aqui a correcao passa a ser da fundacao, e as sobrescritas por
     pagina saem. Excecao de 2 colunas so com escopo de id de tela. */
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .g2 > *, .g3 > *, .g4 > * { min-width: 0; }
}
