/* ==========================================================================
   C4 Científica — Base

   Reset, fundações tipográficas, casca da aplicação e utilitários mínimos.
   Nada aqui é componente: cada componente vive em components/.
   Consome exclusivamente os tokens de tokens.css.
   ========================================================================== */

/* ==========================================================================
   Reset
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html,
body { margin: 0; min-height: 100%; }

body {
    background: var(--color-body);
    color: var(--color-title);
    font-family: var(--font);
    font-size: var(--fs-sm);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button,
input,
select,
textarea { font: inherit; }

button { cursor: pointer; }

svg { flex: none; }

img { max-width: 100%; }

[hidden] { display: none !important; }

h1, h2, h3, h4, p, figure, fieldset { margin: 0; }

fieldset { border: 0; padding: 0; min-width: 0; }

table { border-collapse: collapse; width: 100%; }

/* ==========================================================================
   Ícones

   Lucide, auto-hospedado. Tamanho único via --icon-size; as exceções são
   declaradas no componente que as precisa, nunca na view.
   ========================================================================== */

.ui-icon {
    width: var(--icon-size);
    height: var(--icon-size);
    stroke-width: 1.8;
}

/* ==========================================================================
   Acessibilidade
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link { position: absolute; left: -9999px; z-index: var(--z-skip); }

.skip-link:focus {
    left: var(--space-3); top: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-control);
    background: var(--color-primary-700);
    color: var(--color-text-inverse);
}

/* Foco por teclado do sistema inteiro. Componente que precisa de contorno
   próprio (por recorte ou por fundo escuro) sobrescreve no seu arquivo. */
:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
}

/* ==========================================================================
   Casca da aplicação
   ========================================================================== */

.app {
    display: grid;
    grid-template-columns: var(--container-sidebar) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns var(--transition-layout);
}

.app.is-sidebar-collapsed { grid-template-columns: var(--container-sidebar-collapsed) minmax(0, 1fr); }

.content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-body);
}

/* Âncora de posicionamento para menus flutuantes. */
.popover { position: relative; }

/* ==========================================================================
   Barra de rolagem

   Uma só para o portal inteiro. Antes só o quadro tinha barra desenhada e o
   resto ficava com a do sistema: no mesmo card, rolar a coluna dava uma barra
   fina e discreta e rolar a tabela ao lado dava a barra cinza grossa do
   Windows. Aqui a diferença acaba.

   O `border` transparente com `background-clip: padding-box` é o que afina o
   polegar sem afinar a trilha — trilha estreita demais vira alvo de clique
   impossível de acertar.

   Firefox usa `scrollbar-width`/`scrollbar-color`; o resto usa o pseudo. Os
   dois estão aqui porque nenhum dos dois cobre todos os navegadores sozinho.
   ========================================================================== */

* { scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: var(--radius-full);
    background: var(--color-border-strong);
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover { background-color: var(--color-text-tertiary); }
::-webkit-scrollbar-corner { background: transparent; }

/* A sidebar é escura: o cinza claro do polegar padrão some sobre o teal. */
.sidebar { scrollbar-color: var(--color-side-stroke-strong) transparent; }
.sidebar ::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb { background: var(--color-side-stroke-strong); }

/* ==========================================================================
   Utilitários

   Deliberadamente curtos. Existem porque a CSP proíbe style="" — não são
   um framework de utilitários e não devem crescer para virar um.
   ========================================================================== */

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-5); }

.cluster { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }
.cluster--tight { gap: var(--space-2); flex-wrap: nowrap; }
.cluster--w-md { min-width: 190px; }

.text-muted { color: var(--color-text-secondary); }
.text-faint { color: var(--color-text-tertiary); }
.text-danger { color: var(--color-danger-text); }
.text-success { color: var(--color-success-text); }
.text-warning { color: var(--color-warning-text); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: var(--fs-xs); }
.text-strong { font-weight: var(--fw-semibold); color: var(--color-title); }
.text-relaxed { line-height: var(--lh-base); }
.text-body { line-height: var(--lh-relaxed); color: var(--color-text); }

.nowrap { white-space: nowrap; }
/* Texto digitado pelo usuário: preserva as quebras de linha do original sem
   preservar a indentação do HTML, que `pre` traria junto. */
.text-prewrap { white-space: pre-line; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1 1 0; min-width: 0; }
.is-dimmed { opacity: .55; }

/* Margem vertical pontual, alinhada à escala de espaçamento. */
.margin-top-1 { margin-top: var(--space-1); }
.margin-top-2 { margin-top: var(--space-2); }
.margin-top-3 { margin-top: var(--space-3); }
.margin-top-4 { margin-top: var(--space-4); }
.margin-top-5 { margin-top: var(--space-5); }

/* ==========================================================================
   Documento simples (termos, privacidade)
   ========================================================================== */

.doc {
    max-width: var(--container-prose);
    padding: var(--space-8) var(--gutter) var(--space-12);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.doc h2 {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--color-title);
    margin-top: var(--space-2);
}

.doc p,
.doc li { font-size: var(--fs-sm); line-height: var(--lh-relaxed); color: var(--color-text); }

.doc ul,
.doc ol { margin: 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }

/* ==========================================================================
   Responsivo
   ========================================================================== */

@media (max-width: 900px) {
    :root { --gutter: var(--space-4); }

    .app,
    .app.is-sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
}

@media print {
    .app { grid-template-columns: minmax(0, 1fr); }
}
