/* 0. CSS Variables and Basic Reset */
:root {
    /* Light Theme (default) */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    --titleFont: "Schibsted Grotesk", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --headerFont: "Schibsted Grotesk", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --bodyFont: "Source Sans Pro", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --codeFont: "IBM Plex Mono", ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace;

    --bg-color: #ffffff;
    --text-color: #1f2937;
    --text-muted-color: #6b7280;
    --border-color: #e5e7eb;
    
    --accent-color: #007acc;
    --accent-hover-color: #005d99;

    --left-sidebar-bg: var(--bg-color);
    --left-sidebar-text-color: #797baa;
    --left-sidebar-index-color: #7b97aa;
    --left-sidebar-border-color: var(--border-color);
    --left-sidebar-item-hover: var(--accent-color);
    --left-sidebar-item-hover-bg: #f0f1f3;
    --left-sidebar-toggler-color: var(--text-muted-color);
    --left-sidebar-width: 280px;

    --right-sidebar-toc-bg: #f9fafb;
    --right-sidebar-toc-text-color: #4b5563;
    --right-sidebar-toc-border-color: var(--border-color);
    --right-sidebar-toc-width: 240px;

    --search-input-color: var(--text-color);
    --search-input-bg-color: #eee;

    --content-bg: var(--bg-color);
    --content-max-width: 820px; /* Max width for readable text lines */

    --code-bg: #f3f4f6;
    --code-text-color: #374151;
    --pre-padding: 1em;
    --pre-border-radius: 6px;
    
    --quote-border-color: var(--accent-color);
    --quote-text-color: var(--text-muted-color);
    --quote-bg: #f9fafb;

    --breadcrumb-color: var(--text-muted-color);
    --tag-bg: #e0e7ff; /* Light blue for tags */
    --tag-text-color: #3730a3; /* Darker blue text for tags */
    --tag-hover-bg: #c7d2fe;
    --tag-hover-text-color: #3730a3;

    --scrollbar-color: #ccc;
    --scrollbar-bg: #eee;

    --read-more-button-color: var(--tag-text-color);
    --read-more-button-bg: var(--tag-bg);

    .altova-logo
    {
        background-image: url("/blog/assets/altova.svg");
    }

}

@media (prefers-color-scheme: dark) {
    :root {
        --base-bg-color: #231f20;
        --bg-color: hsl(from var(--base-bg-color) h s calc(l - 3)); /* #161618 #231f20 */
        --text-color: #d1d5db;
        --text-muted-color: #9ca3af;
        --border-color: #374151;
        /* #797baa */
        --accent-color: #38bdf8;
        --accent-hover-color: #0ea5e9;

        --left-sidebar-bg: var(--bg-color);
        --left-sidebar-text-color: var(--text-color);
        --left-sidebar-border-color: var(--border-color);
        --left-sidebar-item-hover: lightgray;
        --left-sidebar-item-hover-bg: #374151;
        --left-sidebar-toggler-color: var(--text-muted-color);

        --right-sidebar-toc-bg: var(--bg-color);
        --right-sidebar-toc-text-color: var(--text-muted-color);
        --right-sidebar-toc-border-color: var(--border-color);

        --search-input-color: #ebebec;
        --search-input-bg-color: #333;

        --content-bg: var(--bg-color);

        --code-bg: var(--bg-color);
        --code-text-color: var(--text-color);
        
        --quote-border-color: var(--accent-color);
        --quote-text-color: var(--text-muted-color);
        --quote-bg: var(--bg-color);

        --breadcrumb-color: var(--text-muted-color);
        --tag-bg: #222;
        --tag-text-color: #e0e7ff;
        --tag-hover-bg: #374151;
        --tag-hover-text-color: #38bdf8;

        --scrollbar-color: #777;
        --scrollbar-bg: #333;

        --read-more-button-color: #ebebec;
        --read-more-button-bg: #333;

        .altova-logo
        {
            background-image: url("/blog/assets/altova-inv.svg");
        }

    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    display: grid;
    grid-template-columns: 1fr var(--left-sidebar-width) 5fr;
    /* overflow: hidden; */
    justify-content: start
}


#left-space {
    min-content: 0;
}

