/* =========================================
   RESET E VARIÁVEIS GERAIS
   ========================================= */
:root {
    /* Cores de Fundo */
    --bg-body: #FAF9F6;

    /* Tipografia */
    --font-ui-serif: 'IM Fell Great Primer', serif;
    --font-mono: 'Special Elite', cursive;
    --font-hand: 'Reenie Beanie', cursive;

    /* Cores de Texto Básicas */
    --text-primary: #1F2937;
    --text-secondary: #57534E;
    --text-divider: #E5E7EB;

    /* Cor da Tinta da Caneta */
    --ink-pen-blue: #1a237e;

    /* TEXTURA DE PAPEL */
    --paper-texture: url('../img/noise.png');
    /* Adjusted path since css is in assets/css/ and noise is in root? No, specs say assets/img usually, but let's check where noise.png is */

    /* ==========================================================================
       QUÍMICA DA TINTA (DEEP INKS)
       ========================================================================== */

    --color-pl: var(--text-primary);
    --color-plo: #951D36;
    --color-pdl: #001C3D;
    --color-pr: #1A4122;

    /* GRADIENTES CROMÁTICOS */
    --bg-pl-start: #efe1cd;
    --bg-pl-end: #EFE6CD;
    --bg-plo-start: #e5c8cf;
    --bg-plo-end: #e5c8d6;
    --bg-pdl-start: #c5cde3;
    --bg-pdl-end: #c5d5e3;
    --bg-pr-start: #cfe3c5;
    --bg-pr-end: #c5e3c7;

    /* CORES DE GRIFO */
    --hl-1-start: #fde047;
    --hl-1-end: #facc15;
    --hl-1-sub: #fef9c3;
    --hl-2-start: #67e8f9;
    --hl-2-end: #22d3ee;
    --hl-2-sub: #cffafe;
    --hl-3-start: #f0abfc;
    --hl-3-end: #e879f9;
    --hl-3-sub: #f5d0fe;
    --hl-4-start: #86efac;
    --hl-4-end: #4ade80;
    --hl-4-sub: #d1fae5;
    --hl-5-start: #fdba74;
    --hl-5-end: #fb923c;
    --hl-5-sub: #ffedd5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

::selection {
    background: rgba(87, 83, 78, 0.2);
    color: inherit;
}

body {
    background-color: var(--bg-body);
    font-family: var(--font-mono);
    padding: 15px 20px;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* TEXTURA NO BODY */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--paper-texture);
    opacity: 0.05;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: -1;
}

/* =========================================
   CONTAINER PRINCIPAL
   ========================================= */
.main-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 40px;
}

/* =========================================
   CABEÇALHO DE BUSCA
   ========================================= */
.search-header {
    margin-bottom: 0;
}

.author-message {
    font-family: var(--font-ui-serif);
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: right;
    margin-bottom: 12px;
}

/* SEARCH-BOX: Vinculada ao estilo do card PL */
.search-box {
    background: linear-gradient(135deg, var(--bg-pl-start), var(--bg-pl-end));
    padding: 16px 20px;
    border-radius: 2px;
    margin-bottom: 9px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transform: rotate(-0.3deg);
    /* Sombras em camadas (mesmo padrão dos cards) */
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 4px 8px rgba(0, 0, 0, 0.03),
        0 12px 24px rgba(0, 0, 0, 0.02);
}

/* Textura de papel na search-box */
.search-box::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--paper-texture);
    opacity: 0.04;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

.search-box>* {
    position: relative;
    z-index: 1;
}

.search-input-wrapper {
    position: relative;
}

.input-container {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 5px 10px;
    padding-bottom: 8px;
    font-size: 2.2rem;
    border: none;
    border-radius: 0;
    background-color: transparent;
    /* Estilo manuscrito */
    font-family: var(--font-hand);
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink-pen-blue);
    mix-blend-mode: multiply;
    opacity: 0.95;
    transform: rotate(-0.5deg);
    caret-color: var(--ink-pen-blue);
}

.search-input::placeholder {
    font-family: var(--font-hand);
    font-size: 2.2rem;
    color: var(--ink-pen-blue);
    opacity: 1;
}

.search-input:focus {
    outline: none;
}

.search-input:focus::placeholder {
    opacity: 0;
}

.search-input:not(:placeholder-shown) {
    text-shadow: 0 0 6px rgba(26, 35, 126, 0.12);
}

