/* Base Theme Variables */
:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --link-color: #1a73e8;
    --border-color: #cccccc;
    --blockquote-bg: #f9f9f9;
    --blockquote-border: #cccccc;
    --code-bg: #f5f5f5;
    --scrollbar-color: #bbbbbb #f5f5f5;
    --nav-h: 56px;
    --radius: 0px;
}

[data-theme='dark'] {
    --bg-color: #222222;
    --text-color: #ffffff;
    --link-color: lightblue;
    --border-color: #333333;
    --blockquote-bg: #191919;
    --blockquote-border: #ccc;
    --code-bg: #272727;
    --scrollbar-color: gray #222222;
}

/* General Styling */
body {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1em;
    box-sizing: border-box;
    line-height: 1.5;
    background: var(--bg-color);
    color: var(--text-color);
    scrollbar-color: var(--scrollbar-color);
    font-family: "Work Sans", "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif;
    font-size: 1rem;
}

a {
    color: var(--link-color);
}

/* Navbar Styles */
#nav-bar {
    position: sticky;
    /* stays visible */
    top: 0;
    z-index: 1000;
    height: var(--nav-h);
    backdrop-filter: saturate(140%) blur(6px);
    -webkit-backdrop-filter: saturate(140%) blur(6px);
    background-color: color-mix(in srgb, var(--bg-color) 92%, transparent);
    border-bottom: 0px solid var(--border-color);
    transition: box-shadow .18s ease;
}

#nav-bar.scrolled {
    box-shadow: 0 6px 16px rgba(0, 0, 0, .08);
}

/* logo sizing stays */
#theme-logo {
    height: calc(var(--nav-h) - 12px);
}

#nav-bar img {
    height: 100%;
    max-height: 40px;
    object-fit: contain;
    margin-right: 15px;
}

.menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu li {
    display: inline-block;
    margin: 0;
}

.menu a {
    text-decoration: none;
    padding: 0 10px;
    color: var(--link-color);
    font-size: 1rem;
    line-height: 50px;
}

.menu-item-active {
    border-bottom: 2px solid var(--link-color);
}


/* desktop menu spacing */
.menu a {
    padding: 0 12px;
}

@media (max-width:768px) {
    .burger-menu {
        display: block;
        font-size: 1.6rem;
        background: none;
        border: 0;
        padding: 6px;
    }

    .menu {
        display: none;
        /* hide by default */
        position: absolute;
        /* place relative to navbar */
        top: var(--nav-h, 50px);
        /* directly under navbar */
        left: 0;
        right: 0;
        width: 100%;
        /* full width */
        margin: 0;
        padding: 8px 0;
        background: var(--bg-color);
        border: 1px solid var(--border-color);
        border-radius: 0;
        /* square corners */
        box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
        flex-direction: column;
        text-align: center;
        /* center menu items */
        z-index: 1200;
    }

    .menu.show {
        display: flex;
    }

    .menu li {
        margin: 4px 0;
    }

    .menu a {
        display: block;
        line-height: 48px;
        padding: 0 14px;
        font-size: 1.05rem;
    }

    .menu a:active {
        background: var(--blockquote-bg);
    }

    body.mobile-menu-open {
        overflow: hidden;
    }
}



/* Headers, Footers, and Menu */
h1 {
    text-align: left;
    margin-bottom: 5px;
}

footer {
    text-align: center;
}

footer a {
    text-decoration: none;
}

/* Articles and Metadata */
.article-meta {
    background: var(--bg-color);
    padding: 5px;
    border-radius: 5px;
    text-decoration: none;
}

.article-container {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    min-height: 230px;
    border: 1px solid var(--border-color);
    padding: 5px;
}

.article-details {
    flex-grow: 1;
}

.article-summary,
.text-content {
    text-align: justify;
}

.article-type {
    color: gray;
}

/* Tag and Category Links */
.tag-item a,
.tag-list a,
.category-list a {
    color: tomato !important;
}

/* Thumbnail */
.thumbnail {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 15px;
    width: 150px;
    height: 230px;
    flex-shrink: 0;
}

