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

html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Light Mode (Default) */
:root {
    --primary-color: #2563eb;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --bg-color: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --code-bg: #1e293b;
    --max-width: 1200px;
    --selection-bg: #fbbf24;
    --selection-text: #1f2937;
    --table-header-bg: #3b82f6;
    --table-header-text: #ffffff;
    --table-row-even: #f9fafb;
    --table-row-hover: #e0f2fe;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --text-color: #f3f4f6;
    --text-secondary: #9ca3af;
    --bg-color: #111827;
    --bg-secondary: #1f2937;
    --border-color: #374151;
    --code-bg: #0f172a;
    --selection-bg: #f59e0b;
    --selection-text: #111827;
    --table-header-bg: #1e40af;
    --table-header-text: #f3f4f6;
    --table-row-even: #1f2937;
    --table-row-hover: #374151;
}

/* Custom Text Selection - Fun gradient effect! */
::selection {
    background: var(--selection-bg);
    color: var(--selection-text);
    text-shadow: none;
}

::-moz-selection {
    background: var(--selection-bg);
    color: var(--selection-text);
    text-shadow: none;
}

body {
    font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    max-width: 100vw;
}

code, pre {
    font-family: 'Fira Code', 'Courier New', monospace;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

/* Header */
.site-header {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Theme Switch (Toggle) */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider:hover {
    opacity: 0.9;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
}

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

.main-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 3rem 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0 4rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 3rem;
    max-width: 100%;
}

.hero h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-color);
}

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

/* Section Titles */
.section-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-color);
    max-width: 100%;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.post-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    max-width: 100%;
    box-sizing: border-box;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

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

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

.post-summary {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
}

.post-summary code,
.post-summary pre {
    display: none;
}


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

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

