/* ============================================
   pirumu::BLOG — Rust Theme · Dark/Light
   ============================================ */

/* ---- Dark theme (default) ---- */
:root,
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --bg-hover: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --rust-orange: #ce422b;
    --rust-orange-glow: #e8563d;
    --rust-light: #f97316;
    --green: #3fb950;
    --green-dim: #238636;
    --yellow: #d29922;
    --red: #f85149;
    --cyan: #58a6ff;
    --purple: #bc8cff;
    --string-color: #a5d6ff;
    --border: #30363d;
    --border-hover: #484f58;
    --selection-bg: var(--rust-orange);
    --selection-fg: #fff;
    --scrollbar-thumb: #30363d;
    --scrollbar-track: #0d1117;
}

/* ---- Light theme ---- */
[data-theme="light"] {
    --bg-primary: #f6f6f4;
    --bg-secondary: #eeeee9;
    --bg-card: #ffffff;
    --bg-hover: #e8e8e3;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --rust-orange: #b7410e;
    --rust-orange-glow: #d4541d;
    --rust-light: #e8601c;
    --green: #1a7f37;
    --green-dim: #116329;
    --yellow: #9a6700;
    --red: #cf222e;
    --cyan: #0969da;
    --purple: #8250df;
    --string-color: #0a3069;
    --border: #d0d0cb;
    --border-hover: #b0b0a8;
    --selection-bg: var(--rust-orange);
    --selection-fg: #fff;
    --scrollbar-thumb: #c8c8c2;
    --scrollbar-track: #f6f6f4;
}

/* ---- Spacing ---- */
:root {
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --font-mono:
        "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", monospace;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.9375rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.375rem;
    --font-size-2xl: 1.75rem;
    --container-max: 760px;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    transition:
        background-color 300ms ease,
        color 300ms ease;
}

a {
    color: var(--rust-orange);
    text-decoration: none;
    transition: color 200ms ease-out;
}
a:hover {
    color: var(--rust-orange-glow);
}
a:focus-visible {
    outline: 2px solid var(--rust-orange);
    outline-offset: 2px;
}

::selection {
    background: var(--selection-bg);
    color: var(--selection-fg);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

/* ---- Container ---- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* ---- Header ---- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color 300ms ease;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    /*border-bottom: 1px solid var(--border);*/
}

.site-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-weight: 600;
    font-size: var(--font-size-base);
}

.site-logo:hover {
    color: var(--rust-orange);
}

.logo-mark {
    color: var(--rust-orange);
    font-weight: 700;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ctrl-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 200ms ease-out;
    min-height: 28px;
}

.ctrl-btn:hover {
    border-color: var(--rust-orange);
    color: var(--rust-orange);
}

.ctrl-btn:focus-visible {
    outline: 2px solid var(--rust-orange);
    outline-offset: 2px;
}

.ctrl-btn.active {
    background: var(--rust-orange);
    color: #fff;
    border-color: var(--rust-orange);
}

/* ---- Navigation ---- */
.nav {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-sm) 0;
}

.nav-link {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: var(--space-xs) 0;
    transition: color 200ms ease-out;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    color: var(--rust-orange);
}

/* ---- Hero ---- */
.hero {
    padding: var(--space-2xl) 0 var(--space-xl);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-lg);
}

.hero-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.hero-sub {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.rust-color {
    color: var(--rust-orange);
    font-weight: 600;
}
.fn-name {
    color: var(--cyan);
}
.string {
    color: var(--string-color);
}
.comment {
    color: var(--text-muted);
}

/* ---- Section title ---- */
.section-title {
    font-size: var(--font-size-base);
    font-weight: 400;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

/* ---- Post card ---- */
.posts-section {
    padding-bottom: var(--space-2xl);
}

.post-card {
    padding: var(--space-lg) 0;
    border-bottom: 1px dashed var(--border);
    transition: background-color 200ms ease-out;
}

.post-card:last-child {
    border-bottom: none;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.separator {
    color: var(--border);
}

.tag {
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-rust {
    color: var(--rust-orange);
}
.tag-math {
    color: var(--cyan);
}
.tag-crypto {
    color: var(--purple);
}

.post-title {
    font-size: var(--font-size-lg);
    font-weight: 500;
    margin-bottom: var(--space-sm);
    line-height: 1.4;
}

.post-title a {
    color: var(--text-primary);
}
.post-title a:hover {
    color: var(--rust-orange);
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.7;
}

/* ---- Post page ---- */
.post-header {
    /*padding: var(--space-2xl) 0 var(--space-lg);*/
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-xl);
}

.post-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.post-header .post-meta {
    margin-bottom: 0;
}

/* ---- Article content ---- */
.post-content {
    padding-bottom: var(--space-2xl);
}

.post-content h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--rust-orange);
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
}

.post-content h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
}