.altova-logo
{
    /* background-image: will be set in :root area */
    width: 133px;
    height: 26px;
    /* margin: 10px 0 5px 20px; */
}

/* 1. Layout */
#left-sidebar {
    width: var(--left-sidebar-width);
    min-width: var(--left-sidebar-width);
    background-color: var(--left-sidebar-bg);
    color: var(--left-sidebar-text-color);
    padding: 1.5em 1em;
    padding-top: 7em;
    padding-left: 0em;
	padding-bottom: 2em;
    height: 98vh;
    /* overflow-y: visible; */
    /* border-right: 1px solid var(--left-sidebar-border-color);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s; */
    font-family: var(--headerFont);
    display: flex;
    flex-direction: column;
}

#main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* overflow: hidden; *//* Only #content-area-wrapper's children will scroll */
    padding-top: 7em;
	padding-bottom: 2em;

}

#page-header {
    padding: 1em 2.5em;
    /* border-bottom: 1px solid var(--border-color); */
    background-color: var(--content-bg); /* Match content bg or specific header bg */
    flex-shrink: 0; /* Prevent header from shrinking */
}

#content-area-wrapper {
    display: flex;
    flex-grow: 1;
    overflow: auto;
    scrollbar-color: var(--scrollbar-color) var(--scrollbar-bg);
}

#content {
    flex-grow: 1;
    padding: 1.5em 2.5em; /* Reduced top padding as header has padding */
    /* overflow-y: auto; */
    background-color: var(--content-bg);
    transition: background-color 0.3s;
}

#content article { /* Wrapper for user Markdown content */
    max-width: var(--content-max-width);
    /* margin-left: auto; */
    margin-right: auto;
}
.archive-list {
    max-width: var(--content-max-width);
    margin-left: auto;
    margin-right: auto;
}


#right-sidebar-toc {
    width: var(--right-sidebar-toc-width);
    min-width: var(--right-sidebar-toc-width);
    background-color: var(--right-sidebar-toc-bg);
    color: var(--right-sidebar-toc-text-color);
    padding: 1.5em 1em;
    height: 100%;
    /* overflow-y: auto; */
    /* border-left: 1px solid var(--right-sidebar-toc-border-color); */
    font-size: 0.85em;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* 2. Left Sidebar Navigation Styling */
#left-sidebar div.heading {
    display: flex;
    text-decoration: none;
}
#left-sidebar div.heading a img {
}
#left-sidebar div.heading a {
    text-decoration: none;
}
#left-sidebar div.heading a:visited {
    text-decoration: none;
}
#left-sidebar div.heading span {
    margin-left: 0.3em;
    font-size: 1.3em;
    font-weight: bold;
}
#left-sidebar div.heading span a {
    color: var(--left-sidebar-text-color);
}
#left-sidebar div.heading span a:visited {
    color: var(--left-sidebar-text-color);
}


div.search {
    display: flex;
    margin-top: 16px;
}
div.search input {
    font-family: var(--headerFont);
    color: var(--search-input-color);
    background-color: var(--search-input-bg-color);
    border: none;
    border-radius: 5px;
    padding: .3em .8em;
    font-size: 1.0em;
    width: 80%;
}

div.search input:focus {
    border: none;
    border-radius: 5px;
}

div.search button {
    background-color: transparent;
    border: none;
    align-items: center;
    justify-content: center;
    display: flex;
    padding-left: .6em;
    padding-right: .6em;
    margin-left: 3px;
    border-radius: 5px;
}
div.search button:hover {
    background-color: #434749;
}

