/* ===== Custom properties ===== */

:root {
    --landing-max-width: 960px;
    --blog-content-width: 720px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --accent-gradient: linear-gradient(135deg, var(--color-brand-primary, #e040a0), var(--color-brand-content, #40a0e0));
}


/* ===== Existing styles ===== */

.sidebar-logo {
    width: 180px;
}

.content h2 {
    font-size: 1.5em;
}

.content h3 {
    font-size: 1.25em;
}

.content h4 {
    font-size: 1.1em;
}

figure.align-default {
    margin-top: 2em;
    margin-bottom: 2em;
}


/* Top-nav bar styles live in top-nav.css (shared across all Tesseract
   ecosystem repos). */


/* ===== Dark-mode inversion utility ===== */

body[data-theme="dark"] .invert-on-dark {
    filter: invert(0.95);
}

@media (prefers-color-scheme: dark) {
    body[data-theme="auto"] .invert-on-dark {
        filter: invert(0.95);
    }
}


/* ===== Shared landing-page & blog-page overrides ===== */

.landing-page .sidebar-drawer,
.landing-page .toc-drawer {
    display: none !important;
}

/* Hide Furo's native mobile header (we use .top-nav instead) */
.landing-page .mobile-header,
.blog-page .mobile-header {
    display: none !important;
}

.landing-page .page,
.landing-page .main,
.blog-page .page,
.blog-page .main {
    display: block;
}


/* ===== Landing page layout ===== */

.landing-page .content {
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0 auto;
}

.landing-page .article-container {
    max-width: none;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Keep theme toggle visible on landing page, hide everything else */
.landing-page .content-icon-container {
    position: absolute;
    top: 2.5rem;
    right: 2.5rem;
    z-index: 99;
}

.landing-page .content-icon-container .edit-this-page,
.landing-page .content-icon-container .view-this-page,
.landing-page .content-icon-container .toc-overlay-icon {
    display: none;
}

/* Hide back-to-top on landing page */
.landing-page .back-to-top {
    display: none !important;
}

/* Horizontal rules as section dividers */
.landing-page article hr {
    border: none;
    border-top: 1px solid var(--color-background-border);
    margin: 0;
}

/* Section dividers */
.landing-divider {
    max-width: var(--landing-max-width);
    margin: 0 auto;
    border-top: 1px solid var(--color-background-border);
}

/* Constrain all landing content to readable width */
.landing-page article#furo-main-content > section {
    max-width: var(--landing-max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* How-it-works: tighten gap between column header and code block */
.howto-define > p:first-child {
    margin-bottom: 0;
}

.howto-define .highlight {
    margin-top: 0.5rem;
}

/* How-it-works: both columns top-aligned, tab header styled to anchor visually */
.landing-page .sd-tab-set > input + label {
    background: var(--color-background-secondary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--color-background-border);
    border-bottom: none;
}

/* Section headings */
.landing-page .content h2 {
    text-align: center;
    margin-top: 3rem;
    margin-bottom: 2rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}


/* ===== Hero ===== */

.landing-hero {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    padding: 3.5rem 1.5rem 2.5rem;
    max-width: var(--landing-max-width);
    margin: 0 auto;
}

.landing-hero-logo {
    flex-shrink: 0;
}

.landing-hero-text {
    text-align: left;
}

.landing-hero-text .landing-cta > p {
    justify-content: flex-start;
}

.landing-logo {
    display: block;
    margin: 0;
}

/* Prevent the hero logo from being a clickable link to the image file */
a.image-reference:has(.landing-logo) {
    pointer-events: none;
    cursor: default;
}

/* Light/dark logo switching */
body[data-theme="dark"] .landing-logo.only-light,
body:not([data-theme="dark"]) .landing-logo.only-dark {
    display: none !important;
}

/* Auto theme: follow system preference */
@media (prefers-color-scheme: dark) {
    body[data-theme="auto"] .landing-logo.only-light {
        display: none !important;
    }
    body[data-theme="auto"] .landing-logo.only-dark {
        display: block !important;
    }
}

@media (prefers-color-scheme: light) {
    body[data-theme="auto"] .landing-logo.only-dark {
        display: none !important;
    }
    body[data-theme="auto"] .landing-logo.only-light {
        display: block !important;
    }
}

.landing-hero-tagline,
.landing-hero-subtitle {
    max-width: 640px;
    margin: 0 0 0.5rem;
    line-height: 1.5;
}

.landing-hero-tagline {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-foreground-primary);
}

.landing-hero-subtitle {
    font-size: 0.95rem;
    color: var(--color-foreground-secondary);
    margin-bottom: 1.25rem;
}

/* CTA buttons — badges are inside a <p> wrapper generated by MyST */
.landing-cta {
    margin-bottom: 2rem;
}

.landing-cta > p {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
}

.landing-cta .sd-badge {
    padding: 0.5rem 1.25rem;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
}


/* ===== Shared landing card base =====
   Overrides sphinx-design's .sd-card (which Furo strips border from via
   furo-extensions.css), so !important is needed on border/border-radius. */

.feature-card,
.demo-card,
.ecosystem-card {
    border: 1px solid var(--color-background-border) !important;
    border-radius: var(--radius-md) !important;
}

.demo-card,
.ecosystem-card {
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}

.demo-card:hover,
.ecosystem-card:hover {
    border-color: var(--color-brand-primary) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.demo-card:focus-visible,
.ecosystem-card:focus-visible {
    border-color: var(--color-brand-primary) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    outline: 2px solid var(--color-brand-primary);
    outline-offset: 2px;
}

body[data-theme="dark"] .demo-card:hover,
body[data-theme="dark"] .ecosystem-card:hover,
body[data-theme="dark"] .demo-card:focus-visible,
body[data-theme="dark"] .ecosystem-card:focus-visible {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.feature-card .sd-card-title,
.demo-card .sd-card-title,
.ecosystem-card .sd-card-title {
    font-weight: 600;
    font-size: 1rem;
}

.demo-card .sd-card-title {
    font-size: 1.05rem;
}

.feature-card .sd-card-body p,
.demo-card .sd-card-body p,
.ecosystem-card .sd-card-body p {
    font-size: 0.9rem;
    color: var(--color-foreground-secondary);
    line-height: 1.5;
}


/* ===== Feature cards — top gradient accent ===== */

.feature-card {
    overflow: hidden;
    position: relative;
}

.feature-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}


/* ===== Demo schematics ===== */

.demo-schematic {
    width: 100%;
    padding: 0.75rem 0.5rem;
    display: block;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.demo-card:hover .demo-schematic {
    opacity: 1;
}


/* ===== Section intro text ===== */

.section-intro {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--color-foreground-secondary);
    font-size: 1.05rem;
}


/* ===== Citation dropdown ===== */

.landing-page details.sd-dropdown {
    margin-bottom: 2rem;
}

.landing-page .sd-summary-title {
    font-size: 0.95rem;
    justify-content: center;
}


/* ===== Landing page footer ===== */

.landing-footer {
    background: var(--color-background-secondary);
    border-top: 1px solid var(--color-background-border);
    padding: 3rem 1.5rem 2rem;
    margin-top: 3rem;
    max-width: none !important;
    /* Full-bleed: use dvw to avoid scrollbar-induced overflow */
    width: 100dvw;
    margin-left: calc(-50dvw + 50%);
}

.landing-footer .sd-row {
    max-width: var(--landing-max-width);
    margin: 0 auto;
}

.landing-footer strong {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-foreground-muted);
    display: block;
    margin-bottom: 0.75rem;
}

.landing-footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.landing-footer li {
    margin-bottom: 0.4rem;
}

.landing-footer a {
    font-size: 0.9rem;
    color: var(--color-foreground-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.landing-footer a:hover {
    color: var(--color-brand-primary);
}

.landing-footer a.reference.external::after {
    content: " \2197";
}

/* Hide Furo's default footer on landing page */
.landing-page footer {
    display: none !important;
}


/* ===== Responsive ===== */

@media (max-width: 768px) {
    .landing-hero {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .landing-hero-text {
        text-align: center;
    }

    .landing-hero-text .landing-cta > p {
        justify-content: center;
    }

    .landing-hero h1 {
        font-size: 2.2rem;
    }

    .landing-hero-tagline {
        font-size: 1.05rem;
    }

    .landing-logo {
        width: 140px !important;
    }
}


/* ===== Blog page styles ===== */

.blog-page .sidebar-drawer {
    display: none !important;
}

.blog-page .content-icon-container {
    float: right;
    display: flex;
    margin: 0;
    padding: 0.5rem 0;
}

.blog-page .content-icon-container .edit-this-page,
.blog-page .content-icon-container .view-this-page,
.blog-page .content-icon-container .toc-overlay-icon,
.blog-page .content-icon-container .toc-header-icon {
    display: none;
}

.blog-page .content {
    max-width: var(--blog-content-width);
    margin: 0 auto;
    padding: 1rem;
    position: relative;
}

/* ToC: fixed sidebar anchored to the right of the content column.
   We reset Furo's mobile-first off-screen positioning and place the
   drawer ourselves, then let Furo's own toc-sticky / toc-scroll /
   toc-title / toc-tree styles handle everything inside it. */
.blog-page .toc-drawer {
    display: block !important;
    position: fixed;
    left: calc(50% + (var(--blog-content-width) / 2) + 3rem);
    top: var(--top-nav-offset, 0px);
    width: 15em;
    height: calc(100vh - var(--top-nav-offset, 0px));
    background: none;
    border: none;
    padding: 0;
    z-index: 10;
}

/* Hide ToC when viewport is too narrow for it */
@media (max-width: 1200px) {
    .blog-page .toc-drawer {
        display: none !important;
    }
}

/* ---- Blog post typography ---- */

.blog-page .content .article-container {
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--color-foreground-primary);
}

.blog-back-link {
    display: inline-block;
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--color-foreground-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.blog-back-link:hover {
    color: var(--color-brand-primary);
}

.blog-page .content h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-background-border);
    letter-spacing: -0.03em;
    line-height: 1.2;
    text-wrap: pretty;
}

.blog-post-meta {
    color: var(--color-foreground-muted);
    font-size: 0.9rem;
    margin-top: 1rem;
    margin-bottom: 0.2rem;
}

.blog-post-meta a {
    color: var(--color-foreground-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.blog-post-meta a:hover {
    color: var(--color-brand-primary);
}

.blog-page .content h2 {
    font-size: 1.45rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-top: 0.75rem;
    letter-spacing: -0.01em;
    line-height: 1.3;
    text-wrap: pretty;
}

.blog-page .content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

/* Paragraph spacing for prose rhythm */
.blog-page .content p {
    margin-bottom: 1.25rem;
}

.blog-page .content ol > p, .blog-page .content li > p {
    margin-bottom: 0.75rem;
}

/* Lead paragraph — slightly larger */
.blog-page .content article > section > p:first-of-type {
    font-size: 1.1rem;
    color: var(--color-foreground-secondary);
    line-height: 1.6;
}

/* Links in blog prose */
.blog-page .content article a {
    color: var(--color-brand-primary);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--color-brand-primary) 35%, transparent);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s;
}

.blog-page .content article a:hover {
    text-decoration-color: var(--color-brand-primary);
}

/* Inline code in prose */
.blog-page .content p code,
.blog-page .content li code {
    font-size: 0.88em;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    background: var(--color-background-secondary);
    border: 1px solid var(--color-background-border);
}

/* Code blocks — border + background on the wrapper, not the pre */
.blog-page .content .highlight {
    background: var(--color-code-background);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-background-border);
    margin: 1.5rem 0;
    overflow: hidden;
}

.blog-page .content .highlight pre {
    background: transparent;
    border-radius: 0;
    border: none;
    padding: 1rem 1.25rem;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
}

/* Images — center and constrain */
.blog-page .content img {
    display: block;
    border-radius: var(--radius-sm);
    margin: 1.75rem auto;
    max-width: 100%;
    height: auto;
}

.blog-page .content img:not(.blog-img-full) {
    max-width: min(100%, 420px);
    max-height: 360px;
    object-fit: contain;
}

/* Reduce gap between consecutive images */
.blog-page .content p:has(> img) + p:has(> img) {
    margin-top: -0.75rem;
}

/* Double figures — opt-in side-by-side layout */
.double-figure {
    display: flex;
    gap: 1rem;
    margin: 1.75rem auto;
}

.double-figure > figure {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    text-align: center;
}

.double-figure > figure > img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
    .double-figure {
        flex-direction: column;
    }
}

/* Image captions — italic paragraph immediately after an image */
.blog-page .content p:has(> img) + p > em:only-child {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-foreground-muted);
    margin-top: -1rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* Videos — match img treatment */
.blog-page .content video {
    display: block;
    border-radius: var(--radius-sm);
    margin: 1.75rem auto;
    max-width: 100%;
    height: auto;
}

.blog-page .content video:not(.blog-img-full) {
    max-width: min(100%, 420px);
    max-height: 360px;
    object-fit: contain;
}

/* Figure + figcaption (MyST/Sphinx generated) */
.blog-page .content figure {
    margin: 1.75rem auto;
    text-align: center;
}

.blog-page .content figure img,
.blog-page .content figure video {
    margin: 0 auto;
}

.blog-page .content figcaption {
    font-size: 0.85rem;
    color: var(--color-foreground-muted);
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* Blockquotes */
.blog-page .content blockquote {
    border-left: 3px solid var(--color-brand-primary);
    padding: 0.5rem 0 0.5rem 1.25rem;
    margin: 1.75rem 0;
    color: var(--color-foreground-secondary);
    font-style: italic;
}

.blog-page .content blockquote p {
    margin-bottom: 0.5rem;
}

.blog-page .content blockquote p:last-child {
    margin-bottom: 0;
}

/* Lists in prose */
.blog-page .content ul,
.blog-page .content ol {
    margin: 1.25rem 0;
    padding-left: 1.5rem;
}

.blog-page .content li {
    margin-bottom: 0.4rem;
    line-height: 1.65;
}

.blog-page .content li > strong:first-child {
    color: var(--color-foreground-primary);
}

/* Nested lists — tighter spacing */
.blog-page .content li ul,
.blog-page .content li ol {
    margin: 0.4rem 0;
}

/* Math blocks */
.blog-page .content .math-wrapper {
    margin: 1.25rem 0;
    overflow-x: auto;
}

.blog-page .content .math-wrapper .math {
    margin: 0;
}

/* Tables */
.blog-page .content table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-background-border);
}

.blog-page .content table thead th {
    background: var(--color-background-secondary);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--color-background-border);
}

