/* Editor de escudo: seletor de simbolos e barra de fontes.
   Desktop: popover ancorado ao lado do canvas (abaixo das abas do painel), abas de categoria e grade de 48px.
   Celular: bottom sheet de ate 55% da tela, 5 colunas de 56px, grade de 3 linhas exatas e area segura embaixo.
   Extraido do trabalho do redesign (nao inclui nenhuma outra tela). */

/* 44. Editor de escudo (Gabriel, 1466): popover ancorado ao lado do canvas no desktop e bottom sheet
   de no maximo 55% no celular; grade compacta de 48px e abas de categoria. O escudo nunca sai de vista. */
.crest-layout { position: relative; }
.crest-symbols-pop { display: none; }
.crest-symbols-pop.is-open { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 761px) {
  .crest-symbols-pop.is-open {
    /* comeca abaixo da barra de abas do painel (44px), para nao cobrir os menus do editor */
    position: absolute; top: 56px; right: 0; z-index: 40;
    width: min(372px, 42%); max-height: calc(100% - 68px);
    padding: 14px; border-radius: 14px;
    background: linear-gradient(180deg, #0a2126, #061417);
    border: 1px solid #1c4852; box-shadow: 0 18px 44px rgba(0, 0, 0, .62);
  }
  .crest-symbols-handle { display: none; }
}
@media (max-width: 760px) {
  .crest-symbols-pop.is-open {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    /* 55% de teto, com respiro embaixo (e area segura do iPhone) para a ultima linha nao colar na borda */
    max-height: 55vh; padding: 8px 14px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0; border-top: 1px solid #1c4852;
    background: linear-gradient(180deg, #0a2126, #061417);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, .65);
    overflow: hidden;
  }
  /* A grade tem altura de 3 linhas exatas (3 x 48 + 2 x 6 de respiro = 162px): assim nenhuma
     linha aparece cortada na borda da gaveta e o resto rola por dentro. */
  .crest-symbols-pop.is-open .crest-grid-shapes {
    /* 3 linhas de 56px; em telas baixas encolhe (max-height) e rola por dentro, sem estourar a gaveta */
    flex: 0 1 auto; height: 188px; max-height: calc(55vh - 150px); overflow-y: auto;
    grid-template-columns: repeat(5, 56px); justify-content: space-between;
    padding: 0 0 6px; scroll-snap-type: y proximity;
  }
  .crest-symbols-pop.is-open .crest-grid-shapes .crest-thumb { width: 56px; height: 56px; min-height: 56px; }
  .crest-symbols-pop.is-open .crest-grid-shapes .crest-thumb :is(img, svg) { max-width: 40px; max-height: 40px; }
  .crest-symbols-pop.is-open .crest-grid-shapes .crest-thumb { scroll-snap-align: start; }
  .crest-symbols-handle { display: flex; justify-content: center; padding: 2px 0 8px; }
  .crest-symbols-handle span { width: 44px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .32); }
}
.crest-symbols-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crest-symbols-head h3 { margin: 0; font-size: var(--text-base); letter-spacing: .01em; }
.crest-symbols-close {
  min-width: 40px; min-height: 40px; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; font-size: var(--text-base); color: #cfe6e2;
  background: rgba(255, 255, 255, .07); border: 1px solid #1c3e47; cursor: pointer;
}
.crest-symbols-close:hover { color: #fff; background: rgba(255, 255, 255, .14); }
/* as abas de categoria quebram em linhas: nenhuma fica cortada na borda do popover */
.crest-symbol-cats { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; }
.crest-symbol-cats::-webkit-scrollbar { display: none; }
.crest-cat-tab {
  flex: 0 0 auto; min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid #1c3e47; background: rgba(255, 255, 255, .04); color: #a9c4c9;
  font-size: var(--text-xs); cursor: pointer; white-space: nowrap;
}
.crest-cat-tab[aria-selected="true"] { background: var(--accent, #b8f34b); border-color: transparent; color: #07211d; font-weight: 700; }
.crest-symbols-pop .crest-grid-shapes { display: grid; grid-template-columns: repeat(auto-fill, 48px); gap: 8px; overflow-y: auto; padding: 2px; }
.crest-symbols-pop .crest-grid-shapes .crest-thumb {
  width: 48px; height: 48px; min-height: 48px; border-radius: 8px; padding: 0;
  display: grid; place-items: center; background: rgba(13, 36, 42, .85); border: 1px solid #183c45; cursor: pointer;
}
/* Gabriel (1503): as formas vinham pretas sobre o tile escuro. Aqui elas ficam claras (#e8f0ec) e o
   item ativo/hover/foco vai para o lima, com o icone de volta ao escuro. Vale nas abas todas. */
.crest-symbols-pop .crest-grid-shapes .crest-thumb { background: rgba(232, 240, 236, .07); border-color: rgba(232, 240, 236, .2); }
.crest-symbols-pop .crest-grid-shapes .crest-thumb :is(img, svg) {
  filter: brightness(0) invert(1); opacity: .92;
  /* o SVG e quadrado: limitar aqui evita o icone vazar da miniatura */
  width: auto; height: auto; max-width: 36px; max-height: 36px; object-fit: contain;
}
.crest-symbols-pop .crest-grid-shapes .crest-thumb:hover,
.crest-symbols-pop .crest-grid-shapes .crest-thumb:focus-visible,
.crest-symbols-pop .crest-grid-shapes .crest-thumb:active,
.crest-symbols-pop .crest-grid-shapes .crest-thumb[aria-pressed="true"],
.crest-symbols-pop .crest-grid-shapes .crest-thumb[aria-selected="true"] {
  background: var(--accent, #b8f34b); border-color: var(--accent, #b8f34b);
}
.crest-symbols-pop .crest-grid-shapes .crest-thumb:hover :is(img, svg),
.crest-symbols-pop .crest-grid-shapes .crest-thumb:focus-visible :is(img, svg),
.crest-symbols-pop .crest-grid-shapes .crest-thumb:active :is(img, svg),
.crest-symbols-pop .crest-grid-shapes .crest-thumb[aria-pressed="true"] :is(img, svg),
.crest-symbols-pop .crest-grid-shapes .crest-thumb[aria-selected="true"] :is(img, svg) {
  filter: brightness(0) saturate(100%); opacity: .9;
}
@media (max-width: 760px) {
  .crest-symbols-pop .crest-grid-shapes { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .crest-symbols-pop .crest-grid-shapes .crest-thumb { width: 56px; height: 56px; }
}

/* Barra de fontes: chips com "Aa" na propria fonte, rolagem horizontal; sem previa grande. */
.crest-fonts-bar-wrap { display: flex; align-items: center; gap: 6px; margin: 8px 0; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, .22); border: 1px solid #193840; }
.crest-font-nav-btn { min-width: 36px; min-height: 40px; width: 36px; padding: 0; display: grid; place-items: center; border-radius: 8px; font-size: var(--text-lg); color: #8ba9b0; flex: none; }
.crest-fonts-strip { display: flex !important; flex-direction: row; gap: 6px; overflow-x: auto; padding: 2px; flex: 1 1 auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.crest-fonts-strip::-webkit-scrollbar { display: none; }
.crest-font-chip { min-height: 40px !important; height: 40px; min-width: 56px; padding: 0 12px !important; border-radius: 10px !important; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; scroll-snap-align: center; }
.crest-font-chip .crest-font-name { font-size: var(--text-base); line-height: 1; }
.crest-font-sample { display: none !important; }


/* Editores de escudo e de camisa (mesmo codigo, dono 19/11/2026). */
/* O aviso abaixo de Salvar / Sair sem salvar: estava colado nos botoes. */
.crest-editor .crest-nav + .crest-hint { margin-top: var(--space-4, 16px); }
/* Formas: -Tamanho, +Tamanho, Girar, Girar, Remover a ultima e Limpar numa linha, do mesmo tamanho e com espaco. O grupo de
   tamanho e giro so agrupa para leitores de tela (display: contents). Texto menor para caber; no celular, tres por linha. */
.crest-editor .crest-shape-tools { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-block: 12px 16px;
  --btn-pad: 6px 4px; --btn-pad-small: 6px 4px; --btn-font-size: var(--text-xs, 12px); --btn-font-size-small: var(--text-xs, 12px); --btn-line-height: 1.2; }
.crest-editor .crest-shape-tools-group { display: contents; }
.crest-editor .crest-shape-tools .btn { width: 100%; min-width: 0; margin: 0; justify-content: center; text-align: center; white-space: normal; }
/* Texto: o formato (Reto, Arco...) e os botoes Adicionar / Alterar na mesma linha; no celular, o formato em cima e os dois embaixo. */
.crest-editor .crest-text-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: stretch; margin-top: 8px; }
.crest-editor .crest-text-row > * { margin: 0; min-height: 44px; }
@media (max-width: 560px) {
  .crest-editor .crest-shape-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crest-editor .crest-text-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crest-editor .crest-text-row > select { grid-column: 1 / -1; }
}
