/* Modern Theme with Light/Dark Mode for k1monfared.github.io */

:root {
    /* Dark Mode Colors (Default) */
    --bg-primary: #0a0e1a;
    --bg-secondary: rgba(25, 30, 40, 0.6);
    --bg-nav: rgba(18, 23, 33, 0.5);
    --bg-nav-secondary: rgba(18, 23, 33, 0.4);
    --bg-sticky: rgba(10, 14, 26, 0.95);
    --bg-gradient-1: rgba(40, 40, 60, 0.08);
    --bg-gradient-2: rgba(30, 30, 50, 0.06);
    --bg-gradient-3: rgba(50, 50, 70, 0.05);
    --bg-button: rgba(25, 30, 40, 0.6);
    --bg-button-hover: rgba(96, 165, 250, 0.15);

    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-dim: #718096;
    --text-dimmer: #4a5568;

    --link-default: #7dd3fc;
    --link-hover: #38bdf8;
    --link-visited: #93c5fd;
    --link-active: #60a5fa;

    --border-color: rgba(113, 128, 150, 0.3);
    --border-hover: rgba(113, 128, 150, 0.5);
    --border-accent: rgba(96, 165, 250, 0.5);

    --gradient-start: #a0aec0;
    --gradient-mid: #cbd5e1;
    --gradient-end: #e2e8f0;

    --shadow-color: rgba(0, 0, 0, 0.3);
    --image-overlay: rgba(0, 0, 0, 0.75);
}

/* Light Mode Colors */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: rgba(255, 255, 255, 0.8);
    --bg-nav: rgba(248, 250, 252, 0.95);
    --bg-nav-secondary: rgba(241, 245, 249, 0.95);
    --bg-sticky: rgba(248, 250, 252, 0.98);
    --bg-gradient-1: rgba(226, 232, 240, 0.3);
    --bg-gradient-2: rgba(203, 213, 225, 0.2);
    --bg-gradient-3: rgba(241, 245, 249, 0.25);
    --bg-button: rgba(226, 232, 240, 0.6);
    --bg-button-hover: rgba(59, 130, 246, 0.1);

    --text-primary: #0f172a;
    --text-secondary: #1e293b;
    --text-muted: #334155;
    --text-dim: #475569;
    --text-dimmer: #64748b;

    --link-default: #0369a1;
    --link-hover: #075985;
    --link-visited: #0284c7;
    --link-active: #0369a1;

    --border-color: rgba(148, 163, 184, 0.3);
    --border-hover: rgba(100, 116, 139, 0.5);
    --border-accent: rgba(59, 130, 246, 0.5);

    --gradient-start: #334155;
    --gradient-mid: #1e293b;
    --gradient-end: #0f172a;

    --shadow-color: rgba(0, 0, 0, 0.1);
    --image-overlay: rgba(0, 0, 0, 0.65);
}

html {
    scroll-padding-top: 62px;
    scroll-behavior: smooth;
}

/* Ensure anchored sections clear the sticky nav */
[id] {
    scroll-margin-top: 62px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Default link styles - applies everywhere unless overridden */
a {
    color: var(--link-default);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

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

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

/* Animated background gradient */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, var(--bg-gradient-1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, var(--bg-gradient-2) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, var(--bg-gradient-3) 0%, transparent 50%);
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Header - Full width with centered content */
.site-header {
    width: 100%;
    padding: 0.5rem 0 0.25rem;
    position: relative;
    z-index: 1;
    background: var(--bg-button);
    backdrop-filter: blur(12px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

.myTitle {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-mid) 50%, var(--gradient-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.myTitleFooter {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 400;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

/* Navigation - Full Width */
#stickThis {
    transition: all 0.3s ease;
    margin: 0;
    width: 100%;
}

#menu {
    background: var(--bg-nav);
    backdrop-filter: blur(16px);
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    width: 100%;
}

#menu a,
#menu a:link,
#menu a:visited {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: relative;
    padding: 0.15rem 0;
    line-height: 1.2;
}

#menu a:hover,
#menu a:active,
#menu #this_page a,
#menu a.active {
    color: var(--text-secondary);
}

#menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--link-active);
    transition: width 0.3s ease;
}

#menu a:hover::after,
#menu #this_page a::after,
#menu a.active::after {
    width: 100%;
}

.menuItem {
    padding-right: 0;
}

#small_menu {
    background: var(--bg-nav-secondary);
    backdrop-filter: blur(8px);
    border: none;
    padding: 0.35rem 1rem;
    border-radius: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    width: 100%;
}

