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

/* CSS Variables */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #fafafa;
    --bg-hover: #f0f0f0;
    --text-primary: #000;
    --text-secondary: #444;
    --text-tertiary: #666;
    --text-muted: #555;
    --accent-primary: #163313;
    --accent-secondary: #2d5a25;
    --accent-hover: #2a5a25;
    --border-primary: #000;
    --border-secondary: #e0e0e0;
    --border-tertiary: #e8e8e8;
    --border-light: #ddd;
    --code-bg: #f5f5f5;
    --code-border: #e8e8e8;
    --code-text: #c7254e;
    --shadow-sm: rgba(0,0,0,0.1);
    --shadow-md: rgba(0,0,0,0.08);
    --link-blue: #0066cc;
    --link-blue-hover: #004499;
    --blockquote-gradient-start: #fafafa;
    --blockquote-gradient-end: #f5f5f5;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #252525;
    --bg-hover: #333;
    --text-primary: #e8e8e8;
    --text-secondary: #c0c0c0;
    --text-tertiary: #a0a0a0;
    --text-muted: #999;
    --accent-primary: #7fb069;
    --accent-secondary: #9bc47d;
    --accent-hover: #8dc273;
    --border-primary: #444;
    --border-secondary: #3a3a3a;
    --border-tertiary: #333;
    --border-light: #404040;
    --code-bg: #2a2a2a;
    --code-border: #404040;
    --code-text: #ff6b9d;
    --shadow-sm: rgba(0,0,0,0.3);
    --shadow-md: rgba(0,0,0,0.25);
    --link-blue: #5ca3ff;
    --link-blue-hover: #7bb5ff;
    --blockquote-gradient-start: #252525;
    --blockquote-gradient-end: #2a2a2a;
}

/* Base Styles */
html {
    height: 100%;
    overflow: hidden;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    font-family: Georgia, Garamond, 'Times New Roman', serif;
    font-size: 11pt;
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 100%;
    margin: 0;
    padding-top: 80px;
    padding-bottom: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1, h2, h3 {
    color: var(--text-primary);
    font-weight: 300;
    font-family: Cambria, Cochin, Georgia, 'Times New Roman', serif;
    transition: color 0.3s ease;
}

h1 {
    margin-bottom: 0.5em;
    font-size: 2em;
}

h2 {
    font-size: 1.5em;
}

h3 {
    margin-top: 1.8em;
    font-weight: 600;
}

strong, b {
    font-weight: 600;
}

em, i {
    font-style: italic;
}

p {
    margin-bottom: 1em;
}

/* Blockquotes */
blockquote {
    margin: 2.5em auto;
    padding: 1.2em 2.5em;
    max-width: 75%;
    border-top: 2px solid var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
    background: linear-gradient(to bottom, var(--blockquote-gradient-start) 0%, var(--blockquote-gradient-end) 100%);
    text-align: center;
    font-size: 1.05em;
    font-style: italic;
    letter-spacing: 0.2px;
    box-shadow: 0 1px 3px var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
}

blockquote::before {
    content: '"';
    position: absolute;
    left: 0.5em;
    top: 0.2em;
    font-size: 2.5em;
    color: var(--accent-primary);
    opacity: 0.2;
    font-family: Georgia, serif;
}

blockquote::after {
    content: '"';
    position: absolute;
    right: 0.5em;
    bottom: -0.1em;
    font-size: 2.5em;
    color: var(--accent-primary);
    opacity: 0.2;
    font-family: Georgia, serif;
}

blockquote:hover {
    background: linear-gradient(to bottom, var(--blockquote-gradient-end) 0%, var(--bg-hover) 100%);
    box-shadow: 0 2px 6px var(--shadow-md);
    transform: translateY(-1px);
}

blockquote p {
    margin: 0;
}

blockquote strong {
    font-weight: 600;
}

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

a:hover {
    background-color: var(--bg-hover);
    color: var(--accent-secondary);
}

/* Header */
header {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    padding: 10px 20px;
    background-color: var(--bg-primary);
    z-index: 1000;
    box-shadow: 0 2px 4px var(--shadow-sm);
    transition: background-color 0.3s ease;
}

.header-content {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.site-name {
    font-size: 1.3em;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    padding: 6px 0;
}

.site-name:hover {
    background-color: transparent;
    color: var(--accent-primary);
}

header nav {
    overflow: visible;
}

header nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
    overflow: visible;
}

header nav li {
    display: inline-block;
    white-space: nowrap;
}

header nav a {
    padding: 6px 12px;
    border-radius: 4px;
    color: var(--text-primary);
    transition: all 0.25s ease;
    display: block;
    position: relative;
}

header nav a::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--accent-primary);
    transition: all 0.25s ease;
    transform: translateX(-50%);
}

