/* Elementos HTML sem classe: tipografia, links, formulários, tabelas e botões.
   Tudo aqui usa só tokens (tokens.css); componentes e utilitárias vêm por cima. */
@layer base {
    * { box-sizing: border-box; }
    html { color-scheme: dark; }

    body {
        margin: 0;
        min-height: 100vh;
        background: var(--bg);
        color: var(--text);
        font-family: var(--font-body);
        font-size: var(--text-md);
        /* Proteção global: nomes técnicos longos (variáveis de ambiente, hashes, URLs) quebram
           quando não cabem, em vez de empurrar a página pra fora da tela com texto grande. */
        overflow-wrap: break-word;
    }

    h1, h2, h3 {
        font-family: var(--font-display); color: var(--text); letter-spacing: -0.01em;
        margin: 0 0 var(--space-1); overflow-wrap: anywhere; hyphens: auto;
    }
    h1 { font-size: var(--text-xl); font-weight: 600; }
    h2 { font-size: var(--text-lg); font-weight: 600; }
    h3 { font-size: var(--text-md); font-weight: 600; }
    strong { color: var(--text); }

    a { color: var(--link); text-decoration: none; }
    /* Links "soltos" no conteúdo (sem classe de componente) ganham sublinhado discreto, pra
       serem reconhecíveis sem depender da cor da marca. Componentes (<a class="nav-link">,
       cards, linhas de tabela) cuidam do próprio estilo. */
    a:not([class]) { text-decoration: underline; text-decoration-color: var(--link-underline); text-underline-offset: 3px; }
    a:hover { color: var(--text); }
    a:not([class]):hover { text-decoration-color: currentColor; }

    /* Anel de foco único (--focus-ring) pra link, aba, botão, summary e campo. */
    :focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
    a:focus-visible, [role="tab"]:focus-visible, summary:focus-visible { border-radius: var(--radius-sm); }

    ::selection { background: rgba(150, 248, 3, 0.25); color: var(--text); }
    code { font-family: var(--font-mono); overflow-wrap: anywhere; }

    /* ---------- Tabelas ---------- */
    table { width: 100%; border-collapse: collapse; }
    th, td { text-align: left; padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--line); font-size: var(--text-base); }
    th { color: var(--text-faint); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
    tbody tr:hover td { background: var(--accent-hover); }

    /* ---------- Formulários ---------- */
    label { display: block; margin-bottom: var(--space-2); color: var(--text-dim); font-size: var(--text-sm); font-weight: 500; }
    input[type=text], input[type=email], input[type=password], input[type=url], input[type=search],
    input[type=tel], input[type=date], input[type=number], select, textarea {
        width: 100%; padding: var(--space-3); margin-bottom: var(--space-4); background: var(--panel-solid);
        border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text);
        font-family: inherit; font-size: var(--text-base);
    }
    input::placeholder, textarea::placeholder { color: var(--text-placeholder); }
    /* Safari/Chrome pintam o ícone do calendário em preto por padrão, invisível no tema escuro. */
    input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.6; }
    textarea { font-family: var(--font-mono); font-size: var(--text-sm); resize: vertical; }
    select:disabled { opacity: 0.7; cursor: not-allowed; }
    /* :focus (não :focus-visible): campo de formulário mostra foco sempre, e o Chromium nem
       sempre marca input[type=date] como focus-visible ao chegar por Tab. O botão do
       calendário fica dentro do campo de data: com ele em foco, o campo só casa com :focus-within. */
    input:focus, select:focus, textarea:focus, input[type=date]:focus-within {
        border-color: var(--brand); outline: var(--focus-ring); outline-offset: 1px;
    }

    /* ---------- Botões ---------- */
    button, .button {
        background: var(--brand); color: var(--brand-ink); border: none;
        padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); font-weight: 600;
        font-size: var(--text-base); cursor: pointer; text-decoration: none; display: inline-block; font-family: inherit;
        box-shadow: none;
    }
    button:hover, .button:hover { filter: brightness(1.08); }

    details summary {
        cursor: pointer; color: var(--text-dim); font-size: var(--text-sm); margin-top: var(--space-1);
        text-decoration: underline; text-decoration-color: var(--link-underline); text-underline-offset: 3px;
    }
}