#search-popup {
    display: none;
    position: fixed;
    top: 7em;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    height: 70%;
    border: 2px solid #666;
    border-radius: 10px;
    z-index: 1000;
    overflow: auto;
    scrollbar-color: var(--scrollbar-color) var(--scrollbar-bg);
    background-color: hsl(from var(--bg-color) h s l / 0.9); /* rgba(0, 0, 0, 0.9); */
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

#popup-content {
    padding: 30px;
    color: var(--text-color);
}

#popup-content li {
    margin-bottom: 0.5em !important;
    padding: 0.5em !important;
    color: var(--text-color);
    font-weight: normal;
}

#popup-content li:hover {
    background-color: var(--tag-hover-bg);
    border-radius: 5px;
}

#popup-content li a {
    color: var(--left-sidebar-index-color);
    text-decoration: none;
    font-weight: bold;
}

#popup-content li a > p {
    color: var(--text-color);
    text-decoration: none;
    font-weight: normal;
}

#popup-content li a:visited {
    color: var(--left-sidebar-index-color);
}

#popup-content li a:hover {
    color: var(--left-sidebar-index-color);
}

#popup-content .loader {
    margin: auto;
    height: 50px;
    aspect-ratio: 2;
    border-bottom: 3px solid #0000;
    background:
            linear-gradient(90deg,#d1d5db 50%,#0000 0)
            -25% 100%/50% 3px repeat-x border-box;
    position: relative;
    animation: l3-0 .75s linear infinite;
}
#popup-content .loader:before {
    content: "";
    position: absolute;
    inset: auto 42.5% 0;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #cf1c44;
    animation: l3-1 .75s cubic-bezier(0,900,1,900) infinite;
}
@keyframes l3-0 {
    to {background-position: -125% 100%}
}
@keyframes l3-1 {
    0%,2% {bottom: 0%}
    98%,to {bottom:.1%}
}



#popup-content li a > p {
}




#close-popup {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 24px;
    color: white;
    cursor: pointer;
    user-select: none;
}

#close-popup:hover {
    color: #ccc;
}


.search-path {
    stroke: darkgray;
    stroke-width: 2px;
    transition: stroke 0.5s ease;
}

.search > .search-button svg {
    cursor: pointer;
    width: 18px;
    min-width: 18px;
}

#left-sidebar div.explorer {
    height: 100vh;
    overflow-y: auto;
    margin-top: 20px;
}



#left-sidebar ul {
    list-style-type: none;
}

#left-sidebar li {
    margin-bottom: 0.1em; /* Tighter spacing */
}

#left-sidebar ul ul {
    padding-left: 1em; /* Indentation for hierarchy */
    margin-top: 0.2em;
}


div.explorer {
    scrollbar-color: var(--scrollbar-color) var(--scrollbar-bg);
}

#left-sidebar .year-list {
    margin-top: 20px;
}

#left-sidebar .year-item, #left-sidebar .month-item, ul.posts-list li {
    display: flex;
    align-items: center;
    cursor: pointer; /* Make the whole item feel clickable for toggling */
    padding: 0 0.4em;
    border-radius: 4px;
}

#left-sidebar .category-item {

}

#left-sidebar .category-item:hover {
    color: var(--left-sidebar-item-hover);
}


#left-sidebar .toggler-icon {
    /* SVG is an img tag, so width/height can control its size */
    width: 12px;
    height: 12px;
    margin-right: 0.5em;
    color: var(--left-sidebar-toggler-color); /* For SVG fill/stroke if set to 'currentColor' */
    stroke: var(--left-sidebar-toggler-color); /* Explicitly for SVGs */
    transition: transform 0.2s ease-in-out;
    flex-shrink: 0; /* Prevent icon from shrinking */
}

#left-sidebar .explorer a, #left-sidebar .year-text, #left-sidebar .month-text {
    font-weight: 600;
    text-decoration: none;
    color: var(--left-sidebar-index-color);
    display: block; /* Make link take available space in item */
    flex-grow: 1;
    font-size: 0.90em;
    line-height: 1.5rem;
}

