/* CSS Variables */
:root {
    --sidebar-width: 16rem;
    --primary-color: #2563eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

/* Dark theme overrides */
body.theme-dark {
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #0b1220;
    --border-color: #374151;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.6);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.6);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
}

/* Layout */
.site-wrapper {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.mobile-header {
    display: none;
}

/* Sidebar */
.sidebar {
    background: var(--bg-primary);
    padding: 2rem;
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

/* Make sidebar content fill height so footer can stick to bottom */
.sidebar > nav {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.theme-toggle:hover {
    border-color: var(--primary-color);
}

.theme-toggle .icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
}

.sidebar-logo {
    margin-bottom: 3rem;
}

.sidebar-logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 3rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.nav-icon {
    font-size: 1.25rem;
}

.sidebar-social {
    display: flex;
    gap: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    justify-content: center;
    margin-top: auto;
}

.social-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.social-link:hover {
    color: var(--primary-color);
}

/* Main content */
main {
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.content-container {
    max-width: 800px;
    margin: 0 auto;
}

.content-container-wide {
    max-width: 1200px;
    margin: 0 auto;
}

/* Page header */
.page-header {
    margin-bottom: 3rem;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.back-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    margin-bottom: 1.5rem;
}

.back-link:hover {
    text-decoration: underline;
}

.header-links {
    margin-top: 1rem;
}

.header-links a {
    color: var(--primary-color);
    text-decoration: none;
    margin-right: 1rem;
}

/* Home page */
.home-container {
    max-width: 800px;
    margin: 0 auto;
}

.about-section {
    margin-bottom: 4rem;
}

.about-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.avatar {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
}

.about-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.about-content p {
    font-size: 1.125rem;
    line-height: 1.7;
}

.latest-post-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.view-all {
    text-align: center;
    margin-top: 2rem;
}

.view-all a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Post cards */
.post-card {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.post-card:hover {
    box-shadow: var(--shadow-md);
}

.post-date {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.post-title {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

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

.post-title a:hover {
    color: var(--primary-color);
}

.post-summary {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.read-more {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.read-more:hover {
    text-decoration: underline;
}

/* Tags */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 9999px;
    font-size: 0.875rem;
}

.tag:hover {
    background: var(--primary-color);
    color: white;
}

/* Blog post */
.blog-post,
.tutorial-post {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 3rem;
    box-shadow: var(--shadow-sm);
}

.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

/* Prose styles */
.prose {
    max-width: 65ch;
    line-height: 1.7;
    font-size: 1.125rem;
}

.prose h1 { font-size: 2.5rem; margin: 2rem 0 1rem; }
.prose h2 { font-size: 2rem; margin: 1.5rem 0 0.75rem; }
.prose h3 { font-size: 1.5rem; margin: 1.25rem 0 0.5rem; }
.prose h4 { font-size: 1.25rem; margin: 1rem 0 0.5rem; }
.prose p { margin: 1rem 0; }
.prose ul, .prose ol { margin: 1rem 0; padding-left: 2rem; }
.prose li { margin: 0.5rem 0; }
.prose a { color: var(--primary-color); text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose code { 
    background: #f1f5f9; 
    padding: 0.2rem 0.4rem; 
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: 'Courier New', monospace;
}
.prose pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}
.prose pre code {
    background: none;
    padding: 0;
}
.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
}
.prose blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
}
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}
.prose th,
.prose td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}
.prose th {
    background: var(--bg-secondary);
    font-weight: 600;
}

/* Archive */
.archive-year {
    margin-bottom: 3rem;
}

.archive-year h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.archive-list {
    list-style: none;
}

.archive-list li {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
}

.archive-list time {
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-width: 6rem;
}

.archive-list a {
    color: var(--text-primary);
    text-decoration: none;
}

.archive-list a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Tutorial grid */
.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.tutorial-card {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 2rem;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.tutorial-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.category-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.tutorial-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.tutorial-card p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.tutorial-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Tutorials list */
.tutorials-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tutorial-item {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.tutorial-item h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

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

.tutorial-item h3 a:hover {
    color: var(--primary-color);
}

.tutorial-item p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.tutorial-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Projects grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.project-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.project-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.project-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.project-link:hover {
    text-decoration: underline;
}

/* Gallery grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.gallery-card {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.gallery-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.gallery-cover {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.gallery-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.gallery-card:hover .gallery-cover img {
    transform: scale(1.05);
}

.gallery-info {
    padding: 1.5rem;
}

.gallery-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.gallery-info p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.photo-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Photo grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    grid-auto-rows: 280px;
}

.photo-card {
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
    display: block;
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s;
}

.photo-card:hover img {
    opacity: 0.9;
}

.photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.photo-card:hover .photo-overlay {
    transform: translateY(0);
}

.photo-overlay h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.photo-overlay p {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Photo viewer */
.photo-viewer {
    background: #000;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 2rem;
}

.photo-full {
    width: 100%;
    height: auto;
    display: block;
}

.photo-info {
    background: var(--bg-primary);
    border-radius: 0.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.photo-info h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.photo-caption {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.photo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.photo-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.photo-nav {
    display: flex;
    justify-content: space-between;
}

.nav-button {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.nav-button:hover {
    background: #1d4ed8;
}

/* Mobile styles */
@media (max-width: 768px) {
    .site-wrapper {
        grid-template-columns: 1fr;
    }
    
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .logo {
        font-size: 1.25rem;
        font-weight: bold;
        color: var(--text-primary);
        text-decoration: none;
    }
    
    .menu-toggle {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-primary);
        cursor: pointer;
        padding: 0.5rem;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        display: none;
        z-index: 999;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    main {
        padding: 1rem;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .about-header {
        flex-direction: column;
        text-align: center;
    }
    
    .about-header h1 {
        font-size: 2rem;
    }
    
    .blog-post,
    .tutorial-post {
        padding: 1.5rem;
    }
    
    .post-header h1 {
        font-size: 2rem;
    }
    
    .prose {
        font-size: 1rem;
    }
    
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        grid-auto-rows: 150px;
    }
    
    .tutorial-grid,
    .projects-grid,
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}


/* Make mugshot.png images circular without outline */
/* Use contains selector to be robust to different paths or query strings */
img[src*="mugshot.png"] {
  border-radius: 50%;
  clip-path: circle(50%);
  object-fit: cover;
  display: block;
  aspect-ratio: 1 / 1; /* ensure square box even if only one dimension is set */
  overflow: hidden; /* ensure perfect circle crop */
}
