:root {
    color-scheme: dark;
    --color-background: #0d1117;
    --color-surface: #161b22;
    --color-border: #30363d;
    --color-text: #c9d1d9;
    --color-text-dim: #8b949e;
    --color-primary: #1aff7e;
    --color-accent-bg: rgba(26, 255, 126, 0.12);
    --font-main: '3270 Nerd Font', 'IBM 3270', '3270', monospace;
}

/* Base Reset & Globals */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    background-color: var(--color-background);
    color: var(--color-text);
    font-family: var(--font-main);
    margin: 0;
}

img,
svg,
iframe,
video {
    max-width: 100%;
    height: auto;
}

/* Layout & Grid System */
.homepage-grid,
.centered-page-grid {
    display: grid;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    align-items: start;
}

.homepage-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
}

.centered-page-grid {
    grid-template-columns: minmax(0, 0.5fr) minmax(0, 4fr) minmax(0, 0.5fr);
}

.left-col,
.right-col {
    min-width: 0;
    overflow: hidden;
}

.center-col {
    grid-column: 2;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.bottom-image img {
    width: 100%;
    border-radius: 8px;
    margin-top: 2rem;
}

.social-links a {
    margin: 0 0.5rem;
    font-weight: bold;
}

/* Navigation & Inline Text Links */
.post-title-link,
.navitem,
.social-links a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease, padding 0.15s ease;
    border-radius: 3px;
}

.post-title-link:hover,
.navitem:hover,
.social-links a:hover {
    color: var(--color-primary);
}

.markdown-body a,
.center-col a,
.left-col a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: background-color 0.15s ease, padding 0.15s ease;
    border-radius: 3px;
}

.markdown-body a:hover,
.center-col a:hover,
.left-col a:hover {
    background-color: var(--color-accent-bg);
}

/* Sidebar & Card Feed Components */
.right-col h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.post-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    display: block;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.post-card:hover {
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.02);
}

.post-card h3,
.text-card h4 {
    margin: 0 0 0.35rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--color-text);
    text-align: left;
}

.post-snippet {
    font-size: 0.8rem;
    color: var(--color-text-dim);
    margin: 0.4rem 0 0 0;
    line-height: 1.4;
    text-align: left;
}

.tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
    align-items: center;
}

