/* Blog article body: code blocks, inline code, tables, syntax highlighting.
   Loaded only on blog/show. Markup for .code-block and .table-wrap is added by article-content.js. */

/* ---------- Inline code ---------- */
.article-body :not(pre) > code {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.85em;
    color: #d97757;
    background: rgba(217, 119, 87, 0.12);
    border: 1px solid rgba(217, 119, 87, 0.2);
    border-radius: 6px;
    padding: 0.1em 0.4em;
    font-variant-ligatures: none;
    overflow-wrap: anywhere;
}

[data-theme="light"] .article-body :not(pre) > code {
    color: #b4532f;
    background: rgba(217, 119, 87, 0.1);
    border-color: rgba(217, 119, 87, 0.25);
}

/* ---------- Code blocks ---------- */
.article-body pre {
    margin: 2rem 0;
    padding: 1rem 1.25rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.9em;
    line-height: 1.6;
    color: #c9d1d9;
    background: var(--bg-secondary, #121214);
    border: 1px solid var(--border-color, #2a2a2d);
    border-radius: var(--radius-md, 12px);
    white-space: pre;
    overflow-x: auto;
    tab-size: 4;
    font-variant-ligatures: none;
    -webkit-overflow-scrolling: touch;
}

.article-body pre code {
    display: block;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    padding: 0;
    white-space: inherit;
    word-break: normal;
    overflow-wrap: normal;
}

.code-block {
    margin: 2rem 0;
    background: var(--bg-secondary, #121214);
    border: 1px solid var(--border-color, #2a2a2d);
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    max-width: 100%;
}

.code-block pre {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.code-block__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2.5rem;
    padding: 0.35rem 0.5rem 0.35rem 1.25rem;
    background: var(--bg-tertiary, #1a1a1d);
    border-bottom: 1px solid var(--border-color, #2a2a2d);
}

.code-block__lang {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #a0a0a0);
}

.code-block__copy {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    padding: 0.3rem 0.7rem;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.8rem;
    line-height: 1.2;
    color: var(--text-secondary, #a0a0a0);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.code-block__copy:hover {
    color: var(--text-primary, #f5f5f3);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-color, #2a2a2d);
}

.code-block__copy:focus-visible {
    outline: 2px solid #d97757;
    outline-offset: 2px;
}

.code-block__copy.is-copied {
    color: #d97757;
}

[data-theme="light"] .article-body pre {
    color: #24292f;
}

[data-theme="light"] .code-block__copy:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ---------- Tables ---------- */
.article-body table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    font-size: 0.95em;
    line-height: 1.55;
    color: inherit;
}

.article-body .table-wrap {
    margin: 2rem 0;
    border: 1px solid var(--border-color, #2a2a2d);
    border-radius: var(--radius-md, 12px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.article-body .table-wrap table {
    margin: 0;
}

.article-body th,
.article-body td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-color, #2a2a2d);
}

.article-body thead th {
    font-weight: 600;
    color: var(--text-primary, #f5f5f3);
    background: var(--bg-tertiary, #1a1a1d);
    border-bottom: 2px solid rgba(217, 119, 87, 0.45);
}

.article-body tbody tr:last-child > * {
    border-bottom: 0;
}

.article-body tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.025);
}

.article-body tbody tr:hover {
    background: rgba(217, 119, 87, 0.06);
}

[data-theme="light"] .article-body tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.025);
}

[data-theme="light"] .article-body tbody tr:hover {
    background: rgba(217, 119, 87, 0.07);
}

@media (max-width: 767.98px) {
    .article-body pre {
        padding: 0.85rem 1rem;
        font-size: 0.85em;
    }

    .code-block__header {
        padding-left: 1rem;
    }

    .article-body table {
        font-size: 0.9em;
    }

    .article-body th,
    .article-body td {
        padding: 0.6rem 0.75rem;
    }

    /* Wide tables scroll inside the wrapper instead of stretching the page */
    .article-body .table-wrap th,
    .article-body .table-wrap td {
        min-width: 9rem;
    }
}

/* ---------- Syntax highlighting (highlight.js tokens) ----------
   Dark: GitHub Dark palette. Light: GitHub palette. */
.article-body .hljs-doctag,
.article-body .hljs-keyword,
.article-body .hljs-meta .hljs-keyword,
.article-body .hljs-template-tag,
.article-body .hljs-template-variable,
.article-body .hljs-type,
.article-body .hljs-variable.language_ { color: #ff7b72; }

.article-body .hljs-title,
.article-body .hljs-title.class_,
.article-body .hljs-title.class_.inherited__,
.article-body .hljs-title.function_ { color: #d2a8ff; }

.article-body .hljs-attr,
.article-body .hljs-attribute,
.article-body .hljs-literal,
.article-body .hljs-meta,
.article-body .hljs-number,
.article-body .hljs-operator,
.article-body .hljs-variable,
.article-body .hljs-selector-attr,
.article-body .hljs-selector-class,
.article-body .hljs-selector-id { color: #79c0ff; }

.article-body .hljs-regexp,
.article-body .hljs-string,
.article-body .hljs-meta .hljs-string { color: #a5d6ff; }

.article-body .hljs-built_in,
.article-body .hljs-symbol { color: #ffa657; }

.article-body .hljs-comment,
.article-body .hljs-code,
.article-body .hljs-formula { color: #8b949e; font-style: italic; }

.article-body .hljs-name,
.article-body .hljs-quote,
.article-body .hljs-selector-tag,
.article-body .hljs-selector-pseudo { color: #7ee787; }

.article-body .hljs-section { color: #79c0ff; font-weight: 600; }
.article-body .hljs-bullet { color: #f2cc60; }
.article-body .hljs-emphasis { font-style: italic; }
.article-body .hljs-strong { font-weight: 600; }
.article-body .hljs-addition { color: #aff5b4; background-color: #033a16; }
.article-body .hljs-deletion { color: #ffdcd7; background-color: #67060c; }

[data-theme="light"] .article-body .hljs-doctag,
[data-theme="light"] .article-body .hljs-keyword,
[data-theme="light"] .article-body .hljs-meta .hljs-keyword,
[data-theme="light"] .article-body .hljs-template-tag,
[data-theme="light"] .article-body .hljs-template-variable,
[data-theme="light"] .article-body .hljs-type,
[data-theme="light"] .article-body .hljs-variable.language_ { color: #cf222e; }

[data-theme="light"] .article-body .hljs-title,
[data-theme="light"] .article-body .hljs-title.class_,
[data-theme="light"] .article-body .hljs-title.class_.inherited__,
[data-theme="light"] .article-body .hljs-title.function_ { color: #8250df; }

[data-theme="light"] .article-body .hljs-attr,
[data-theme="light"] .article-body .hljs-attribute,
[data-theme="light"] .article-body .hljs-literal,
[data-theme="light"] .article-body .hljs-meta,
[data-theme="light"] .article-body .hljs-number,
[data-theme="light"] .article-body .hljs-operator,
[data-theme="light"] .article-body .hljs-variable,
[data-theme="light"] .article-body .hljs-selector-attr,
[data-theme="light"] .article-body .hljs-selector-class,
[data-theme="light"] .article-body .hljs-selector-id { color: #0550ae; }

[data-theme="light"] .article-body .hljs-regexp,
[data-theme="light"] .article-body .hljs-string,
[data-theme="light"] .article-body .hljs-meta .hljs-string { color: #0a3069; }

[data-theme="light"] .article-body .hljs-built_in,
[data-theme="light"] .article-body .hljs-symbol { color: #953800; }

[data-theme="light"] .article-body .hljs-comment,
[data-theme="light"] .article-body .hljs-code,
[data-theme="light"] .article-body .hljs-formula { color: #6e7781; }

[data-theme="light"] .article-body .hljs-name,
[data-theme="light"] .article-body .hljs-quote,
[data-theme="light"] .article-body .hljs-selector-tag,
[data-theme="light"] .article-body .hljs-selector-pseudo { color: #116329; }

[data-theme="light"] .article-body .hljs-section { color: #0550ae; }
[data-theme="light"] .article-body .hljs-bullet { color: #953800; }
[data-theme="light"] .article-body .hljs-addition { color: #116329; background-color: #f0fff4; }
[data-theme="light"] .article-body .hljs-deletion { color: #82071e; background-color: #ffebe9; }