#small_menu a,
#small_menu a:link,
#small_menu a:visited {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    line-height: 1.2;
}

#small_menu a:hover,
#small_menu a:active {
    color: var(--text-secondary);
}

.small_menuItem {
    padding-right: 0;
}

/* Sticky Navigation */
#stickThis.stick {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0;
    margin: 0;
    width: 100%;
}

#stickThis.stick #menu {
    background: var(--bg-nav);
    backdrop-filter: blur(16px);
    margin: 0;
    padding: 0.4rem 1rem;
}

#stickThis.stick #small_menu {
    background: var(--bg-nav-secondary);
    backdrop-filter: blur(8px);
    padding: 0.35rem 1rem;
}

/* Main Content */
#pageContent {
    display: block;
    width: 100%;
    padding-top: 0;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 0 2rem 2rem;
    font-size: 1rem;
    line-height: 1.6;
}

#mainContent {
    font-size: 16px;
    width: 100%;
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 0 2rem 2rem;
    border-right: none;
    color: var(--text-secondary);
}

#mainContent h2,
#mainContent h3 {
    background: linear-gradient(90deg, var(--text-primary) 0%, var(--gradient-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
    font-weight: 700;
    margin-bottom: 1rem;
}

#mainContent h2 {
    font-size: 1.75rem;
}

#mainContent h3 {
    font-size: 1.25rem;
}

#mainContent ul {
    list-style: none;
    padding-left: 0;
}

#mainContent ul li {
    padding: 0.5rem 0 0.5rem 1.5rem;
    position: relative;
    line-height: 1.6;
}

#mainContent ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--text-dimmer);
    font-size: 1.1rem;
}

#mainContent a,
#mainContent a:link {
    color: var(--link-default);
    text-decoration: none;
    transition: color 0.2s ease;
    border-bottom: 1px solid transparent;
}

#mainContent a:visited {
    color: var(--link-visited);
}

#mainContent a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

#mainContent a:active {
    color: var(--link-active);
}

/* Tables */
table, #table1 {
    border: none;
    width: 100%;
    border-collapse: collapse;
}

td, th {
    border: none;
    text-align: left;
    padding: 1rem 0;
    vertical-align: top;
    color: var(--text-secondary);
}

th {
    color: var(--text-primary);
    font-weight: 600;
}

tr {
    border-bottom: none;
}

tr:last-child {
    border-bottom: none;
}

tr:hover {
    transform: translateX(4px);
    transition: transform 0.2s ease;
}

