:root {
    --html-bg: #1a1a1a;
    --body-bg: rgba(32, 32, 32, 0.85);
    --text: #e0e0e0;
    --text-dim: #888888;
    --accent: #83CA6F;
    --border: #444444;
    --code-bg: #252525;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --grid-color: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] {
    --html-bg: #e8e8e8;
    --body-bg: rgba(250, 250, 245, 0.85);
    --text: #1a1a1a;
    --text-dim: #666666;
    --accent: #008800;
    --border: #cccccc;
    --code-bg: #f5f5f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --grid-color: rgba(0, 0, 0, 0.02);
}

* {
    font-family: 'Source Code Pro', monospace, serif, sans-serif;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: var(--html-bg);
    background-image: repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            var(--grid-color) 2px,
            var(--grid-color) 4px
    ),
    repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            var(--grid-color) 2px,
            var(--grid-color) 4px
    );
    background-size: 100% 100%;
    min-height: 100vh;
    transition: background 0.3s ease;
}

body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--body-bg);
    backdrop-filter: blur(8px);
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    box-shadow: inset 0 0 100px var(--shadow-color),
    0 0 0 1px var(--border);
    transition: background 0.3s ease, color 0.3s ease;

}

/* Wider body for posts with TOC */
body.has-toc {
    max-width: 1300px;
}

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

a:hover {
    text-decoration: underline;
}

/* Header */
.site-header {
    /*font-family: "Source Code Pro", monospace, serif, sans-serif;*/
    /*font-family: 'Monaco', 'Menlo', 'Courier New', monospace;*/
    font-family: 'Source Code Pro', monospace, serif, sans-serif;

    font-size: 18px;
    /*font-weight: bold;*/
    /*color: var(--text);*/

    padding-bottom: 20px;
    margin-bottom: 40px;
    position: relative;
}

.site-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 1px;
    background: var(--border);
    transition: background 0.3s ease;
}

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

.logo {
    font-size: 18px;
    font-weight: bold;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: var(--text-dim);
}

.nav-links a:hover {
    color: var(--accent);
}


/* Theme toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 12px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Typography */
h1 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-dim);
    font-weight: normal;
}

h2 {
    font-size: 20px;
    margin: 30px 0 15px;
    color: var(--text-dim);
    font-weight: normal;
}

h3 {
    font-size: 16px;
    margin: 20px 0 10px;
    color: var(--text-dim);
    font-weight: normal;
}

p {
    font-family: "Inter", sans-serif;
    margin-bottom: 15px;
    font-size: 15px;
    line-height: 1.5;
}

code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: inherit;
    transition: background 0.3s ease;
}

pre {
    background: var(--code-bg);
    padding: 15px;
    overflow-x: auto;
    margin: 20px 0;
    transition: background 0.3s ease;
}

pre code {
    background: none;
    padding: 0;
}

/* Home page */
.intro {
    margin-bottom: 60px;
    font-family: 'Source Code Pro', monospace, serif, sans-serif;
}

.intro h1 {
    margin-bottom: 15px;
}

.intro p {
    color: #5C86DF;
    /*color: #5C86DF(--text-dim);*/
    font-size: 13px;
    font-family: "Source Code Pro", monospace;
}

.recent-posts,
.recent-photos {
    margin-bottom: 60px;
}

.more-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--text-dim);
    font-size: 13px;
}

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

.post-list li {
    margin-bottom: 10px;
    display: flex;
    gap: 15px;
}

.post-list time {
    color: var(--text-dim);
    flex-shrink: 0;
}

/* Post container with TOC sidebar */
.post-container {
    display: flex;
    gap: 40px;
    position: relative;
}

.post {
    flex: 0 1 900px;
    min-width: 0;
    max-width: 900px;
    font-family: "Inter", sans-serif;
}

