/* ========================================================= */
/* == Blog Styles for faray.tech                          == */
/* == Themes: Light (default), Dark, Colorful             == */
/* ========================================================= */

/* --- Theme Tokens (Light Theme Default) --- */
:root {
    /* Brand accents */
    --accent: #8b5cf6;
    --accent-2: #6944ab;
    --accent-glow: rgba(139, 92, 246, 0.10);
    --focus: #f7e40b;

    /* Surfaces & text */
    --bg-0: #fafafa;
    --surface: #ffffff;
    --surface-2: #f1f1f6;
    --sidebar-bg: #eeeeee;
    --text: #212529;
    --text-2: #495057;
    --muted: #6c757d;
    --line: #dee2e6;

    /* Header */
    --header-bg: rgba(255, 255, 255, 0.82);
    --header-link: #212529;
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.12);

    /* Code */
    --code-bg: #e9ecef;
    --code-text: #141414;
    --pre-bg: #f1f1f1;
    --pre-text: #212529;
    --code-header-bg: rgba(0, 0, 0, 0.04);

    /* Syntax highlighting */
    --syn-comment: #6a737d;
    --syn-keyword: #7c3aed;
    --syn-string: #0b5394;
    --syn-attr: #005cc5;
    --syn-value: #22863a;
    --syn-tag: #c2185b;
    --syn-number: #b45309;
    --syn-function: #0e7490;
    --syn-property: #7c3aed;

    /* Callouts */
    --info: #3b82f6;
    --warning: #f59e0b;
    --success: #22c55e;
    --callout-info-bg: rgba(59, 130, 246, 0.08);
    --callout-info-border: rgba(59, 130, 246, 0.3);
    --callout-info-text: #1d4ed8;
    --callout-warning-bg: rgba(245, 158, 11, 0.08);
    --callout-warning-border: rgba(245, 158, 11, 0.3);
    --callout-warning-text: #92600a;
    --callout-success-bg: rgba(34, 197, 94, 0.08);
    --callout-success-border: rgba(34, 197, 94, 0.3);
    --callout-success-text: #15803d;

    /* Layout metrics */
    --header-h: 64px;     /* set via JS */
    --radius-xl: 30px;

    color-scheme: light;
}

/* --- Dark Theme Tokens --- */
html[data-theme='dark'] {
    --accent: #976cf6;
    --accent-glow: rgba(139, 92, 246, 0.15);
    --bg-0: #0b0c11;
    --surface: #11131a;
    --surface-2: #1a1a23;
    --sidebar-bg: #131218;
    --text: #e9e9f3;
    --text-2: #dfe0e1;
    --muted: #8f93a6;
    --line: rgba(255, 255, 255, 0.16);
    --header-bg: rgba(15, 17, 23, 0.55);
    --header-link: #ffffff;
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.45);
    --code-bg: #16161e;
    --code-text: #c4b5fd;
    --pre-bg: #16161e;
    --pre-text: #e0def4;
    --code-header-bg: rgba(42, 42, 61, 0.5);
    --syn-comment: #6272a4;
    --syn-keyword: #c4b5fd;
    --syn-string: #a5d6ff;
    --syn-attr: #7dd3fc;
    --syn-value: #86efac;
    --syn-tag: #f9a8d4;
    --syn-number: #fbbf24;
    --syn-function: #67e8f9;
    --syn-property: #c4b5fd;
    --callout-info-text: #93c5fd;
    --callout-warning-text: #fcd34d;
    --callout-success-text: #86efac;

    color-scheme: dark;
}

