@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:ital,wght@0,400;0,700;1,400&display=swap');

html {
    scroll-behavior: smooth;
}

:root {
    --bg-color: #ffffff;
    --section-bg: #f8fafc;
    --header-bg: #e0f2fe;
    --header-text: #0f172a;
    --header-link: #475569;
    --text-color: #334155;
    --heading-color: #0f172a;
    --accent-color: #2563eb;
    --muted-color: #64748b;
    --border-color: #bae6fd;
    --code-keyword: #d73a49;
    --code-string: #032f62;
    --code-comment: #6a737d;
    --code-name: #24292e;
    --code-func: #6f42c1;
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-serif: 'Lora', Georgia, serif;
    --max-width: 720px;

    --notice-info-bg: #e0f2fe;
    --notice-info-border: #0ea5e9;
    --notice-warning-bg: #ffedd5;
    --notice-warning-border: #f97316;
    --notice-tip-bg: #d1fae5; /* Green for Tip */
    --notice-tip-border: #10b981;
    --notice-note-bg: #dbeafe; /* Blue for Note */
    --notice-note-border: #3b82f6;
    --notice-important-bg: #fee2e2; /* Red for Important */
    --notice-important-border: #ef4444;
}

/* Dark Mode Overrides */
html[data-theme='dark'] {
    --bg-color: #0f172a;
    --section-bg: #1e293b;
    --header-bg: #1e293b;
    --header-text: #f8fafc;
    --header-link: #cbd5e1;
    --text-color: #cbd5e1;
    --heading-color: #f8fafc;
    --accent-color: #38bdf8;
    --muted-color: #94a3b8;
    --border-color: #334155;
    --code-keyword: #ff7b72;
    --code-string: #a5d6ff;
    --code-comment: #8b949e;
    --code-name: #c9d1d9;
    --code-func: #d2a8ff;

    --notice-info-bg: #082f49;
    --notice-warning-bg: #431407;
    --notice-tip-bg: #064e3b;
    --notice-note-bg: #1e3a8a;
    --notice-important-bg: #7f1d1d;
}

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

body {
    font-family: var(--font-ui);
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header - Magazine Layout */
.site-header {
    background-color: var(--header-bg);
    padding: 1.5rem 0 1rem 0;
    margin-bottom: 2.5rem;
    transition: background-color 0.3s ease;
}

header nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

header h1 a {
    text-decoration: none;
    color: var(--header-text);
}

.nav-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding-top: 1rem;
    position: relative;
}

html[data-theme="dark"] .nav-bottom {
    border-top: 1px solid rgba(255,255,255,0.05);
}

header ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
}

header ul li a {
    text-decoration: none;
    color: var(--header-link);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s ease;
}

header ul li a:hover {
    color: var(--accent-color);
}

/* Move theme toggle to the top right */
.theme-toggle {
    position: absolute;
    right: 0;
    top: -3rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--header-link);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--accent-color);
}

html[data-theme='dark'] .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Icons */
.sun-icon, .moon-icon { width: 18px; height: 18px; }
.sun-icon { display: none; }
.moon-icon { display: block; }

html[data-theme='dark'] .sun-icon { display: block; }
html[data-theme='dark'] .moon-icon { display: none; }

/* Main Content Area */
.site-main {
    min-height: 60vh;
}

/* Headings */
h1, h2, h3, h4 {
    font-family: var(--font-ui);
    color: var(--heading-color);
    line-height: 1.25;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

h1 { font-size: 2.2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; letter-spacing: -0.01em; }

/* Links */
a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Post List */
.post-list {
    list-style: none;
    padding: 0;
}

.post-item {
    margin-bottom: 3rem;
}

.post-date {
    font-size: 0.8rem;
    color: var(--muted-color);
    margin-bottom: 0.25rem;
    display: block;
    font-weight: 500;
}

.post-title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.post-title a {
    color: var(--heading-color);
}

.post-title a:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.post-summary {
    color: var(--muted-color);
    font-size: 1rem;
    line-height: 1.6;
}

/* Intro Section */
.intro {
    margin-bottom: 4rem;
}

.intro h2 {
    margin-top: 0;
    font-size: 2.5rem;
}

.intro p {
    font-size: 1.1rem;
    color: var(--muted-color);
    max-width: 540px;
    line-height: 1.5;
}

/* Single Post Content */
article header {
    margin-bottom: 3rem;
}

.post-meta {
    font-size: 0.9rem;
    color: var(--muted-color);
}

.content {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: inherit;
}

.content p {
    margin-bottom: 1.5rem;
}

.content ul, .content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.content li {
    margin-bottom: 0.5rem;
}

.content ul { list-style-type: disc; }
.content ol { list-style-type: decimal; }

.content blockquote {
    border-left: 3px solid var(--accent-color);
    margin: 2rem 0;
    padding: 0.5rem 0 0.5rem 1.5rem;
    font-style: italic;
    color: var(--muted-color);
}

.content blockquote p:last-child {
    margin-bottom: 0;
}

.content img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2.5rem 0;
}

/* Notices / Callouts (Custom Shortcode) */
.notice {
    padding: 1.5rem;
    margin: 2rem 0;
    border-left: 4px solid;
    border-radius: 4px;
}