header nav a:hover {
    background-color: var(--bg-secondary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

header nav a:hover::after {
    width: 60%;
}

header hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid var(--border-primary);
    margin: 0.5em 0;
}

/* Dark Mode Toggle - Fixed bottom right */
.dark-mode-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-secondary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    font-size: 1.3em;
    box-shadow: 0 2px 8px var(--shadow-sm);
    z-index: 999;
}

.dark-mode-toggle:hover {
    transform: rotate(20deg) scale(1.1);
    box-shadow: 0 4px 12px var(--shadow-md);
}

.dark-mode-toggle:active {
    transform: rotate(20deg) scale(1);
}

/* Main Content */
main {
    display: block;
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 200px);
}

/* Layout */
.left {
    float: left;
    width: 45%;
    margin-right: 5%;
}

.right {
    float: right;
    width: 45%;
}

.home, .about, .contact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5%;
    max-width: 1000px;
    margin: 0 auto;
    margin-bottom: 0;
    min-height: 60vh;
}

.home .left,
.about .left,
.contact .left {
    flex: 1;
    max-width: 500px;
}

.home .right,
.about .right,
.contact .right {
    flex: 1;
    max-width: 450px;
}

.home h1,
.about h1,
.contact h1 {
    font-size: 2.2em;
    margin-bottom: 0.8em;
    font-weight: 300;
}

.home h2 {
    font-size: 1.3em;
    margin-bottom: 0.4em;
    font-weight: 300;
    color: var(--text-secondary);
}

.home p,
.about p,
.contact p {
    line-height: 1.8;
    margin-bottom: 1.2em;
}

.contact p {
    margin-bottom: 1.5em;
}

.contact a {
    color: var(--accent-primary);
    font-weight: 500;
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 1.2em;
    margin-top: 2em;
}

.contact-item {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
}

.contact-label {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    font-weight: 600;
}

.contact-item a {
    font-size: 1.05em;
    text-decoration: none;
    color: var(--accent-primary);
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-block;
}

.contact-item a:hover {
    color: var(--accent-secondary);
    transform: translateX(4px);
}

.home img,
.about img,
.contact img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px var(--shadow-sm);
    transition: filter 0.3s ease;
}

[data-theme="dark"] .about img,
[data-theme="dark"] .contact img {
    filter: invert(1) hue-rotate(180deg);
}

/* Footer */
footer {
    width: 100%;
    padding: 20px;
    margin-top: 60px;
    margin-bottom: 0;
    font-size: 0.9em;
    text-align: center;
}

.footer-nav {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9em;
    transition: opacity 0.2s;
}

.footer-nav a:hover { opacity: 0.6; }

footer hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid var(--border-primary);
    margin: 0.5em 0;
}

/* Lists */
li {
    margin-top: 8px;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Art Gallery */
.art-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 2em 0;
}

.art-gallery img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.art-gallery img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px var(--shadow-md);
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 4px;
    animation: zoomIn 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.3s ease;
}

.lightbox-close:hover {
    color: #ccc;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Project Page Styles */
.page-article {
    max-width: 800px;
    margin: 0 auto;
}

.page-title {
    margin-bottom: 2em;
    padding-bottom: 1em;
    border-bottom: 2px solid var(--border-secondary);
}

.page-title h1 {
    font-size: 2.2em;
    line-height: 1.3;
    margin: 0;
}

.post-date {
    color: var(--text-tertiary);
    font-size: 0.9em;
    margin-top: 0.5em;
    font-style: italic;
}

.page-content h2 {
    margin-top: 2em;
    margin-bottom: 0.8em;
    font-size: 1.5em;
    color: var(--accent-primary);
}

.page-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.6em;
}

.page-content p {
    margin-bottom: 1.2em;
    line-height: 1.8;
    /* text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto; */
}

