/* ==========================================================================
   Meridian — a Pelican theme (forked from Storm by redVi). Plain CSS,
   no Sass/Compass build required.
   Theme is controlled by [data-theme="dark"|"light"] on <html>.
   Dark is the default; see templates/base.html for the no-flash bootstrap
   script and static/js/theme.js for the toggle behavior.
   ========================================================================== */

:root,
html[data-theme="dark"] {
    --bg: #14171c;
    --bg-elevated: #1b1e24;
    --bg-card: #1c1f26;
    --bg-code: #12151a;
    --text-primary: #e8eaed;
    --text-secondary: #9aa1ac;
    --text-muted: #6b7280;
    --border: #2c3038;
    --border-strong: #383d47;
    --accent: #5dcaa5;
    --accent-text: #0e3529;
    --accent-tint: #16332b;
    --link: #7fd9c4;
    --header-bg: #0f1114;
}

html[data-theme="light"] {
    --bg: #ffffff;
    --bg-elevated: #fafaf9;
    --bg-card: #ffffff;
    --bg-code: #f5f1ec;
    --text-primary: #1a1a1a;
    --text-secondary: #666560;
    --text-muted: #96938c;
    --border: #ececea;
    --border-strong: #dcdad5;
    --accent: #c1440e;
    --accent-text: #ffffff;
    --accent-tint: #fdeee6;
    --link: #c1440e;
    --header-bg: #ffffff;
}

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

html,
body {
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text-primary);
    font:
        400 17px/1.6 "Inter",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

#outer-wrapper {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--link);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ---------- Top bar ---------- */
#site-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1.1em 1.5em;
    display: flex;
    align-items: center;
    gap: 0.9em;
}

#sidebar-toggle {
    display: none;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#sidebar-toggle:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.site-header-titles {
    text-align: left;
    flex: 1;
    min-width: 0;
}
.logo a {
    font-family: "Inter", sans-serif;
    font-weight: 700;
    font-size: 1.4em;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.logo a:hover {
    text-decoration: none;
    color: var(--accent);
}
#site-header .small {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-top: 0.1em;
}

.header-social {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}
.social-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.social-badge svg {
    display: block;
}
.social-badge:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

#theme-toggle {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#theme-toggle:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}
#theme-toggle .icon-sun {
    display: none;
}
html[data-theme="dark"] #theme-toggle .icon-moon {
    display: block;
}
html[data-theme="dark"] #theme-toggle .icon-sun {
    display: none;
}
html[data-theme="light"] #theme-toggle .icon-moon {
    display: none;
}
html[data-theme="light"] #theme-toggle .icon-sun {
    display: block;
}

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 20;
}

/* ---------- Layout: sidebar + main ---------- */
#layout {
    display: flex;
    align-items: flex-start;
    width: 100%;
}

#sidebar {
    flex: none;
    width: 220px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    border-right: 1px solid var(--border);
    min-height: calc(100vh);
}

.sidebar-scroll {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
    padding: 1.75em 1em 2em 1em;
}
#sidebar-close {
    display: none;
}

.sidebar-heading {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.6em;
    font-weight: 600;
}

.sidebar-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35em;
}
.sidebar-nav a {
    display: block;
    color: var(--text-secondary);
    font-size: 0.92em;
    font-weight: 500;
    padding: 0.35em 0.5em;
    border-radius: 6px;
    margin-left: -0.5em;
}
.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
    text-decoration: none;
}

.sidebar-social a {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-social svg {
    flex: none;
    color: var(--text-muted);
}
.sidebar-social a:hover svg {
    color: var(--accent);
}

/* Pinned projects section in the sidebar */
.sidebar-pinned ul {
    gap: 0.7em;
}
.pinned-item a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.4em 0.5em;
}
.pinned-name {
    color: var(--text-primary);
    font-size: 0.92em;
    font-weight: 600;
}
.pinned-desc {
    color: var(--text-muted);
    font-size: 0.78em;
    line-height: 1.4;
    font-weight: 400;
}
.pinned-item a:hover .pinned-name {
    color: var(--accent);
}

/* ---------- Main content ---------- */
#main {
    flex: 1;
    min-width: 0;
    max-width: 760px;
    margin: 0 auto;
    padding: 2.5em 2em 4em;
}

.listing-heading {
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 1.5em;
    font-weight: 600;
}