.thumbnail img {
    max-width: 150px;
    max-height: 220px;
    height: auto;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}

.thumb-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 5px;
}

/* Typography and Misc Elements */
blockquote {
    background: var(--blockquote-bg);
    border-left: 5px solid var(--blockquote-border);
    padding: 3px 1em;
}

hr {
    color: var(--border-color);
}

img,
iframe,
video {
    max-width: 100%;
    margin: 5px auto;
    display: block;
}

main {
    hyphens: auto;
}

li {
    margin: 0 0 10px 0;
}

/* Tables */
table {
    margin: auto;
    width: 90%;
    border-collapse: collapse;
    /* Merge borders for a cleaner look */
    border: 1px solid var(--border-color);
    /* Unified border around the table */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* Subtle shadow for a modern touch */
    font-family: Arial, sans-serif;
    /* Ensure consistent styling */
    font-size: 14px;
}

thead th {
    border-bottom: 2px solid var(--border-color);
    /* Slightly thicker border for the header */
    padding: 10px;
    /* Extra padding for better visual separation */
    text-transform: uppercase;
    /* Capitalize headers for clarity */
    font-weight: bold;
    color: var(--text-color);
    /* Matches your site theme */
}

th,
td {
    padding: 10px;
    /* Uniform padding for cells */
    text-align: center;
    /* Center-align for better readability */
}

thead,
tfoot {
    background: var(--blockquote-bg);
    /* Retain theme consistency */
}

tr:nth-child(even) {
    background: var(--blockquote-bg);
    /* Alternating row colors */
}

tr:hover {
    background: rgba(0, 0, 0, 0.05);
    /* Subtle hover effect */
}

caption {
    margin-bottom: 10px;
    /* Spacing between caption and table */
    font-size: 16px;
    /* Slightly larger than table text */
    font-weight: bold;
    text-align: center;
    color: var(--text-color);
    /* Matches your theme */
    text-transform: capitalize;
    /* Consistent capitalization style */
    letter-spacing: 0.5px;
    /* Subtle letter spacing for better aesthetics */
}

/* Figures */
figure {
    display: table;
    /* behaves like inline-block but respects margin auto */
    margin: 10px auto;
    padding: 5px;
    border: 1px solid var(--border-color);
    text-align: center;
}

figure figcaption {
    font-size: 0.9em;
    margin-top: 5px;
    max-width: 100%;
    word-wrap: break-word;
}


.figure-right,
.figure-right-white {
    float: right;
    max-width: 25%;
    min-width: 40px;
    margin: 10px;
}

.figure-right-white {
    background-color: var(--bg-color);
}

/* Code Blocks */
pre {
    border: 1px solid var(--border-color);
    padding: 1em;
    overflow-x: auto;
    background: var(--code-bg);
}

code {
    background: var(--code-bg);
}

pre code {
    background: none;
}

.article-links {
    margin: 3px 0;
    text-align: center;
    /* padding: 3px 10px; */
    /* background-color: var(--code-bg);
    border: 1px solid var(--border-color);  */
}

/* Special Blocks */
.note,
.quote,
.warn {
    margin: 3px 0;
    padding: 3px 10px;
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-left: 5px solid;
}

.note {
    border-left-color: lightblue;
    overflow: hidden;
}

.quote {
    border-left-color: lightslategray;
    overflow: hidden;
}

.warn {
    border-left-color: tomato;
    overflow: hidden;
}

.article-links {
    border-left-color: lightblue;
}

.article-type {
    color: gray;
}

/* Table of Contents */
.toc {
    float: right;
    border: 1px solid var(--border-color);
    max-width: 40%;
    margin: 0 0 0 1em;
    padding: 0 20px 10px 15px;
}

.toc-heading {
    font-size: 20px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .toc {
        float: none;
        width: 100%;
        /* Adjust to take full width */
        margin: 10px auto;
        max-width: 100%;
        padding: 15px;
        /* Add more padding for better readability */
        border: 1px solid var(--border-color);
        /* Ensure a clean look */
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        /* Optional shadow for depth */
        font-size: 1rem;
        /* Adjust font size for mobile readability */
    }
}