/* --- Colorful Theme Tokens --- */
html[data-theme='colorful'] {
    --accent: #5908ed;
    --accent-2: #0e7490;
    --accent-glow: rgba(255, 255, 255, 0.35);
    --bg-0: transparent; /* body carries gradient */
    --surface: rgba(255, 255, 255, 0.92);
    --surface-2: rgba(255, 255, 255, 0.55);
    --sidebar-bg: transparent; /* sidebar carries gradient */
    --text: #111111;
    --text-2: #2d2d2d;
    --muted: #404040;
    --line: #87ceab;
    --header-bg: rgba(255, 255, 255, 0.6);
    --header-link: #111111;
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.25);
    --code-bg: #fffacd;
    --code-text: #8b0000;
    --pre-bg: #efefc7;
    --pre-text: #333333;
    --code-header-bg: rgba(0, 0, 0, 0.06);
    --syn-comment: #6a737d;
    --syn-keyword: #6d36d1;
    --syn-string: #0b5394;
    --syn-attr: #005cc5;
    --syn-value: #1e7e34;
    --syn-tag: #c2185b;
    --syn-number: #b45309;
    --syn-function: #0e7490;
    --syn-property: #6d36d1;
    --info: #00a4ee;
    --warning: #ff2001;
    --success: #00ee76;
    --callout-info-bg: rgba(59, 130, 246, 0.25);
    --callout-info-border: rgba(59, 130, 246, 0.4);
    --callout-info-text: #0d1e38;
    --callout-warning-bg: rgba(245, 158, 11, 0.25);
    --callout-warning-border: rgba(245, 158, 11, 0.4);
    --callout-warning-text: #221003;
    --callout-success-bg: rgba(34, 197, 94, 0.25);
    --callout-success-border: rgba(34, 197, 94, 0.4);
    --callout-success-text: #053c21;
}

/* --- Base & General Styling --- */
html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

html.reduced-motion {
    scroll-behavior: auto;
}

body {
    margin: 0;
    background: var(--bg-0);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Body background per theme */
html[data-theme='dark'] body {
    background:
        radial-gradient(1200px 800px at 12% 10%, #1b1440 0%, transparent 60%),
        radial-gradient(1000px 900px at 85% 10%, #0b3b4a 0%, transparent 55%),
        linear-gradient(180deg, #11131a 0%, #0b0c11 100%);
    background-attachment: fixed;
}

html[data-theme='colorful'] body {
    background: radial-gradient(circle at 100%, #4CA2CD -50%, #38BF7D 50%, #67B281 75%, #11998E 110%);
    background-attachment: fixed;
    color: #030509;
}

button {
    font-family: inherit;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

img, video {
    display: block;
    max-width: 100%;
}

::selection {
    background: rgba(139, 92, 246, 0.35);
}

/* --- Accessibility --- */
.skip-link {
    position: absolute;
    left: 12px;
    top: -50px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 10px;
    color: var(--text);
    transition: top .2s ease;
    z-index: 9999;
}
.skip-link:focus, .skip-link:focus-visible {
    top: 12px;
    outline: 2px solid var(--focus);
}
#main-content:focus {
    outline: none;
}
a:focus-visible, button:focus-visible, select:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

/* --- Background Accents --- */
.bg-accents {
    position: fixed;
    inset: -10vh -10vw auto -10vw;
    pointer-events: none;
    z-index: -1;
}
.bg-accents .glow {
    position: absolute;
    filter: blur(80px);
    opacity: 0.18;
    background: radial-gradient(closest-side, var(--accent), transparent);
    width: 40vw;
    height: 40vw;
    border-radius: 9999px;
}
.bg-accents .glow-a { top: 8vh; left: -10vw; }
.bg-accents .glow-b {
    top: 18vh;
    right: -12vw;
    background: radial-gradient(closest-side, var(--accent-2), transparent);
}
html[data-theme='colorful'] .bg-accents {
    display: none; /* body already carries a gradient */
}

/* --- Containers --- */
.container {
    max-width: 1432px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* ========================================================= */
/* == Top Navigation Bar                                  == */
/* ========================================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border: 3px solid var(--line);
    border-image: linear-gradient(
        90deg,
        transparent 0%,
        transparent 2%,
        var(--accent) 2%,
        var(--accent-2) calc(2% + (var(--scroll-progress, 0%) * 0.96)),
        var(--line) calc(2% + (var(--scroll-progress, 0%) * 0.96)),
        var(--line) 98%,
        transparent 98%,
        transparent 100%
    ) 1;
    transition: box-shadow .25s ease, background .25s ease;
}
.site-header.scrolled {
    box-shadow: var(--shadow-soft);
}
.header-inner {
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Single header row (hamburger + brand + nav) */
.header-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-row .fill {
    flex: 1 1 auto;
	width: var(-52px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    padding: 5px;
    color: var(--header-link);
}
.brand:hover {
    text-decoration: none;
}
.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent));
    box-shadow: 0 0 0 2px rgba(255,255,255,0.06), 0 6px 20px rgba(139,92,246,0.35);
}
.brand-word {
    font-size: 16px;
    font-family: 'Fira Code', monospace;
    opacity: .95;
}
.brand-word:hover {
    transition: text-shadow 0.3s ease-in-out;
    text-shadow: 0 0 20px var(--accent);
}

.primary-nav {
    display: inline-flex;
    gap: 18px;
}

.nav-link {
    position: relative;
    color: var(--header-link);
    padding: 8px 10px;
    border-radius: 12px;
    transition: color 0.2s ease, background 0.2s ease;
}
.nav-link:hover {
    text-decoration: none;
}

/* Underline effect */
.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 100%;
    height: 2px;
    background-color: var(--header-link);
    opacity: 0;
    transform: scaleX(0) scaleY(0.5);
    transform-origin: center;
    transition: transform 0.2s ease-out, opacity 0.2s ease-in;
}

.link-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.02);
    color: var(--header-link);
    transition: border-color .2s ease, background .2s ease;
}
.link-pill:hover {
    background: rgba(139,92,246,0.18);
    border-color: rgba(139,92,246,0.75);
    text-decoration: none;
}

/* Hamburger button (for all screen sizes) */
.hamburger {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .02);
    cursor: pointer;
    transition: border-color .2s, background .2s;
    flex-shrink: 0;
}
.hamburger:hover {
    border-color: rgba(139, 92, 246, .45);
    background: rgba(139, 92, 246, .12);
}

