/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables */
:root {
    --bg-primary: #fff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #e1e4e8;
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #999;
    --heading-color: #000;
    --link-color: #0366d6;
    --border-color: #e1e4e8;
    --code-bg: #f6f8fa;
    --lightbox-overlay: rgba(0, 0, 0, 0.95);
    --lightbox-caption-bg: rgba(255, 255, 255, 0.95);
    --lightbox-btn-bg: rgba(255, 255, 255, 0.9);
}

/* Dark Mode Variables */
body[data-theme="dark"] {
    --bg-primary: #111;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    --heading-color: #fff;
    --link-color: #6db3f2;
    --border-color: #333;
    --code-bg: #1a1a1a;
    --lightbox-overlay: rgba(0, 0, 0, 0.98);
    --lightbox-caption-bg: rgba(20, 20, 20, 0.95);
    --lightbox-btn-bg: rgba(30, 30, 30, 0.9);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    max-width: 650px;
    margin: 0 auto;
    padding: 40px 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1 {
    font-size: 2em;
    font-weight: 600;
    margin-bottom: 0.5em;
    color: var(--heading-color);
}

h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.5em;
    color: var(--heading-color);
}

h3 {
    font-size: 1.2em;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    color: var(--heading-color);
}

p {
    margin-bottom: 1em;
    color: var(--text-primary);
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Lists */
ul {
    margin-bottom: 1em;
    padding-left: 2em;
}

li {
    margin-bottom: 0.5em;
}

/* Dividers */
hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* Navigation */
nav {
    margin-bottom: 2em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-links {
    display: flex;
    gap: 0.75em;
}

nav a {
    margin-right: 0;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8em;
    color: var(--text-primary);
    font-family: inherit;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

/* Utility Classes */
.subtitle {
    color: var(--text-secondary);
    font-size: 1.1em;
    margin-bottom: 2em;
}

/* Photo Grid - Landing Page */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 1em;
}

.photo-item {
    border: 1px solid var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.photo-placeholder {
    width: 100%;
    height: 150px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 0.9em;
}

.photo-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

/* Gallery Page Specific Styles */
body.gallery-page .photo-grid {
    gap: 15px;
    margin-top: 2em;
}

body.gallery-page .photo-item {
    cursor: pointer;
    transition: transform 0.2s;
}

body.gallery-page .photo-item:hover {
    transform: scale(1.02);
}

body.gallery-page .photo-placeholder {
    height: 200px;
}

body.gallery-page .photo-item img {
    height: 200px;
}

.photo-caption {
    padding: 10px;
    background: var(--bg-secondary);
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Blog Post Styles */
.post {
    margin-bottom: 3em;
    padding-bottom: 2em;
    border-bottom: 1px solid var(--border-color);
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.post:last-child {
    border-bottom: none;
}

.post-header {
    margin-bottom: 1em;
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 0.8em;
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-wrap: wrap;
}

.post-date {
    color: var(--text-secondary);
}

.post-reading-time {
    color: var(--text-tertiary);
}

.separator {
    color: var(--text-tertiary);
}

.post-title {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 0.5em;
    color: var(--heading-color);
    line-height: 1.3;
}

.post-title a {
    color: var(--heading-color);
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: var(--link-color);
    text-decoration: none;
}

.post-excerpt {
    color: var(--text-primary);
    margin-top: 0.5em;
    line-height: 1.6;
}

.read-more {
    display: inline-block;
    margin-top: 0.5em;
    color: var(--link-color);
    font-weight: 500;
    transition: transform 0.2s ease;
}

.read-more:hover {
    transform: translateX(5px);
}

/* Blog Tags */
.post-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 0.8em;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Blog Filters */
.blog-filters {
    display: flex;
    gap: 10px;
    margin: 2em 0;
    flex-wrap: wrap;
}

/* Year Timeline */
.blog-timeline {
    margin-top: 2em;
}

.year-section {
    margin-bottom: 3em;
}

.year-heading {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 1.5em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid var(--border-color);
}

.no-results {
    text-align: center;
    padding: 3em 1em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-top: 2em;
}

/* Individual Blog Post Page */
.blog-post-page {
    max-width: 720px;
}

.blog-post {
    margin-bottom: 2em;
}

.breadcrumb {
    margin-bottom: 2em;
}

.breadcrumb a {
    color: var(--link-color);
    font-size: 0.9em;
}

.blog-post .post-header {
    margin-bottom: 2em;
    padding-bottom: 2em;
    border-bottom: 1px solid var(--border-color);
}

.blog-post .post-title {
    font-size: 2.5em;
    line-height: 1.2;
    margin-bottom: 0.8em;
}

.blog-post .post-meta {
    font-size: 1em;
}

.post-content {
    line-height: 1.8;
    font-size: 1.05em;
}

.post-content .lead {
    font-size: 1.2em;
    color: var(--text-primary);
    margin-bottom: 2em;
    line-height: 1.6;
}

.post-content h2 {
    margin-top: 2.5em;
    margin-bottom: 1em;
}

.post-content h3 {
    margin-top: 2em;
    margin-bottom: 0.8em;
}

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

.post-content li {
    margin-bottom: 0.8em;
}

.post-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5em;
    overflow-x: auto;
    margin: 1.5em 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.post-content code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-footer {
    margin-top: 4em;
    padding-top: 2em;
    border-top: 1px solid var(--border-color);
}

.post-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2em;
    margin-bottom: 2em;
}

.nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    padding: 1em;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    text-decoration: none;
}

.nav-link.prev {
    text-align: left;
}

.nav-link.next {
    text-align: right;
}

.nav-label {
    font-size: 0.8em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-title {
    font-weight: 600;
    color: var(--heading-color);
}

.back-to-blog {
    text-align: center;
}

.back-to-blog a {
    color: var(--link-color);
    font-weight: 500;
}

/* Footer */
footer {
    margin-top: 4em;
    padding-top: 2em;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Gallery Filters */
.gallery-filters {
    display: flex;
    gap: 10px;
    margin: 2em 0;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.filter-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--link-color);
    color: #fff;
    border-color: var(--link-color);
}

/* Enhanced Photo Caption for Gallery */
.caption-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.caption-meta {
    font-size: 0.85em;
    color: var(--text-tertiary);
}

/* Photo Item Animation */
body.gallery-page .photo-item {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--lightbox-overlay);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    background: var(--lightbox-caption-bg);
    padding: 15px 20px;
    border-radius: 4px;
    margin-top: 15px;
    text-align: center;
    max-width: 500px;
}

.lightbox-title {
    font-weight: 600;
    color: var(--heading-color);
    font-size: 1.1em;
    margin-bottom: 5px;
}

.lightbox-meta {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: var(--lightbox-btn-bg);
    border: none;
    font-size: 2em;
    color: var(--heading-color);
    cursor: pointer;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 1001;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: #fff;
    transform: scale(1.1);
}

.lightbox-close {
    top: 20px;
    right: 20px;
    font-size: 2.5em;
    line-height: 1;
}

.lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-prev:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-next:hover {
    transform: translateY(-50%) scale(1.1);
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--lightbox-btn-bg);
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--heading-color);
    font-size: 0.9em;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .photo-grid {
        grid-template-columns: 1fr;
    }

    .gallery-filters {
        justify-content: center;
    }

    .filter-btn {
        font-size: 0.85em;
        padding: 6px 12px;
    }

    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 1.5em;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-caption {
        font-size: 0.9em;
        padding: 12px 16px;
    }

    #lightbox-img {
        max-height: 70vh;
    }
}