/* Search Input */
.search-container {
    width: 100%;
    text-align: center;
}

#search-input {
    width: 90%;
    background-color: var(--code-bg);
    color: var(--text-color);
    padding: 8px 15px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#search-input::placeholder {
    color: var(--blockquote-border);
    font-style: italic;
}

#search-input:focus {
    border-color: lightblue;
    outline: none;
    box-shadow: 0 0 5px rgba(6, 128, 250, 0.5);
}

/* Responsive Design */
@media (max-width: 600px) {
    .article-container {
        flex-direction: column;
        min-height: auto;
    }

    .thumbnail {
        margin: 0 auto 10px;
        width: 80%;
        height: auto;
    }

    .thumbnail img {
        max-width: 100%;
        height: auto;
    }
}

/* Equations */
.MathJax_Display {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

.theme-btn {
    height: 32px;
    padding: 0 10px;
    border: 0px solid var(--border-color);
    background: var(--bg-color);
    color: #08324e;
    font-size: .95rem;
    cursor: pointer;
    border-radius: 4px;
}

html[data-theme='dark'] .theme-btn {
    background: var(--bg-color);
    color: #0b2133;
    /* darker for dark mode */
}

.theme-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0px solid var(--border-color);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}

/* icon box */
.theme-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    display: block;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    /* adjust icon size */
    background-image: url('/img/dark-theme-toggle.png');
    /* light-mode icon */
}

/* swap icon in dark mode */
html[data-theme='dark'] .theme-btn::before {
    background-image: url('/img/dark-theme-toggle-dark.png');
}


/* Default (Light Mode) Logo */
#theme-logo {
    content: url('/img/logo-light.png');
    /* Light mode logo */
}

/* Dark Mode Logo */
[data-theme='dark'] #theme-logo {
    content: url('/img/logo-dark.png');
    /* Dark mode logo */
}

/* Auto Numbering */
body {
    counter-reset: h2
}

h2 {
    counter-reset: h3
}

h3 {
    counter-reset: h4
}

/* h4 {counter-reset: h5} */

article[autonumbering] h2:before {
    counter-increment: h2;
    content: counter(h2) ". "
}

article[autonumbering] h3:before {
    counter-increment: h3;
    content: counter(h2) "." counter(h3) ". "
}

/* article[autonumbering] h4:before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ". "} */

article[autonumbering] .toc ul {
    counter-reset: item
}

article[autonumbering] .toc li a:before {
    content: counters(item, ".") ". ";
    counter-increment: item
}



/* Navbar Layout */
#nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    background-color: var(--bg-color);
    height: 50px;
    box-sizing: border-box;
}

/* Logo */
#theme-logo {
    height: 40px;
    max-height: 100%;
}

/* Menu */
.menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    /* Ensures items align vertically */
    text-align: right;
    /* Align menu text to the right */
}

.menu li {
    margin: 0 10px;
}

.menu a {
    text-decoration: none;
    color: var(--link-color);
    font-size: 1rem;
    line-height: 50px;
    text-align: right;
    /* Align text to the right */
}


/* Theme Toggle */
.theme-toggle {
    display: flex;
    margin-left: 15px;
    align-items: center
}


/* Hide Burger Menu Button on Desktop */
.burger-menu {
    display: none;
}


@media (max-width: 768px) {

    /* Burger Menu Button */
    .burger-menu {
        display: block;
        font-size: 1.5rem;
        background: none;
        border: none;
        color: var(--text-color);
        cursor: pointer;
    }

    /* Hide Menu by Default */
    .menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 50px;
        /* Adjust based on navbar height */
        right: 0;
        background-color: var(--bg-color);
        width: 100%;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        align-items: right;
        border: 3px solid var(--border-color);
        /* Add border for mobile */
        border-radius: 5px;
        /* Optional: rounded corners */
    }

    .menu.show {
        display: flex;
        transform: translateY(0);
    }

    .menu li {
        margin: 5px;
        margin-right: 10px;
        text-align: right;
        align-items: right;
    }

    .theme-toggle {
        margin: 10px auto;
        /* Center theme toggle on mobile */
    }
}



