html {
    font-size: 100%;
    scroll-behavior: smooth;
}
:root {
    /*base theme*/
    --bg-color: #ffffff;
    --text-color: #333333;
    --nav-border: #eeeeee;
    --comment-color: #999999;
    --font-main: "Consolas", monospace;

    /*interaction colors*/
    --highlight-bg: #dcedc8;
    --highlight-text: #1b381d;
    --row-hover-bg: #e0e0e0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    margin: 0;
    line-height: 1.6;
    padding-top: 80px;
}
/*global text selection*/
::selection {
    background: var(--highlight-bg);
    color: var(--highlight-text);
}

::-moz-selection {
    background: var(--highlight-bg);
    color: var(--highlight-text);
}
/*layout*/
main {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}
.content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}
/*headers*/
h1, h2, h3, h4 {
    color: var(--text-color);
    font-weight: bold;
    scroll-margin-top: 100px;
}
h1::before { content: "// "; color: var(--comment-color); }
.bio-box h1::before { content: none; }

h2::before { content: "// "; color: var(--comment-color); }
h3::before { content: "/* "; color: var(--comment-color); }
h3::after  { content: " */"; color: var(--comment-color); }

/*nav bar*/
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 100%;
    border-bottom: 2px solid var(--nav-border);
    padding: 10px 40px;
    box-sizing: border-box;
    background-color: var(--bg-color);
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.nav-logo { margin-right: 30px; display: flex; border: none; }
.nav-logo img { height: 40px; width: auto; display: block; }

.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 30px; }
.main-nav li { font-size: 1.1rem; font-weight: bold; }

/*links*/
a {
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

/*standard text links (scoped to main content)*/
main a:not(.card):not(.project-card):not(.list-item):not(.back-arrow):not(.fixed-side-arrow) {
    border-bottom: 4px solid var(--highlight-bg);
    color: var(--highlight-text);
}

/*hover effect (global)*/
a:not(.card):not(.nav-logo):not(.list-item):not(.project-card):not(.back-arrow):not(.fixed-side-arrow):not(.toc-link):hover {
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    border-bottom: none;
    padding: 0 4px;
    margin: 0 -4px;
    border-radius: 3px;
}

/*box/card styling*/
.card {
    position: relative;
    display: block;
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    overflow: hidden;
    background-color: transparent;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 0; height: 100%;
    background-color: var(--highlight-bg);
    transition: width 0.3s ease;
    z-index: 0;
}
.card h2, .card p, .card div { position: relative; z-index: 1; }

.card:hover {
    border-color: var(--highlight-bg);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}
.card:hover::before { width: 8px; }
.card h2 { margin-top: 0; }
a.card:hover h2, a.card:hover p, a.card:hover span { color: var(--text-color); }

.card.no-hover:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--nav-border);
}

.card.no-hover:hover::before {
    width: 0;
}

/*project cards*/
.project-card {
    position: relative;
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 40px;
    display: block;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.project-card::after {
    content: "";
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 0;
    background-color: var(--highlight-bg);
    transition: height 0.3s ease;
    z-index: 2; opacity: 0.8;
}
.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    border-color: var(--highlight-bg);
}
.project-card:hover::after { height: 10px; }
.project-info { padding: 25px; }

/*clean project image styling*/
.project-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--nav-border);
}

/*home scroll list*/
.scroll-window {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--nav-border);
    border-radius: 8px;
    background-color: #fafafa;
}
.list-item {
    display: flex; justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px dashed #eee;
    color: var(--text-color); text-decoration: none;
    font-size: 0.95rem;
    transition: background-color 0.2s;
}
.list-item:last-child { border-bottom: none; }
.list-title { display: flex; gap: 8px; align-items: center; }

/*animation elements*/
.list-item .text {
    transition: transform 0.2s ease-out, background-color 0.3s ease, color 0.3s ease;
    padding: 0 2px; border-radius: 2px;
}
.list-item .arrow {
    transition: transform 0.2s ease-out; transition-delay: 0.05s;
    color: var(--comment-color);
}
.list-meta {
    display: flex; gap: 15px; align-items: center;
    font-family: monospace; font-size: 0.85rem;
    color: var(--comment-color); transition: color 0.2s;
}
.section-tag { opacity: 0.8; }

