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

/* ─── 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: var(--fs-4xl);
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.md h2 {
    font-size: var(--fs-3xl);
    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: var(--fs-xl);
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
}

.md h4 {
    font-size: var(--fs-lg);
    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,
.md h1:focus-within .anchor,
.md h2:focus-within .anchor,
.md h3:focus-within .anchor,
.md h4:focus-within .anchor {
    opacity: 1;
}

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

.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: var(--font-mono);
    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: var(--fs-md);
    color: #c8cedc;
}

.md pre code [class^="hljs-"] {
    transition: color 0.15s ease;
}

.md pre code .hljs-comment {
    font-style: italic;
}

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

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

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

.md thead th {
    text-align: left;
    font-weight: 600;
    color: var(--text);
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    font-size: var(--fs-2xs);
    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: var(--sidebar-hover);
}

.md tbody td code {
    font-size: var(--fs-base);
}

/* All syntax highlighting is now in syntax.css */

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

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

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

.error__message {
    font-size: var(--fs-lg);
    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: 12px 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;
    }
}