/* The three bars */
.hamburger span {
    position: absolute;
    width: 20px;
    height: 2px;
    background: var(--header-link);
    border-radius: 2px;
    transform-origin: center;
    transition: transform 0.25s ease-in-out, opacity 0.25s ease-in-out;
}
.hamburger span:nth-child(1) { transform: translateY(-7px); }
.hamburger span:nth-child(3) { transform: translateY(7px); }

/* Animated "X" state */
.hamburger.is-active span:nth-child(1) { transform: translateY(0) rotate(45deg); }
.hamburger.is-active span:nth-child(2) { opacity: 0; }
.hamburger.is-active span:nth-child(3) { transform: translateY(0) rotate(-45deg); }

/* --- Language Switcher (from styles.css) --- */
.lang-cube {
    display: inline-flex;
    flex-direction: column;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .02);
    vertical-align: middle;
}
.lang-option {
    padding: 1px 0px 2px;
    width: 50px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    transition: background-color .2s ease, color .2s ease;
}
.lang-option:not(:first-child) {
    border-top: 1px solid var(--line);
}
a.lang-option {
    color: var(--muted);
}
a.lang-option:hover {
    background-color: rgba(139, 92, 246, .12);
    color: var(--text);
    text-decoration: none;
}
.lang-option.is-active {
    color: var(--text);
    background-color: rgba(255, 255, 255, 0.05);
    cursor: default;
}

/* Floating header (from styles.css) */
@media (min-width: 1200px) {
    .site-header {
        top: -1px;
        left: 10%;
        width: 80%;
        border-radius: 20px;
    }
}