/* Buttons */
.togglebutton,
.togglebuttonh3,
input[type="button"],
button {
    background: var(--bg-button);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.togglebutton:hover,
.togglebuttonh3:hover,
button:hover {
    background: var(--bg-button-hover);
    border-color: var(--border-accent);
    color: var(--link-default);
}

/* Images */
.imageContainer {
    position: relative;
    text-align: center;
    color: white;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.imageContainer:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.imageContainer img {
    width: 100%;
    height: auto;
    transition: transform 0.4s ease;
    filter: brightness(0.7);
}

.imageContainer:hover img {
    transform: scale(1.05);
    filter: brightness(0.9);
}

.top-right {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(10, 14, 26, 0.95), transparent);
    padding: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

/* Footer */
.PageFooter {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--text-dimmer);
    font-size: 0.85rem;
    max-width: 1200px;
    margin: 2rem auto 0;
}

.social-media {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.social-icon {
    width: 36px;
    height: 36px;
    background-color: var(--text-muted);
    mask-size: 20px 20px;
    mask-position: center;
    mask-repeat: no-repeat;
    transition: all 0.3s ease;
    display: inline-block;
}

.social-icon:hover {
    background-color: var(--text-secondary);
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px rgba(203, 213, 225, 0.8));
}

.social-github {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z'/%3E%3C/svg%3E");
}

.social-linkedin {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z'/%3E%3C/svg%3E");
}

.social-scholar {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 24a7 7 0 110-14 7 7 0 010 14zm0-24L0 9.5l4.838 3.94A8 8 0 0112 9a8 8 0 017.162 4.44L24 9.5z'/%3E%3C/svg%3E");
}

.social-arxiv {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17.732 24.269'%3E%3Cpath d='M573.549,280.916l2.266,2.738,6.674-7.84c.353-.47.52-.717.353-1.117a1.218,1.218,0,0,0-1.061-.748h0a.953.953,0,0,0-.712.262Z' transform='translate(-566.984 -271.548)'/%3E%3Cpath d='M579.525,282.225l-10.606-10.174a1.413,1.413,0,0,0-.834-.5,1.09,1.09,0,0,0-1.027.66c-.167.4-.047.681.319,1.206l8.44,10.242h0l-6.282,7.716a1.336,1.336,0,0,0-.323,1.3,1.114,1.114,0,0,0,1.04.69A.992.992,0,0,0,571,293l8.519-7.92A1.924,1.924,0,0,0,579.525,282.225Z' transform='translate(-566.984 -271.548)'/%3E%3Cpath d='M584.32,293.912l-8.525-10.275,0,0L573.53,280.9l-1.389,1.254a2.063,2.063,0,0,0,0,2.965l10.812,10.419a.925.925,0,0,0,.742.282,1.039,1.039,0,0,0,.953-.667A1.261,1.261,0,0,0,584.32,293.912Z' transform='translate(-566.984 -271.548)'/%3E%3C/svg%3E");
}

.social-wordpress {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12.06 0C5.398 0 0 5.397 0 12.06c0 6.662 5.397 12.06 12.06 12.06s12.06-5.398 12.06-12.06C24.12 5.397 18.722 0 12.06 0zM2.391 12.06c0-1.42.303-2.767.85-3.984l4.684 12.843A9.614 9.614 0 012.39 12.06zm9.67 9.671c-.948 0-1.86-.162-2.713-.46l2.883-8.382 2.953 8.09.021.05a9.566 9.566 0 01-3.144.702zm1.338-14.263c.583-.03 1.109-.091 1.109-.091.522-.061.46-.83-.061-.799 0 0-1.571.122-2.585.122-.952 0-2.555-.122-2.555-.122-.522-.03-.584.769-.061.798 0 0 .491.061 1.012.092l1.502 4.117-2.111 6.33-3.513-10.447c.583-.03 1.109-.091 1.109-.091.522-.061.46-.83-.062-.799 0 0-1.571.122-2.585.122-.182 0-.396-.004-.625-.011A9.64 9.64 0 0112.06 2.45c2.232 0 4.265.76 5.888 2.034-.037-.002-.074-.007-.113-.007-.952 0-1.627.829-1.627 1.719 0 .799.46 1.475.952 2.274.368.645.799 1.475.799 2.673 0 .829-.319 1.79-.737 3.127l-.967 3.23-3.506-10.432zm4.895 13.516l2.934-8.486c.547-1.368.73-2.462.73-3.43 0-.353-.023-.681-.066-.986a9.635 9.635 0 01-3.598 12.902z'/%3E%3C/svg%3E");
}

.social-sponsor {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
}

/* Footer - Sticky to bottom */
.site-footer {
    margin-top: auto;
    padding: 2rem 0 1.5rem;
    width: 100%;
}

/* On non-mobile, pin the footer to the bottom of the screen (always visible).
   Content gets bottom padding so nothing hides behind the fixed bar. */
@media (min-width: 768px) {
    .site-footer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        margin-top: 0;
        padding: 0.75rem 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        z-index: 50;
    }
    .container {
        padding-bottom: 84px;
    }
}

.footer-credit {
    color: var(--text-dimmer);
    font-size: 0.85rem;
    margin-top: 1rem;
    text-align: right;
    padding-right: 2rem;
}

/* Scroll to top button - mobile only */
.scroll-to-top {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background: rgba(25, 30, 40, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.scroll-to-top:hover {
    background: rgba(30, 35, 45, 0.95);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.scroll-to-top::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(0px) rotate(45deg);
    width: 14px;
    height: 14px;
    border-top: 3px solid #94a3b8;
    border-left: 3px solid #94a3b8;
}

.scroll-to-top::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(8px) rotate(45deg);
    width: 14px;
    height: 14px;
    border-top: 3px solid #94a3b8;
    border-left: 3px solid #94a3b8;
}

/* Responsive - mobile/tablet */
@media (max-width: 1023px) {
    .site-header {
        padding: 0.4rem 0 0.2rem;
    }

    .header-content {
        padding: 0 1rem;
    }

    .myTitle {
        font-size: 1.5rem;
    }

    .myTitleFooter {
        font-size: 0.7rem;
    }

    /* Nav stays sticky on tablets, only static on very small screens */

    #menu {
        gap: 0.75rem;
        padding: 0.3rem 0.5rem;
    }

    #menu a {
        font-size: 0.8rem;
    }

    #small_menu {
        gap: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    #small_menu a {
        font-size: 0.75rem;
    }

    /* Show scroll to top button on mobile */
    .scroll-to-top {
        display: block;
    }

    #mainContent {
        padding: 0 1rem 1rem;
    }

    table, #table1 {
        font-size: 0.9rem;
    }

    td, th {
        padding: 0.75rem 0;
    }

    /* Portfolio grid - 2 columns on mobile */
    .portfolio-grid table {
        display: block;
    }

    .portfolio-grid table tbody {
        display: block;
    }

    .portfolio-grid table tr {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .portfolio-grid table td {
        display: block;
        padding: 0;
    }

    .main-content {
        padding: 0 1rem 2rem;
    }
}

