/* Observable-Inspired Clean Design for Entangled Code */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* Clean Color Palette - Observable Style */
:root {
    --primary-blue: #3B5FC0;
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --border-light: #e8e8e8;
    --code-bg: #f5f5f5;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Global Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    font-weight: 400;
    font-size: 16px;
    margin: 0 !important;
    padding: 0 !important;
}

html {
    margin: 0;
    padding: 0;
}

/* Distill-style centered content column */
#quarto-content main {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Reduce gap between title banner and content on homepage */
.page-layout-full #quarto-content {
    margin-top: 0;
}

.page-layout-full #quarto-content main > p:first-of-type {
    margin-top: 0;
    padding-top: 0;
}

/* Title banner should break out and be full width */
#quarto-header {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.quarto-title-banner {
    width: 100%;
}

.quarto-title-block {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Clean Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2em;
    margin-bottom: 0.75em;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 2rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.5rem;
}

/* Paragraph spacing */
p {
    margin-bottom: 1.25em;
    color: var(--text-primary);
}

/* Links - Simple & Clean */
a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Clean Code Blocks */
/* Remove padding from cell containers to give code blocks full width */
.cell {
    padding: 0 !important;
    margin: 1.5rem 0 !important;
}

.cell-code {
    padding: 0 !important;
    margin: 0 !important;
}

pre.sourceCode, div.sourceCode {
    background-color: var(--code-bg) !important;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 1rem !important;
    margin: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    font-size: 0.85rem;
    line-height: 1.4;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

pre.sourceCode code, div.sourceCode code {
    white-space: pre !important;
    display: block;
    padding: 0 !important;
}

code {
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace !important;
    font-size: 0.9em;
}

/* Inline code */
p code, li code {
    background-color: var(--code-bg);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    font-size: 0.88em;
}

pre code {
    background-color: transparent !important;
    border: none;
    padding: 0;
}

/* Clean Post Cards */
.quarto-post {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    gap: 1.5rem;
    align-items: center; /* Center items vertically */
    overflow: hidden; /* Keep content inside card */
}

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

/* Post metadata (date + reading time) - positioned first on left */
.quarto-post .metadata {
    min-width: 110px;
    flex-shrink: 0;
    order: 1;
}

.quarto-post .listing-date {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.quarto-post .listing-reading-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Post body should grow to fill space - positioned second in middle */
.quarto-post .body {
    flex-grow: 1;
    order: 2;
}

/* Thumbnail - positioned third on right */
.quarto-post .thumbnail {
    order: 3;
}

/* Post Listings */
.quarto-listing-default .listing-item {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.2s ease;
}

.quarto-listing-default .listing-item:hover {
    background-color: var(--bg-secondary);
}

.listing-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.listing-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.listing-description {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Categories/Tags - Minimal Pills */
.quarto-category {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    margin-right: 8px;
    border: 1px solid var(--border-light);
}

.quarto-category:hover {
    background: var(--border-light);
}

/* Navbar - Clean & Minimal */
#quarto-header {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.navbar {
    background: linear-gradient(90deg,
        #000000 0%,
        #000000 15%,
        #6366f1 30%,
        #8b5cf6 40%,
        #d946ef 45%,
        #ec4899 50%,
        #f43f5e 55%,
        #fb923c 60%,
        #fbbf24 70%,
        #000000 85%,
        #000000 100%);
    border-bottom: none;
    box-shadow: var(--shadow-sm);
    padding: 0 !important;
    margin: 0 !important;
    min-height: 50px;
    height: 50px;
    display: flex;
    align-items: center;
}

.navbar-collapse {
    display: flex;
    align-items: center;
}

.navbar > .container-fluid {
    display: flex;
    align-items: center;
    height: 100%;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1rem;
    color: white !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
}

.navbar-nav {
    display: flex;
    align-items: center;
}

.navbar-nav .nav-link {
    color: white !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0 0.75rem !important;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
}

.navbar-nav .nav-link:hover {
    opacity: 0.8;
}

.navbar-nav .nav-item .bi {
    color: white !important;
}

/* Title Block Banner */
.quarto-title-banner {
    background-color: var(--bg-primary);
    padding: 3rem 0 1rem 0;
}

.quarto-title .title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* Post Metadata */
.quarto-title-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.quarto-title-meta-heading {
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 0.5rem;
}

.quarto-title-meta-contents {
    color: var(--text-primary);
}

/* Blockquotes - Clean Style */
blockquote {
    border-left: 3px solid var(--primary-blue);
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

blockquote p {
    margin: 0;
    color: var(--text-secondary);
}

/* Tables - Clean & Readable */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 2rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
    min-width: 600px; /* Ensure table doesn't get too cramped */
}

table thead {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-light);
}

table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}

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

/* Mobile table improvements */
@media (max-width: 768px) {
    table {
        font-size: 0.9rem;
        min-width: 500px;
    }

    table th, table td {
        padding: 8px;
    }
}

/* Images and Figures - Generous Spacing */
img, .quarto-figure {
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    height: auto;
}

figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 10px;
    font-style: italic;
}