.tags-row .tag {
    font-size: 0.7rem;
    font-family: var(--font-main);
    background: rgba(110, 118, 129, 0.15);
    color: var(--color-text-dim);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.photo-card img {
    width: 100%;
    border-radius: 6px;
    display: block;
    margin-bottom: 0.5rem;
}

.photo-caption {
    font-size: 0.8rem;
    color: var(--color-text-dim);
}

/* Markdown Content & Typography */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 3rem;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child {
    margin-top: 0;
}

.markdown-body p {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 6px;
}

/* Blockquotes */
.markdown-body blockquote {
    margin: 1.25rem 0;
    padding: 0.25rem 0 0.25rem 1rem;
    border-left: 3px solid #ff8a00;
    background: transparent;
    color: var(--color-text-dim);
}

.markdown-body blockquote p {
    margin: 0;
    font-size: 0.95rem;
    font-style: italic;
    line-height: 1.5;
    color: var(--color-text);
}

/* GitHub Style Alerts */
.markdown-body blockquote.markdown-alert {
    padding: 0.5rem 1rem;
    margin: 1.5rem 0;
    color: var(--color-text);
    border: none;
    border-left: 3px solid var(--color-border);
}

.markdown-body blockquote.markdown-alert p {
    font-style: normal;
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}

.markdown-body blockquote.markdown-alert p:last-child {
    margin-bottom: 0;
}

.markdown-alert-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.markdown-body blockquote.markdown-alert-note {
    border-left-color: #00d8ff;
}

.markdown-alert-note .markdown-alert-title {
    color: #00d8ff;
}

.markdown-body blockquote.markdown-alert-tip {
    border-left-color: #00ff66;
}

.markdown-alert-tip .markdown-alert-title {
    color: #00ff66;
}

.markdown-body blockquote.markdown-alert-important {
    border-left-color: #df80ff;
}

.markdown-alert-important .markdown-alert-title {
    color: #df80ff;
}

.markdown-body blockquote.markdown-alert-warning {
    border-left-color: #ffcc00;
}

.markdown-alert-warning .markdown-alert-title {
    color: #ffcc00;
}

.markdown-body blockquote.markdown-alert-caution {
    border-left-color: #ff3333;
}

.markdown-alert-caution .markdown-alert-title {
    color: #ff3333;
}

/* Code Blocks & Captions */
code {
    background-color: rgba(255, 255, 255, 0.15);
    color: #e6e6e6;
    font-family: var(--font-main);
    font-size: 0.85em;
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

pre,
code {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
    font-size: 1em;
}

.markdown-body pre {
    position: relative;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem;
    margin: 1.5rem 0;
}

.markdown-body pre.has-caption {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
    border-bottom: none;
}

.code-wrapper {
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
}

.markdown-body .code-wrapper pre {
    margin: 0;
    border: none;
    border-radius: 0;
}

.code-caption-bar {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 0.6rem 1.25rem;
    font-family: var(--font-main);
    font-size: 0.8rem;
    color: var(--color-text-dim);
    margin-bottom: 1.5rem;
}

.code-caption {
    background-color: #21252b;
    color: #abb2bf;
    padding: 0.5rem 1rem;
    font-family: var(--font-main);
    font-size: 0.85rem;
    border-top: 1px solid #181a1f;
}

/* Lightbox Component */
#lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(5, 5, 5, 0.92);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.lightbox-content-wrapper {
    position: relative;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 4px;
    object-fit: contain;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

#lightbox-caption {
    margin-top: 1.5rem;
    color: var(--color-text-dim);
    font-family: var(--font-main);
    font-size: 0.9rem;
    text-align: center;
}

.lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    user-select: none;
    padding: 1rem;
    transition: color 0.2s;
}

.lightbox-btn:hover {
    color: var(--color-text-dim);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2.5rem;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: var(--color-text-dim);
}

.markdown-body img,
.bottom-image img,
.photo-card img {
    cursor: zoom-in;
}

/* Responsive Breakpoints */
@media (max-width: 1199px) {

    .markdown-body blockquote.markdown-alert,
    blockquote.markdown-alert {
        float: none;
        clear: both;
        width: 100%;
        margin: 1.25rem 0;
    }
}

@media (max-width: 900px) {

    .lightbox-prev,
    .lightbox-next {
        display: none;
    }

    .homepage-grid,
    .centered-page-grid {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 2rem;
        padding: 0;
        margin: 0;
    }

    aside,
    .left-col {
        display: none;
    }

    .right-col {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 0 1.25rem;
        box-sizing: border-box;
        order: 2;
    }

    .center-col,
    article {
        width: 100%;
        max-width: 100%;
        padding: 0 1.25rem;
        box-sizing: border-box;
        margin: 0 auto;
        order: 1;
    }

    .center-col p,
    article p {
        text-align: left;
        overflow-wrap: break-word;
    }

    body footer,
    body #footer,
    body .site-footer,
    body .footer {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        align-content: flex-start;
        padding: 1rem 1.25rem 2rem 1.25rem;
        box-sizing: border-box;
        width: 100%;
        gap: 0.75rem 0.5rem;
        order: 3;
    }

    body footer br,
    body #footer br,
    body .site-footer br {
        display: none;
    }

    body footer>div,
    body footer>p,
    body footer>nav,
    body footer>section,
    body #footer>div,
    body .site-footer>div {
        flex: 0 0 100%;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 0.5rem;
        margin: 0;
        padding: 0;
    }

    body footer a,
    body #footer a,
    body .site-footer a {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
        margin: 0;
    }

    body footer img,
    body footer svg {
        display: block;
        margin: 0;
    }

    body footer *,
    body #footer *,
    body .site-footer * {
        text-align: left;
    }
}