/* Theme Toggle Button (site_kit theme.js targets #theme-toggle) */
#theme-toggle {
    position: fixed;
    top: 0.75rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: var(--bg-button);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 8px var(--shadow-color);
    padding: 8px;
    color: transparent;
    font-size: 0;
    overflow: hidden;
}

#theme-toggle:hover {
    background: var(--bg-button-hover);
    border-color: var(--border-accent);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-color);
}

#theme-toggle:active {
    transform: scale(0.95);
}

/* Sun icon for dark mode, light colored */
#theme-toggle::before {
    content: '';
    width: 100%;
    height: 100%;
    background-color: #f1f5f9;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
    mask-size: contain;
    mask-position: center;
    mask-repeat: no-repeat;
    transition: all 0.3s ease;
}

#theme-toggle:hover::before {
    background-color: #ffffff;
}

/* Moon icon for light mode, dark colored */
[data-theme="light"] #theme-toggle::before {
    background-color: #334155;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}

[data-theme="light"] #theme-toggle:hover::before {
    background-color: #1e293b;
}

@media (max-width: 1023px) {
    #theme-toggle {
        top: 0.5rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
        padding: 7px;
    }
}

/* Blog post navigation in small_menu */
#small_menu .current-post {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

#small_menu .disabled {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.3;
    cursor: default;
}

/* ===== Collapsible sections (vanilla JS toggle) ===== */
.collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.collapsible.expanded {
    overflow: visible;
}

/* ===== Hero section (homepage) ===== */
.hero {
    text-align: center;
    padding: 2rem 1rem;
}

.hero-tagline {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.hero-narrative {
    max-width: 700px;
    margin: 0 auto;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
}

/* ===== Expertise cards (homepage) ===== */
.expertise-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 1.5rem 0;
}

@media (max-width: 800px) {
    .expertise-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .expertise-grid {
        grid-template-columns: 1fr;
    }
}

.expertise-card {
    border: none;
    border-radius: 10px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
    display: block;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    min-height: 160px;
}

.expertise-card::before {
    content: '';
    position: absolute;
    inset: 0;
    /* Light wash only: keep the artwork visible while a text-shadow carries
       title legibility on both dark and light images. */
    background: rgba(0, 0, 0, 0.22);
    transition: background 0.3s ease;
    z-index: 0;
    border-radius: inherit;
}

.expertise-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 16px var(--shadow-color);
}

.expertise-card:hover::before {
    background: rgba(0, 0, 0, 0.08);
}

.expertise-card h3,
.expertise-card p {
    position: relative;
    z-index: 1;
}

.expertise-card h3 {
    color: #f1f5f9;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    /* Black outline around the letters for legibility over any image; the
       stroke is painted behind the fill so it does not thin the glyphs. */
    -webkit-text-stroke: 0.6px #000;
    text-stroke: 0.6px #000;
    paint-order: stroke fill;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.7);
}