#left-sidebar .year-text {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--left-sidebar-index-color);
}

/* Style for the currently active post link in the sidebar */
#left-sidebar a.active-post {
    color: var(--accent-color);
    font-weight: 600; /* Make it bold for extra emphasis */
    background-color: var(--sidebar-item-hover-bg); /* Use the hover background for a clear selection */
}

#left-sidebar a:hover, #left-sidebar .year-item:hover, #left-sidebar .year-text:hover, #left-sidebar .month-item:hover, #left-sidebar .month-text:hover, ul.posts-list a:hover  {
    /* background-color: var(--left-sidebar-item-hover-bg); */
    color: var(--left-sidebar-item-hover);
}

/* 3. Right Sidebar ToC Styling */
#right-sidebar-toc h4 {
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted-color);
    margin-bottom: 0.8em;
    font-weight: 600;
}
#right-sidebar-toc ul {
    list-style-type: none;
    padding-left: 0.5em;
}
#right-sidebar-toc li a {
    text-decoration: none;
    color: var(--right-sidebar-toc-text-color);
    display: block;
    padding: 0.25em 0;
    border-left: 2px solid transparent; /* For active indication */
    padding-left: 0.5em;
    transition: color 0.2s, border-color 0.2s;
}
#right-sidebar-toc li a:hover {
    color: var(--accent-color);
}
#right-sidebar-toc li.toc-level-3 a { /* Indent H3s */
    padding-left: 1.5em;
}
/* Active ToC link - JS would set this class */
/* #right-sidebar-toc li a.active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    font-weight: 500;
} */


/* 4. Page Header (Breadcrumbs, Date, Tags) */
#breadcrumb-trail {
    font-size: 0.85em;
    margin-bottom: 0.75em;
}
#breadcrumb-trail ol {
    list-style-type: none;
    padding-left: 0;
    display: flex;
    flex-wrap: wrap;
}
#breadcrumb-trail li {
    color: var(--breadcrumb-color);
}
#breadcrumb-trail li:not(:last-child)::after {
    content: '/';
    margin: 0 0.5em;
    color: var(--breadcrumb-color);
}
#breadcrumb-trail a {
    color: var(--accent-color);
    text-decoration: none;
}
#breadcrumb-trail a:hover {
    text-decoration: underline;
}

/* Style for the container of post date and reading time */
.post-meta {
    font-size: 0.9em;
    color: var(--text-muted-color);
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 0.5em; /* Space between items */
}

.post-meta span {
    display: inline-block;
    font-size: 0.9em;
    color: var(--text-muted-color);
}

.post-date {
}

.reading-time {
    font-style: italic;
}

.tags-container {
    margin-bottom: 0.5em;
    font-size: 0.8em;
}
.tag-link {
    display: inline-block;
    background-color: var(--tag-bg);
    color: var(--tag-text-color);
    padding: 0.2em 0.6em;
    border-radius: 4px;
    text-decoration: none;
    margin-right: 0.5em;
    margin-bottom: 0; /* For wrapping */
    transition: background-color 0.2s;
}
.tag-link:hover {
    background-color: var(--tag-hover-bg);
    color: var(--tag-hover-text-color);
    text-decoration: none !important;
    border-bottom-color: transparent !important;
}

/* Style for the container of post date and reading time */
.post-meta {
    font-size: 0.9em;
    color: var(--text-muted-color);
    margin-bottom: 0.75em;
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 0.5em; /* Space between items */
}

.post-meta span {
    display: inline-block;
}

/* Optional: a slightly different style for the reading time */
.reading-time {
    font-style: italic;
}