/* Table of contents */
.toc-wrapper {
    width: 250px;
    flex-shrink: 0;
    background: var(--code-bg);
    padding: 20px;
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease;
    align-self: flex-start;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.toc-heading {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 14px;
}

.toc-wrapper .toc {
    all: unset;
    display: block;
}

.toc-wrapper ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-wrapper li {
    margin-bottom: 8px;
}

.toc-wrapper ul ul {
    margin-top: 5px;
}

.toc-wrapper ul ul li {
    margin-left: 15px;
    font-size: 12px;
}

.toc-wrapper a {
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    display: block;
    line-height: 1.4;
}

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

/* Collapsible TOC sections */
.toc-wrapper li.has-children {
    position: relative;
}

.toc-wrapper .toc-toggle {
    display: inline-block;
    margin-right: 5px;
    font-size: 10px;
    cursor: pointer;
    color: var(--text-dim);
    transition: transform 0.2s ease, color 0.2s ease;
    user-select: none;
}

.toc-wrapper .toc-toggle:hover {
    color: var(--accent);
}

.toc-wrapper li.has-children.expanded > .toc-toggle {
    transform: rotate(90deg);
}

.toc-wrapper li.has-children > ul {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.toc-wrapper li.has-children.expanded > ul {
    max-height: 1000px;
    opacity: 1;
}

.toc-wrapper a.active {
    color: var(--accent);
    font-weight: bold;
}

/* Scrollbar styling for TOC */
.toc-wrapper::-webkit-scrollbar {
    width: 6px;
}

.toc-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.toc-wrapper::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.toc-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Post content */
.post-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    position: relative;
}

.post-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 65%;
    height: 1px;
    background: var(--border);
    transition: background 0.3s ease;
}

.post-header h1 {
    margin-bottom: 10px;
}

.post-header time {
    color: var(--text-dim);
    font-size: 13px;
    transition: color 0.3s ease;
}

.tags {
    margin-top: 10px;
}

.tag {
    display: inline-block;
    background: var(--code-bg);
    padding: 2px 8px;
    margin-right: 5px;
    font-size: 12px;
    border-radius: 3px;
    color: var(--text-dim);
    transition: background 0.3s ease, color 0.3s ease;
}

.post-content {
    margin-bottom: 40px;
    font-family: "Inter", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-size: 15px;
}

.post-content strong {
    color: var(--text);
    font-family: "Inter", sans-serif;
}

.post-content ul,
.post-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

/* Keep code blocks monospaced */
.post-content code,
.post-content pre,
.post-content pre code {
    font-family: 'Source Code Pro', monospace, serif, sans-serif;
    font-size: 13px;
    background: var(--code-bg);
}

/* Photo grid */
/* Photo grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
    grid-auto-flow: dense;
}

.photo-grid-item {
    display: block;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: border-color 0.3s ease;
    background: var(--code-bg);
}

/* Portrait: ~2:3 or taller */
.photo-grid-item.aspect-portrait {
    grid-row: span 2;
    aspect-ratio: 2/3;
}

/* Square: ~1:1 */
.photo-grid-item.aspect-square {
    aspect-ratio: 1/1;
}

/* Landscape: ~3:2 */
.photo-grid-item.aspect-landscape {
    grid-column: span 2;
    aspect-ratio: 3/2;
}

/* Panorama: wider than 1.8:1 */
.photo-grid-item.aspect-panorama {
    grid-column: span 3;
    aspect-ratio: 2.5/1;
}

.photo-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.photo-grid-item:hover img {
    transform: scale(1.05);
}

.photo-title {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: var(--body-bg);
    backdrop-filter: blur(4px);
    color: var(--text);
    font-size: 13px;
    transition: background 0.3s ease, color 0.3s ease;
}

.photo-location {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    padding: 4px 12px;
    color: var(--text-dim);
    font-size: 11px;
}

/* Photo post */
.photo-post .post-header {
    margin-bottom: 20px;
}

.photo-post .location {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 5px;
}

.photo-main {
    margin-bottom: 30px;
}

.photo-main img {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    transition: border-color 0.3s ease;
}