/* Jupyter Output Cells - Clean Background */
.cell-output-display {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    background: white;
}

/* Quantum Circuit Visualizations */
.jp-RenderedImage {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Footer */
.nav-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    padding: 2rem 0;
    margin-top: 4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* TOC (Table of Contents) */
.toc-active {
    color: var(--primary-blue) !important;
    font-weight: 600;
}

#TOC {
    border-left: 2px solid var(--primary-blue);
}

/* Scrollbar - Subtle */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 991px) {
    /* Navbar responsive fixes */
    .navbar {
        min-height: 50px;
        height: auto !important; /* Allow navbar to expand when collapsed */
    }

    .navbar-collapse {
        background: linear-gradient(180deg, #000000 0%, #1a1a1a 100%);
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 8px;
    }

    .navbar-nav {
        flex-direction: column;
        align-items: flex-start !important;
        width: 100%;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 0 !important;
        width: 100%;
    }

    /* Right side icons (GitHub, RSS) in collapsed menu */
    .navbar-nav.ms-auto {
        flex-direction: row;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        justify-content: flex-start;
        width: auto;
    }

    .navbar-nav.ms-auto .nav-link {
        width: auto;
        padding: 0.5rem !important;
    }

    /* Hide elements that create white rectangles */
    .navbar-collapse .quarto-navbar-tools,
    .navbar-collapse #quarto-search,
    #quarto-search-results {
        display: none !important;
    }
}

/* Keep icons on the right on larger screens */
@media (min-width: 992px) {
    .navbar-nav.ms-auto {
        margin-left: auto !important;
    }
}