/* Single Post */
.post-single {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

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

.post-single .post-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.post-single .post-meta {
    font-size: 1rem;
}

.post-author {
    font-weight: 500;
    color: var(--text-color);
}

.meta-separator {
    margin: 0 0.5rem;
    color: var(--text-secondary);
}

.article-feedback {
    margin-top: 3rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
}

.article-feedback p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.article-feedback a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.article-feedback a:hover {
    text-decoration: underline;
}

.post-content {
    font-size: 1.125rem;
    line-height: 1.8;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.post-content h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.post-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.post-content p {
    margin-bottom: 1.25rem;
}

.post-content ul, .post-content ol {
    margin-bottom: 1.25rem;
    margin-left: 2rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content code {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.post-content pre {
    background-color: var(--code-bg);
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    max-width: 100%;
}

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

.post-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content a {
    color: var(--primary-color);
    text-decoration: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.post-content a:hover {
    text-decoration: underline;
}

.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

/* Article images with captions (Unsplash attribution) */
.post-content figure.article-image {
    margin: 2rem auto;
    max-width: 100%;
}

.post-content figure.article-image img {
    margin: 0 auto;
    border-radius: 8px;
}

.post-content figure.article-image figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    line-height: 1.5;
}

.post-content figure.article-image figcaption a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-secondary);
}

.post-content figure.article-image figcaption a:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Posts List */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.archive-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

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

.tag {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: #bfdbfe;
    color: #1e40af;
    border: none;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tag:hover {
    background: #93c5fd;
    transform: translateY(-1px);
    color: #1e3a8a;
}

.tag-active {
    background: #93c5fd;
    color: #1e3a8a;
}

[data-theme="dark"] .tag {
    background: #1e3a8a;
    color: #bfdbfe;
}

[data-theme="dark"] .tag:hover {
    background: #1e40af;
    color: #dbeafe;
}

[data-theme="dark"] .tag-active {
    background: #1e40af;
    color: #dbeafe;
}

.tag-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.page-link {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: all 0.2s;
}

.page-link:hover:not(.disabled):not(.active) {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

.page-link.disabled {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.page-link.ellipsis {
    border: none;
    background: none;
    cursor: default;
    padding: 0.5rem 0.5rem;
}

.page-link.ellipsis:hover {
    background: none;
    border: none;
    color: var(--text-color);
}

/* Legacy pagination support */
.pagination a, .pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
}

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

.pagination .active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Footer */
.site-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    margin-top: 4rem;
}

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

.footer-note {
    font-size: 0.875rem;
    font-style: italic;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

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

.footer-text-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.rss-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.rss-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.rss-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    /* Remove sticky header on mobile for better readability */
    .site-header {
        position: static;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .main-nav {
        gap: 1rem;
        justify-content: center;
        width: 100%;
    }

    .main-nav a {
        font-size: 0.9rem;
    }

    .hero {
        padding: 2rem 0 3rem;
    }

    .hero h2 {
        font-size: 2rem;
        word-wrap: break-word;
    }

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 100%;
    }

    .post-card {
        max-width: 100%;
        box-sizing: border-box;
    }

    .post-single {
        max-width: 100%;
    }

    .post-single .post-title {
        font-size: 2rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .post-content {
        font-size: 1rem;
    }

    .post-content pre {
        padding: 1rem;
        border-radius: 6px;
        font-size: 0.875rem;
    }

    /* Mobile-friendly pagination */
    .pagination {
        gap: 0.25rem;
        flex-wrap: wrap;
    }

    .page-link {
        padding: 0.4rem 0.7rem;
        font-size: 0.9rem;
    }

    .page-link.ellipsis {
        padding: 0.4rem 0.4rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
    .container {
        padding: 0 0.75rem;
    }

    .main-nav {
        gap: 0.75rem;
    }

    .main-nav a {
        font-size: 0.85rem;
    }

    .hero h2 {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .post-card {
        padding: 1rem;
    }

    .post-single .post-title {
        font-size: 1.75rem;
    }

    .post-content {
        font-size: 0.95rem;
    }

    .post-content h2 {
        font-size: 1.5rem;
    }

    .post-content h3 {
        font-size: 1.25rem;
    }
}

/* Enhanced Table Styling */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background-color: var(--bg-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    /* Allow horizontal scrolling when table is too wide */
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Restore proper table display for all child elements */
.post-content table > thead,
.post-content table > tbody,
.post-content table > tfoot {
    display: table-row-group;
}

.post-content table > thead {
    display: table-header-group;
}

.post-content table > tfoot {
    display: table-footer-group;
}

.post-content table > thead > tr,
.post-content table > tbody > tr,
.post-content table > tfoot > tr {
    display: table-row;
}

.post-content table > thead > tr > th,
.post-content table > thead > tr > td,
.post-content table > tbody > tr > th,
.post-content table > tbody > tr > td,
.post-content table > tfoot > tr > th,
.post-content table > tfoot > tr > td {
    display: table-cell;
}

.post-content table thead {
    background: linear-gradient(135deg, var(--table-header-bg), #1d4ed8);
    color: var(--table-header-text);
}

.post-content table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 3px solid var(--primary-color);
}

.post-content table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.95rem;
}

.post-content table tbody tr {
    transition: background-color 0.2s ease;
}

.post-content table tbody tr:nth-child(even) {
    background-color: var(--table-row-even);
}

.post-content table tbody tr:hover {
    background-color: var(--table-row-hover);
    transform: scale(1.01);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.post-content table tbody tr:last-child td {
    border-bottom: none;
}

/* Table cell with strong emphasis */
.post-content table td strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Search Button in Navigation */
.search-button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease, transform 0.2s ease;
    border-radius: 4px;
}

.search-button:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.search-button svg {
    width: 20px;
    height: 20px;
}

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding-top: 10vh;
    backdrop-filter: blur(4px);
}

.search-modal.active {
    display: flex;
}

.search-modal-content {
    background-color: var(--bg-color);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Input Wrapper */
.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    gap: 0.75rem;
}

.search-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 1.1rem;
    color: var(--text-color);
    outline: none;
    font-family: inherit;
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.close-search {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.close-search:hover {
    background-color: var(--bg-secondary);
    color: var(--text-color);
}

/* Search Results */
.search-results {
    overflow-y: auto;
    max-height: calc(80vh - 80px);
    padding: 0.5rem;
}

.search-result-item {
    display: block;
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s ease, transform 0.2s ease;
    margin-bottom: 0.5rem;
}

.search-result-item:hover {
    background-color: var(--bg-secondary);
    transform: translateX(4px);
}

.search-result-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.search-result-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-result-date {
    flex-shrink: 0;
}

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

.search-result-tag {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-modal {
        padding-top: 5vh;
    }
    
    .search-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .search-input-wrapper {
        padding: 1rem;
    }
    
    #search-input {
        font-size: 1rem;
    }
}

/* Highlight mark style for search results */
mark {
    background-color: #fbbf24;
    color: #1f2937;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] mark {
    background-color: #f59e0b;
    color: #111827;
}

/* ========================================
   Diagram Styling - Mermaid & GoAT
   ======================================== */

/* Mermaid Diagram Container */
.post-content .mermaid {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2.5rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-color) 100%);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow-x: auto;
    min-height: 200px;
    max-width: 100%;
}

.post-content .mermaid:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Mermaid SVG styling */
.post-content .mermaid svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Dark mode adjustments for Mermaid */
[data-theme="dark"] .post-content .mermaid {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #0f172a 100%);
    border-color: #374151;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .post-content .mermaid:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* GoAT Diagram Container */
.post-content .goat-svg {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2.5rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    max-width: 100%;
    overflow-x: auto;
}

.post-content .goat-svg:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* GoAT SVG styling */
.post-content .goat-svg svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Dark mode adjustments for GoAT */
[data-theme="dark"] .post-content .goat-svg {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: #374151;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .post-content .goat-svg:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Adjust GoAT colors for dark mode */
[data-theme="dark"] .post-content .goat-svg svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) invert(0.9) hue-rotate(180deg);
}

/* Diagram caption/figure styling */
.post-content .mermaid + p em,
.post-content .goat-svg + p em {
    display: block;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .post-content .mermaid,
    .post-content .goat-svg {
        padding: 1rem;
        margin: 1.5rem 0;
        border-radius: 8px;
    }
    
    .post-content .mermaid svg,
    .post-content .goat-svg svg {
        font-size: 12px;
    }
}

/* Table of Contents */
.table-of-contents {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    margin: 2rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.table-of-contents details {
    cursor: pointer;
}

.table-of-contents summary {
    padding: 1rem 1.5rem;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
}

.table-of-contents summary::-webkit-details-marker {
    display: none;
}

.table-of-contents summary::before {
    content: '▼';
    margin-right: 0.75rem;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.table-of-contents details:not([open]) summary::before {
    transform: rotate(-90deg);
}

.table-of-contents summary h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.table-of-contents summary:hover h2 {
    color: var(--text-color);
}

.toc-content {
    padding: 0 1.5rem 1.5rem;
}

.table-of-contents nav {
    padding: 0;
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.table-of-contents ul ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.table-of-contents li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.table-of-contents a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.table-of-contents a:hover {
    color: var(--primary-color);
    padding-left: 0.5rem;
}

.table-of-contents a:visited {
    color: var(--text-secondary);
}

.table-of-contents a:hover:visited {
    color: var(--primary-color);
}

/* Heading Anchor Links */
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    position: relative;
    scroll-margin-top: 80px;
}

.post-content h2[id]:hover::before,
.post-content h3[id]:hover::before,
.post-content h4[id]:hover::before,
.post-content h5[id]:hover::before,
.post-content h6[id]:hover::before {
    content: '#';
    position: absolute;
    left: -1.5rem;
    color: var(--primary-color);
    font-weight: normal;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.post-content h2[id]:hover::before:hover,
.post-content h3[id]:hover::before:hover,
.post-content h4[id]:hover::before:hover,
.post-content h5[id]:hover::before:hover,
.post-content h6[id]:hover::before:hover {
    opacity: 1;
}

/* Anchor link styling for direct links */
.post-content h2[id] a.anchor,
.post-content h3[id] a.anchor,
.post-content h4[id] a.anchor,
.post-content h5[id] a.anchor,
.post-content h6[id] a.anchor {
    color: var(--primary-color);
    text-decoration: none;
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.8em;
}

.post-content h2:hover a.anchor,
.post-content h3:hover a.anchor,
.post-content h4:hover a.anchor,
.post-content h5:hover a.anchor,
.post-content h6:hover a.anchor {
    opacity: 0.6;
}

.post-content h2 a.anchor:hover,
.post-content h3 a.anchor:hover,
.post-content h4 a.anchor:hover,
.post-content h5 a.anchor:hover,
.post-content h6 a.anchor:hover {
    opacity: 1;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Highlight target heading when navigating via anchor */
.post-content :target {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% {
        background-color: rgba(37, 99, 235, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

/* Reading time indicator */
.reading-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive TOC */
@media (max-width: 768px) {
    .table-of-contents {
        margin: 1.5rem -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .post-content h2[id]:hover::before,
    .post-content h3[id]:hover::before,
    .post-content h4[id]:hover::before,
    .post-content h5[id]:hover::before,
    .post-content h6[id]:hover::before {
        display: none;
    }
}

/* Breadcrumb Navigation */
.breadcrumb {
    margin: 1rem 0;
    padding: 0.75rem 0;
    font-size: 0.9rem;
}

.breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.breadcrumb li {
    display: flex;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: '›';
    margin: 0 0.5rem;
    color: var(--text-secondary);
    font-weight: bold;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.breadcrumb li:last-child span {
    color: var(--text-color);
    font-weight: 500;
}

@media (max-width: 768px) {
    .breadcrumb {
        font-size: 0.85rem;
        overflow-x: auto;
        white-space: nowrap;
    }
}
