/* =============================================================================
   content.css
   Shared styles for markdown content pages (docs + tutorials).
   Covers: markdown body, code blocks, tables, syntax highlighting, errors.
   ============================================================================= */

/* ─── Content Token Overrides ────────────────────────────────────────────── */

:root {
    --bg-code: #18181e;
    --bg-code-inline: #1c1c24;
    --radius-sm: 5px;
}

[data-theme-mode="light"] {
    --bg-code: #f0f0f5;
    --bg-code-inline: #eaeaf0;
}

/* ─── Markdown body ──────────────────────────────────────────────────────── */

.md {
    max-width: 820px;
    margin: 0 auto;
    padding: 40px 48px 80px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.md h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.md h2 {
    font-size: 27px;
    font-weight: 650;
    margin-top: 48px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.3px;
}

.md h3 {
    font-size: 21px;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
}

.md h4 {
    font-size: 17px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.md h1:first-child {
    margin-top: 0;
}

.md h2:first-child {
    margin-top: 0;
}

/* Anchor links on headings */

.md h1 .anchor,
.md h2 .anchor,
.md h3 .anchor,
.md h4 .anchor {
    color: var(--text-dim);
    text-decoration: none;
    margin-left: 6px;
    opacity: 0;
    transition: opacity 0.15s;
    font-weight: 400;
}

.md h1:hover .anchor,
.md h2:hover .anchor,
.md h3:hover .anchor,
.md h4:hover .anchor {
    opacity: 1;
}

.md p {
    margin-bottom: 16px;
    color: var(--text-muted);
    line-height: 1.7;
}

.md blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin-bottom: 16px;
    background: var(--accent-dim);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.md blockquote p {
    color: var(--text-muted);
    margin-bottom: 0;
}

.md strong {
    font-weight: 600;
    color: var(--text);
}

.md a {
    color: var(--accent-text);
    text-decoration: none;
}

.md ul,
.md ol {
    margin-bottom: 16px;
    padding-left: 24px;
    color: var(--text-muted);
}

.md li {
    margin-bottom: 4px;
    line-height: 1.7;
}

.md li > ul,
.md li > ol {
    margin-top: 4px;
    margin-bottom: 4px;
}

.md hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ─── Code ───────────────────────────────────────────────────────────────── */

.md code {
    font-family:
        "SF Mono", Monaco, Menlo, "Cascadia Code", "Consolas", monospace;
    font-size: 0.88em;
    background: var(--bg-code-inline);
    padding: 2px 7px;
    border-radius: 4px;
    color: #c8cedc;
}

[data-theme-mode="light"] .md code {
    color: #374151;
}

.md pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    overflow-x: auto;
    line-height: 1.55;
}

.md pre::-webkit-scrollbar {
    height: 4px;
}

.md pre::-webkit-scrollbar-track {
    background: transparent;
}

.md pre::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.md pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 16px;
    color: #c8cedc;
}

[data-theme-mode="light"] .md pre code {
    color: #374151;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */

.md table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 16px;
}

.md thead th {
    text-align: left;
    font-weight: 600;
    color: var(--text);
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.md tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    vertical-align: top;
}

.md tbody tr:last-child td {
    border-bottom: none;
}

.md tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.md tbody td code {
    font-size: 15px;
}

/* ─── Syntax highlighting — dark theme (default) ─────────────────────────── */

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-type {
    color: #c792ea;
}

.hljs-string,
.hljs-attr {
    color: #c3e88d;
}

.hljs-number,
.hljs-literal {
    color: #f78c6c;
}

.hljs-comment {
    color: #546e7a;
    font-style: italic;
}

.hljs-function .hljs-title,
.hljs-title.function_ {
    color: #82aaff;
}

.hljs-variable,
.hljs-template-variable {
    color: #eeffff;
}

.hljs-params {
    color: #c8cedc;
}

.hljs-property {
    color: #80cbc4;
}

.hljs-punctuation {
    color: #89ddff;
}

.hljs-meta {
    color: #ffcb6b;
}

.hljs-selector-class {
    color: #ffcb6b;
}

.hljs-selector-id {
    color: #82aaff;
}

.hljs-attribute {
    color: #c792ea;
}

.hljs-regexp {
    color: #89ddff;
}

.hljs-addition {
    color: #c3e88d;
}

.hljs-deletion {
    color: #ff5370;
}

/* ─── Syntax highlighting — light theme ─────────────────────────────────── */

[data-theme-mode="light"] .hljs-keyword,
[data-theme-mode="light"] .hljs-selector-tag,
[data-theme-mode="light"] .hljs-built_in,
[data-theme-mode="light"] .hljs-type {
    color: #7c3aed;
}

[data-theme-mode="light"] .hljs-string,
[data-theme-mode="light"] .hljs-attr {
    color: #16a34a;
}

[data-theme-mode="light"] .hljs-number,
[data-theme-mode="light"] .hljs-literal {
    color: #ea580c;
}

[data-theme-mode="light"] .hljs-comment {
    color: #94a3b8;
}

[data-theme-mode="light"] .hljs-function .hljs-title,
[data-theme-mode="light"] .hljs-title.function_ {
    color: #2563eb;
}

[data-theme-mode="light"] .hljs-variable,
[data-theme-mode="light"] .hljs-template-variable {
    color: #1e293b;
}

[data-theme-mode="light"] .hljs-params {
    color: #475569;
}

[data-theme-mode="light"] .hljs-property {
    color: #0d9488;
}

[data-theme-mode="light"] .hljs-punctuation {
    color: #6366f1;
}

[data-theme-mode="light"] .hljs-meta {
    color: #d97706;
}

[data-theme-mode="light"] .hljs-selector-class {
    color: #d97706;
}

[data-theme-mode="light"] .hljs-selector-id {
    color: #2563eb;
}

[data-theme-mode="light"] .hljs-attribute {
    color: #7c3aed;
}

[data-theme-mode="light"] .hljs-regexp {
    color: #6366f1;
}

[data-theme-mode="light"] .hljs-addition {
    color: #16a34a;
}

[data-theme-mode="light"] .hljs-deletion {
    color: #dc2626;
}

/* ─── Error ──────────────────────────────────────────────────────────────── */

.error {
    padding: 40px;
    text-align: center;
    color: var(--text-dim);
}

.error__title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.error__message {
    font-size: 17px;
    margin-bottom: 20px;
}

.error__link {
    color: var(--accent-text);
    text-decoration: none;
}

.error__link:hover {
    text-decoration: underline;
}

/* ─── Responsive: large screens ─────────────────────────────────────────── */

@media (min-width: 1200px) {
    .md {
        max-width: 920px;
    }
}

/* ─── Responsive: medium screens ────────────────────────────────────────── */

@media (max-width: 900px) {
    .md {
        padding: 32px 32px 60px;
    }
}

/* ─── Responsive: small screens ─────────────────────────────────────────── */

@media (max-width: 720px) {
    .md {
        padding: 24px 20px 60px;
        max-width: 100%;
    }

    .md h1 {
        font-size: 28px;
    }

    .md h2 {
        font-size: 22px;
        margin-top: 36px;
    }

    .md h3 {
        font-size: 18px;
        margin-top: 24px;
    }

    .md h4 {
        font-size: 15px;
    }

    .md pre {
        padding: 12px 14px;
    }

    .md pre code {
        font-size: 14px;
        word-break: break-all;
        white-space: pre-wrap;
    }

    .md table {
        font-size: 14px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .md thead th {
        font-size: 13px;
    }

    .md tbody td code {
        font-size: 13px;
    }

    .md table thead,
    .md table tbody,
    .md table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
}