.page-content ul, .page-content ol {
    margin-bottom: 1.5em;
    padding-left: 2em;
}

.page-content li {
    margin-bottom: 0.8em;
    line-height: 1.7;
}

.page-content a {
    color: var(--accent-primary);
    font-weight: 500;
    border-bottom: 1px solid var(--accent-primary);
    transition: all 0.2s;
}

.page-content a:hover {
    background-color: transparent;
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-secondary);
}

.page-links {
    margin-top: 3em;
    padding-top: 2em;
    border-top: 1px solid var(--border-secondary);
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
}

.page-links-top {
    margin-top: 0;
    margin-bottom: 2.5em;
    padding-top: 0;
    padding-bottom: 1.5em;
    border-top: none;
    border-bottom: 1px solid var(--border-tertiary);
    justify-content: center;
}

.page-link-button {
    display: inline-block;
    padding: 0.7em 1.5em;
    background-color: transparent;
    color: var(--accent-primary);
    text-decoration: none;
    border: 2px solid var(--accent-primary);
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.page-link-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background-color: var(--accent-primary);
    transition: left 0.3s ease;
    z-index: -1;
}

.page-link-button:hover {
    color: var(--bg-primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-sm);
}

.page-link-button:hover::before {
    left: 0;
}

/* Comments Section */
.comments-section {
    margin-top: 5em;
    padding-top: 2.5em;
    border-top: 1px solid var(--border-tertiary);
}

.comments-section::before {
    content: 'Comments';
    display: block;
    font-family: Cambria, Cochin, Georgia, 'Times New Roman', serif;
    font-size: 1.5em;
    font-weight: 300;
    color: var(--accent-primary);
    margin-bottom: 1.5em;
    letter-spacing: 0.5px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.95em;
    box-shadow: 0 2px 8px var(--shadow-md);
    overflow: hidden;
    border-radius: 8px;
    transition: box-shadow 0.3s ease;
}

table thead tr {
    background-color: var(--accent-primary);
    color: #ffffff;
    text-align: left;
    font-weight: 500;
}

table th,
table td {
    padding: 16px 20px;
    border: 1px solid var(--border-secondary);
}

table th {
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.3px;
}

table tbody tr {
    background-color: var(--bg-primary);
    transition: background-color 0.2s ease;
}

table tbody tr:nth-of-type(even) {
    background-color: var(--bg-tertiary);
}

table tbody tr:hover {
    background-color: var(--bg-hover);
}

table tbody tr:last-of-type {
    border-bottom: 2px solid var(--accent-primary);
}

/* Center-aligned table columns */
table th:not(:first-child),
table td:not(:first-child) {
    text-align: center;
}

/* Code Styling */
code {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.88em;
    background-color: var(--code-bg);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: var(--code-text);
    border: 1px solid var(--code-border);
    margin: 0 0.1em;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 1.2em;
    overflow-x: auto;
    margin: 1.5em 0;
    line-height: 1.5;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

pre code {
    background-color: transparent;
    padding: 0;
    border: none;
    font-size: 0.9em;
    margin: 0;
    color: inherit;
}

/* Figure and Image Captions */
figure {
    margin: 2.5em auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

figure img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: block;
}

figure img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow-md);
}

figcaption {
    margin-top: 1em;
    font-size: 0.92em;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.6;
    text-align: center;
    width: 100%;
}

.page-content figure {
    margin: 2.5em auto;
}

/* Bibliography */
.bibliography {
    list-style: none;
    padding: 0;
    margin: 2em 0;
}

.bibliography li {
    margin-bottom: 1.5em;
    padding-left: 2em;
    position: relative;
    line-height: 1.7;
}

.bibliography li::before {
    content: "[" counter(list-item) "]";
    position: absolute;
    left: 0;
    font-weight: 600;
    color: var(--accent-primary);
}

.bibliography-item {
    display: block;
}

.bibliography-item a {
    color: var(--accent-primary);
    font-weight: 500;
}

/* Blog Styles */
.blog-list {
    max-width: 800px;
}