/* ========================================================= */
/* == Blog Post Sidebar                                   == */
/* ========================================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1030;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

body.sidebar-is-open {
    overflow: hidden;
}
body.sidebar-is-open .sidebar {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1025;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
body.sidebar-is-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* --- Sidebar Header & Footer --- */
.sidebar-header {
    text-align: center;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.sidebar-header:hover {
    color: var(--accent);
    text-decoration: none;
}

.sidebar-footer {
    padding: 20px 20px 18px 20px;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}
.sidebar-footer .text-muted {
    color: var(--muted);
    font-size: 0.9em;
    margin: 0;
}
.side-legal a, .side-legal span { font-size: 0.9rem; color: var(--text-2); }
.side-copyright { font-size: 0.9em; }

.theme-switch-cont { margin-bottom: 12px; }
.theme-switch-cont label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.85rem;
}

#theme-switcher {
    width: 100%;
    padding: 5px 8px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    box-sizing: border-box;
}

/* --- Sidebar Navigation --- */
.sidebar-inner {
    padding: 1rem 1rem 0rem 1rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 1.5rem;
}
/* The year heading */
.nav-group-title {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text);
    opacity: 0.7;
    margin: 0 0 0.75rem 0;
    padding-left: 0.5rem;
}

.nav-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-group li a {
    display: block;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--text-2);
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}
.nav-group li a:hover {
    background: var(--accent-glow);
    color: var(--text);
    text-decoration: none;
}
.nav-group li a.active {
    background: var(--accent-glow);
    color: var(--text);
    font-weight: 600;
    border-left: 2px solid var(--accent);
}

/* Date shown below a post title */
.nav-group .post-date {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
}

/* --- Sidebar Side Links --- */
.side-link-section {
    flex-shrink: 0;
    border-top: 1px solid var(--line);
}
.side-link-big {
    display: block;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}
.side-link-big:hover {
    background: var(--accent-glow);
    text-decoration: none;
}

/* ========================================================= */
/* == Blog Layout                                         == */
/* ========================================================= */
.blog-main {
    flex-grow: 1;
    width: 100%;
}

/* Article column + chapter navigation column */
.blog-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 4rem;
}

/* Reading Progress Bar */
.progress-bar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    z-index: 1001;
    transition: width 0.1s linear;
}

/* ========================================================= */
/* == Article Header                                      == */
/* ========================================================= */

.article-header {
    max-width: 800px;
    margin: 0 auto;
    padding: 3.5rem 2rem 1.5rem;
}

.article-title {
    font-size: clamp(2rem, 4.5vw, 2.8rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin: 0 0 1.25rem 0;
    color: var(--text);
    background: linear-gradient(135deg, var(--text) 0%, var(--text-2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.article-subtitle {
    font-size: 1.2rem;
    color: var(--text-2);
    line-height: 1.6;
    margin: 0 0 2rem 0;
}

.article-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    font-size: 0.92rem;
    color: var(--text-2);
}
.article-meta .meta-label {
    color: var(--text);
}
.article-meta .meta-value {
    color: var(--text);
    font-weight: 600;
}
.article-meta .meta-sep {
    color: var(--muted);
    opacity: 0.6;
}

/* Share button */
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.9rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent-2);
    border: 1px solid var(--accent);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}
.share-btn:hover {
    background: #7c3aed;
    border-color: #7c3aed;
    transform: translateY(-1px);
}
.share-btn:active {
    transform: scale(0.97);
}
.share-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    flex-shrink: 0;
    display: inline-block;
}

/* State after the link has been copied */
.share-btn.copied {
    background: var(--success);
    border-color: var(--success);
}

/* ========================================================= */
/* == Article Content                                     == */
/* ========================================================= */
.article-content {
    max-width: 800px;
    min-width: 0;
}
.article-content > :first-child {
    margin-top: 0;
}
.article-content > :last-child {
    margin-bottom: 0;
}

.article-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 3rem;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    color: var(--text);
    scroll-margin-top: calc(var(--header-h) + 24px);
}
.article-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
    color: var(--text);
    scroll-margin-top: calc(var(--header-h) + 24px);
}
.article-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text);
    scroll-margin-top: calc(var(--header-h) + 24px);
}

