/* ── Secondary sidebar (right-side TOC) ────────────────────────────── */
/* Hidden by default and enabled only when JS marks body.toc-has-content */
.md-sidebar--secondary.md-sidebar {
    display: none;
}

/* Desktop behavior: keep native Material layout */
@media (min-width: 76.25em) {
    body.toc-visible.toc-has-content .md-sidebar--secondary.md-sidebar,
    body.toc-visible.toc-has-content .md-nav--secondary {
        display: block;
    }

    body.toc-visible.toc-has-content .md-sidebar--secondary .md-sidebar__scrollwrap {
        height: 85vh !important;
        overflow-y: auto !important;
    }

    body.toc-visible.toc-has-content .md-sidebar--secondary .md-sidebar__inner {
        background: rgba(0, 0, 0, 0.03);
        border-radius: 4px;
    }

    [data-md-color-scheme="slate"] body.toc-visible.toc-has-content .md-sidebar--secondary .md-sidebar__inner {
        background: rgba(255, 255, 255, 0.04);
    }

    body.toc-visible.toc-has-content .md-grid {
        max-width: 95%;
    }
}

/* Active TOC link highlighting */
body.toc-visible.toc-has-content .md-nav--secondary .md-nav__link--active {
    font-weight: 600;
    border-left: 3px solid var(--heading-accent, #3c678a);
    padding-left: 0.5em;
}

/* TOC search box (under md-nav__title) */
body.toc-has-content .md-sidebar--secondary .toc-search {
    margin: 0.6rem 0.2rem 0.45rem;
}

body.toc-has-content .md-sidebar--secondary .toc-search__input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--md-default-fg-color--lightest);
    border-radius: 0.25rem;
    padding: 0.35rem 0.55rem;
    background: var(--md-default-bg-color);
    color: var(--md-default-fg-color);
    font-size: 0.62rem;
    line-height: 1.25;
}

body.toc-has-content .md-sidebar--secondary .toc-search__input::placeholder {
    color: var(--md-default-fg-color--light);
}

body.toc-has-content .md-sidebar--secondary .toc-search__input:focus {
    border-color: var(--md-accent-fg-color);
    outline: none;
}

body.toc-search-active .md-sidebar--secondary .md-nav__link.toc-search-hit {
    color: var(--md-accent-fg-color);
    font-weight: 600;
}

/* ── Heading permalink anchors (GitHub octicon-link style) ── */
.md-typeset .headerlink {
    visibility: hidden;
    opacity: 0.55;
    margin-left: 0.3em;
    text-decoration: none;
    transition: visibility 0.15s, opacity 0.15s;
    vertical-align: middle;
}
.md-typeset h1:hover .headerlink,
.md-typeset h2:hover .headerlink,
.md-typeset h3:hover .headerlink,
.md-typeset h4:hover .headerlink,
.md-typeset h5:hover .headerlink,
.md-typeset h6:hover .headerlink,
.md-typeset .headerlink:hover,
.md-typeset .headerlink:focus {
    visibility: visible;
    opacity: 0.85;
}

/* ── TOC hamburger toggle button in the header bar ── */
.toc-toggle-btn {
    background: transparent;
    border: none;
    color: currentColor;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 0.2rem;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0.7;
    position: relative;
    vertical-align: middle;
}
.toc-toggle-btn:hover {
    opacity: 1;
    background: rgba(127,127,127,0.12);
}
.toc-toggle-btn.active {
    opacity: 1;
}
.toc-toggle-btn svg {
    width: 1.2rem;
    height: 1.2rem;
}
/* Button is shown only when page has a generated TOC */
body.toc-has-content .toc-toggle-btn {
    display: inline-flex;
}