.photo-main figcaption {
    margin-top: 10px;
    color: var(--text-dim);
    font-size: 13px;
    font-style: italic;
    transition: color 0.3s ease;
}

.photo-meta {
    margin-bottom: 30px;
    padding: 15px;
    background: var(--code-bg);
    transition: background 0.3s ease;
}

.photo-meta p {
    margin-bottom: 5px;
    font-size: 13px;
}

.meta-label {
    color: var(--text-dim);
}

/* Footer */
.site-footer {
    margin-top: 80px;
    padding-top: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    position: relative;
}

.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 1px;
    background: var(--border);
    transition: background 0.3s ease;
}

/* Responsive */
@media (max-width: 1200px) {
    /* Hide TOC on tablets and smaller */
    .toc-wrapper {
        display: none;
    }

    .post-container {
        display: block;
    }

    body.has-toc {
        max-width: 900px;
    }

    .post {
        max-width: 100%;
    }
}

@media (max-width: 900px) {
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    /* Reduce spans on tablets */
    .photo-grid-item.aspect-panorama {
        grid-column: span 2;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 13px;
        padding: 15px;
    }

    .post-list li {
        flex-direction: column;
        gap: 5px;
    }

    .photo-grid {
        grid-template-columns: 1fr;
    }

    /* Reset spans on mobile */
    .photo-grid-item.aspect-landscape,
    .photo-grid-item.aspect-panorama {
        grid-column: span 1;
    }

    .photo-grid-item.aspect-portrait {
        grid-row: span 1;
    }
}

/* Syntax Highlighting */
/* Base styles for code blocks */
pre[class*="language-"] {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    /*display: inline-block;*/
}

code[class*="language-"],
pre[class*="language-"] {
    color: var(--text);
    text-shadow: none;
    display: inline-block;
    background: var(--code-bg);
    font-family: 'Source Code Pro', monospace, serif, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    /*padding: 2px 6px;*/
    /*border-radius: 3px;*/
    /*transition: background 0.3s ease;*/
}

/* Dark theme syntax colors */
:root {
    --syntax-comment: #6a9955;
    --syntax-keyword: #c586c0;
    --syntax-string: #ce9178;
    --syntax-function: #dcdcaa;
    --syntax-number: #b5cea8;
    --syntax-operator: #d4d4d4;
    --syntax-class: #4ec9b0;
    --syntax-punctuation: #d4d4d4;
    --syntax-property: #9cdcfe;
}

[data-theme="light"] {
    --syntax-comment: #008000;
    --syntax-keyword: #af00db;
    --syntax-string: #a31515;
    --syntax-function: #795e26;
    --syntax-number: #098658;
    --syntax-operator: #000000;
    --syntax-class: #267f99;
    --syntax-punctuation: #000000;
    --syntax-property: #001080;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: var(--syntax-comment);
    font-style: italic;
}

.token.keyword,
.token.tag,
.token.boolean,
.token.constant {
    color: var(--syntax-keyword);
}

.token.string,
.token.attr-value,
.token.template-string,
.token.char {
    color: var(--syntax-string);
}

.token.function,
.token.function-name {
    color: var(--syntax-function);
}

.token.number {
    color: var(--syntax-number);
}

.token.operator,
.token.entity,
.token.url {
    color: var(--syntax-operator);
}

.token.class-name,
.token.type-hint {
    color: var(--syntax-class);
}

.token.punctuation {
    color: var(--syntax-punctuation);
}

.token.property,
.token.variable,
.token.attr-name {
    color: var(--syntax-property);
}

.token.selector,
.token.important,
.token.atrule {
    color: var(--syntax-keyword);
    font-weight: bold;
}

.token.builtin {
    color: var(--syntax-class);
}

.token.deleted {
    color: #ce9178;
}

.token.inserted {
    color: #b5cea8;
}

.token.italic {
    font-style: italic;
}

.token.bold {
    font-weight: bold;
}