.article-content p {
    margin: 0 0 1.25rem 0;
    color: var(--text-2);
    font-size: 1.02rem;
}

.article-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(139, 92, 246, 0.4);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s;
}
.article-content a:hover {
    text-decoration-color: var(--accent);
}

.article-content ul,
.article-content ol {
    margin: 0 0 1.25rem 0;
    padding-left: 1.75rem;
    color: var(--text-2);
}
.article-content li {
    margin-bottom: 0.5rem;
    font-size: 1.02rem;
}

.article-content strong {
    color: var(--text);
    font-weight: 600;
}

.article-content hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 3rem 0;
}

.article-content img {
    border-radius: 12px;
    margin: 1.5rem 0;
}

.article-content blockquote {
    margin: 1.5rem 0;
    padding: 0.25rem 0 0.25rem 0.25rem;
    border-left: 3px solid var(--accent);
    color: var(--text-2);
    font-style: italic;
}
.article-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Inline code */
.article-content code {
    font-family: "SF Mono", "Fira Code", "JetBrains Mono", Consolas, monospace;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.2em 0.45em;
    border-radius: 5px;
    font-size: 0.88em;
    border: 1px solid var(--line);
}

/* Bare pre blocks */
.article-content pre {
    background: var(--pre-bg);
    border: 1px solid var(--line);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
}
.article-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: var(--pre-text);
}

/* --- Code Blocks --- */
.code-block {
    background: var(--pre-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin: 1.5rem 0 2rem;
    overflow: hidden;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--code-header-bg);
    border-bottom: 1px solid var(--line);
}

