/* ===============================================================
   imagas — NAVEGAÇÃO COM ÍCONES + MALHA CENTRAL 1080 × 1080
   Carregado apenas nas seis páginas internas.
   Troque o arquivo da malha usando a regra .subpage-mesh.
================================================================ */

/* Opções fáceis de ajustar */
body.subpage {
    --subpage-nav-icon-width: 105px; /* largura de cada botão PNG no topo */
    --subpage-nav-gap: 16px;         /* distância entre botões no topo */
    --subpage-brand-art-width: 130px; /* largura da sua arte para o link imagas */
    --subpage-mesh-size: 1080px;     /* tamanho máximo do quadrado */
    --subpage-content-width: 700px;  /* largura da caixa de conteúdo */
    --subpage-header-height: 74px;
    --subpage-content-x: 0px;
    --subpage-content-y: 0px;
    --mesh-line: rgba(75, 93, 138, .14);
    --panel-backdrop: rgba(247,247,247,.96);
    --page-ui-color: #4b5d8a;
}

html:has(body.subpage),
body.subpage {
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100%;
}

body.subpage .hero,
body.subpage .hero canvas { pointer-events: none; }

/* Faixa superior: marca + 6 PNGs. Os botões mantêm suas cores. */
.subpage-topbar {
    position: relative;
    z-index: 30;
    width: 100%;
    min-height: var(--subpage-header-height);
    display: flex;
    align-items: center;
    gap: clamp(16px, 2.5vw, 36px);
    padding: 12px clamp(14px, 3vw, 42px);
    background: var(--panel-backdrop);
    border-bottom: 1px solid var(--page-ui-color);
    font-family: "Courier New", monospace;
}
.subpage-brand {
    flex: 0 0 auto;
    text-decoration: none;
    color: var(--page-ui-color);
    font-size: 19px;
    font-weight: bold;
    letter-spacing: -.04em;
}
.subpage-brand:hover,
.subpage-brand:focus-visible { text-decoration: underline; }

.subpage-links {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: var(--subpage-nav-gap);
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 3px 7px;
    scrollbar-width: thin;
    scrollbar-color: var(--page-ui-color) transparent;
}
.subpage-links a {
    flex: 0 0 var(--subpage-nav-icon-width);
    width: var(--subpage-nav-icon-width);
    display: block;
    line-height: 0;
    text-decoration: none;
    opacity: 1;
    transition: opacity .2s ease;
    border-bottom: 2px solid transparent;
}
.subpage-links a img {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: auto;
    filter: none;
    transform: none;
}
.subpage-links a:hover,
.subpage-links a:focus-visible { opacity: .67; }
.subpage-links a:focus-visible { outline: 2px solid var(--page-ui-color); outline-offset: 1px; }
.subpage-links a[aria-current="page"] { border-bottom-color: var(--page-ui-color); }

/* Área principal centrada num QUADRADO de referência 1080 × 1080.
   O quadrado diminui proporcionalmente para caber na janela; o conteúdo
   permanece no centro da malha. */
.subpage-main {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: calc(100dvh - var(--subpage-header-height));
    padding: 20px 16px 110px;
    pointer-events: none;
}
.subpage-stage {
    position: relative;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: min(var(--subpage-mesh-size), calc(100vw - 32px), calc(100dvh - var(--subpage-header-height) - 110px));
    aspect-ratio: 1 / 1;
}

/* Malha gráfica de referência (fallback CSS).
   Caso tenha a SUA malha como PNG 1080×1080, substitua background-image por:
   background-image: url("/malha-1080.png");
   background-size: 100% 100%;
   e coloque o arquivo malha-1080.png na raiz do site.
   A imagem da malha é diferente dos arquivos ascii/PAGINA.png. */
.subpage-mesh {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, var(--mesh-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--mesh-line) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center center;
    background-repeat: repeat;
}