/* Botão limpar */
.clear-btn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0;
    background-color: transparent;
    border: none;
    color: rgba(87, 83, 78, 0.5);
    cursor: pointer;
    transition: color 0.2s ease, opacity 0.2s ease;
    letter-spacing: 0.15em;
    font-weight: 400;
    position: absolute;
    right: 0;
    bottom: 1px;
    mix-blend-mode: multiply;
    opacity: 0;
    pointer-events: none;
}

.search-input:not(:placeholder-shown)~.clear-btn {
    opacity: 1;
    pointer-events: auto;
}

.clear-btn::after {
    content: '';
    position: absolute;
    height: 1px;
    bottom: -1px;
    right: 0;
    left: 0;
    transform: scaleX(0);
    background-color: #951D36;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: right;
}

.clear-btn:hover {
    color: #951D36;
}

.clear-btn:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Log de resultados */
.results-log {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #27272A;
    padding: 5px 0;
    letter-spacing: 0.15em;
    line-height: 1.6;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    text-transform: uppercase;
}

.results-log strong {
    font-weight: 600;
}

.results-count strong {
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

/* =========================================
   ESTRUTURA DO CARD
   ========================================= */
.card {
    background: linear-gradient(135deg, var(--bg-pl-start), var(--bg-pl-end));
    border-radius: 2px 5px 2px 3px;
    padding: 16px 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 4px 8px rgba(0, 0, 0, 0.03),
        0 12px 24px rgba(0, 0, 0, 0.02);
    -webkit-font-smoothing: subpixel-antialiased;
    backface-visibility: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--paper-texture);
    opacity: 0.04;
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

.card>* {
    position: relative;
    z-index: 1;
}

.card:hover {
    transform: translateY(-4px) rotate(var(--card-rotation, 0deg));
    border-color: rgba(0, 0, 0, 0.1);
    z-index: 10;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.06),
        0 12px 24px rgba(0, 0, 0, 0.04),
        0 32px 64px rgba(0, 0, 0, 0.03);
}

/* ESTILOS POR TIPO */

/* PLO */
.card[data-type="PLO"] {
    background: linear-gradient(135deg, var(--bg-plo-start), var(--bg-plo-end));
    box-shadow: 0 1px 2px rgba(149, 29, 54, 0.08), 0 4px 8px rgba(149, 29, 54, 0.04), 0 12px 24px rgba(149, 29, 54, 0.02);
}

.card[data-type="PLO"]:hover {
    box-shadow: 0 4px 8px rgba(149, 29, 54, 0.08), 0 12px 24px rgba(149, 29, 54, 0.04), 0 32px 64px rgba(149, 29, 54, 0.02);
}

.card[data-type="PLO"] .id-type {
    color: var(--color-plo);
    mix-blend-mode: multiply;
}

.card[data-type="PLO"] .action-btn:hover {
    color: var(--color-plo);
}

/* PDL */
.card[data-type="PDL"] {
    background: linear-gradient(135deg, var(--bg-pdl-start), var(--bg-pdl-end));
    box-shadow: 0 1px 2px rgba(0, 28, 61, 0.08), 0 4px 8px rgba(0, 28, 61, 0.04), 0 12px 24px rgba(0, 28, 61, 0.02);
}

.card[data-type="PDL"]:hover {
    box-shadow: 0 4px 8px rgba(0, 28, 61, 0.08), 0 12px 24px rgba(0, 28, 61, 0.04), 0 32px 64px rgba(0, 28, 61, 0.02);
}

.card[data-type="PDL"] .id-type {
    color: var(--color-pdl);
    mix-blend-mode: multiply;
}

.card[data-type="PDL"] .action-btn:hover {
    color: var(--color-pdl);
}

/* PR */
.card[data-type="PR"] {
    background: linear-gradient(135deg, var(--bg-pr-start), var(--bg-pr-end));
    box-shadow: 0 1px 2px rgba(26, 65, 34, 0.08), 0 4px 8px rgba(26, 65, 34, 0.04), 0 12px 24px rgba(26, 65, 34, 0.02);
}

.card[data-type="PR"]:hover {
    box-shadow: 0 4px 8px rgba(26, 65, 34, 0.08), 0 12px 24px rgba(26, 65, 34, 0.04), 0 32px 64px rgba(26, 65, 34, 0.02);
}

.card[data-type="PR"] .id-type {
    color: var(--color-pr);
    mix-blend-mode: multiply;
}

.card[data-type="PR"] .action-btn:hover {
    color: var(--color-pr);
}

/* PL */
.card[data-type="PL"] .id-type {
    color: var(--color-pl);
    mix-blend-mode: multiply;
}

.card[data-type="PL"] .action-btn:hover {
    color: var(--text-secondary);
}