.blog-item {
    margin-bottom: 2.5em;
    padding-bottom: 1.5em;
    border-bottom: 1px solid var(--border-secondary);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.blog-item:last-child {
    border-bottom: none;
}

.blog-item h2 {
    margin-bottom: 0.3em;
    font-size: 1.4em;
}

.blog-item h2 a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.blog-item h2 a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.post-date {
    color: var(--text-tertiary);
    font-size: 0.9em;
    margin-bottom: 0.8em;
}

.post-excerpt {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Fade-in animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.project-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding-top: 100px;
    }
    
    header {
        padding: 10px 15px;
    }
    
    .header-content {
        gap: 15px;
    }
    
    .site-name {
        font-size: 1.1em;
        flex-shrink: 0;
    }
    
    header nav {
        flex: 1;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    header nav ul {
        gap: 12px;
        overflow: visible;
        flex-wrap: nowrap;
    }
    
    header nav a {
        font-size: 0.9em;
        padding: 5px 10px;
    }
    
    .dark-mode-toggle {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.2em;
    }
    
    main {
        padding: 15px;
    }
    
    .home, .about, .contact {
        flex-direction: column;
        gap: 2em;
    }
    
    .home .left, .home .right,
    .about .left, .about .right,
    .contact .left, .contact .right {
        max-width: 100%;
        width: 100%;
    }
    
    .page-title h1 {
        font-size: 1.8em;
    }
    
    .home h1 {
        font-size: 2em;
    }
    
    .page-links {
        flex-direction: column;
    }
    
    .page-link-button {
        width: 100%;
        text-align: center;
    }
    
    /* Responsive tables */
    table {
        font-size: 0.85em;
    }
    
    table th,
    table td {
        padding: 12px 10px;
    }
    
    /* Responsive blockquotes */
    blockquote {
        max-width: 95%;
        padding: 1em 1.5em;
        font-size: 1em;
        margin: 1.5em auto;
    }
    
    blockquote::before,
    blockquote::after {
        font-size: 2em;
    }
    
    blockquote::before {
        left: 0.3em;
        top: 0.1em;
    }
    
    blockquote::after {
        right: 0.3em;
        bottom: -0.05em;
    }
}

/* Footnotes */
.footnotes {
    margin-top: 2.5em;
    padding-top: 1.5em;
    border-top: 1px solid var(--border-light);
    font-size: 0.9em;
    color: var(--text-muted);
    transition: border-color 0.3s ease, color 0.3s ease;
}

.footnotes ol {
    margin: 0;
    padding-left: 1.2em;
}

.footnotes li {
    margin-bottom: 0.4em;
    padding-left: 0.3em;
}

.footnotes li:last-child {
    margin-bottom: 0;
}

.footnotes p {
    margin: 0;
}

/* Footnote reference in text */
sup {
    line-height: 0;
    font-size: 0.85em;
}

sup a,
a.footnote,
.page-content sup a {
    text-decoration: none;
    border-bottom: none;
    color: var(--link-blue);
    font-weight: normal;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-block;
}

sup a:hover,
a.footnote:hover,
.page-content sup a:hover {
    transform: scale(1.2);
}

/* Ensure footnote references aren't hidden behind fixed header when jumping back */
sup[id],
.footnote-backref {
    scroll-margin-top: 100px;
}

a.footnote:hover {
    color: var(--link-blue-hover);
    text-decoration: underline;
}

/* Return link from footnote */
a.reversefootnote {
    text-decoration: none;
    margin-left: 0.2em;
    font-size: 0.85em;
    color: var(--text-muted);
}

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

/* Ensure all anchor targets have proper scroll margin for fixed header */
:target {
    scroll-margin-top: 100px;
    animation: highlightTarget 2s ease;
}

@keyframes highlightTarget {
    0% {
        background-color: var(--accent-primary);
        color: var(--bg-primary);
        border-radius: 4px;
    }
    100% {
        background-color: transparent;
        color: inherit;
    }
}

/* Page load fade-in animation */
main {
    animation: fadeIn 0.4s ease-out;
}

/* Home/About/Contact page content staggered entrance */
.home .left,
.about .left,
.contact .left {
    animation: slideInLeft 0.6s ease-out;
}

.home .right,
.about .right,
.contact .right {
    animation: slideInRight 0.6s ease-out 0.15s both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Focus styles for accessibility with nice animation */
a:focus-visible,
button:focus-visible,
.page-link-button:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
    border-radius: 2px;
}

/* Smooth loading indicator for images */
img {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Selection styling */
::selection {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
}

::-moz-selection {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
}
