/* General Styles */
body {
    font-family: 'Raleway', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: #e4e4e4;
    line-height: 1.6;
}

/* Header - same bar used by the tools pages */
body {
    padding-top: 71px;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 16px 24px;
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.breadcrumb a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9fef00;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    padding: 10px 16px;
    border: 1px solid rgba(159, 239, 0, 0.3);
    border-radius: 8px;
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.breadcrumb a:hover {
    background: rgba(159, 239, 0, 0.1);
    border-color: #9fef00;
    transform: translateX(-5px);
}

.breadcrumb svg {
    width: 18px;
    height: 18px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

/* Language Toggle - links the article to its counterpart */
.language-toggle {
    display: flex;
    gap: 12px;
}

.language-toggle a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.language-toggle a:hover {
    opacity: 1;
    transform: scale(1.1);
}

.language-toggle a.active {
    opacity: 1;
    border-color: #9fef00;
}

.language-toggle svg {
    width: 100%;
    height: 100%;
}

/* Responsive Header */
@media (max-width: 768px) {
    body {
        padding-top: 63px;
    }

    .header {
        padding: 12px 16px;
    }

    .breadcrumb a {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .breadcrumb svg {
        width: 16px;
        height: 16px;
    }
}

/* ==========================================================================
   Layout do artigo

   Todo artigo tem a mesma estrutura: cabeçalho em cima, índice fixo à
   esquerda acompanhando a leitura e o texto numa coluna estreita. Nos
   artigos comuns o índice é montado pelo article-toc.js a partir dos h2.
   ========================================================================== */

.content {
    max-width: min(94%, 1200px);
    margin: 32px auto 60px;
    padding: 32px 40px 48px;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-areas:
        "cabecalho cabecalho"
        "indice    corpo";
    column-gap: 56px;
    background-color: #111;
    border-radius: 20px;
    border: 1px solid #1f1f1f;
}

/* --- Cabeçalho do artigo --- */
.article-header {
    grid-area: cabecalho;
    margin-bottom: 8px;
    padding-bottom: 28px;
    border-bottom: 1px solid #242424;
}

.article-header h1 {
    margin: 0 0 14px;
    font-size: clamp(28px, 3.4vw, 42px);
    line-height: 1.15;
    letter-spacing: -1px;
    color: #fff;
}

.article-header .meta {
    margin: 0;
    font-size: 14px;
    color: #8a8a8a;
}

.article-header .meta a {
    color: #9fef00;
    text-decoration: none;
}

.article-header .meta a:hover {
    text-decoration: underline;
}

.article-header .meta .read-time {
    float: right;
    color: #777;
}

/* --- Índice fixo --- */
html {
    scroll-behavior: smooth;
}

.article-body h2[id],
.article-body h3[id] {
    /* compensa o header fixo ao pular para a âncora */
    scroll-margin-top: 90px;
}

.toc {
    grid-area: indice;
    position: sticky;
    top: 96px;
    align-self: start;
    counter-reset: indice;
    /* índices longos (o roadmap tem 26 itens) rolam por dentro em vez de
       serem cortados pela tela */
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 0 0 0 1px;
    scrollbar-width: thin;
    scrollbar-color: #262626 transparent;
}

.toc::-webkit-scrollbar {
    width: 6px;
}

.toc::-webkit-scrollbar-track {
    background: transparent;
}

.toc::-webkit-scrollbar-thumb {
    background: #262626;
    border-radius: 3px;
}

.toc:hover::-webkit-scrollbar-thumb {
    background: #3a3a3a;
}

.toc::-webkit-scrollbar-thumb:hover {
    background: rgba(159, 239, 0, 0.45);
}

.toc h2 {
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #6f6f6f;
}

.toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc > ul > li {
    counter-increment: indice;
    margin: 0;
}

/* o trilho contínuo à esquerda é o que dá a noção de percurso */
.toc a {
    display: block;
    padding: 7px 0 7px 16px;
    font-size: 14px;
    line-height: 1.45;
    color: #8a8a8a;
    text-decoration: none;
    border-bottom: none;
    border-left: 2px solid #2b2b2b;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.toc > ul > li > a::before {
    content: counter(indice, decimal-leading-zero) '  ';
    font-family: 'Ubuntu Mono', ui-monospace, monospace;
    font-size: 0.9em;
    color: #5f5f5f;
    transition: color 0.2s ease;
}

.toc a:hover {
    color: #ddd;
    border-left-color: #555;
}

/* seção em leitura */
.toc a.active {
    color: #9fef00;
    border-left-color: #9fef00;
}

.toc a.active::before {
    color: #9fef00;
}

/* grupo que contém a subseção em leitura */
.toc a.active-group {
    color: #e4e4e4;
    border-left-color: #5c7a12;
}

.toc ul ul {
    margin: 0 0 6px;
}

.toc ul ul a {
    padding-left: 28px;
    font-size: 13px;
    color: #757575;
}

/* --- Corpo --- */
.article-body {
    grid-area: corpo;
    max-width: 74ch;
    counter-reset: secao;
    font-size: 17px;
    line-height: 1.75;
}

/* Seções: régua e número, sem caixa */
.article-body h2 {
    margin: 76px 0 26px;
    padding-top: 30px;
    font-size: clamp(24px, 2.4vw, 30px);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.6px;
    color: #fff;
    border-top: 1px solid #2b2b2b;
}

.article-body h2[id] {
    counter-increment: secao;
}

/* o mesmo número que aparece no índice, acima do título */
.article-body h2[id]::before {
    content: counter(secao, decimal-leading-zero);
    display: block;
    margin-bottom: 10px;
    font-family: 'Ubuntu Mono', ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #9fef00;
}

.article-body h2:first-child,
.article-body > h2:first-of-type {
    margin-top: 40px;
}

.article-body h3 {
    margin: 36px 0 10px;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.2px;
    color: #fff;
}

.article-body h4 {
    margin: 26px 0 8px;
    font-size: 17px;
    color: #d8d8d8;
    letter-spacing: 0.2px;
}

.article-body p {
    margin: 0 0 22px;
    color: #c8c8c8;
}

.article-body ul,
.article-body ol {
    margin: 0 0 22px;
    padding-left: 24px;
}

.article-body li {
    margin-bottom: 8px;
    color: #c8c8c8;
}

.article-body ul ul,
.article-body ol ol {
    margin: 8px 0 10px;
}

.article-body li::marker {
    color: #6f6f6f;
}

/* Muitos artigos usam <b> no começo de um parágrafo como subtítulo. O :has()
   separa esse caso (negrito seguido de quebra de linha) do negrito inline no
   meio da frase, que continua igual. */
.article-body p > b:first-child:has(+ br),
.article-body p > br + b:has(+ br) {
    font-size: 1.14em;
    line-height: 2.2;
    letter-spacing: -0.2px;
    color: #fff;
}

.article-body strong {
    color: #e8e8e8;
}

.article-body i {
    color: #d0d0d0;
}

/* Links no texto ganham o verde do site */
.article-body a {
    color: #9fef00;
    /* URLs longas quebram em vez de estourar a largura da tela */
    overflow-wrap: anywhere;
    text-decoration: none;
    border-bottom: 1px solid rgba(159, 239, 0, 0.3);
    transition: border-color 0.2s ease;
}

.article-body a:hover {
    border-bottom-color: #9fef00;
}

.article-body img {
    display: block;
    margin: 32px 0;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid #262626;
}

a {
    color: #fff;
}

/* --- Código --- */
.code-block {
    margin: 22px 0;
    padding: 16px 18px;
    background-color: #0c0c0c;
    color: #b3ff00;
    border: 1px solid #242424;
    border-radius: 10px;
    font-family: 'Ubuntu Mono', 'Courier New', Courier, monospace;
    font-size: 14.5px;
    line-height: 1.6;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    /* mantém o formato original e rola na horizontal quando passa da largura */
    white-space: pre;
    overflow-x: auto;
    word-wrap: normal;
}

.code-block code {
    display: block;
    white-space: pre;
    overflow-wrap: normal;
    word-wrap: normal;
}

.code-block::-webkit-scrollbar {
    height: 8px;
}

.code-block::-webkit-scrollbar-track {
    background: transparent;
}

.code-block::-webkit-scrollbar-thumb {
    background: #2f2f2f;
    border-radius: 4px;
}

.code-block::-webkit-scrollbar-thumb:hover {
    background: rgba(159, 239, 0, 0.4);
}

footer {
    background-color: #111;
    text-align: center;
    padding: 10px;
    color: #777;
    font-size: 15px;
}

/* ==========================================================================
   Páginas-guia (dicas de carreira): body.guide
   Só o que é específico das guias; o resto vem do layout comum acima.
   ========================================================================== */

/* nas guias o h3 é uma entrada de catálogo (curso, ferramenta), não uma
   subseção de texto: aparece dezenas de vezes e pede menos peso */
.guide .article-body h3 {
    font-size: 19px;
}

/* o rótulo "Link:" vira redundante ao lado do próprio link */
.guide .link-label {
    display: none;
}

.guide .article-body .link-list {
    margin: 8px 0 22px;
    padding: 0;
    list-style: none;
}

.guide .article-body .link-list li {
    margin: 0 0 4px;
}

.guide .article-body .link-list a {
    font-size: 14px;
    color: #9fef00;
    border-bottom: 1px solid rgba(159, 239, 0, 0.25);
}

.guide .article-body .link-list a::after {
    content: ' ↗';
    opacity: 0.6;
}

.guide .article-body .link-list a:hover {
    border-bottom-color: #9fef00;
}

/* ==========================================================================
   Responsivo
   ========================================================================== */

/* Abaixo de 1100px não sobra largura para a coluna lateral: o índice volta
   para o topo, em fluxo normal. */
@media (max-width: 1100px) {
    .content {
        display: block;
        max-width: min(92%, 860px);
    }

    .article-body {
        max-width: none;
    }

    .toc {
        position: static;
        max-height: none;
        margin: 24px 0 40px;
        padding: 20px 0 4px;
        border-top: 1px solid #2b2b2b;
        border-bottom: 1px solid #2b2b2b;
    }
}

@media (max-width: 768px) {
    .content {
        margin: 20px auto 40px;
        padding: 24px 20px 32px;
        border-radius: 16px;
    }

    .article-body {
        font-size: 16px;
    }

    .article-body h2 {
        margin-top: 52px;
        padding-top: 24px;
    }

    .article-body h3 {
        font-size: 19px;
    }

    .code-block {
        font-size: 13px;
        padding: 12px 14px;
    }
}

@media (max-width: 480px) {
    .content {
        max-width: 100%;
        padding: 20px 16px 28px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .code-block {
        font-size: 12.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .toc a {
        transition: none;
    }
}

/* Attack-flow diagram (write-ups) */
.attack-flow {
    margin: 26px 0 30px;
    padding: 18px 18px 20px;
    background: #111;
    border: 1px solid #1f1f1f;
    border-radius: 10px;
}

.attack-flow figcaption {
    color: #9fef00;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 6px;
}

.attack-flow svg {
    width: 100%;
    height: auto;
    display: block;
    font-family: 'Raleway', sans-serif;
}

/* Write-ups: tighter spacing between sections (many short sections) */
.writeup-body h2 {
    margin: 38px 0 16px;
    padding-top: 18px;
}

.writeup-body h2:first-child,
.writeup-body > h2:first-of-type {
    margin-top: 22px;
}

.writeup-body h2[id]::before {
    margin-bottom: 6px;
}

.writeup-body .code-block {
    margin: 16px 0;
}