.expertise-card p {
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

/* Card art is stored dark, so it sits right in the default dark theme. In light
   mode the whole card is inverted as a group to flip the image, then the overlay
   and text are inverted a second time to cancel, leaving only the image flipped. */
[data-theme="light"] .expertise-card {
    filter: invert(1);
}
[data-theme="light"] .expertise-card::before,
[data-theme="light"] .expertise-card h3,
[data-theme="light"] .expertise-card p {
    filter: invert(1);
}

/* Cards whose art must not invert (photos): keep the image and cancel the group flip. */
[data-theme="light"] .expertise-card.no-invert,
[data-theme="light"] .expertise-card.no-invert::before,
[data-theme="light"] .expertise-card.no-invert h3,
[data-theme="light"] .expertise-card.no-invert p {
    filter: none;
}

/* In light mode the card titles read as black with a white outline. */
[data-theme="light"] .expertise-card h3 {
    color: #0f172a;
    -webkit-text-stroke-color: #ffffff;
    text-stroke-color: #ffffff;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.95), 0 0 8px rgba(255, 255, 255, 0.7);
}

/* ===== Horizontal career timeline (homepage) ===== */
.h-timeline-wrapper {
    margin: 1.5rem 0;
    overflow: visible;
}

.h-timeline {
    position: relative;
    width: 100%;
    height: 280px;
}

/* The horizontal line */
.h-timeline-track {
    position: absolute;
    top: 50%;
    left: 4%;
    right: 4%;
    height: 2px;
    background: var(--border-color);
    transform: translateY(-50%);
}

/* Year markers along the track */
.h-timeline-years {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 0;
}

.h-timeline-years span {
    position: absolute;
    transform: translateX(-50%) translateY(16px);
    font-size: 0.65rem;
    color: var(--text-dimmer);
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* Each entry: positioned absolutely along the track */
.h-timeline-entry {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    transform: translateX(-50%);
}

/* Duration bars on the track */
.h-timeline-bar {
    position: absolute;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    border-radius: 2px;
    z-index: 1;
    opacity: 0.25;
    background: var(--link-default);
    transition: opacity 0.2s ease, height 0.2s ease;
}

.h-timeline-bar.highlight {
    opacity: 0.8;
    height: 6px;
}

/* Dot on the line */
.h-timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    background: var(--link-default);
    flex-shrink: 0;
    z-index: 2;
}

/* Card with text */
.h-timeline-card {
    text-align: center;
    padding: 0.25rem;
    width: auto;
    max-width: 120px;
    position: relative;
}

/* Dotted connector from the dot on the line to the (possibly offset) card.
   Height is set per-card by the layout script via the --conn variable. It picks
   up the accent colour along with the bar when its entry is hovered. */
.h-timeline-card::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 0;
    height: var(--conn, 0);
    border-left: 1px dotted var(--text-dimmer);
    pointer-events: none;
}
.h-timeline-entry.above .h-timeline-card::after { top: 100%; }
.h-timeline-entry.below .h-timeline-card::after { bottom: 100%; }
.h-timeline-entry:hover .h-timeline-card::after { border-color: var(--link-default); }

.h-timeline-date {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-weight: 600;
}

.h-timeline-role {
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.2;
}

.h-timeline-org {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.2;
}

/* "above" entries: card above line, dot on line */
.h-timeline-entry.above {
    top: 50%;
    transform: translateX(-50%) translateY(-100%);
}

.h-timeline-entry.above .h-timeline-card {
    display: flex;
    flex-direction: column-reverse;
}

/* "below" entries: dot on line, card below */
.h-timeline-entry.below {
    top: 50%;
    transform: translateX(-50%);
}

/* Edge items: left-align to prevent clipping */
.h-timeline-entry.edge-left {
    transform: translateX(-5px);
}

.h-timeline-entry.edge-left .h-timeline-card {
    text-align: left;
}

/* On narrow screens the proportional timeline can't fit; instead of letting the
   absolutely-positioned cards overlap and spill outside the page, keep the full
   spacing and let the whole timeline scroll horizontally within its box. */
@media (max-width: 760px) {
    .h-timeline-wrapper {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .h-timeline {
        min-width: 700px;
    }
}

/* ===== Selected highlights (homepage) ===== */
.highlights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.highlight-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
}

.highlight-item .highlight-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--link-active);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.highlight-item h4 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.highlight-item p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

/* ===== Section blocks (math-and-cs domain sections) ===== */
.section-block {
    margin: 1.5rem 0;
}

.section-block h3 {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
}

.section-block ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.section-block ul li {
    padding: 0.35rem 0;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.section-block ul li + li {
    margin-top: 0.15rem;
}

/* ===== Domain section (math-and-cs) ===== */
.domain-section {
    margin-bottom: 3rem;
    padding-top: 0;
}



.domain-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.domain-intro {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    max-width: 800px;
}

/* Paper items */
.paper-item {
    padding: 0.6rem 0;
}

.paper-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.paper-thumb {
    width: 96px;
    height: 96px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.3s ease, box-shadow 0.3s ease;
    cursor: zoom-in;
    position: relative;
    z-index: 1;
}

.paper-item:hover .paper-thumb {
    opacity: 1;
}

.paper-thumb:hover {
    transform: scale(1.5);
    transform-origin: top left;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}

.paper-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.25;
}

.paper-icon-lg {
    width: 96px;
    height: 96px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.paper-icon svg {
    width: 36px;
    height: 36px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--text-secondary);
}