/* Mobile behavior: TOC as a right drawer overlay */
@media (max-width: 76.1875em) {
    .md-sidebar--secondary.md-sidebar {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        width: min(82vw, 20rem);
        height: 100dvh;
        margin: 0;
        padding-right: 0 !important;
        z-index: 16;
        background: var(--md-default-bg-color);
        border-left: 1px solid var(--md-default-fg-color--lightest);
        box-shadow: none;
        transform: translateX(100%);
        transition: transform 0.2s ease;
        pointer-events: none;
    }

    .md-sidebar--secondary .md-sidebar__inner {
        height: 100%;
        padding-right: 0 !important;
        background: transparent;
        border-radius: 0;
    }

    .md-sidebar--secondary .md-sidebar__scrollwrap {
        height: 100% !important;
        max-height: none !important;
        min-height: 0;
        padding-right: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .md-sidebar--secondary .md-nav--secondary {
        padding-right: 0 !important;
    }

    body.toc-visible.toc-mobile-open.toc-has-content .md-sidebar--secondary.md-sidebar {
        transform: translateX(0);
        pointer-events: auto;
    }

    body.toc-visible.toc-mobile-open.toc-has-content .md-nav--secondary {
        display: block;
    }

    .md-sidebar--secondary .md-nav--secondary .md-nav__list {
        margin: 0;
        padding-left: 0;
    }

    .md-sidebar--secondary .md-nav--secondary .md-nav__link {
        display: block;
        width: 100%;
    }

    .md-sidebar--secondary .md-nav--secondary > .md-nav__list > .md-nav__item > .md-nav__link {
        padding-left: 0.1rem;
    }

    .md-sidebar--secondary .md-nav--secondary .md-nav__list .md-nav__list {
        margin-left: 0.9rem;
        padding-left: 0.7rem;
        border-left: 1px solid var(--md-default-fg-color--lightest);
    }

    .md-sidebar--secondary .md-nav--secondary .md-nav__list .md-nav__list .md-nav__list {
        margin-left: 0.75rem;
        padding-left: 0.55rem;
    }

    .toc-mobile-backdrop {
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(0, 0, 0, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    body.toc-visible.toc-mobile-open.toc-has-content .toc-mobile-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.toc-visible.toc-mobile-open.toc-has-content {
        overflow: hidden;
    }

    /* Prevent any layout expansion on mobile when TOC is missing/hidden */
    .md-main__inner,
    .md-content {
        margin-right: 0 !important;
    }

    body.toc-visible.toc-has-content .md-grid {
        max-width: 100%;
    }
}

/* ── Code block language label (.filename): hidden by default ── */
/* Use same specificity as theme rule (.highlight span.filename) and !important
   to override its display:flow-root. */
.highlight span.filename {
    display: none !important;
}
.highlight span.filename.filename--visible {
    display: flow-root !important;  /* restore theme value when shown */
}
/* When .filename is hidden the theme's .filename+pre margin/radius reset
   no longer applies, so restore normal pre border-radius */
.highlight span.filename:not(.filename--visible) + pre {
    margin-top: 1em;
    border-top-left-radius: 0.1rem;
    border-top-right-radius: 0.1rem;
}

/* Language toggle button — positioned like the copy-to-clipboard btn */
.lang-toggle-btn {
    position: absolute;
    top: 0.45em;
    right: 2.8em;  /* leave room for the copy button to the right */
    z-index: 2;
    background: transparent;
    border: none;
    color: var(--md-default-fg-color--lightest, rgba(0,0,0,0.26));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    padding: 0;
    border-radius: 0.15em;
    transition: color 0.2s, background 0.2s;
    opacity: 0.6;
}
.lang-toggle-btn:hover {
    opacity: 1;
    color: var(--md-accent-fg-color, #526cfe);
    background: rgba(127,127,127,0.08);
}
.lang-toggle-btn.active {
    opacity: 1;
    color: var(--md-accent-fg-color, #526cfe);
}
.lang-toggle-btn svg {
    width: 1.1em;
    height: 1.1em;
    fill: currentColor;
}

/* General styles for navigation and typeset */
.md-nav {
    font-size: 14px;
    line-height: 1.4;
}

.md-nav__link {
    display: inline-flex;
}

.md-typeset {
    font-size: .7rem;
    line-height: 1.5;
}

/* Adjust spacing for paragraphs and line breaks */
.md-typeset p {
    margin: 0.5em 0;
}

/* Hide double line breaks in markdown source (e.g. between list items) */
.md-typeset p br + br {
    display: none;
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5 {
    color: var(--heading-color);
    letter-spacing: 0.01em;
}

.md-typeset h1 {
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--heading-rule);
}

.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5 {
    font-weight: 500;
    margin-top: 1.4em;
    margin-bottom: 0.65em;
    padding-bottom: 0.12rem;
    border-bottom: 1px dashed var(--heading-accent);
}

.md-typeset code,
.md-typeset pre {
    color: var(--code-color);
}

.md-typeset table:not([class]) th {
    color: var(--table-foreground);
    background-color: var(--table-background);
}

.md-grid {
/*  max-width: 1440px; */
    max-width: 1680px;
}

.text-center {
    text-align: center !important;
}

[data-md-color-primary="blue-grey"] {
    --md-primary-fg-color: #436584;
}

[data-md-color-scheme="default"] {
    --code-color: #0891b2;        /* teal — matches colorscheme-modern.css .part1 */
    --table-foreground: var(--md-default-bg-color); /* table header backgrounds */
    --table-background: var(--md-default-fg-color--light); /* table header (text) */
    --heading-color: #203146;
    --heading-accent: #3c678a;
    --heading-rule: rgba(60, 103, 138, 0.32);
}

[data-md-color-scheme="slate"] {
    --code-color: #06b6d4;        /* bright cyan — readable on dark slate */
    --md-typeset-a-color: #7c90ff; /* links */
    --table-foreground: #a3acdf; /* table header (text) */
    --table-background: #272e53; /* table header backgrounds */
    --heading-color: #dfe7ff;
    --heading-accent: #6a85d8;
    --heading-rule: rgba(106, 133, 216, 0.45);
}

/* Freetz-EVO documentation home */
[data-md-color-scheme="default"] {
    --evo-home-surface: #f7fafc;
    --evo-home-panel: #ffffff;
    --evo-home-muted: #4b6075;
    --evo-home-border: rgba(67, 101, 132, 0.22);
    --evo-home-hero: #eef6f7;
    --evo-home-accent: #0f766e;
    --evo-home-accent-2: #2563eb;
    --evo-home-accent-3: #7c5800;
    --evo-home-button-fg: #ffffff;
    --evo-home-terminal: #111827;
    --evo-home-terminal-fg: #dbeafe;
    --evo-home-shadow: 0 14px 34px rgba(32, 49, 70, 0.12);
}

[data-md-color-scheme="slate"] {
    --evo-home-surface: #101821;
    --evo-home-panel: #172231;
    --evo-home-muted: #b2c0d1;
    --evo-home-border: rgba(172, 190, 214, 0.2);
    --evo-home-hero: #111c29;
    --evo-home-accent: #2dd4bf;
    --evo-home-accent-2: #78a6ff;
    --evo-home-accent-3: #f3c969;
    --evo-home-button-fg: #08111f;
    --evo-home-terminal: #0b111a;
    --evo-home-terminal-fg: #d9e7ff;
    --evo-home-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.md-typeset .evo-home {
    display: block;
    margin-top: 1rem;
}

.md-typeset .evo-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 0.9fr);
    gap: 1.2rem;
    align-items: stretch;
    margin: 1rem 0 1.2rem;
    padding: clamp(1rem, 2.2vw, 1.7rem);
    background: var(--evo-home-hero);
    border: 1px solid var(--evo-home-border);
    border-radius: 8px;
    box-shadow: var(--evo-home-shadow);
}

.md-typeset .evo-hero h2 {
    margin-top: 0.25rem;
    border-bottom: 0;
    font-size: clamp(1.35rem, 1.1rem + 1vw, 2rem);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.12;
}

.md-typeset .evo-kicker {
    margin: 0 0 0.3rem;
    color: var(--evo-home-accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.md-typeset .evo-hero__copy p {
    max-width: 48rem;
}

.md-typeset .evo-actions {
    justify-content: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin: 1rem 0 0;
}

.md-typeset .evo-actions br {
    display: none;
}

.md-typeset .evo-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.1rem;
    padding: 0.45rem 0.72rem;
    border: 1px solid var(--evo-home-border);
    border-radius: 6px;
    background: var(--evo-home-panel);
    color: var(--md-typeset-a-color);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
}

.md-typeset .evo-button:hover,
.md-typeset .evo-button:focus {
    border-color: var(--evo-home-accent-2);
    text-decoration: none;
}

.md-typeset .evo-button--primary {
    background: var(--evo-home-accent-2);
    border-color: var(--evo-home-accent-2);
    color: var(--evo-home-button-fg);
}

.md-typeset .evo-hero__panel {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.85rem;
    min-height: 16rem;
    border-radius: 8px;
}

.md-typeset .evo-logo {
    width: min(5rem, 42%);
    height: auto;
    border-radius: 8px;
}

.md-typeset .evo-terminal-card {
    display: grid;
    gap: 0.35rem;
    width: 100%;
    max-width: 18rem;
    padding: 0.85rem;
    border: 1px solid rgba(120, 166, 255, 0.35);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    font-family: var(--md-code-font-family, monospace);
    font-size: 0.66rem;
    line-height: 1.5;
}

.md-typeset .evo-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    margin: 0 0 1.3rem;
}

.md-typeset .evo-metrics > div,
.md-typeset .evo-card,
.md-typeset .evo-feature-grid > div,
.md-typeset .evo-link-columns > div {
    background: var(--evo-home-panel);
    border: 1px solid var(--evo-home-border);
    border-radius: 8px;
}

.md-typeset .evo-metrics > div {
    min-height: 5.4rem;
    padding: 0.8rem;
}

.md-typeset .evo-metrics strong {
    display: block;
    color: var(--evo-home-accent-2);
    font-size: 1.55rem;
    line-height: 1;
}

.md-typeset .evo-metrics span,
.md-typeset .evo-feature-grid span {
    display: block;
    color: var(--evo-home-muted);
}

.md-typeset .evo-section {
    margin: 1.45rem 0;
}

.md-typeset .evo-section > h2 {
    border-bottom-color: var(--evo-home-border);
}

.md-typeset .evo-card-grid,
.md-typeset .evo-feature-grid,
.md-typeset .evo-link-columns {
    display: grid;
    gap: 0.8rem;
}

.md-typeset .evo-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.md-typeset .evo-feature-grid,
.md-typeset .evo-link-columns {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.md-typeset .evo-link-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.md-typeset .evo-card,
.md-typeset .evo-feature-grid > div,
.md-typeset .evo-link-columns > div {
    padding: 0.85rem;
}

.md-typeset .evo-card__title,
.md-typeset .evo-column__title {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 700;
    line-height: 1.25;
}

.md-typeset .evo-card__title {
    color: var(--evo-home-accent-2);
}

.md-typeset .evo-column__title {
    color: var(--heading-color);
}

.md-typeset .evo-card p:last-child,
.md-typeset .evo-feature-grid p,
.md-typeset .evo-link-columns p {
    margin-bottom: 0;
}

.md-typeset .evo-feature-grid strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--heading-color);
    font-size: 0.78rem;
}

.md-typeset .evo-reference a {
    display: inline-block;
    margin: 0.08rem 0;
}

@media (max-width: 64em) {
    .md-typeset .evo-hero,
    .md-typeset .evo-card-grid,
    .md-typeset .evo-feature-grid,
    .md-typeset .evo-link-columns {
        grid-template-columns: 1fr;
    }

    .md-typeset .evo-hero__panel {
        min-height: 12rem;
    }

    .md-typeset .evo-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 34em) {
    .md-typeset .evo-hero {
        padding: 0.85rem;
    }

    .md-typeset .evo-actions,
    .md-typeset .evo-actions .evo-button {
        width: 100%;
    }

    .md-typeset .evo-metrics {
        grid-template-columns: 1fr;
    }
}

/* Final mobile override: disable theme max-height clamps and keep scrolling */
@media (max-width: 76.1875em) {
    body.toc-visible.toc-mobile-open.toc-has-content .md-sidebar--secondary .md-sidebar__inner,
    body.toc-visible.toc-mobile-open.toc-has-content .md-sidebar--secondary .md-sidebar__scrollwrap,
    body.toc-visible.toc-mobile-open.toc-has-content .md-sidebar--secondary .md-nav--secondary {
        max-height: none !important;
    }

    body.toc-visible.toc-mobile-open.toc-has-content .md-sidebar--secondary .md-sidebar__scrollwrap,
    body.toc-visible.toc-mobile-open.toc-has-content .md-sidebar--secondary .md-nav--secondary {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}
