/* GitHub-style markdown rendering — dark/light theme */

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

html {
    overflow-y: scroll; /* always show scrollbar to prevent layout shift between pages */
}

/* === THEME VARIABLES === */
:root {
    --bg-canvas: #0d1117;
    --bg-primary: #161b22;
    --bg-even-row: rgba(22, 27, 34, 0.5);
    --border: #30363d;
    --border-heading: #21262d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --text-marker: #484f58;
    --link: #58a6ff;
    --key: #7ee787;
    --comment: #8b949e;
}

[data-theme="light"] {
    --bg-canvas: #ffffff;
    --bg-primary: #f6f8fa;
    --bg-even-row: rgba(246, 248, 250, 0.5);
    --border: #d0d7de;
    --border-heading: #d8dee4;
    --text: #1f2328;
    --text-muted: #656d76;
    --text-marker: #656d76;
    --link: #0969da;
    --key: #116329;
    --comment: #6e7781;
}

body {
    background: var(--bg-canvas);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.2s, color 0.2s;
}

/* File header bar */
.file-header {
    max-width: 860px;
    margin: 24px auto 0;
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text);
}
.file-icon { font-size: 16px; }
.file-name { font-weight: 600; }

/* Repo-style tab navigation */
.repo-nav {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.repo-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.repo-nav-item:hover {
    color: var(--text);
    text-decoration: none;
}

.repo-nav-item.active {
    color: var(--text);
    font-weight: 600;
    border-bottom-color: #f78166;
}

.repo-nav-item svg {
    flex-shrink: 0;
}

/* Profile header with photo */
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 4px;
}

.profile-header h1 {
    margin-bottom: 0;
}

.profile-header p {
    margin-bottom: 0;
}

.profile-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
    flex-shrink: 0;
}

/* Social links below title */
.social-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 4px;
    margin-bottom: 12px;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 13px;
    transition: color 0.15s;
}
.social-link:hover {
    color: var(--link);
    text-decoration: none;
}
.social-link svg {
    flex-shrink: 0;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    margin-left: auto;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 24px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--link);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    line-height: 1;
    transition: opacity 0.2s;
}
.toggle-icon--dark {
    right: 5px;
    opacity: 1;
}
.toggle-icon--light {
    left: 5px;
    opacity: 0;
}
.toggle-switch input:checked ~ .toggle-slider .toggle-icon--dark {
    opacity: 0;
}
.toggle-switch input:checked ~ .toggle-slider .toggle-icon--light {
    opacity: 1;
}

/* Markdown body container */
.markdown-body {
    max-width: 860px;
    margin: 0 auto 80px;
    padding: 32px 40px 48px;
    background: var(--bg-canvas);
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    transition: background 0.2s, border-color 0.2s;
}

/* Headings */
.markdown-body h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 4px;
    padding-bottom: 0;
    border: none;
    color: var(--text);
}

.markdown-body h2 {
    font-size: 24px;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-heading);
    color: var(--text);
}

.markdown-body h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 4px;
    color: var(--text);
}

/* Paragraph */
.markdown-body p {
    margin-bottom: 12px;
    color: var(--text);
}

/* Horizontal rule */
.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-heading);
    margin: 16px 0 24px;
}

/* Links */
.markdown-body a {
    color: var(--link);
    text-decoration: none;
}
.markdown-body a:hover {
    text-decoration: underline;
}

/* Inline code */
.markdown-body code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    padding: 2px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
}

/* Code blocks */
.code-block {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 12px 0 16px;
    overflow-x: auto;
    transition: background 0.2s, border-color 0.2s;
}

.code-block pre {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 16px;
    margin: 0;
    color: var(--text);
    white-space: pre;
}

.code-block a {
    color: var(--link);
}

/* Syntax colors */
.c { color: var(--comment); }
.na { color: var(--key); }

/* Unordered lists */
.markdown-body ul {
    margin: 8px 0 16px;
    padding-left: 28px;
}

.markdown-body li {
    margin-bottom: 4px;
    color: var(--text);
}

.markdown-body li::marker {
    color: var(--text-marker);
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 16px;
    font-size: 14px;
}

.markdown-body th {
    text-align: left;
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--text);
}

.markdown-body td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    color: var(--text);
}

.markdown-body tr:nth-child(even) td {
    background: var(--bg-even-row);
}

/* Bold */
.markdown-body strong {
    font-weight: 600;
    color: var(--text);
}

/* Breadcrumb navigation */
.breadcrumb {
    font-size: 14px;
    margin-bottom: 16px;
    color: var(--text-muted);
}
.breadcrumb a {
    color: var(--link);
    text-decoration: none;
}
.breadcrumb a:hover {
    text-decoration: underline;
}

/* Page link cards (on index) */
.page-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 16px;
}
.page-link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}
.page-link-card:hover {
    border-color: var(--link);
    text-decoration: none;
}
.page-link-icon {
    font-size: 28px;
    flex-shrink: 0;
}
.page-link-card strong {
    font-size: 16px;
    display: block;
    margin-bottom: 2px;
}
.page-link-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}
.page-link-arrow {
    margin-left: auto;
    font-size: 18px;
    color: var(--text-muted);
    transition: color 0.15s;
}
.page-link-card:hover .page-link-arrow {
    color: var(--link);
}

/* Project cards */
.project-card {
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 12px 0 16px;
    transition: border-color 0.15s;
}
.project-card:hover {
    border-color: var(--link);
}
.project-card h3 {
    margin-top: 0;
}
.project-card p {
    margin-bottom: 8px;
}

/* Tags */
.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tag {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg-canvas);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-muted);
}

/* Blog entries */
.blog-entry {
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 12px 0 16px;
    transition: border-color 0.15s;
}
.blog-entry:hover {
    border-color: var(--link);
}
.blog-entry h3 {
    margin-top: 0;
}
.blog-date {
    font-size: 13px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
    .markdown-body {
        margin: 0 8px 60px;
        padding: 24px 20px 32px;
    }
    .file-header {
        margin: 12px 8px 0;
    }
    .repo-nav {
        margin-left: 8px;
        margin-right: 8px;
    }
}

@media (max-width: 480px) {
    .markdown-body h1 { font-size: 26px; }
    .markdown-body h2 { font-size: 20px; }
    .markdown-body h3 { font-size: 16px; }
    .markdown-body { font-size: 14px; }
}
