/* ==========================================================================
   1. VARIÁVEIS / DESIGN TOKENS (Otimizadas para WCAG AAA - Contraste > 7:1)
   ========================================================================== */
:root {
    /* Cores ajustadas para garantir legibilidade extrema em fundo creme */
    --cor-primaria: #b71c1c;     /* Vermelho Cívico Escuro (Passa AAA) */
    --cor-secundaria: #0d47a1;   /* Azul de Destaque Seguro (Passa AAA) */
    --cor-fundo: #F1E9D2;
    --cor-fundo-alt: #e8dcc5;    /* Fundo subtil para alternar secções */
    --cor-texto: #1a1a1a;        /* Quase preto para máximo contraste */
    --cor-links: #0b4596;
    
    /* Tipografia Fluida (Modern CSS clamp - adapta-se sem Media Queries) */
    --fonte-principal: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --tam-h1: clamp(1.75rem, 4vw, 2.5rem);
    --tam-h2: clamp(1.4rem, 3vw, 2rem);
    --tam-h3: 1.25rem;
    --tam-corpo: 1rem;

    /* Espaçamentos usando propriedades lógicas */
    --espacamento-base: 1rem;
    --espacamento-bloco: clamp(2rem, 5vw, 4rem);
}

/* ==========================================================================
   2. MODERN CSS RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-family: var(--fonte-principal);
    color: var(--cor-texto);
    background-color: var(--cor-fundo);
    font-size: 100%; /* 16px por defeito, garantindo que o REM respeita o utilizador */
    line-height: 1.6; /* WCAG AAA exige espaçamento de linha de pelo menos 1.5 */
    color-scheme: light;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Evitar foco feio mas manter acessibilidade nativa */
main:focus {
    outline: none;
}

/* ==========================================================================
   3. ACESSIBILIDADE CRÍTICA (a11y)
   ========================================================================== */
/* Skip Link Invisível que aparece ao navegar via Tab */
.skip-link {
    position: absolute;
    top: -10rem;
    left: 1rem;
    background-color: var(--cor-primaria);
    color: var(--cor-fundo);
    padding: var(--espacamento-base);
    font-weight: bold;
    text-decoration: none;
    z-index: 9999;
    border-radius: 0 0 0.25rem 0.25rem;
    transition: transform 0.2s ease-in-out;
}

.skip-link:focus-visible {
    transform: translateY(10rem);
}

/* Indicador de foco global super visível para navegação por teclado */
*:focus-visible {
    outline: 0.25rem solid var(--cor-secundaria);
    outline-offset: 0.25rem;
}

/* ==========================================================================
   4. TIPOGRAFIA E LINKS
   ========================================================================== */
h1, h2, h3 {
    line-height: 1.2;
    color: var(--cor-texto);
    font-weight: 800;
}

h1 { font-size: var(--tam-h1); }
h2 { font-size: var(--tam-h2); }
h3 { font-size: var(--tam-h3); }

/* Estilo de links gerais do corpo de texto */
a {
    color: var(--cor-links);
    text-decoration: underline;
    text-underline-offset: 0.2rem;
    text-decoration-thickness: 0.0625rem;
    transition: color 0.2s ease, text-decoration-thickness 0.2s ease;
}

a:hover, a:active {
    color: var(--cor-primaria);
    text-decoration-thickness: 0.125rem;
}

/* ==========================================================================
   5. ESTRUTURA DE LAYOUT (Mobile-First / Propriedades Lógicas)
   ========================================================================== */
header, main, footer {
    width: 100%;
    max-width: 75rem; /* 1200px em REM */
    margin-inline: auto;
    padding-inline: var(--espacamento-base);
}

/* Cabeçalho */
header {
    padding-block: var(--espacamento-base);
    display: flex;
    flex-direction: column;
    gap: var(--espacamento-base);
    border-bottom: 0.0625rem solid #e0e0e0;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

/* Navegações (Header e Footer) */
nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

nav a {
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 0;
    display: inline-block;
}

nav a:hover {
    color: var(--cor-primaria);
    text-decoration: underline;
}

/* Conteúdo Principal e Secções */
main {
    flex: 1;
    padding-block: var(--espacamento-base);
}

/* Organização vertical limpa para as secções */
main section {
    padding-block: var(--espacamento-bloco);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Alternância subtil de fundos para quebrar a monotonia visual */
main section:nth-child(even) {
    background-color: var(--cor-fundo-alt);
    margin-inline: calc(var(--espacamento-base) * -1);
    padding-inline: var(--espacamento-base);
}

address {
    font-style: normal;
}

/* Rodapé */
footer {
    padding-block: calc(var(--espacamento-bloco) * 0.75);
    border-top: 0.0625rem solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.footer-brand a {
    color: var(--cor-texto);
    text-decoration: none;
    font-size: var(--tam-h3);
}

footer h3 {
    margin-top: 0.5rem;
}

/* Lista de Redes Sociais em Grid Flexível */
footer h3 + ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

footer h3 + ul a {
    background-color: var(--cor-fundo-alt);
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    text-decoration: none;
    font-weight: 500;
}

footer h3 + ul a:hover {
    background-color: var(--cor-primaria);
    color: var(--cor-fundo);
}

/* ==========================================================================
   6. RESPONSIVIDADE (Media Queries para Ecrãs Médios/Grandes)
   ========================================================================== */
@media (min-width: 48rem) { /* 768px */
    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    header h1 {
        max-width: 60%;
    }
    
    nav ul {
        justify-content: flex-end;
    }
}