/* ---------- Preface homepage ---------- */
.preface-intro {
    margin-bottom: 2.5em;
}
.preface-tagline {
    font-size: 1.4em;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 0.6em;
}
.preface-blurb {
    font-size: 1em;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 1.2em;
    max-width: 58ch;
}
.preface-now {
    display: flex;
    align-items: baseline;
    gap: 10px;
    border-left: 3px solid var(--accent);
    padding: 0.2em 0 0.2em 0.9em;
    color: var(--text-secondary);
}
.preface-now-label {
    flex: none;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--accent);
}
.preface-now p {
    margin: 0;
}

.preface-section {
    margin-bottom: 2.5em;
}
.preface-heading {
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 1em;
}

.skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.skill-pill {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.85em;
    font-weight: 500;
}

.preface-projects {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.preface-project-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    color: var(--text-primary);
}
.preface-project-card:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.preface-project-name {
    font-weight: 600;
    font-size: 1em;
}
.preface-project-desc {
    color: var(--text-secondary);
    font-size: 0.88em;
    line-height: 1.5;
}
.preface-project-card .tag-list {
    margin-top: 4px;
}

.preface-cta {
    margin-bottom: 0;
}

.post-card {
    padding: 1.75em 0;
    border-bottom: 1px solid var(--border);
}
.post-card:first-child {
    padding-top: 0;
}

.post-card h2,
.post-full h2 {
    font-size: 1.5em;
    margin-bottom: 0.4em;
    line-height: 1.3;
}
.post-card h2 a,
.post-full h2 a {
    color: var(--text-primary);
}
.post-card h2 a:hover,
.post-full h2 a:hover {
    color: var(--accent);
    text-decoration: none;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 0.75em;
}

.post-summary {
    color: var(--text-secondary);
    margin-bottom: 0.75em;
}

.category-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--accent-tint);
    color: var(--accent);
    font-size: 0.85em;
    font-weight: 500;
}
.category-pill:hover {
    text-decoration: none;
    opacity: 0.85;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tag-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    font-size: 0.8em;
}
.tag-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.tag-pill-small {
    font-size: 0.72em;
    padding: 1px 8px;
}

.footer-tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 1em;
}

/* ---------- Article body ---------- */
.post-full {
    max-width: 100%;
}
.post-full .tag-list {
    margin-bottom: 1.5em;
}

.post-content {
    line-height: 1.75;
}
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    margin: 1.4em 0 0.6em;
    line-height: 1.35;
    color: var(--text-primary);
}
.post-content p {
    margin-bottom: 1em;
}
.post-content ul,
.post-content ol {
    margin: 0 0 1em 1.4em;
}
.post-content img {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin: 1.2em auto;
}
.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.2em 1em;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1em;
}
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
}
.post-content th,
.post-content td {
    text-align: left;
    padding: 0.5em 0.75em;
    border: 1px solid var(--border);
}
.post-content th {
    background: var(--bg-elevated);
}

.post-content code {
    font-family:
        "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: var(--bg-code);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--accent);
}
.post-content pre {
    position: relative;
    font-family:
        "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    line-height: 1.6;
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1em 1.2em;
    overflow-x: auto;
    margin-bottom: 1.4em;
}
.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
}
.copy-code-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.copy-code-btn .icon-check {
    display: none;
    color: var(--accent);
}
.copy-code-btn.copied .icon-copy {
    display: none;
}
.copy-code-btn.copied .icon-check {
    display: block;
}

.back-to-top {
    text-align: center;
    margin-top: 2em;
    font-size: 0.85em;
}

/* ---------- Archive / listing pages ---------- */
.archive-year {
    margin: 1.2em 0 0.5em;
    font-size: 1.1em;
    color: var(--text-primary);
}
.archive-list dd {
    display: flex;
    justify-content: space-between;
    padding: 0.4em 0;
    border-bottom: 1px solid var(--border);
    list-style: none;
}
.archive-list a {
    color: var(--text-primary);
}
.archive-list a:hover {
    color: var(--accent);
}
.archive-date {
    color: var(--text-muted);
    font-size: 0.85em;
    white-space: nowrap;
    margin-left: 1em;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2em;
    margin: 2em 0 0;
    font-size: 0.9em;
    color: var(--text-muted);
}
.page-link {
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 0.35em 0.9em;
    color: var(--text-primary);
}
.page-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

/* ---------- Footer ---------- */
#footer-wrapper {
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    padding: 2em 1.5em;
    text-align: center;
}
.footer-meta {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 2em;
    font-size: 0.8em;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}
.footer-meta a {
    color: var(--text-muted);
}
.footer-meta a:hover {
    color: var(--accent);
}

.align-center {
    text-align: center;
}

/* ---------- Forms (search box, if enabled) ---------- */
input[type="text"],
textarea {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 0.4em 0.6em;
}
input[type="submit"] {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: 6px;
    padding: 0.4em 0.9em;
    cursor: pointer;
}