.code-block-lang {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.code-block-dots {
    display: flex;
    gap: 6px;
}
.code-block-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface-2);
}
.code-block-dots span:nth-child(1) { background: #f87171; }
.code-block-dots span:nth-child(2) { background: #fbbf24; }
.code-block-dots span:nth-child(3) { background: #34d399; }

.code-block pre {
    margin: 0;
    border: none;
    border-radius: 0;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    font-family: 'JetBrains Mono', "SF Mono", 'Fira Code', Consolas, monospace;
    font-size: 0.87rem;
    line-height: 1.7;
    color: var(--pre-text);
}
.code-block pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* Syntax highlighting */
.code-block pre .comment  { color: var(--syn-comment); }
.code-block pre .keyword  { color: var(--syn-keyword); }
.code-block pre .string   { color: var(--syn-string); }
.code-block pre .attr     { color: var(--syn-attr); }
.code-block pre .value    { color: var(--syn-value); }
.code-block pre .tag      { color: var(--syn-tag); }
.code-block pre .number   { color: var(--syn-number); }
.code-block pre .function { color: var(--syn-function); }
.code-block pre .property { color: var(--syn-property); }

/* --- Callout Boxes --- */
.callout {
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    border: 1px solid;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.callout-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 2px;
}
.callout-text { font-size: 0.95rem; line-height: 1.6; }
.callout-text code { font-size: 0.85em; }

.callout-info { background: var(--callout-info-bg); border-color: var(--callout-info-border); }
.callout-info .callout-icon { background: rgba(59, 130, 246, 0.2); color: var(--info); }
.callout-info .callout-text { color: var(--callout-info-text); }

.callout-warning { background: var(--callout-warning-bg); border-color: var(--callout-warning-border); }
.callout-warning .callout-icon { background: rgba(245, 55, 11, 0.2); color: var(--warning); }
.callout-warning .callout-text { color: var(--callout-warning-text); }

.callout-success { background: var(--callout-success-bg); border-color: var(--callout-success-border); }
.callout-success .callout-icon { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.callout-success .callout-text { color: var(--callout-success-text); }

/* --- Tables --- */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.92rem;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.article-content th {
    background: var(--surface-2);
    padding: 0.85rem 1.25rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--line);
}
.article-content td {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--line);
    color: var(--text-2);
}
.article-content tr:last-child td { border-bottom: none; }
.article-content tbody tr:hover td { background: var(--accent-glow); }
.article-content table code { font-size: 0.83em; }

/* ========================================================= */
/* == Chapter Navigation                                  == */
/* ========================================================= */
.chapter-nav {
    position: sticky;
    top: calc(var(--header-h) + 32px);
    align-self: start;
}
.chapter-nav-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.chapter-nav-title {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 1rem 0;
}

/* Chapter list */
.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.toc-list li {
    margin-bottom: 0.5rem;
}
.toc-list a {
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.88rem;
    display: block;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.toc-list a:hover {
    background: var(--accent-glow);
    border-left-color: var(--accent);
    text-decoration: none;
}
.toc-list a.active {
    border-left-color: var(--accent);
    background: var(--accent-glow);
}

/* --- Tags --- */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tag {
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text-2);
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}
.tag:hover {
    border-color: var(--accent);
    text-decoration: none;
}

/* --- Related Articles --- */
.related-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.related-list li {
    margin-bottom: 0.5rem;
}
.related-list a {
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.88rem;
    display: block;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.related-list a:hover {
    color: var(--accent);
    background: var(--accent-glow);
    border-left-color: var(--accent);
    text-decoration: none;
}

/* ========================================================= */
/* == Blog Index                                          == */
/* ========================================================= */
.post-list {
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}
.post-list-year {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 2rem 0 1rem 0;
    color: var(--text);
}
.post-list-year:first-child { margin-top: 0; }

.post-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s;
}
.post-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
}
.post-card-title {
    margin: 0 0 0.35rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.post-card-meta {
    font-size: 0.85rem;
    color: var(--muted);
}
.post-card-excerpt {
    margin: 0.5rem 0 0 0;
    color: var(--text-2);
    font-size: 0.95rem;
}

/* ========================================================= */
/* == Footer                                              == */
/* ========================================================= */
.site-footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
}
.footer-grid {
    display: grid;
    gap: 28px;
    padding-top: 40px;
    padding-bottom: 18px;
    grid-template-columns: 1fr 1fr;
}
.footer-h {
    margin: 0 0 10px 0;
    font-size: 17px;
    color: var(--text);
    font-weight: 700;
}
.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
}
.footer-links li { margin: 6px 0; }
.footer-links a {
    color: var(--text-2);
    padding: 6px 0;
    display: inline-block;
    transition: color .2s ease;
}
.footer-links a:hover {
    color: var(--text);
    text-decoration: underline;
}

.legal-line {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    padding-bottom: 26px;
    color: var(--text-2);
    display: grid;
    gap: 8px;
    justify-items: center;
}
.legal-line .sep { display: none; }

@media (min-width: 860px) {
    .footer-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .legal-line {
        display: flex;
        gap: 12px;
        align-items: center;
        justify-content: space-between;
    }
    .legal-line .sep {
        display: inline;
        opacity: 0.6;
    }
}

/* ========================================================= */
/* == Colorful Theme                                      == */
/* ========================================================= */
html[data-theme='colorful'] .sidebar, html[data-theme='colorful'] .chapter-nav-section {
    background: linear-gradient(60deg, #517775 0%, #46c0fa 35%, #9494ef 65%, #4b7896);
    border-right-color: #9aabbc;
}
html[data-theme='colorful'] .sidebar-header {
    color: #111;
}
html[data-theme='colorful'] .sidebar-header:hover {
    color: #111;
    text-shadow: 0px 0px 25px #222;
}
html[data-theme='colorful'] .nav-group-title {
    color: #000;
    opacity: 1;
}
html[data-theme='colorful'] .nav-group li a {
    color: #111;
}
html[data-theme='colorful'] .nav-group li a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #000;
}
html[data-theme='colorful'] .nav-group li a.active {
    background: #333;
    color: #fff;
    border-left-color: #775ac7;
}
html[data-theme='colorful'] .nav-group .post-date {
    color: #eee;
}
html[data-theme='colorful'] .side-link-big {
    color: #111;
}
html[data-theme='colorful'] .side-link-big:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #000;
}
html[data-theme='colorful'] #theme-switcher {
    background: rgba(255, 255, 255, 0.5);
    color: #010509;
    border-color: #87ceeb;
}