.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.pagination-prev {
    flex: 1;
    text-align: left;
}

.pagination-numbers {
    flex: 1;
    text-align: center;
}

.pagination-next {
    flex: 1;
    text-align: right;
}

.pagination a {
    text-decoration: none;
    padding: 5px 10px;
    margin: 0 5px;
    /* border: 1px solid var(--border-color); */
    padding: 5px;
    color: var(--link-color);
}

.pagination a.current {
    /* background-color: #007BFF; */
    color: var(--text-color);
    font-weight: bold;
}

.dropcap {
    float: left;
    font-size: 4rem;
    /* line-height: 1; */

    margin: 0.0em 0.2em 0 0;
    padding: 0.0;

    margin-top: -1.1rem;
    margin-bottom: 0.1em;
    /* margin-right: 0.4rem; */

    font-weight: bold;
    font-family: serif;
    color: var(--text-color);
    text-transform: uppercase;
    height: 1em;
    /* Ensures the letter doesn't extend beyond */
    display: block;
    text-shadow: tomato .05em .05em;
    display: inline;
}

.footnote-ref {
    padding: 1px;
}

.dropcap-rest {
    text-transform: uppercase;
    display: inline;
}

.artifact-ribbon {
    border: 1px solid var(--border-color);
    background-color: var(--border-color);
    border-radius: 7px;
    padding-left: 2px;
    padding-right: 2px;
    text-align: center;
    /* center inline content */
    display: inline-block;
    /* allow them to flow horizontally */
    margin-right: 4px;
}

.artifact-ribbon a {
    padding-top: 0;
    font-size: 10pt;
    color: var(--text-color);
    font-weight: bold;
    text-decoration: none !important;
}


.flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;   /* circle size */
  height: 1rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 100;
  line-height: 1;
  color: #fff;
  margin-left: 0.2rem;  /* small spacing from text */
  padding: 0;           /* no extra padding */
  vertical-align: text-bottom;  /* lowers the circle */
}


/* Compact legend table to fit beside .toc */
.flag-legend {
  width: auto;                 /* ignore global width:90% */
  max-width: 58ch;             /* keep narrow; adjust as needed */
  display: inline-table;       /* shrink-to-content */
  margin: 0 0 .5rem 0;         /* no horizontal margins */
  box-shadow: none;            /* remove heavy chrome */
  font-size: 0.95rem;          /* slightly smaller */
}

.flag-legend thead th {
  padding: 6px 8px;            /* tighter header */
}

.flag-legend th,
.flag-legend td {
  padding: 4px 8px;            /* tighter cells */
  text-align: left;            /* read better in narrow table */
}

.flag-legend tr:nth-child(even) {
  background: transparent;     /* avoid zebra stripes in tiny table */
}

/* If the legend should avoid wrapping under the .toc float */
.flag-legend {
  clear: none;                 /* allow it to sit next to the TOC */
}

/* Optional: ensure main content has room when TOC floats right */
main:has(.toc) .flag-legend {
  max-width: calc(60% - 1rem); /* content column width next to .toc */
}


.plot-figure {
  width: 700px;            /* scale to container */
  min-width: 400px;
  aspect-ratio: 7 / 5;    /* maintain shape */
  height: auto;           /* let aspect ratio determine height */
  margin: 0 auto;         /* center on large screens */
  min-height: 280px;      /* avoid collapsing on small mobile */
}


@media (max-width: 700px) {
  figure {
    width: 500px;           /* fit small screens */
  }
  .plot-figure {
    width: 500px;            /* scale to container */
  }
}

@media (max-width: 500px) {
  figure {
    width: 100%;           /* fit small screens */
  }
  .plot-figure {
    width: 400px;            /* scale to container */
  }
}