.blog-page .content table tbody td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--color-background-border);
}

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

.blog-page .content table tbody tr:hover {
    background: color-mix(in srgb, var(--color-background-secondary) 50%, transparent);
}

/* Horizontal rules in blog posts — used as section dividers */
.blog-page .content hr {
    border: none;
    border-top: 1px solid var(--color-background-border);
    margin: 2.5rem 0;
}

/* Footnotes */
.blog-page .content .footnote-reference {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 1;
    text-decoration: none;
}

.blog-page .content dl.footnote {
    font-size: 0.88rem;
    color: var(--color-foreground-secondary);
    border-top: 1px solid var(--color-background-border);
    margin-top: 2.5rem;
    padding-top: 1.5rem;
}

.blog-page .content dl.footnote dt {
    float: left;
    margin-right: 0.5rem;
    font-weight: 600;
}

.blog-page .content dl.footnote dd {
    margin-bottom: 0.5rem;
    margin-left: 2rem;
}

/* Admonitions / callouts in blog posts */
.blog-page .content .admonition {
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

/* Hide docs-style footer on blog pages */
.blog-page .related-pages {
    display: none;
}

.blog-page footer .bottom-of-page {
    border-top: 1px solid var(--color-background-border);
    margin-top: 3rem;
    padding-top: 1rem;
}


/* Blog index heading — extra breathing room */
.blog-index .content h1 {
    margin-top: 1.5rem;
}

/* ---- Blog index / post listing ---- */

.blog-post-listing {
    margin-top: 0.5rem;
}

.blog-post-entry {
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--color-background-border);
}