/* =========================================
   CABEÇALHO DO CARD
   ========================================= */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.project-id {
    display: flex;
    align-items: baseline;
    gap: 4px;
    line-height: 1;
}

.id-type {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.id-number {
    font-family: var(--font-hand);
    font-weight: 600;
    font-size: 2.5rem;
    line-height: 0.8;
    margin: 0 4px;
    color: var(--ink-pen-blue) !important;
    mix-blend-mode: multiply;
    opacity: 0.9;
    position: relative;
    top: 4px;
}

.id-slash {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--text-secondary);
    mix-blend-mode: multiply;
}

.id-year {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    mix-blend-mode: multiply;
}

/* =========================================
   BOTÕES DE TEXTO
   ========================================= */
.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    transition: color 0.2s ease;
    mix-blend-mode: multiply;
    position: relative;
    text-decoration: none;
}

.action-btn::after {
    content: '';
    position: absolute;
    width: 0%;
    height: 1px;
    bottom: -2px;
    right: 0;
    background-color: currentColor;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.action-btn:hover::after {
    width: 100%;
}

.separator-pipe {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 400;
    user-select: none;
    mix-blend-mode: multiply;
}

/* =========================================
   CORPO E METADADOS
   ========================================= */
.card-body {
    margin-bottom: 16px;
}

.ementa {
    font-family: var(--font-ui-serif);
    font-weight: 400;
    font-size: 1.25rem;
    line-height: 1.45;
    color: var(--text-primary);
    white-space: normal;
    text-align: left;
    mix-blend-mode: multiply;
    opacity: 0.95;
}

.card-footer {
    padding-top: 12px;
    border-top: 1px solid var(--text-secondary);
    mix-blend-mode: multiply;
}

.meta-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    mix-blend-mode: multiply;
}

.authors-list {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-end;
    text-align: right;
}

.author-item {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    align-items: flex-end;
}

.author-name {
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-primary);
}

.author-party {
    font-weight: 400;
    font-size: 0.7rem;
    opacity: 0.8;
    letter-spacing: 0.15em;
    margin-top: 2px;
}

.keywords {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    display: flex;
    flex-wrap: wrap;
    column-gap: 12px;
    row-gap: 2px;
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    max-width: 100%;
    font-size: 0.65rem;
}

.keyword-chip {
    display: inline-block;
    color: var(--text-secondary);
    font-weight: 400;
    mix-blend-mode: multiply;
    line-height: 1.15;
}

.keyword-chip [class*="hl-"] {
    padding: 0 1px;
}

/* =========================================
   ESTILOS DE GRIFO
   ========================================= */
