/* ==========================================================================
   Atlas PPGEPS — celular (≤620 px)
   Carregado por research-groups.html com media="(max-width: 620px)", depois do atlas.css;
   as regras-base dos elementos que só existem aqui (ícones das abas, .m-tabs, #profileMore)
   ficam no atlas.css. Layout de app: abas com ícone no rodapé, cabeçalho de uma linha,
   a página inteira rola e as colunas laterais viram abas de seção.
   ========================================================================== */
@media (max-width: 620px) {
  :root { --header-h: 52px; --nav-h: 58px; }

  /* ---- Cabeçalho: marca · idioma · filtros · tema, numa linha ---- */
  .app-header { display: flex; align-items: center; gap: 8px; height: var(--header-h); padding: 0 12px; }
  .brand { gap: 8px; }
  .brand-mark { width: 24px; height: 24px; }
  .brand-text strong { font-size: var(--fs-base); }
  .header-actions { margin-left: auto; gap: 6px; }
  .lang-switch .seg { padding: 5px 7px; }

  /* ---- Barra de abas no rodapé ---- */
  .view-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; width: auto;
    display: flex; gap: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom); overflow: visible; scroll-snap-type: none;
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .view-nav button {
    flex: 1 1 0; min-width: 0; padding: 7px 0 5px; border-radius: 0; scroll-snap-align: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 10px; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; color: var(--muted); white-space: nowrap;
  }
  .view-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .view-nav .tab-icon { display: block; }
  .view-nav button:hover { background: transparent; color: var(--muted); }
  .view-nav button[aria-selected="true"] { color: var(--accent); background: transparent; box-shadow: inset 0 2px 0 var(--accent); font-weight: 600; }

  .app-body { height: calc(100dvh - var(--header-h) - var(--nav-h) - env(safe-area-inset-bottom)); }

  /* ---- Cabeçalhos das vistas: compactos, sem texto explicativo nem botão de minimizar ---- */
  .view-head { padding: 8px 12px; gap: 6px 8px; }
  #view-publicacoes .view-head, #view-professores .view-head, #view-perfil .view-head, #view-galaxia .view-head, .wk-head { padding-right: 12px; }
  .view-explainer, .head-toggle { display: none; }
  #view-mapa .view-head, #view-grafo .view-head,
  #view-galaxia .view-heading, #view-professores .view-heading, #view-publicacoes .view-heading { display: none; }

  /* Galáxia: os controles numa fileira que rola de lado; "Ajustes" abre sobre o canvas
     (o recipiente dele é o cabeçalho, então a rolagem lateral não o corta). */
  #view-galaxia .scene-controls { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #view-galaxia .scene-controls::-webkit-scrollbar { display: none; }
  #view-galaxia .scene-controls > * { flex: none; }
  #view-galaxia .scene-more-body { left: 12px; right: 12px; }   /* o painel flutuante vem do atlas.css */

  /* Professores: Rede | Diretório na largura toda; Grupo e Ordenar dividem a linha seguinte. */
  #view-professores .view-filters { gap: 6px 8px; }
  #view-professores .subview-tabs { width: 100%; }
  #view-professores .subview-tabs .seg { flex: 1; text-align: center; }
  #view-professores .inline-field { flex: 1 1 40%; min-width: 0; font-size: var(--fs-sm); }
  #view-professores .inline-field .select { flex: 1; min-width: 0; }
  .directory { padding: 10px; }
  .directory-list { gap: 8px; }
  .directory-toolbar { padding: 0 0 8px; gap: 8px; }
  .directory-toolbar input { width: 100%; }
  .prof-card { padding: 12px; gap: 5px; }

  /* ---- Busca: campo + botão-lupa; a linha de baixo são ações em texto ---- */
  #pubSearchBtn, #profileSearchBtn {
    flex: none; width: 40px; min-height: 36px; padding: 0; font-size: 0; position: relative;
    background: var(--accent); border-color: var(--accent); color: var(--accent-fg);
  }
  #pubSearchBtn::before, #profileSearchBtn::before {
    content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 20 20'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 20 20'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  #pubForm, .profile-main .view-filters { gap: 6px 10px; }
  #pubForm .vf-query, #profileForm .vf-query { flex: 1 1 calc(100% - 50px); min-width: 0; }   /* campo + lupa fecham a linha */
  #pubForm > .inline-field { flex: none; }
  /* "Ordenar" sai da tela mas segue como nome acessível do select (display:none o apagaria do leitor de tela). */
  #pubForm > .inline-field > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #pubForm .select {
    min-height: 32px; padding: 4px 24px 4px 6px; background-color: transparent; border-color: transparent;
    color: var(--accent); font-weight: 600; background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
  }
  .toolbar-more summary { min-height: 32px; padding: 4px 6px; border-color: transparent; background: transparent; color: var(--accent); }
  .toolbar-more[open] summary { border-color: var(--accent); background: var(--accent-soft); }
  .toolbar-more-body { margin-top: 6px; padding: 10px; gap: 8px 10px; }
  #profileMore { flex: 1 1 100%; }
  #profileMore > summary { display: inline-flex; }
  #profileMore .toolbar-more-body { margin-top: 6px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }

  /* ---- Lista de trabalhos: cartões compactos ---- */
  .results-list { padding: 8px 10px 14px; gap: 8px; }
  .result-item { padding: 11px 12px 9px 13px; }
  .result-item .ri-meta { font-size: var(--fs-2xs); gap: 2px 8px; margin-bottom: 4px; }
  .result-item .ri-year { padding: 0 6px; }
  .result-item .ri-full-none { display: none; }   /* "Sem PDF" é ruído; só o positivo aparece */
  .result-item .tag { font-size: var(--fs-2xs); padding: 1px 7px; }
  .result-item .ri-title { font-size: var(--fs-base); line-height: 1.35; }
  .result-item .ri-score { width: 38px; height: 38px; font-size: var(--fs-xs); }
  .result-item .ri-authors { display: block; margin-top: 5px; font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .result-item .ri-author { display: inline; background: none; padding: 0; font-weight: 600; color: var(--fg-soft); font-size: inherit; }
  .result-item .ri-others { font-size: inherit; }
  .result-item .ri-authors > * + *::before { content: ' · '; color: var(--faint); font-weight: 400; }
  .result-item .ri-snippet { margin-top: 6px; font-size: var(--fs-sm); line-height: 1.5; }
  .result-item .ri-more { font-size: var(--fs-xs); }
  .result-item .ri-foot { margin-top: 8px; padding-top: 6px; gap: 4px 10px; font-size: var(--fs-xs); }
  .result-item .ri-related { padding: 1px 8px; }
  .pagination { gap: 10px; padding: 10px; }

  /* ---- Abas de seção (perfil: Trabalhos | Coautoria e temas; leitura: Texto | Sumário) ---- */
  .m-tabs { display: block; position: sticky; top: 0; z-index: 4; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .m-tabs .seg { padding: 6px 8px; }
  #view-perfil:not([data-mtab="side"]) .profile-side, #view-trabalho:not([data-mtab="side"]) .wk-side { display: none; }
  #view-perfil[data-mtab="side"] .profile-main, #view-trabalho[data-mtab="side"] .wk-main { display: none; }
  #view-trabalho:has(#wkPdf:not([hidden])) .m-tabs { display: none; }
  .profile-side, .wk-side { max-height: none; overflow: visible; border-bottom: 0; box-shadow: none; padding: 0 14px 20px; }
  .side-toggle { display: none; }

  /* ---- Voltar (perfil e leitura): só a seta, sem moldura, alvo de 40 px ---- */
  #profileBack, .wk-back {
    width: 40px; height: 40px; margin-left: -10px; padding: 0; justify-content: center; flex: none; gap: 0;
    font-size: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--accent);
  }
  #profileBack::before, .wk-back::before {
    content: ''; width: 11px; height: 11px; margin-left: 4px;
    border-left: 2.5px solid currentColor; border-top: 2.5px solid currentColor; transform: rotate(-45deg);
  }
  #profileBack:hover, .wk-back:hover { background: transparent; box-shadow: none; }
  #profileBack:active, .wk-back:active { background: var(--accent-soft); }

  /* ---- Perfil: seta · iniciais · nome; grupo e instituição; quatro números em azulejos ---- */
  #view-perfil .view-head { padding: 6px 12px 10px; gap: 8px 0; }
  .profile-title-row { flex-wrap: nowrap; gap: 10px; }
  .profile-avatar { display: grid; place-content: center; width: 38px; height: 38px; border-radius: 50%; flex: none; font-weight: 600; font-size: var(--fs-md); letter-spacing: .03em; }
  #profileName { flex: 1; min-width: 0; font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #view-perfil .view-explainer { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-sm); margin-top: 4px; }
  #profileMetrics { flex: 1 1 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-size: var(--fs-2xs); color: var(--muted); }
  #profileMetrics .metric {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; min-width: 0;
    padding: 7px 4px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #profileMetrics .metric b { font-size: var(--fs-lg); line-height: 1.15; }
  #profileMetrics .ext-btn { grid-column: 1 / -1; justify-self: start; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; font-size: var(--fs-xs); color: var(--accent); }
  .profile-main .view-filters { padding: 8px 12px; }

  /* ---- Leitura: título, um autor por linha, metadados "rótulo valor" numa linha ---- */
  .wk-head { padding: 8px 12px 12px; }
  .wk-topbar, .wk-topbar-right { gap: 6px; }
  .wk-title { font-size: 19px; line-height: 1.3; }
  .wk-authors { flex-direction: column; align-items: flex-start; gap: 3px; }
  .wk-authors > * + *::before { content: none; }
  .wk-metrics { margin-top: 10px; gap: 2px 0; font-size: var(--fs-xs); color: var(--muted); }
  .wk-metrics .metric { display: inline-flex; flex-direction: row-reverse; gap: 4px; align-items: baseline; background: none; border: 0; padding: 0; min-width: 0; }
  .wk-metrics .metric b { display: inline; font-size: var(--fs-sm); line-height: 1.3; }
  .wk-metrics .metric.year b { font-size: var(--fs-base); }
  .wk-metrics .metric.topic b { max-width: none; }
  .wk-metrics .metric + .metric::after { content: '·'; margin: 0 8px; color: var(--faint); }   /* row-reverse: o ::after fica à esquerda */
  .wk-actions { font-size: var(--fs-sm); }
  .wk-article { padding: 14px 14px 90px; }
  #wkPdf { height: calc(100dvh - var(--header-h) - var(--nav-h) - env(safe-area-inset-bottom)); }

  /* ---- Constelação: a nota sai (a ficha do ponto tocado traz as ações) ---- */
  .related-panel .rp-note { display: none; }
  .related-panel .rp-head { padding: 10px 12px; }
  .rp-card { left: 8px; right: 8px; bottom: 8px; }
}