/* ==========================================================================
   Syntax highlighting (Pygments) — two palettes, switched via [data-theme]
   ========================================================================== */
html[data-theme="dark"] .post-content pre .c,
html[data-theme="dark"] .post-content pre .c1,
html[data-theme="dark"] .post-content pre .cm {
    color: #6b7280;
    font-style: italic;
}
html[data-theme="dark"] .post-content pre .k,
html[data-theme="dark"] .post-content pre .kn,
html[data-theme="dark"] .post-content pre .kd,
html[data-theme="dark"] .post-content pre .kr {
    color: #5dcaa5;
}
html[data-theme="dark"] .post-content pre .s,
html[data-theme="dark"] .post-content pre .s1,
html[data-theme="dark"] .post-content pre .s2,
html[data-theme="dark"] .post-content pre .sb {
    color: #e0a95d;
}
html[data-theme="dark"] .post-content pre .n,
html[data-theme="dark"] .post-content pre .nx {
    color: #e8eaed;
}
html[data-theme="dark"] .post-content pre .nb,
html[data-theme="dark"] .post-content pre .nc,
html[data-theme="dark"] .post-content pre .nf {
    color: #7fb3e0;
}
html[data-theme="dark"] .post-content pre .m,
html[data-theme="dark"] .post-content pre .mi,
html[data-theme="dark"] .post-content pre .mf {
    color: #d987c9;
}
html[data-theme="dark"] .post-content pre .o,
html[data-theme="dark"] .post-content pre .p {
    color: #9aa1ac;
}
html[data-theme="dark"] .post-content pre .err {
    color: #e06c75;
}

html[data-theme="light"] .post-content pre .c,
html[data-theme="light"] .post-content pre .c1,
html[data-theme="light"] .post-content pre .cm {
    color: #96938c;
    font-style: italic;
}
html[data-theme="light"] .post-content pre .k,
html[data-theme="light"] .post-content pre .kn,
html[data-theme="light"] .post-content pre .kd,
html[data-theme="light"] .post-content pre .kr {
    color: #8a5a2a;
    font-weight: 500;
}
html[data-theme="light"] .post-content pre .s,
html[data-theme="light"] .post-content pre .s1,
html[data-theme="light"] .post-content pre .s2,
html[data-theme="light"] .post-content pre .sb {
    color: #3f7d3f;
}
html[data-theme="light"] .post-content pre .n,
html[data-theme="light"] .post-content pre .nx {
    color: #1a1a1a;
}
html[data-theme="light"] .post-content pre .nb,
html[data-theme="light"] .post-content pre .nc,
html[data-theme="light"] .post-content pre .nf {
    color: #2952a3;
}
html[data-theme="light"] .post-content pre .m,
html[data-theme="light"] .post-content pre .mi,
html[data-theme="light"] .post-content pre .mf {
    color: #a3396b;
}
html[data-theme="light"] .post-content pre .o,
html[data-theme="light"] .post-content pre .p {
    color: #666560;
}
html[data-theme="light"] .post-content pre .err {
    color: #c1440e;
}

/* ---------- Responsive ---------- */
/* ---------- Responsive: sidebar becomes an off-canvas drawer ---------- */
@media (max-width: 860px) {
    #sidebar-toggle {
        display: flex;
    }

    #layout {
        display: block;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        background: var(--bg);
        border-right: 1px solid var(--border);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 30;
        overflow: visible;
    }
    html.sidebar-open #sidebar {
        transform: translateX(0);
    }
    html.sidebar-open #sidebar-overlay {
        display: block;
    }

    .sidebar-scroll {
        height: 100%;
        overflow-y: auto;
        padding: 1.75em 1.25em 2em;
    }

    #sidebar-close {
        display: none;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 22px;
        right: -33px;
        width: 33px;
        height: 46px;
        border: 1px solid var(--border);
        border-left: none;
        border-radius: 0 10px 10px 0;
        background: var(--bg);
        color: var(--text-secondary);
        cursor: pointer;
    }
    html.sidebar-open #sidebar-close {
        display: flex;
    }
    #sidebar-close:hover {
        color: var(--text-primary);
    }

    #main {
        max-width: 100%;
        padding: 1.75em 1.25em 3em;
    }
    .post-meta {
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .header-social {
        display: none;
    }
}

@media print {
    #site-header,
    #sidebar,
    #footer-wrapper,
    #sidebar-toggle,
    .pagination {
        display: none;
    }
    body {
        color: #000;
        background: #fff;
    }
}