[class*="-full"],
[class*="-sub"] {
    font-weight: 600;
    color: inherit;
    padding: 0 2px;
    border-radius: 0;
    mix-blend-mode: multiply;

    background-repeat: no-repeat;
    background-position: 0 88%;

    --hl-height: 45%;
    background-size: 100% var(--hl-height);

    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.hl-1-full {
    background-image: linear-gradient(100deg, var(--hl-1-start), var(--hl-1-end));
}

.hl-1-sub {
    background-image: linear-gradient(to right, var(--hl-1-sub), var(--hl-1-sub));
}

.hl-2-full {
    background-image: linear-gradient(100deg, var(--hl-2-start), var(--hl-2-end));
}

.hl-2-sub {
    background-image: linear-gradient(to right, var(--hl-2-sub), var(--hl-2-sub));
}

.hl-3-full {
    background-image: linear-gradient(100deg, var(--hl-3-start), var(--hl-3-end));
}

.hl-3-sub {
    background-image: linear-gradient(to right, var(--hl-3-sub), var(--hl-3-sub));
}

.hl-4-full {
    background-image: linear-gradient(100deg, var(--hl-4-start), var(--hl-4-end));
}

.hl-4-sub {
    background-image: linear-gradient(to right, var(--hl-4-sub), var(--hl-4-sub));
}

.hl-5-full {
    background-image: linear-gradient(100deg, var(--hl-5-start), var(--hl-5-end));
}

.hl-5-sub {
    background-image: linear-gradient(to right, var(--hl-5-sub), var(--hl-5-sub));
}

/* =========================================
   RESPONSIVIDADE
   ========================================= */
@media (max-width: 768px) {
    body {
        padding: 10px 15px;
    }

    .search-box {
        padding: 12px 15px;
    }

    .search-input {
        font-size: 1.8rem;
    }

    .search-input::placeholder {
        font-size: 1.8rem;
    }

    .clear-btn {
        font-size: 0.85rem;
    }

    .results-log {
        flex-direction: column;
        gap: 4px;
        font-size: 12px;
    }

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

    .author-message {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .search-input {
        font-size: 1.5rem;
    }

    .search-input::placeholder {
        font-size: 1.5rem;
    }

    .results-log {
        font-size: 11px;
    }

    /* Ajustes Mobile para Norma e Carimbo */
    .norma-wrapper {
        padding-left: 0;
        margin-top: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stamp-approved {
        position: relative;
        left: 0;
        top: 0;
        transform: rotate(-2deg);
        font-size: 1.4rem;
        margin-bottom: 5px;
        display: inline-block;
        /* Garante que o box respeite o tamanho */
    }

    .norma-number {
        font-size: 1.8rem;
        margin-left: 5px;
    }

    .norma-links {
        margin-left: 0;
    }
}

/* =========================================
   NOVOS ELEMENTOS: STATUS NORMAL E CARIMBO
   ========================================= */

/* LINHA DA NORMA (Wrapper Principal) */
.norma-wrapper {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 00px;
    padding-left: 150px;
    /* Espaço maior para o carimbo estendido */
    margin-top: -18px;
    position: relative;
    min-height: 40px;
}

/* 1. CARIMBO "APROVADO" */
.stamp-approved {
    position: absolute;
    left: -15px;
    top: -15px;
    /* Invade bem a linha de cima */

    font-family: var(--font-mono);
    /* Special Elite */
    font-size: 2.2rem;
    /* Bem maior */
    font-weight: 700;
    /* Bold */
    /* font-style removed */

    color: #d64045;
    /* Vermelho mais desbotado/rosado */
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 2px 15px;


    /* Borda fina dupla (estilo da imagem) */
    /* border: 3px double #d64045;
    border-radius: 2px 5px 1px 3px; */

    /* Rotação e mixagem */
    transform: rotate(-6deg);
    mix-blend-mode: multiply;
    opacity: 0.8;
    pointer-events: none;
    z-index: 5;

    /* TEXTURA INTERNA (Estilo Stencil/Falhado) */
    /* Máscara de ruído para "corroer" a tinta */
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.6'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.6'/%3E%3C/svg%3E");
}

/* 2. NÚMERO DA NORMA */
.norma-number {
    font-family: var(--font-hand);
    font-size: 2.2rem;
    color: var(--ink-pen-blue);
    font-weight: 600;
    line-height: 0.8;
    mix-blend-mode: multiply;
    transform: rotate(-1deg);
}

/* 3. BOTÕES DA NORMA */
.norma-links {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
}

.norma-links .action-btn {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* Ajuste de espaçamento do card quando tem norma */
.card:has(.norma-wrapper) .card-header {
    margin-bottom: 24px;
}

/* =========================================
   CAMPO DE INFORMAÇÕES (HELP)
   ========================================= */

.info-field {
    background: var(--paper-cream);
    border: 1px solid var(--border-warm);
    border-radius: 2px;
    padding: 24px 28px;
    margin: 16px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
    box-shadow:
        0 1px 2px rgba(60, 50, 40, 0.06),
        0 2px 4px rgba(60, 50, 40, 0.04);
}

.info-section {
    margin-bottom: 20px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.info-field p {
    margin: 6px 0;
}

.info-field ul {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.info-field li {
    margin: 4px 0;
}

.info-field code {
    background: rgba(60, 50, 40, 0.06);
    padding: 2px 6px;
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* =========================================
   BOTÃO CARREGAR MAIS
   ========================================= */

.load-more-btn {
    display: block;
    width: 100%;
    padding: 16px;
    margin: 24px 0;
    background: transparent;
    border: 1px dashed var(--border-warm);
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-more-btn:hover {
    background: rgba(60, 50, 40, 0.03);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.load-more-btn:active {
    transform: translateY(1px);
}

/* =========================================
   BOTÃO RECARREGAR (ERRO)
   ========================================= */

.reload-btn {
    display: inline-block;
    margin-left: 12px;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border-warm);
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.reload-btn:hover {
    background: rgba(60, 50, 40, 0.05);
    color: var(--text-primary);
}

/* =========================================
   HIGHLIGHT CINZA (PARA TERMOS EXTRAS)
   ========================================= */

.hl-gray-full {
    background: linear-gradient(102deg,
            transparent 0%,
            rgba(120, 120, 120, 0.25) 3%,
            rgba(120, 120, 120, 0.30) 50%,
            rgba(120, 120, 120, 0.25) 97%,
            transparent 100%);
    background-size: 100% var(--hl-height, 50%);
    background-position: 0 95%;
    background-repeat: no-repeat;
    padding: 0 2px;
    margin: 0 -2px;
    border-radius: 1px;
}