.post-content p {
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}
.post-content strong {
    color: var(--text-primary);
    font-weight: 600;
}
.post-content em {
    color: var(--yellow);
    font-style: italic;
}

.post-content ul,
.post-content ol {
    margin-bottom: var(--space-md);
    padding-left: var(--space-lg);
    color: var(--text-secondary);
}

.post-content li {
    margin-bottom: var(--space-xs);
}
.post-content li::marker {
    color: var(--rust-orange);
}

/* Code blocks */
.post-content code {
    font-family: var(--font-mono);
    background: var(--bg-secondary);
    padding: 2px 6px;
    font-size: var(--font-size-sm);
    color: var(--green);
    border: 1px solid var(--border);
}

.post-content pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    overflow-x: auto;
    position: relative;
    transition: background-color 300ms ease;
}

.post-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: var(--font-size-sm);
    line-height: 1.7;
}

.code-label {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* Blockquote */
.post-content blockquote {
    border-left: 3px solid var(--rust-orange);
    padding-left: var(--space-md);
    margin-bottom: var(--space-md);
    color: var(--text-muted);
    font-style: italic;
}

/* Math block */
.math-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    text-align: center;
    color: var(--cyan);
    font-size: var(--font-size-lg);
    overflow-x: auto;
    transition: background-color 300ms ease;
}

/* ---- KaTeX overrides ---- */
.katex-display {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md) !important;
    overflow-x: auto;
    transition: background-color 300ms ease;
}

.katex-display > .katex {
    color: var(--cyan);
}
.katex {
    font-size: 1.1em;
}

.math-block .katex-display {
    border: none;
    padding: 0;
    margin: 0 !important;
    background: none;
    border-left: none;
}

/* ---- About page ---- */
.about-section {
    padding: var(--space-2xl) 0;
}

.about-section h1 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: var(--space-lg);
}

.rust-code {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: var(--space-lg);
    overflow-x: auto;
    transition: background-color 300ms ease;
    font-size: var(--font-size-sm);
    line-height: 1.8;
}

.rust-code code {
    font-family: var(--font-mono);
}

.rust-code a {
    color: var(--string-color);
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 2px;
}

.rust-code a:hover {
    text-decoration-color: var(--rust-orange);
}

.contact-links {
    list-style: none;
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.contact-links a {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    transition: color 200ms ease-out;
}

.contact-links a:hover {
    color: var(--rust-orange);
}
.about-terminal .label {
    color: var(--green);
}
.about-terminal .value {
    color: var(--text-primary);
}

/* ---- Tags page ---- */
.tags-section {
    padding: var(--space-2xl) 0;
}
.tags-section h1 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: var(--space-lg);
}

.tag-group {
    margin-bottom: var(--space-xl);
}

.tag-group-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
}

.tag-group-title .count {
    color: var(--text-muted);
    font-weight: 400;
    font-size: var(--font-size-sm);
}

.tag-post-list {
    list-style: none;
}
.tag-post-list li {
    padding: var(--space-sm) 0;
    border-bottom: 1px dashed var(--border);
}
.tag-post-list li:last-child {
    border-bottom: none;
}
.tag-post-list a {
    color: var(--text-primary);
}
.tag-post-list a:hover {
    color: var(--rust-orange);
}
.tag-post-list time {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-right: var(--space-sm);
}

/* ---- Back link ---- */
.back-link {
    display: inline-block;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-lg);
    padding-top: var(--space-lg);
    transition: color 200ms ease-out;
    cursor: pointer;
}

.back-link:hover {
    color: var(--rust-orange);
}

/* ---- Comments ---- */
.comments-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border);
}

.comments-title {
    font-size: var(--font-size-base);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

/* ---- i18n: hide inactive lang ---- */
[data-lang="vi"] .lang-en {
    display: none;
}
[data-lang="en"] .lang-vi {
    display: none;
}

/* ---- Site Footer ---- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-xl) 0 var(--space-2xl);
    margin-top: var(--space-xl);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-rust-badge {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-muted);
}

.footer-rust-badge svg {
    width: 14px;
    height: 14px;
    fill: var(--rust-orange);
}

@media (max-width: 480px) {
    .footer-bottom {
        flex-direction: column;
        gap: var(--space-sm);
        text-align: center;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-md);
    }
    .ascii-art {
        font-size: 0.45rem;
    }
    .nav {
        gap: var(--space-md);
    }
    .post-title {
        font-size: var(--font-size-base);
    }
    .hero-text {
        padding: var(--space-sm) var(--space-md);
    }
    .post-header h1 {
        font-size: var(--font-size-xl);
    }
    .header-controls {
        gap: 4px;
    }
    .ctrl-btn {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    .nav {
        flex-wrap: wrap;
        gap: var(--space-sm) var(--space-md);
    }
    .ascii-art {
        display: none;
    }
    .post-meta {
        flex-wrap: wrap;
    }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0ms !important;
    }
}