/* Gradient text reset (gradient headings are used instead) */
html[data-theme='colorful'] .article-title {
    background: none;
    -webkit-text-fill-color: #111;
    color: #111;
}
html[data-theme='colorful'] .article-content h2,
html[data-theme='colorful'] .article-content h3 {
    background: linear-gradient(60deg, #FFB88C, #EC6F66, #ee6e7f, #FFB88C);
    color: #333;
}
html[data-theme='colorful'] .article-content th {
    background: radial-gradient(circle at 500%, #EECDA3 -50%, #C779D0 50%, #FEAC5E 75%, #EF629F 110%);
    color: #1a1a1a;
}
html[data-theme='colorful'] .code-block {
    border-color: #3a6f9a;
}
html[data-theme='colorful'] .toc-list li {
	background: rgba(255, 255, 255, 0.55);
}
html[data-theme='colorful'] .toc-list li a.active {
	background: rgba(255, 255, 255, 0.8);
}
html[data-theme='colorful'] .toc-list a {
	border-radius: initial;
}
html[data-theme='colorful'] .article-subtitle {
	color: #000;
}
 html[data-theme='colorful'] .article-content p {
	color: #070707;
}
html[data-theme='colorful'] .site-footer {
    background: radial-gradient(circle at 100%, #4CA2CD -50%, #38BF7D 50%, #67B281 75%, #11998E 110%);
    background-attachment: fixed;
}
html[data-theme='colorful'] .callout-info .callout-icon {
	background: rgba(59, 130, 246, 0.7);
}
html[data-theme='colorful'] .callout-warning .callout-icon {
	background: rgba(245, 158, 11, 0.7);
}
html[data-theme='colorful'] .callout-success .callout-icon {
	background: rgba(34, 197, 94, 0.7);
}
html[data-theme='colorful'] .article-content table {
	border-radius: initial;
}

/* ========================================================= */
/* == Reduced Motion                                      == */
/* ========================================================= */
.reduced-motion * {
    animation: none !important;
    transition: none !important;
}

/* ========================================================= */
/* == Responsive Design                                   == */
/* ========================================================= */
@media (max-width: 1024px) {
    .blog-layout {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    /* Chapter navigation moves below the article */
    .chapter-nav {
        position: static;
    }
}

@media (max-width: 959px) {
    /* Only the hamburger navigation is kept on small screens */
    .primary-nav,
    .header-row > .link-pill {
        display: none;
    }
    /* Glow instead of the underline effect (from styles.css) */
    .nav-link:hover {
        text-shadow: 0 0 20px var(--accent);
        transition: text-shadow 0.4s ease-in-out;
    }
    .nav-link:hover::before {
        opacity: 0;
        transform: scaleX(0) scaleY(0.5);
    }
}

@media (min-width: 960px) {
    .nav-link:hover::before {
        opacity: 0.9;
        transform: scaleX(0.87);
    }
}

@media (max-width: 768px) {
    .article-header {
        padding: 2.5rem 1.25rem 1rem;
    }
    .blog-layout {
        padding: 0 1.25rem 1.5rem;
    }
    .article-title {
        font-size: 2rem;
    }
    .article-meta {
        gap: 0.5rem;
    }
    .code-block pre {
        font-size: 0.8rem;
    }
    .article-content table {
        display: block;
        overflow-x: auto;
    }
    .post-list {
        padding: 2rem 1.25rem;
    }
}

/* ========================================================= */
/* == Print                                               == */
/* ========================================================= */
@media print {
    .site-header, .site-footer,
    .sidebar, .sidebar-overlay, .chapter-nav,
    .progress-bar, .bg-accents, .share-btn {
        display: none;
    }
    .blog-layout {
        grid-template-columns: 1fr;
    }
    body {
        background: #ffffff;
        color: #000000;
    }
}

/* ========================================================= */
/* == Diagrams                                            == */
/* ========================================================= */
.mermaid-diagram {
	margin: 1.75rem 0 2rem;
	padding: 1.5rem 1.25rem 1.25rem;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 12px;
	overflow-x: auto;
}
.mermaid-svg {
	display: block;
	margin: 0 auto;
	max-width: 100%;
	height: auto;
}
.mermaid-edge {
	fill: none;
	stroke: var(--muted);
	stroke-width: 1.25;
}

.mermaid-arrow-head { fill: var(--muted); }

.mermaid-edge-label-bg {
	fill: var(--surface-2);
	stroke: var(--line);
}
.mermaid-edge-label {
	fill: var(--text-2);
	font-size: 11px;
	font-family: inherit;
}

.mermaid-node-shape {
	fill: var(--surface-2);
	stroke: var(--line);
	stroke-width: 1.25;
}
.mermaid-node-label {
	fill: var(--text);
	font-size: 11px;
	font-family: inherit;
}

.mermaid-caption {
	margin: 1rem 0 0 0;
	font-size: 0.85rem;
	color: var(--muted);
	text-align: center;
}

/* Colorful Theme */
html[data-theme='colorful'] .mermaid-diagram, html[data-theme='colorful'] .linkcheck-demo {
	background:
		radial-gradient(620px 220px at 18% -12%, rgba(255, 255, 255, 0.85) 0%, transparent 60%),
		linear-gradient(135deg, #f6d365 0%, #fda085 35%, #fbc2eb 70%, #a18cd1 100%);
	background-size: auto, 170% 170%;
	background-position: center, 0% 0%;
	border: 1px solid rgba(255, 255, 255, 0.75);
	box-shadow: 0 14px 34px rgba(84, 31, 122, 0.35),
	            inset 0 0 0 1px rgba(255, 255, 255, 0.35);
	transition: transform 0.25s ease, box-shadow 0.25s ease, background-position 0.6s ease;
}

html[data-theme='colorful'] .mermaid-node-shape {
	stroke-width: 1.6;
	filter: drop-shadow(0 3px 4px rgba(84, 31, 122, 0.28));
}
html[data-theme='colorful'] rect.mermaid-node-shape {    /* box & stadium */
	fill: rgba(240, 232, 255, 0.95);
	stroke: #6d36d1;
}
html[data-theme='colorful'] circle.mermaid-node-shape {  /* circle */
	fill: rgba(208, 250, 255, 0.95);
	stroke: #0e7490;
}
html[data-theme='colorful'] polygon.mermaid-node-shape { /* diamond */
	fill: rgba(255, 224, 239, 0.95);
	stroke: #c2185b;
}
html[data-theme='colorful'] path.mermaid-node-shape {    /* cylinder */
	fill: rgba(255, 244, 191, 0.95);
	stroke: #92600a;
}

/* Labels & edges */
html[data-theme='colorful'] .mermaid-node-label {
	fill: #230a3d;
	font-weight: 600;
}
html[data-theme='colorful'] .mermaid-edge {
	stroke: #4c1d95;
	stroke-width: 1.6;
	stroke-linecap: round;
}
html[data-theme='colorful'] .mermaid-arrow-head {
	fill: #4c1d95;
}
html[data-theme='colorful'] .mermaid-edge-label-bg {
	fill: #ffffff;
	stroke: #b983e8;
}
html[data-theme='colorful'] .mermaid-edge-label {
	fill: #4c1d95;
	font-weight: 700;
}
html[data-theme='colorful'] .mermaid-caption {
	color: #3b1560;
	font-style: italic;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}