.subpage-panel {
    position: relative;
    z-index: 1;
    width: min(var(--subpage-content-width), calc(100% - 32px));
    max-height: min(72dvh, 720px);
    overflow-y: auto;
    padding: clamp(20px, 3vw, 46px);
    pointer-events: auto;
    transform: translate(var(--subpage-content-x), var(--subpage-content-y));
    color: var(--page-ui-color);
    background: var(--panel-backdrop);
    border: 1px solid var(--page-ui-color);
    box-shadow: 7px 7px 0 var(--page-ui-color);
}
.subpage-kicker { font-size: 11px; letter-spacing: .14em; margin-bottom: 17px; }
.subpage-title {
    font-size: clamp(30px, 5vw, 61px);
    margin: 0 0 18px;
    line-height: 1.06;
    letter-spacing: -.055em;
}
.subpage-lede { font-size: 16px; line-height: 1.65; margin-bottom: 20px; }
.subpage-description { font-size: 13px; line-height: 1.8; margin-bottom: 24px; }
.subpage-placeholder {
    padding: 16px 19px;
    font-size: 12px;
    line-height: 1.7;
    border: 1px dashed var(--page-ui-color);
    background: var(--panel-backdrop);
}
.subpage-return {
    display: inline-block;
    margin-top: 22px;
    color: var(--page-ui-color);
    text-decoration: none;
    font-size: 12px;
}
.subpage-return:hover { text-decoration: underline; }

/* Controles iguais aos da home: na parte inferior das páginas internas */
body.subpage {
    --terminal-top: auto;
    --terminal-right: auto;
    --terminal-button-x: 0px;
    --terminal-button-y: 0px;
    --static-toggle-x: 0px;
    --static-toggle-y: 0px;
    --terminal-window-x: 0px;
    --terminal-window-y: 0px;
}
body.subpage .ascii-editor {
    position: fixed;
    top: auto;
    right: auto;
    bottom: 16px;
    left: 16px;
    z-index: 40;
    width: max-content;
    max-width: calc(100vw - 32px);
}
body.subpage .terminal-actions { flex-wrap: wrap; gap: 7px; }
body.subpage #ascii-panel {
    top: auto;
    right: auto;
    bottom: 55px;
    left: 0;
    width: 320px;
    max-width: min(320px, calc(100vw - 32px));
    max-height: min(65vh, 420px);
}

/* Escolha de imagem ASCII independente em cada página */
.ascii-image-editor {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 42;
    font: 12px/1.5 "Courier New", monospace;
    color: var(--page-ui-color);
}
#edit-ascii-image,
#reset-ascii-image {
    cursor: pointer;
    padding: 10px 14px;
    background: var(--panel-backdrop);
    color: var(--page-ui-color);
    border: 1px solid var(--page-ui-color);
    font: inherit;
}
#edit-ascii-image:hover,
#reset-ascii-image:hover { background: var(--page-ui-color); color: var(--page-bg); }
#ascii-image-panel {
    position: absolute;
    bottom: 55px;
    right: 0;
    width: min(330px, calc(100vw - 32px));
    max-height: 70dvh;
    overflow-y: auto;
    color: var(--page-ui-color);
    background: var(--panel-backdrop);
    border: 1px solid var(--page-ui-color);
    box-shadow: 5px 5px 0 var(--page-ui-color);
}
#ascii-image-panel[hidden] { display: none; }
#close-ascii-image {
    padding: 0 4px;
    border: none;
    background: transparent;
    color: var(--page-ui-color);
    font: inherit;
    cursor: pointer;
}
.ascii-image-body { padding: 17px; }
.ascii-image-body label { display: block; margin-bottom: 9px; }
#ascii-image-upload { display: block; max-width: 100%; font: inherit; }
#ascii-image-status { margin: 17px 0; font-size: 11px; line-height: 1.65; }
.ascii-image-note { margin-top: 12px; font-size: 10px; line-height: 1.7; }

/* Cores para o tema escuro das páginas internas */
html[data-theme="dark"] body.subpage {
    --mesh-line: rgba(255,255,255,.14);
    --panel-backdrop: rgba(0,0,0,.95);
    --page-ui-color: #ffffff;
}