/*hover effects*/
.list-item:hover { background-color: var(--row-hover-bg); color: var(--text-color); }
.list-item:hover .text {
    transform: translateX(10px); font-weight: bold;
    background-color: var(--highlight-bg); color: var(--highlight-text);
}
.list-item:hover .arrow { transform: translateX(10px); }
.list-item:hover .list-meta { color: var(--text-color); }

/*project/writing list*/
.project-list {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/*post layout*/
.post-grid {
    display: block;
    position: relative;
}

.post-grid article {
    width: 100%;
}

/*floating table of contents*/
.toc-sidebar {
    position: fixed;
    top: 100px;
    right: 50px;
    left: auto;
    width: 200px;
    z-index: 10;
}

.toc-container {
    font-size: 0.85rem;
    font-family: var(--font-main);
    border-left: 2px solid #eee;
    padding-left: 15px;
}

.toc-container h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--comment-color);
    font-size: 0.8rem;
}

.toc-container nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toc-container nav ul ul {
    margin-top: 6px;
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-container li {
    display: block;
    line-height: 1.3;
}

.toc-container a {
    text-decoration: none;
    color: #888;
    transition: all 0.2s;
    display: block;
    border-bottom: none !important; /* override the global link underline */
}

.toc-container a:hover {
    color: var(--text-color);
    transform: translateX(-3px);
}

.toc-container a.active {
    color: var(--highlight-text);
    font-weight: bold;
}

/*hide on laptops/tablets*/
@media (max-width: 1150px) {
    .toc-sidebar { display: none; }
}

/*fixed side arrow*/
.fixed-side-arrow {
    position: fixed;
    top: 100px;
    left: calc(50vw - 480px);
    font-size: 2rem;
    color: var(--comment-color);
    text-decoration: none;
    line-height: 1;
    width: 60px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    z-index: 100;
}
.fixed-side-arrow:hover {
    color: var(--highlight-text);
    background-color: rgba(0,0,0,0.03);
    transform: translateX(-5px);
}

/*code blocks*/
pre {
    background-color: #f7f7f7;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--nav-border);
    overflow-x: auto;
    font-size: 0.9rem;
    margin-bottom: 30px;
}

code {
    font-family: "Consolas", monospace;
    background-color: rgba(0,0,0,0.05);
    padding: 2px 5px;
    border-radius: 4px;
}

pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

/*copy button*/
.copy-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--bg-color);
    border: 1px solid var(--nav-border);
    border-radius: 4px;
    color: var(--comment-color);
    font-family: var(--font-main);
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
}

.copy-button:hover {
    opacity: 1;
    color: var(--text-color);
    border-color: var(--comment-color);
}

.copy-button.success {
    border-color: var(--highlight-text);
    color: var(--highlight-text);
    background-color: var(--highlight-bg);
}

/*typing cursor*/
#cursor {
    display: inline-block;
    color: var(--highlight-text);
    font-weight: bold;
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/*pcb dynamic background*/
.pcb-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

/*layer dim*/
.layer-dim {
    color: #f0f0f0;
    animation: pulseColor 2.5s ease-out 1;
}

/*layer lit*/
.layer-lit {
    color: #999;
}

/*animation*/
@keyframes pulseColor {
    0%   { color: #f0f0f0; }
    50%  { color: #f0f0f0; }
    100% { color: #f0f0f0; }
}
footer {
    text-align: center;
    margin-top: 50px;
    margin-bottom: 20px;
    color: var(--comment-color); 
    font-size: 0.8rem;
    width: 100%;
}
/*mobile optimization*/
@media (max-width: 768px) {
    .pcb-container {
        display: none !important;
    }

    /*hide desktop specific ui*/
    .fixed-side-arrow, .toc-sidebar {
        display: none !important;
    }

    /*adjust body for taller stacked nav*/
    body {
        padding-top: 140px;
    }

    /*stack nav bar vertically*/
    .main-nav {
        flex-direction: column;
        padding: 15px 20px;
        gap: 15px;
        height: auto;
    }

    /*center logo*/
    .nav-logo {
        margin-right: 0;
        justify-content: center;
    }

    /*wrap and center links*/
    .main-nav ul {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    /*tighten main content margins*/
    main {
        margin-top: 20px;
        padding: 0 15px;
    }
}