/**
 * SISTEMA DE TIPOGRAFIA ACESSÍVEL
 * Padronização de tamanhos de fonte para melhor acessibilidade
 * Baseado em boas práticas WCAG 2.1 e design responsivo
 * 
 * Princípios:
 * - Tamanho base: 16px (1rem)
 * - Escala harmônica para leitura melhorada
 * - Suporte a zoom do navegador até 200%
 * - Contraste mínimo de 4.5:1 para texto pequeno
 * - Altura de linha mínima de 1.5 para corpo de texto
 */

:root {
    /* ===== ESCALA DE TAMANHOS BASE ===== */
    /* Seguindo escala modular 1.125 (9:8 ratio) */
    --font-size-xs: 0.75rem;      /* 12px - Ajudas, captions */
    --font-size-sm: 0.875rem;     /* 14px - Textos menores, descrições */
    --font-size-base: 1rem;       /* 16px - Texto padrão */
    --font-size-lg: 1.125rem;     /* 18px - Corpo de texto confortável */
    --font-size-xl: 1.25rem;      /* 20px - Subtítulos */
    --font-size-2xl: 1.5rem;      /* 24px - Subtítulos maiores */
    --font-size-3xl: 1.875rem;    /* 30px - Títulos pequenos */
    --font-size-4xl: 2.25rem;     /* 36px - Títulos */
    --font-size-5xl: 3rem;        /* 48px - Títulos grandes */
    
    /* ===== ALTURA DE LINHA ===== */
    --line-height-tight: 1.25;    /* Títulos */
    --line-height-normal: 1.5;    /* Padrão para acessibilidade */
    --line-height-relaxed: 1.75;  /* Corpo de texto longo */
    --line-height-loose: 2;       /* Texto com muita densidade */
    
    /* ===== ESPAÇAMENTO DE LETRAS ===== */
    --letter-spacing-tight: -0.02em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.03em;
    
    /* ===== PESOS DE FONTE ===== */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;
    
    /* ===== FAMÍLIA DE FONTES ===== */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji';
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-mono: 'Monaco', 'Courier New', monospace;
}

/* ===== ESTILOS GLOBAIS ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Permite zoom até 200% sem problemas */
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: #1a1a1a;
    background-color: #ffffff;
    
    /* Permitir aumento de zoom */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    
    /* Anti-aliasing para melhor render */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== ESCALA DE TÍTULOS ===== */
h1 {
    font-size: var(--font-size-4xl);    /* 36px */
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    margin: 0.5em 0;
    letter-spacing: var(--letter-spacing-tight);
}

h2 {
    font-size: var(--font-size-3xl);    /* 30px */
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    margin: 0.67em 0;
    letter-spacing: var(--letter-spacing-tight);
}

h3 {
    font-size: var(--font-size-2xl);    /* 24px */
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-normal);
    margin: 0.83em 0;
}

h4 {
    font-size: var(--font-size-xl);     /* 20px */
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-normal);
    margin: 1em 0;
}

h5 {
    font-size: var(--font-size-lg);     /* 18px */
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-normal);
    margin: 1.17em 0;
}

h6 {
    font-size: var(--font-size-base);   /* 16px */
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-normal);
    margin: 1.33em 0;
}

/* ===== PARÁGRAFO E TEXTO DE CORPO ===== */
p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    margin-bottom: 1em;
}

/* Texto longo - aumentar altura de linha para melhor legibilidade */
article p,
main p,
.content p {
    font-size: var(--font-size-lg);     /* 18px para melhor leitura */
    line-height: var(--line-height-relaxed);
}

/* ===== ELEMENTOS ESPECIAIS ===== */
small,
.small,
.text-sm {
    font-size: var(--font-size-sm);     /* 14px */
    line-height: var(--line-height-normal);
}

/* Muito pequeno - apenas para labels ou informações secundárias */
.text-xs {
    font-size: var(--font-size-xs);     /* 12px */
    line-height: 1.5;
}