/* Em telas pequenas: a malha fica centralizada e o conteúdo pode crescer. */
@media (max-width: 900px) {
    .subpage-topbar { flex-wrap: wrap; justify-content: center; }
    .subpage-links { flex: 0 1 100%; justify-content: safe center; }
    .subpage-main { min-height: calc(100dvh - 110px); padding-bottom: 130px; }
}
@media (max-width: 650px) {
    .subpage-topbar { padding: 12px 13px; }
    .subpage-brand { font-size: 17px; }
    .subpage-links { justify-content: flex-start; gap: 10px; }
    body.subpage { --subpage-nav-icon-width: 94px; }
    .subpage-main { padding: 18px 16px 180px; }
    .subpage-stage {
        width: 100%;
        aspect-ratio: auto;
        min-height: min(700px, calc(100dvh - 160px));
        padding: 50px 0;
    }
    .subpage-mesh {
        inset: auto;
        top: 50%;
        left: 50%;
        width: 100%;
        aspect-ratio: 1 / 1;
        transform: translate(-50%, -50%);
    }
    .subpage-panel {
        width: min(var(--subpage-content-width), 100%);
        max-height: none;
        transform: none;
    }
    body.subpage .ascii-editor { bottom: 68px; }
    .ascii-image-editor { bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .subpage-links a { transition: none; }
}


/* ================================================================
   IMAGAS — ÍCONES PADRONIZADOS NA BARRA SUPERIOR
   Inclusive Recursos: todos ocupam o mesmo quadro 88:31.
   Imagens com outras dimensões cabem dentro dele sem esticar.
================================================================ */
body.subpage .subpage-links > a {
    box-sizing: border-box;
    flex: 0 0 var(--subpage-nav-icon-width) !important;
    width: var(--subpage-nav-icon-width) !important;
    height: auto;
    aspect-ratio: 88 / 31;
    max-width: var(--subpage-nav-icon-width);
    overflow: hidden;
}

body.subpage .subpage-links > a > img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    object-position: center;
    transform: none !important;
    image-rendering: auto;
}

/* Seu logo no topo. Se o PNG não existir, fica o texto clicável 'imagas'. */
body.subpage .subpage-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 0;
}
body.subpage .subpage-brand .brand-art {
    display: none;
    width: var(--subpage-brand-art-width);
    max-width: min(35vw, 210px);
    max-height: 54px;
    height: auto;
    object-fit: contain;
    image-rendering: auto;
}
body.subpage .subpage-brand.has-brand-art .brand-art {
    display: block;
}
body.subpage .subpage-brand.has-brand-art .brand-text {
    display: none;
}
body.subpage .subpage-brand:hover .brand-art,
body.subpage .subpage-brand:focus-visible .brand-art {
    opacity: .75;
}