.notice-title {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.notice.info {
    background-color: var(--notice-info-bg);
    border-color: var(--notice-info-border);
}

.notice.warning {
    background-color: var(--notice-warning-bg);
    border-color: var(--notice-warning-border);
}

/* AsciiDoc Admonitions */
.admonitionblock {
    margin: 2rem 0;
}

.admonitionblock td.icon .icon-note:before {
    content: "\f05a"; /* FontAwesome info-circle */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: var(--notice-note-border);
}
.admonitionblock td.icon .icon-tip:before {
    content: "\f0eb"; /* FontAwesome lightbulb */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: var(--notice-tip-border);
}
.admonitionblock td.icon .icon-warning:before {
    content: "\f071"; /* FontAwesome exclamation-triangle */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: var(--notice-warning-border);
}
.admonitionblock td.icon .icon-important:before {
    content: "\f06a"; /* FontAwesome exclamation-circle */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: var(--notice-important-border);
}

.admonitionblock table {
    width: 100%;
    border-collapse: collapse;
}

.admonitionblock td.content {
    padding: 1.5rem;
    border-left: 4px solid;
    border-radius: 4px;
    background-color: var(--notice-note-bg); /* Default to note background */
}

.admonitionblock.note td.content {
    background-color: var(--notice-note-bg);
    border-color: var(--notice-note-border);
}
.admonitionblock.tip td.content {
    background-color: var(--notice-tip-bg);
    border-color: var(--notice-tip-border);
}
.admonitionblock.warning td.content {
    background-color: var(--notice-warning-bg);
    border-color: var(--notice-warning-border);
}
.admonitionblock.important td.content {
    background-color: var(--notice-important-bg);
    border-color: var(--notice-important-border);
}

.admonitionblock td.icon {
    vertical-align: top;
    padding-right: 1rem;
}

.admonitionblock td.icon .title {
    display: none; /* Hide default title */
}

/* Utilities */
.text-center {
    text-align: center;
}

.content pre {
    background: var(--section-bg);
    color: var(--code-name);
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9rem;
    margin: 2rem 0;
    line-height: 1.5;
    border: 1px solid var(--border-color);
}

.chroma .k { color: var(--code-keyword); font-weight: bold; }
.chroma .s { color: var(--code-string); }
.chroma .c { color: var(--code-comment); font-style: italic; }
.chroma .n { color: var(--code-name); }
.chroma .nf { color: var(--code-func); }
.chroma .m { color: var(--code-keyword); }

.content code {
    background: var(--section-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--heading-color);
}

/* Pagination */
.pagination {
    display: flex;
    list-style: none;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 3rem;
    padding: 0;
}

.pagination li a {
    display: block;
    padding: 0.4rem 0.8rem;
    background: var(--section-bg);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.pagination li.active a, .pagination li a:hover {
    background: var(--accent-color);
    color: white;
}

/* Table of Contents */
.post-toc {
    background-color: var(--section-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.post-toc h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--heading-color);
}

.post-toc ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.post-toc ul ul {
    padding-left: 1rem;
}

.post-toc li {
    margin-bottom: 0.5rem;
}

.post-toc a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-toc a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Single Post Layout with Sidebar TOC */
.single-post-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 1200px) {
    body.single-post .container {
        max-width: 1100px;
    }

    .single-post-layout {
        flex-direction: row-reverse;
        justify-content: center;
        align-items: flex-start;
        gap: 4rem;
    }

    .single-post-layout .content {
        flex: 0 1 var(--max-width);
        width: var(--max-width);
    }

    .post-toc {
        position: sticky;
        top: 4rem;
        width: 280px;
        flex: 0 0 280px;
        margin-bottom: 0;
        max-height: calc(100vh - 8rem);
        overflow-y: auto;
    }
}

/* Back to Top Button - Vertically Centered */
.back-to-top {
    position: fixed;
    top: 50%;
    right: 2rem;
    background-color: var(--accent-color);
    color: #ffffff !important;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    transform: translateY(-50%);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    stroke: #ffffff;
}

.back-to-top:hover {
    transform: translateY(-50%) translateY(-4px);
    background-color: var(--heading-color);
}

/* Footer */
.site-footer {
    background-color: var(--section-bg);
    border-top: 1px solid var(--border-color);
    margin-top: 6rem;
    padding: 4rem 0;
    color: var(--muted-color);
    font-size: 0.85rem;
    transition: background-color 0.3s ease;
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-right {
    display: flex;
    gap: 1.5rem;
}

.site-footer a {
    color: var(--muted-color);
    font-weight: 500;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--accent-color);
}

/* Responsive */
@media (max-width: 768px) {
    .site-header { padding: 0.75rem 0; }
    header nav { flex-direction: row; gap: 0; }
    .nav-right { gap: 1rem; }
    header ul { gap: 1rem; }
    h1 { font-size: 1.8rem; }
    .intro { flex-direction: column; text-align: center; gap: 1.5rem; }
    .intro h2 { font-size: 2.2rem; }
    .site-footer .container {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    .back-to-top {
        top: 50%;
        bottom: auto;
        right: 1.5rem;
        transform: translateY(-50%);
    }
    .back-to-top:hover {
        transform: translateY(-50%) translateY(-4px);
    }
}