/* Perfect Mobile Experience */
@media (max-width: 768px) {
    /* Beautiful typography for mobile reading */
    body {
        font-size: 18px;
        line-height: 1.75; /* Generous line height for comfortable reading */
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Optimal heading sizes and spacing */
    h1 {
        font-size: 2rem;
        line-height: 1.3;
        margin-top: 1.5em;
        margin-bottom: 0.75em;
    }

    h2 {
        font-size: 1.6rem;
        line-height: 1.35;
        margin-top: 1.75em;
        margin-bottom: 0.75em;
    }

    h3 {
        font-size: 1.35rem;
        line-height: 1.4;
        margin-top: 1.5em;
        margin-bottom: 0.5em;
    }

    /* Comfortable paragraph spacing */
    p {
        margin-bottom: 1.5em;
        max-width: 100%; /* Prevent overflow */
    }

    /* Post cards - beautiful vertical layout */
    .quarto-post {
        padding: 1.5rem;
        flex-direction: column;
        margin-bottom: 1.5rem;
        border-radius: 16px; /* Softer corners on mobile */
    }

    /* Stunning thumbnails on mobile */
    .quarto-post .thumbnail {
        width: calc(100% + 3rem); /* Extend beyond card padding */
        max-width: calc(100% + 3rem);
        height: auto;
        aspect-ratio: 16/9;
        margin: -1.5rem -1.5rem 1.25rem -1.5rem; /* Negative margins to align with card border */
        padding: 0;
        order: 0;
        border-radius: 16px 16px 0 0; /* Round only top corners to match card */
        box-shadow: none; /* Remove shadow since it's flush with card */
    }

    /* Date and reading time - clear and accessible */
    .quarto-post .metadata {
        order: 1;
        min-width: auto;
        margin-bottom: 1rem;
        font-size: 0.95rem;
        opacity: 0.8;
    }

    .quarto-post .listing-date {
        font-size: 0.95rem;
        margin-bottom: 0.25rem;
    }

    .quarto-post .listing-reading-time {
        font-size: 0.9rem;
    }

    /* Content body - perfect reading width */
    .quarto-post .body {
        order: 2;
    }

    .listing-title {
        font-size: 1.4rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }

    .listing-description {
        font-size: 1rem;
        line-height: 1.65;
        margin-top: 0.75rem;
    }

    /* Article content - generous mobile spacing */
    #quarto-content main {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        padding-top: 1rem;
        max-width: 100%;
    }

    /* Code blocks - smooth scrolling */
    pre.sourceCode, div.sourceCode {
        font-size: 0.9rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        margin: 1.5rem 0;
    }

    /* Inline code - comfortable size */
    p code, li code {
        font-size: 0.92em;
        padding: 3px 6px;
    }

    /* Tables - smooth horizontal scroll */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.95rem;
    }

    /* Hide TOC on mobile */
    #TOC {
        display: none !important;
    }

    /* Categories - wrap nicely */
    .listing-categories {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }

    .quarto-category {
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    /* Links - larger touch targets */
    a {
        padding: 2px 0;
        text-decoration-thickness: 1px;
        text-underline-offset: 3px;
    }

    /* Images - fit screen perfectly */
    img, .quarto-figure {
        max-width: 100%;
        height: auto;
        border-radius: 8px;
        margin: 1.5rem 0;
    }

    /* Navbar - optimize for mobile */
    .navbar {
        padding: 0.5rem 1rem !important;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    /* Title banner - perfect spacing */
    .quarto-title-banner {
        padding: 2rem 1.25rem 1.5rem 1.25rem;
    }

    .quarto-title .title {
        font-size: 2rem;
        line-height: 1.3;
        margin-bottom: 0.75rem;
    }

    .quarto-title .subtitle {
        font-size: 1.1rem;
        line-height: 1.5;
    }

    /* Blockquotes - comfortable reading */
    blockquote {
        margin: 1.5rem 0;
        padding: 1rem 1.25rem;
        border-radius: 8px;
        font-size: 1rem;
    }

    /* Lists - good spacing */
    ul, ol {
        padding-left: 1.5rem;
        margin-bottom: 1.5rem;
    }

    li {
        margin-bottom: 0.5rem;
        line-height: 1.7;
    }

    /* Smooth scrolling for better UX */
    html {
        scroll-behavior: smooth;
    }

    /* Remove hover effects on mobile (they don't work well) */
    .quarto-post:hover {
        transform: none;
    }
}

/* Extra small phones - adjust for tiny screens */
@media (max-width: 480px) {
    body {
        font-size: 17px;
        line-height: 1.7;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .quarto-post {
        padding: 1.25rem;
    }

    #quarto-content main {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .quarto-title .title {
        font-size: 1.75rem;
    }
}

/* Thumbnail images for post listings */
.thumbnail {
    width: 200px;
    min-width: 200px;
    height: auto; /* Auto height to respect aspect ratio */
    overflow: hidden; /* Keep content inside thumbnail container */
    border-radius: 8px;
    margin-left: 2rem;
    padding-left: 3rem; /* More padding for better spacing from left border */
    box-sizing: border-box;
    display: flex !important; /* Use flex for centering */
    align-items: center; /* Center image vertically */
    justify-content: center; /* Center image horizontally */
    visibility: visible !important;
    flex-shrink: 0; /* Prevent thumbnail from shrinking */
}

.thumbnail img.thumbnail-image {
    width: 100%;
    height: auto; /* Auto height for proper aspect ratio */
    max-height: 200px;
    object-fit: contain; /* Contain instead of cover for SVGs */
    display: block !important;
    visibility: visible !important;
}

.thumbnail a {
    display: block;
    width: 100%;
    height: 100%;
}

.thumbnail p {
    margin: 0;
    padding: 0;
    height: 100%;
}

/* Ensure thumbnails are visible on larger screens */
@media (min-width: 768px) {
    .quarto-post.image-right .thumbnail {
        display: block !important;
    }
}

/* Hover effects for post listings */
.quarto-listing-default .listing-item {
    transition: all 0.3s;
}

.quarto-listing-default .listing-item:hover {
    transform: translateX(10px);
}

/* Custom button styles */
.btn-primary {
    background: var(--primary-blue);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    color: white;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(59, 95, 192, 0.4);
}