/* ==============================================================
   IMAGAS — LOGO / BARRA SUPERIOR SEM PISCADA OU DESLOCAMENTO
   Reserva uma largura fixa para o link imagas desde o primeiro frame.
   Enquanto a arte não carrega, oculta SOMENTE a aparência do texto.
   No erro (404), mostra o texto novamente sem mover os demais links.
============================================================== */
body.subpage .subpage-brand {
    display: inline-flex !important;
    box-sizing: border-box;
    flex: 0 0 var(--subpage-brand-art-width) !important;
    width: var(--subpage-brand-art-width) !important;
    min-width: var(--subpage-brand-art-width) !important;
    max-width: var(--subpage-brand-art-width) !important;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
body.subpage .subpage-brand .brand-art {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 44px !important;
    object-fit: contain;
}
body.subpage .subpage-brand:not(.has-brand-art):not(.brand-art-fallback) .brand-text {
    visibility: hidden !important;
}
body.subpage .subpage-brand.has-brand-art .brand-text {
    display: none !important;
}
body.subpage .subpage-brand.brand-art-fallback .brand-text {
    display: inline !important;
    visibility: visible !important;
}

/* Limita a altura da barra ao mesmo valor durante o download das artes.
   No mobile, o próprio CSS anterior pode permitir duas linhas. */
@media (min-width: 901px) {
    body.subpage .subpage-topbar {
        height: var(--subpage-header-height);
        min-height: var(--subpage-header-height);
        box-sizing: border-box;
    }
}
body.subpage .subpage-brand {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px;
    height: 62px !important;
    min-height: 62px !important;
    max-height: 62px !important;
    text-decoration: none;
}
body.subpage .subpage-brand .brand-art {
    width: min(100%, 120px) !important;
    height: 37px !important;
    max-height: 37px !important;
    object-fit: contain;
}
body.subpage .subpage-brand .brand-text,
body.subpage .subpage-brand.has-brand-art .brand-text,
body.subpage .subpage-brand.brand-art-fallback .brand-text {
    display: block !important;
    visibility: visible !important;
    font-size: 11px;
    line-height: 1;
    text-align: center;
}
/* Enquanto a imagem não existe, texto continua visivel. */
body.subpage .subpage-brand:not(.has-brand-art) .brand-art {
    display: none !important;
}

/* IMAGAS — marca superior: somente a arte configurada. */
body.subpage .subpage-brand .brand-text,
body.subpage .subpage-brand.has-brand-art .brand-text,
body.subpage .subpage-brand.brand-art-fallback .brand-text {display:none!important;}
body.subpage .subpage-brand .brand-art {height:auto!important;max-height:60px!important;object-fit:contain;}
body.subpage .subpage-brand.brand-art-fallback::after {content:'⌂';font-family:monospace;font-size:24px;color:var(--page-ui-color);}
/* ============================================================
   IMAGAS — PÁGINA SOBRE: SÓ TEXTO CENTRALIZADO
   Alterações restritas à página Sobre; não afetam MP3, ASCII,
   menu ou conteúdo das demais páginas.
   ============================================================ */
body.page-sobre {
    /* DESKTOP — EDITE AQUI */
    --sobre-texto-largura: 650px;
    --sobre-texto-fonte: "Courier New", monospace;
    --sobre-texto-tamanho: 15px;
    --sobre-texto-entrelinhas: 1.8;
    --sobre-texto-paragrafos: 18px;
    --sobre-texto-x: 0px;
    --sobre-texto-y: 0px;
}

body.page-sobre .imagas-sobre-texto {
    position: relative;
    z-index: 3;
    box-sizing: border-box;
    width: min(var(--sobre-texto-largura), calc(100vw - 48px));
    max-height: min(70dvh, 720px);
    overflow-y: auto;
    padding: 6px;
    margin: 0 auto;
    border: none;
    box-shadow: none;
    background: transparent;
    color: var(--page-ui-color, #4b5d8a);
    font-family: var(--sobre-texto-fonte);
    font-size: var(--sobre-texto-tamanho);
    line-height: var(--sobre-texto-entrelinhas);
    text-align: center;
    overflow-wrap: anywhere;
    pointer-events: auto;
    transform: translate(var(--sobre-texto-x), var(--sobre-texto-y));
}

body.page-sobre .imagas-sobre-texto p { margin: 0; }
body.page-sobre .imagas-sobre-texto p + p {
    margin-top: var(--sobre-texto-paragrafos);
}

/* MOBILE — LARGURA ADEQUADA AO CORREDOR CENTRAL */
html[data-imagas-layout="mobile"] body.page-sobre {
    --sobre-texto-largura: 58vw;
    --sobre-texto-tamanho: 12px;
    --sobre-texto-entrelinhas: 1.65;
    --sobre-texto-paragrafos: 12px;
    --sobre-texto-x: 0px;
    --sobre-texto-y: 0px;
}
html[data-imagas-layout="mobile"] body.page-sobre .imagas-sobre-texto {
    max-height: 55dvh;
    padding: 4px;
}
/* =========================================================
   IMAGAS — ORBITRON NOS TITULOS DAS PAGINAS
   Cole ao FINAL de /paginas.css.
   Coloque as fontes em /fontes/ na raiz do seu site.
   Nao altera os tamanhos atuais dos titulos nem os demais textos.
   ========================================================= */

/* Orbitron Regular: disponivel para subtitulos, caso deseje. */
@font-face {
  font-family: "OrbitronImagas";
  src: url("/fontes/orbitron-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* Orbitron Black: para os titulos principais. */
@font-face {
  font-family: "OrbitronImagas";
  src: url("/fontes/orbitron-black-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

/* Titulos principais: mesmas dimensoes anteriores, so muda a fonte. */
body.page-musicas .imagas-music-page-content h1,
body.page-sobre h1,
body.page-projetos .projects-page-heading h1,
body.page-galeria .ig-gallery-heading h1,
body.page-contato .ic-heading h1,
body.page-recursos .ir-heading h1 {
  font-family: "OrbitronImagas", "Courier New", sans-serif !important;
  font-weight: 900 !important;
  letter-spacing: 0.03em;
}

/* OPCIONAL — descomente este bloco se quiser Orbitron Regular
   tambem nos subtitulos das secoes (h2).

body.page-musicas .imagas-music-page-content h2,
body.page-sobre .imagas-sobre-texto h2,
body.page-projetos .projects-page-content h2,
body.page-galeria .ig-gallery-page h2,
body.page-contato .ic-page h2,
body.page-recursos .ir-page h2 {
  font-family: "OrbitronImagas", "Courier New", sans-serif !important;
  font-weight: 400 !important;
}

*/
/* ==========================================
   ORBITRON NOS SUBTÍTULOS
   ========================================== */

body.page-musicas .imagas-music-page-content h2,
body.page-sobre .imagas-sobre-texto h2,
body.page-projetos .projects-page-content h2,
body.page-galeria .ig-gallery-page h2,
body.page-contato .ic-page h2,
body.page-recursos .ir-page h2 {

    font-family: "OrbitronImagas", sans-serif !important;
    font-weight: 400 !important;
    letter-spacing: 0.03em;
}
/* CORREÇÃO DO LOGO DE RETORNO */

body.subpage
.subpage-brand:not(.has-brand-art):not(.brand-art-fallback)
.brand-text {
    visibility: visible !important;
}
/* ==============================================================
   IMAGAS — LOGO DE VOLTA À HOME / CORREÇÃO GLOBAL
   ADICIONE AO FINAL DE /paginas.css (após Orbitron e outros ajustes).

   O GIF não fica mais dependente da classe .has-brand-art para
   aparecer. O texto "imagas" é um fallback atrás da imagem.
   Afeta apenas o link de retorno nas páginas internas.
   ============================================================= */

body.subpage .subpage-brand {
  position: relative !important;
  isolation: isolate;
}

/* Fallback clicável, visível quando a imagem não carregou. */
body.subpage .subpage-brand .brand-text {
  display: flex !important;
  visibility: visible !important;
  position: absolute;
  inset: 0;
  z-index: 0;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* A imagem pode ser mostrada mesmo antes de o JS marcar o estado. */
body.subpage .subpage-brand .brand-art {
  display: block !important;
  position: relative;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 44px !important;
  object-fit: contain;
}

/* Sem src, o fallback textual aparece sem ícone de imagem vazia. */
body.subpage .subpage-brand .brand-art:not([src]),
body.subpage .subpage-brand .brand-art[src=""] {
  visibility: hidden !important;
}

/* Quando o carregamento for confirmado, deixa somente o GIF. */
body.subpage .subpage-brand.has-brand-art .brand-text {
  visibility: hidden !important;
}

/* Se o carregamento falhar, o texto imAgas segue visível. */
body.subpage .subpage-brand.brand-art-fallback .brand-text {
  visibility: visible !important;
}
/* ===============================================================
   IMAGAS — LOGO DE RETORNO ESTÁVEL (F5 + NAVEGAÇÃO CONTÍNUA)
   COLE ESTE TRECHO NO FINAL DE /paginas.css.

   O GIF passa a ser o FUNDO do link de retorno à Home.
   Não depende mais das classes has-brand-art / brand-art-fallback
   que podem ser alteradas por diferentes scripts em cada rota.

   TROQUE APENAS O ENDEREÇO abaixo se o nome real do GIF mudar.
   =============================================================== */

body.subpage .subpage-topbar a.subpage-brand {
    position: relative !important;
    isolation: isolate;
}

/* Desativa a antiga imagem sem alterar o HTML nem impedir o roteador. */
body.subpage .subpage-topbar a.subpage-brand img.brand-art {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* O GIF fica visível mesmo se o JavaScript trocar classes ou falhar. */
body.subpage .subpage-topbar a.subpage-brand::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    z-index: 2 !important;
    background-image: url("/logo1-ezgif.com-resize%20(1).gif") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: contain !important;
    pointer-events: none !important;
}

/* Segurança: mantém o link textual como reserva, atrás da arte. */
html body.subpage .subpage-topbar a.subpage-brand[href] .brand-text {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    inset: 0 !important;
    z-index: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap;
}
/* IMAGAS — REMOVER TEXTO ATRÁS DO LOGO */

html body.subpage .subpage-topbar
a.subpage-brand[href] .brand-text {
    display: none !important;
    visibility: hidden !important;
}