:root {
    --card-bg: #ffffff;
    --muted: #6c757d;
    --page-bg: #f6f7f9
}

#matrix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    z-index: -1; /* push canvas behind */
}

.matrix-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0; /* Keep overlay below headers/nav and content */
}

.noticias-container {
    max-width: 1100px;
    margin: 150px auto;
    padding: 32px 24px;
    position: relative;
    z-index: 2;
    background-color: var(--cararra);
    border-color: rgba(28, 44, 60);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}


/* Header */
.noticias-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap; /* allow wrapping on small widths */
    row-gap: 8px;
}

.noticias-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* Header */
.noticias-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap; /* allow wrapping on small widths */
    row-gap: 8px;
}

.noticias-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* Header */
.noticias-header-er {
    display: block;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap; /* allow wrapping on small widths */
    row-gap: 8px;
}

.noticias-header-er h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}
/* Underline effect */
.noticias-header h1::after {
    content: "";
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg,
    var(--macaroni-and-cheese),
    var(--pomegranate));
    border-radius: 2px;
    margin-top: 8px;
}

/* Updated: style the source container with logo */
.noticias-source {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--mirage);
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
    margin-left: auto; /* keep it to the right when wrapping */
}

.noticias-source-logo {
    height: 1.2em; /* scales with text */
    width: auto;
    max-height: 32px;
    aspect-ratio: auto;
}

@media (max-width: 640px) {
    .noticias-header h1 {
        font-size: 1.2rem;
        margin-bottom: 8px; /* reduzir espaço para caber melhor */
    }
    .noticias-source {
        font-size: 0.9rem;
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
    }
    .noticias-source-logo {
        max-height: 22px;
    }
}

/* Notice / errors */
.noticias-notice {
    padding: 14px 16px;
    background: #fff;
    border-left: 4px solid var(--pomegranate);
    border-radius: 8px;
    margin-bottom: 18px;
    color: var(--mirage);
    box-shadow: 0 6px 18px rgba(22, 32, 43, 0.04)
}

.noticias-notice a {
    color: var(--mirage);
    text-decoration: underline
}

.noticias-error {
    color: var(--pomegranate)
}

/* Grid */
.noticias-grid {
    display: grid;
    grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px
}

.noticias-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(22, 32, 43, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease;
    border: 1.2px solid var(--mirage);
}

.noticias-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(22, 32, 43, 0.09)
}

.noticias-thumb {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: #e9eef3
}

.noticias-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px
}

.noticias-card h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--mirage);
    font-weight: 600
}

.noticias-card p.noticias-date {
    margin: 0;
    margin-top: auto;
    color: var(--muted);
    font-size: 0.92rem
}

/* Links */
.noticias-card a {
    color: inherit;
    text-decoration: none
}

.noticias-card h3 a {
    color: var(--mirage);
    display: inline-block;
    transition: color .12s ease
}

.noticias-card:hover h3 a {
    color: var(--pomegranate)
}

/* Fallback image block */
.noticias-no-thumb {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa4ad;
    font-size: 0.95rem
}

/* Responsive tweaks */
@media (max-width: 640px) {
    .noticias-container {
        /* Em mobile a navbar é fixa — garantir margem superior suficiente
           para que o header das notícias não fique por baixo da navbar. */
        margin: 180px auto !important; /* aumentado e forçado */
        padding: 20px 16px;
        border-radius: 12px;
    }

    .noticias-header h1 {
        font-size: 1.2rem;
        margin-bottom: 8px; /* reduzir espaço para caber melhor */
    }

    .noticias-thumb {
        height: 140px
    }

    /* garantir que título e fonte estão visíveis e permitem wrap */
    .noticias-source {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
    }
}

/* Small utility */
.noticias-external {
    color: var(--mirage);
    text-decoration: underline
}

/* Make sure nav and footer (if inserted) don't collide */
body > header, body > nav {
    position: relative;
    z-index: 5
}

/* Improve accessibility focus */
.noticias-card h3 a:focus {
    outline: 3px solid rgba(192, 57, 43, 0.14);
    outline-offset: 3px;
    border-radius: 4px
}

/* Prevent horizontal overflow on this page */
html, body {
    overflow-x: hidden;
}