.paper-title-text {
    color: var(--text-secondary);
}

.paper-info {
    flex: 1;
    min-width: 0;
}

.paper-authors {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
    margin-top: 0.15rem;
}

.paper-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.paper-venue {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.paper-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    background: var(--bg-button);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.3;
}

.paper-action-btn:hover {
    background: var(--bg-button-hover);
    border-color: var(--border-accent);
    color: var(--link-default);
}

.paper-action-btn.active {
    background: var(--bg-button-hover);
    border-color: var(--border-accent);
    color: var(--link-default);
}

.paper-action-btn svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.paper-details {
    margin-top: 0.5rem;
    padding-left: calc(44px + 0.75rem);
}

.paper-details p {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.55;
    margin: 0;
}

.paper-details p + p {
    margin-top: 0.4rem;
}

/* ===== Sub-menu for math-and-cs ===== */
#small_menu a.sub-active {
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: var(--link-active);
    text-underline-offset: 4px;
}

/* ===== Publication tags (inline, for "In Progress" etc.) ===== */
.pub-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: none;
    color: var(--text-dim);
    border: 1px solid var(--border-color);
    margin-left: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Archive banner (old pages) ===== */
.archive-banner {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin: 1rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.archive-banner a {
    font-weight: 600;
}

/* ===== Interest cards ===== */
.interests-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.interest-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0;
}

.interest-card .interest-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    margin-top: 0.1rem;
    opacity: 0.3;
}

.interest-card .interest-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--text-secondary);
}

.interest-card h3 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.interest-card p,
.interest-card li {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.interest-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.interest-card ul li {
    padding: 0.2rem 0;
}

.interest-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.interest-card h3 a:hover {
    color: var(--link-default);
}

.interest-card .interest-links {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.interest-card .interest-links a {
    color: var(--link-default);
    text-decoration: none;
}

.interest-card .interest-links a:hover {
    text-decoration: underline;
}

/* ===== About page ===== */
.about-section {
    margin-bottom: 2rem;
}

.about-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.contact-info {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.contact-photo {
    width: 180px;
    border-radius: 50%;
    clip-path: circle(45% at center);
}

.contact-links {
    flex: 1;
    min-width: 250px;
}

.contact-links p {
    margin: 0.4rem 0;
    color: var(--text-primary);
    font-size: 1rem;
}


.resume-table {
    width: 100%;
    border-collapse: collapse;
}

.resume-table td {
    padding: 0.45rem 0;
    color: var(--text-primary);
    font-size: 1rem;
    vertical-align: top;
    line-height: 1.6;
}

.resume-table .resume-date {
    width: 100px;
    color: var(--text-dim);
    font-size: 0.85rem;
    white-space: nowrap;
    padding-right: 1rem;
}

@media (max-width: 600px) {
    .collaborators-list {
        column-count: 1;
    }

    .contact-info {
        flex-direction: column;
        align-items: center;
    }

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

    .section-block {
        margin: 1rem 0;
    }

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

    .interests-grid {
        gap: 0.25rem;
    }
}

/* ===== Sponsor page ===== */
.sponsor-intro {
    max-width: 680px;
    margin: 0 0 2rem;
}

.sponsor-intro h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.sponsor-intro p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    margin: 0 0 0.75rem;
}

.sponsor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.sponsor-card {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.sponsor-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-accent);
    background: var(--bg-button-hover);
    text-decoration: none;
}

.sponsor-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-primary);
}

.sponsor-icon svg {
    width: 24px;
    height: 24px;
}

.sponsor-github .sponsor-icon { color: #db61a2; }
.sponsor-kofi .sponsor-icon   { color: #ff5e5b; }
.sponsor-patreon .sponsor-icon { color: #ff6b4a; }

.sponsor-body {
    flex: 1;
    min-width: 0;
}

.sponsor-body h3 {
    margin: 0 0 0.35rem;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
}

.sponsor-body p {
    margin: 0 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.sponsor-cta {
    display: inline-block;
    color: var(--link-default);
    font-size: 0.85rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    word-break: break-all;
}

.sponsor-footnote {
    max-width: 680px;
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.6;
    font-style: italic;
    margin-top: 1.5rem;
}


@media (max-width: 550px) {
    #stickThis {
        position: static !important;
    }

    #stickThis.stick {
        position: static !important;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
    }
}

/* ===== Content card (sections) ===== */
.content-card {
    margin-bottom: 2rem;
}

.content-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}