strong,
b {
    font-weight: var(--font-weight-bold);
}

em,
i {
    font-style: italic;
}

/* ===== LISTAS ===== */
ul, ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

li {
    margin-bottom: 0.5em;
    line-height: var(--line-height-normal);
}

/* ===== LINKS ===== */
a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

a:hover {
    opacity: 0.8;
}

a:focus-visible {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

/* ===== BOTÕES ===== */
button,
.button {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-normal);
    min-height: 44px;  /* WCAG 2.5 - Tamanho mínimo para toque */
    padding: 0.625em 1em;
}

/* ===== INPUTS E FORMULÁRIOS ===== */
input,
select,
textarea {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    min-height: 44px;  /* WCAG 2.5 - Tamanho mínimo para toque */
}

textarea {
    line-height: var(--line-height-relaxed);
}

label {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-normal);
    display: block;
    margin-bottom: 0.25em;
}

/* ===== CABEÇALHOS E RODAPÉS ===== */
header,
footer {
    font-size: var(--font-size-sm);
}

header h1,
header h2 {
    font-size: var(--font-size-2xl);
}

/* ===== NAVS E MENUS ===== */
nav a,
.nav-item {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
}

/* ===== BLOCKQUOTES ===== */
blockquote {
    font-size: var(--font-size-lg);
    font-style: italic;
    line-height: var(--line-height-relaxed);
    margin: 1em 0;
    padding: 0 1em;
    border-left: 4px solid currentColor;
}

/* ===== CÓDIGO ===== */
code,
pre {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-tight);
    background: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
}

pre {
    padding: 1em;
    overflow-x: auto;
}

/* ===== TABELAS ===== */
table {
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
}

th,
td {
    padding: 0.75em;
}

th {
    font-weight: var(--font-weight-bold);
    text-align: left;
}

/* ===== MEDIA QUERIES RESPONSIVO ===== */

/* Dispositivos pequenos (mobile) */
@media (max-width: 480px) {
    h1 {
        font-size: var(--font-size-2xl);    /* 24px */
    }
    
    h2 {
        font-size: var(--font-size-xl);     /* 20px */
    }
    
    h3 {
        font-size: var(--font-size-lg);     /* 18px */
    }
    
    h4 {
        font-size: var(--font-size-base);   /* 16px */
    }
    
    p {
        font-size: var(--font-size-base);
    }
    
    article p,
    main p,
    .content p {
        font-size: var(--font-size-base);
    }
}

/* Tablet e além */
@media (min-width: 768px) {
    body {
        font-size: var(--font-size-lg);     /* 18px */
    }
}

/* ===== PREFERÊNCIAS DO USUÁRIO ===== */

/* Respeitar preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Respeitar preferência de alto contraste */
@media (prefers-contrast: more) {
    body {
        color: #000000;
        background-color: #ffffff;
    }
    
    a {
        color: #0000ee;
        text-decoration-thickness: 3px;
    }
}

/* Respeitar preferência de tema escuro */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #ffffff;
    }
    
    a {
        color: #66b3ff;
    }
    
    code,
    pre {
        background: #2d2d2d;
        color: #e8e8e8;
    }
}

/* ===== UTILITÁRIOS ===== */

.text-center {
    text-align: center;
}

.text-justify {
    text-align: justify;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.font-light {
    font-weight: var(--font-weight-light);
}

.font-normal {
    font-weight: var(--font-weight-normal);
}

.font-semibold {
    font-weight: var(--font-weight-semibold);
}

.font-bold {
    font-weight: var(--font-weight-bold);
}

.font-extrabold {
    font-weight: var(--font-weight-extrabold);
}

.italic {
    font-style: italic;
}

.not-italic {
    font-style: normal;
}

/* Classe para ocultar visualmente mas manter para leitores de tela */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip link para acessibilidade */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
    border-radius: 0 0 5px 0;
    font-weight: var(--font-weight-bold);
}

.skip-link:focus {
    top: 0;
}