/* 5. Main Content Typography & Elements */
#content h1 { /* Page title in main content */
    font-size: 2.4em; 
    margin-top: 0; /* Already spaced by header */
    margin-bottom: 0.8em;
    color: var(--text-color); 
    font-weight: 700;
    line-height: 1.2;
}
#content h2, #content h3, #content h4, #content h5, #content h6 {
    color: var(--text-color);
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    line-height: 1.3;
    font-weight: 600;
}
#content h2 { font-size: 1.8em; }
#content h3 { font-size: 1.5em; }
#content h4 { font-size: 1.25em; }

#content p { margin-bottom: 1.2em; }
#content a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-color); /* Subtle underline */
    transition: color 0.2s, border-color 0.2s;
}
#content a:hover {
    color: var(--accent-hover-color);
    border-bottom-color: var(--accent-hover-color);
}
#content ul, #content ol { margin-bottom: 1.2em; padding-left: 2em; }
#content li { margin-bottom: 0.5em; }

#content blockquote {
    margin: 1.5em 0;
    padding: 0.8em 1.2em;
    border-left: 4px solid var(--quote-border-color);
    background-color: var(--quote-bg);
    color: var(--quote-text-color);
    font-style: italic;
    transition: background-color 0.3s, border-color 0.3s;
}
#content blockquote p:last-child { margin-bottom: 0; }

#content pre {
    background-color: var(--code-bg); /* code-bg is often better for pre than pre-bg for consistency */
    color: var(--code-text-color);
    padding: var(--pre-padding);
    border-radius: var(--pre-border-radius);
    overflow-x: auto;
    margin-bottom: 1.5em;
    font-family: var(--font-mono);
    font-size: 0.9em;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
#content code {
    font-family: var(--font-mono);
    background-color: var(--code-bg);
    color: var(--code-text-color);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}
#content pre code { padding: 0; background-color: transparent; border-radius: 0; font-size: inherit; border: none;}
#content hr { border: 0; border-top: 1px solid var(--border-color); margin: 2em 0; }
#content img, #content video { max-width: 100%; height: auto; border-radius: 4px; margin: 1em 0; }
#content table { width: 100%; border-collapse: collapse; margin-bottom: 1.5em; font-size: 0.95em; }
#content th, #content td { border: 1px solid var(--border-color); padding: 0.6em 0.8em; text-align: left; }
#content th { background-color: var(--left-sidebar-bg); font-weight: 600; }

.archive-list { list-style-type: none; padding-left: 0; }
.archive-list li { margin-bottom: 0.75em; font-size: 1.05em; }
.archive-list .post-meta-date { font-size: 0.85em; color: var(--text-muted-color); margin-left: 0.5em; }

/* Responsive Video Embed Container */
.video-embed-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio (divides 9 by 16) */
    margin: 1.5em 0; /* Add some space above and below the video */
    border-radius: 6px; /* Optional: adds rounded corners */
}

.video-embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0; /* Ensure no border from the iframe itself */
}

/* Read more button on index page */
p:has( > a.read-more-button)
{
    display: flex;
}

a.read-more-button {
    border: 1px outset buttonborder;
    border-radius: 4px;
    padding: 6px 10px;
    text-decoration: none;
    color: var(--read-more-button-color);
    background-color: var(--read-more-button-bg);
    margin-left: auto;
}


/* Responsive Adjustments */
@media (max-width: 1024px) { /* Hide ToC sidebar on medium screens */
    #right-sidebar-toc { display: none; }
    #content article, .archive-list { margin-left: 0; margin-right: 0; } /* Allow content to use more space */
}

@media (max-width: 768px) { /* Stack layout on small screens */
    body { display: block; overflow: auto; }
    #main-wrapper { height: auto; }
    #content-area-wrapper { display: block; height: auto; }

    #left-sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh; /* Scrollable area for sidebar */
        border-right: none;
        border-bottom: 1px solid var(--left-sidebar-border-color);
    }
    #page-header { padding: 1em 1.5em; }
    #content { height: auto; padding: 1.5em; }
    #content article, .archive-list { max-width: 100%; } /* Full width */
}