.blog-post-entry:first-child {
    padding-top: 1rem;
}

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

/* Post titles on the listing */
.blog-post-entry h3 {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 0;
    margin-bottom: 0.3rem;
    letter-spacing: -0.01em;
}

.blog-post-entry h3 a {
    color: var(--color-foreground-primary);
    text-decoration: none;
    transition: color 0.15s;
}

.blog-post-entry h3 a:hover {
    color: var(--color-brand-primary);
}

/* Date/author line */
.blog-post-entry-meta {
    color: var(--color-foreground-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.blog-post-entry-meta a {
    color: var(--color-foreground-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.blog-post-entry-meta a:hover {
    color: var(--color-brand-primary);
}

/* Excerpt text — clamp to 3 lines for consistent layout */
.blog-post-entry-excerpt {
    color: var(--color-foreground-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ---- Blog image lightbox ---- */

.blog-page .content img {
    cursor: zoom-in;
}

.blog-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: zoom-out;
}

.blog-lightbox.is-visible {
    opacity: 1;
}

.blog-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.blog-lightbox.is-visible img {
    transform: scale(1);
}

.blog-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    padding: 0.25rem 0.5rem;
}

.blog-lightbox-close:hover {
    opacity: 1;
}


/* ---- Blog responsive ---- */

@media (max-width: 768px) {
    .blog-page .content h1 {
        font-size: 1.8rem;
    }

    .blog-page .content h2 {
        font-size: 1.25rem;
        margin-top: 2rem;
    }

    .blog-page .content .article-container {
        font-size: 1rem;
        line-height: 1.6;
    }

    .blog-page .content .highlight pre {
        padding: 0.75rem 1rem;
        font-size: 0.82rem;
    }

    .blog-post-entry h3 {
        font-size: 1.15rem;
    }

    /* Full-bleed images & videos on mobile */
    .blog-page .content img:not(.blog-img-full),
    .blog-page .content video:not(.blog-img-full) {
        max-width: 100%;
    }

    .blog-page .content blockquote {
        margin-left: 0;
        margin-right: 0;
    }
}
