/* custom styles */
:root {
    --primary-color: #007bff;
    --dark-color: #343a40; 
}

.container {
    max-width: 960;  /* or whatever width you prefer */
}
/* Default for home page cards */
.card-img-top {
    width: 100%;
    height: auto;      /* natural aspect ratio — full image, no edge cropping */
    object-fit: cover;
    object-position: center top;
}

/* Category page wider cards — same natural fill */
.col-md-6 .card-img-top {
    height: auto;
    object-position: center top;
}

/* Article detail featured image */
.article-featured-img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    object-position: center top;
    border-radius: 8px;
}

/* Article wrapper - center the article content */
.article-wrapper {
    max-width: 680px;
    margin: 0 auto;
}

.article-header h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.article-meta {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* Project list page */
.project-list-header {
    text-align: center;
    margin-bottom: 1rem;
}

.project-list-header .lead {
    font-family: 'Inter', sans-serif;
    color: #555;
}

/* Project detail - don't constrain width like articles */
.project-content {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #fafafa;
}

/* Headings use Inter for clean, minimalist look */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
}

/* UI elements use Inter */
.navbar, .btn, .card-title, .card-footer, .nav-link {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

main {
    flex: 1;
}

.jumbotron {
    background:linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card {
    transition: transform 0.3s ease;
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    background-color: #ffffff;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.card-title {
    font-weight: 600;
    letter-spacing: 0.01em;
    font-size: 1.15rem;
}

.card-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
}

.card-body {
    padding: 1.5rem;
}

.article-content {
    font-size: 1.125rem;
    line-height: 1.75;
    margin-bottom: 0.85rem;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

/* Project content overrides - full width, not centered */
.project-content {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Superscript/subscript - prevent line shifting */
.article-content sup,
.article-content sub {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

.article-content sup {
    top: -0.5em;
}

.article-content sub {
    bottom: -0.25em;
}

/* Uniform paragraph spacing */
.article-content p {
    margin-bottom: 1rem;
    margin-top: 0;
}

/* Article content images - tight text wrapping */
.article-content img {
    max-width: 100%;
    max-height: 400px;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    margin: 0.5rem 0 !important;  /* Only top/bottom margin by default */
}

/* Left-floated images: margin on right only */
.article-content img[style*="float: left"],
.article-content img[style*="float:left"] {
    margin-right: 1rem !important;
    margin-left: 0 !important;
}

/* Right-floated images: margin on left only */
.article-content img[style*="float: right"],
.article-content img[style*="float:right"] {
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

/* Clear floats after content */
.article-content::after {
    content: "";
    display: table;
    clear: both;
}

/* Full-width images when needed */
.article-content img.full-width {
    float: none;
    display: block;
    max-width: 100%;
    max-height: none;
    margin: 1.5rem auto;
}

/* Clear floats after content sections */
.article-content::after {
    content: "";
    display: table;
    clear: both;
}

.article-content h2,
.article-content h3,
.article-content h4 {
    clear: both;  /* Headings start on new line */
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.social-links a {
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--primary-color) !important;
}

/* Code Block Styling - VS Code style */
.article-content pre[class*="language-"],
.article-content pre {
    padding: 0.5em 0.75em !important;
    margin: 0.5em 0 !important;
    border-radius: 4px;
}

.article-content pre code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875em;
    line-height: 1.4;
    padding: 0 !important;
}

/* Mermaid diagram styling - GitHub-like */
.article-content .mermaid-container {
    position: relative;
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 1em;
    margin: 1em 0;
}

.article-content .mermaid {
    text-align: center;
}

.mermaid-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    /* Keep the zoom buttons above the diagram: mermaid's htmlLabels render
       <span>/<rect> elements over the top-right corner, and without a z-index
       they intercept clicks meant for the buttons. */
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: white;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mermaid-controls button {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #57606a;
    font-size: 14px;
}

.mermaid-controls button:hover {
    background: #f3f4f6;
}

.mermaid-controls .divider {
    height: 1px;
    background: #d0d7de;
    margin: 2px 0;
}

footer {
    margin-top: auto;
}

/* Auto-generated Table of Contents */
.toc {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.toc-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin: 0 0 0.75rem 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    padding: 0.35rem 0;
    border-bottom: 1px solid #eee;
}

.toc-list li:last-child {
    border-bottom: none;
}

.toc-list a {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Sticky "On this page" rail for long-form sections (Pattern 1, 2026-08-18).
   Content sits left (col-lg-8); the rail is sticky right and follows the
   reader. On small screens it simply flows above the content. */
.toc-rail {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e9ecef;
    border-top: 3px solid var(--primary-color);  /* rail identity accent */
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    padding: 1.25rem 1.5rem;
}
.toc-rail .toc-list a {
    font-size: 0.85rem;
    line-height: 1.35;
    color: #444;                      /* neutral default */
    border-left: 3px solid transparent;
    padding-left: 0.6rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-rail li {
    padding: 0.2rem 0;
    border-bottom: none;
}
.toc-rail .toc-title {
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}

/* All items neutral by default; blue is reserved for the ACTIVE section so it
   reads as a precise "you are here" placeholder, not as blanket coloring. */
.toc-rail > .toc-list > li > a {
    font-weight: 600;
}
/* Active section (click or scrollspy): filled left rule + blue text. */
.toc-rail .toc-list a.active {
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}
.toc-rail .toc-list a:not(.active):hover {
    border-left-color: #d0d5db;
    color: var(--primary-color);
}

/* Nested TOC entries: h4+ indent under their h3 parent. */
.toc-nested {
    padding-left: 0.25rem;
    margin-top: 0.1rem;
}
.toc-nested li {
    padding: 0.15rem 0;
    border-bottom: none;
}
.toc-nested a {
    font-size: 0.8rem;
    color: #555;
    font-weight: 400;
}
.toc-nested a:hover {
    color: var(--primary-color);
}

/* Keep the h3/h4 hierarchy visible in the body too: a stepped type ladder.
   title 32px -> h3 21px -> h4 17.5px -> body 18px. h4 is subordinate (smaller,
   weight 500) and indented, so the h3->h4 relationship reads via size + weight
   + structure rather than a jarring jump. */
.article-content h4 {
    font-size: 1.1rem;   /* ~17.5px */
    font-weight: 500;
    color: #555;
    padding-left: 0.75rem;
    border-left: 3px solid #d0d5db;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}
.article-content h3 {
    font-size: 1.3rem;   /* ~21px */
    font-weight: 600;
    margin-top: 2rem;
}

/* Project card-style table of contents */
.toc-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    margin: 0;
}

.toc-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    background: #fff;
    color: #333;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.toc-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 14px rgba(0, 123, 255, 0.12);
    text-decoration: none;
}

.toc-card-icon {
    flex: none;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(0, 123, 255, 0.1);
    color: var(--primary-color);
    font-size: 0.95rem;
}

.toc-card-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.toc-card-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #222;
    line-height: 1.25;
}

.toc-card:hover .toc-card-title {
    color: var(--primary-color);
}

/* Drill-down project pages: breadcrumb + back link */
.project-breadcrumb {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #888;
    padding: 0.6rem 0 1rem;
}
.project-breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}
.project-breadcrumb a:hover { text-decoration: underline; }
.project-breadcrumb .sep { margin: 0 6px; color: #bbb; }
.project-breadcrumb .current { color: #555; }

.back-link {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--primary-color);
    text-decoration: none;
    margin-bottom: 0.5rem;
}
.back-link:hover { text-decoration: underline; }

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

/* Offset for fixed headers if needed */
.article-content h2[id],
.article-content h3[id],
.article-content h4[id] {
    scroll-margin-top: 1rem;
}

/* responsive adjustments */
@media (max-width: 768px) {
    .jumbotron h1 {
        font-size: 2rem;
    }
}

/* resume page */
.resume-page h1 { font-size: 1.75rem; }
.resume-page h2 { font-size: 1.25rem; }
.resume-page h4 { font-size: .8rem; }

/* resume — animated vertical timeline */
.vertical-timeline {
    position: relative;
    max-width: 900px;
    padding-left: 40px;
}
.vertical-timeline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 15px;
    width: 2px;
    background: #dee2e6;
}
.timeline-event {
    position: relative;
    margin-bottom: 24px;
}
.timeline-dot {
    position: absolute;
    top: 6px;
    left: -31px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #212529;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px #212529;
}
.timeline-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ---------- clinical copilot demo ---------- */

.demo-status {
    min-height: 8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border: 1px dashed #d0d5dd;
    border-radius: .5rem;
    background: #fbfcfd;
    text-align: center;
}

.demo-status--error {
    border-color: #f1aeb5;
    background: #fdf2f3;
    color: #b02a37;
}

/* The A2UI surface styles itself through the catalog's own CSS custom
   properties. These variables are the supported way to theme it — reaching
   into its shadow DOM is not, and would break on any renderer upgrade. */
#surface-host {
    --a2ui-color-background: #ffffff;
    --a2ui-color-on-background: #1f2933;
    --a2ui-color-border: #e3e8ef;
    --a2ui-border-radius: .5rem;
}

.demo-prose {
    color: #4a5568;
    font-size: .95rem;
    line-height: 1.6;
    border-left: 3px solid #e3e8ef;
    padding-left: .875rem;
    white-space: pre-wrap;
}

#patients .list-group-item-action.active {
    background: #eef4ff;
    border-color: #b6d0ff;
    color: inherit;
}

/* CKEditor content: font-size presets.
   CKEditor 5 emits these classes for the named fontSize options (tiny/small/
   big/huge). The editor styles them via its own content CSS (admin only); the
   public site renders content inside .article-content, so define them here.
   Values match CKEditor's defaults (--ck-content-font-size-*). */
.article-content .text-tiny { font-size: 0.7em; }
.article-content .text-small { font-size: 0.85em; }
.article-content .text-big { font-size: 1.4em; }
.article-content .text-huge { font-size: 1.8em; }

/* CKEditor 5 image styles.
   The editor stores image alignment/resize as classes on a
   <figure class="image ..."> wrapper (image-style-block / side / align-* /
   image_resized), which CKEditor styles only inside the admin editor. The
   public site renders that HTML inside .article-content / .project-content,
   so mirror the content rules here. Spacing mirrors django_ckeditor_5
   dist/styles.css (--ck-content-image-style-spacing: 1.5em). */

.article-content figure.image,
.project-content figure.image {
    clear: both;
    display: table;
    margin: 1.5rem auto;          /* centered by default = "block" style */
    max-width: 100%;
    min-width: 50px;
    text-align: center;
}

.article-content figure.image img,
.project-content figure.image img {
    display: block;
    height: auto;
    margin: 0 auto;
    max-width: 100%;
}

.article-content figure.image > figcaption,
.project-content figure.image > figcaption {
    background-color: #f7f7f7;
    color: #333;
    font-size: 0.75em;
    padding: 0.6em;
}

/* Side style: floated right, ~50% width. */
.article-content figure.image.image-style-side,
.project-content figure.image.image-style-side {
    float: right;
    margin-left: 1.5em;
    margin-top: 0.5rem;
    max-width: 50%;
}

/* Align left / right: floated. */
.article-content figure.image.image-style-align-left,
.project-content figure.image.image-style-align-left {
    clear: none;
    float: left;
    margin-right: 1.5em;
}

.article-content figure.image.image-style-align-right,
.project-content figure.image.image-style-align-right {
    clear: none;
    float: right;
    margin-left: 1.5em;
}

/* Block-align variants: block-level, pushed to one side. */
.article-content figure.image.image-style-block-align-left,
.project-content figure.image.image-style-block-align-left {
    margin-left: 0;
    margin-right: auto;
}

.article-content figure.image.image-style-block-align-right,
.project-content figure.image.image-style-block-align-right {
    margin-left: auto;
    margin-right: 0;
}

/* Manually resized images: honor the editor's inline width. */
.article-content figure.image.image_resized,
.project-content figure.image.image_resized {
    box-sizing: border-box;
    display: block;
    max-width: 100%;
}

.article-content figure.image.image_resized img,
.project-content figure.image.image_resized img {
    width: 100%;
}

/* Inline images (imageStyle:inline): keep in flow, capped. */
.article-content span.image-inline img,
.project-content span.image-inline img {
    max-width: 100%;
}

/* Clear floats inside content (articles already clear; cover projects too). */
.article-content::after,
.project-content::after {
    content: "";
    display: table;
    clear: both;
}

/* --- Typography: Inter for all UI; Source Serif 4 scoped strictly to the
   long-form reading payload (article bodies and project prose). UI, headings,
   and code-heavy project sections stay Inter. --- */

/* Articles: serif reading text at a comfortable measure. */
.article-content p,
.article-content li {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 1.125rem;
    line-height: 1.7;
    max-width: 70ch;
}

/* Project content: the container stays full-width so diagrams/plots breathe;
   only the reading text is capped, and visuals break out to full width. */
.project-content p,
.project-content ul,
.project-content ol {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 1.125rem;
    line-height: 1.7;
    max-width: 65ch;
}

.project-content pre,
.project-content figure {
    max-width: 100%;
    margin: 2rem 0;
}

.project-content img {
    max-width: 100%;
}
