/* ==========================================================================
   fsmc Modern Documentation Design System
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & Color Palettes (Modern Light Blue & Slate)
   -------------------------------------------------------------------------- */
:root {
    --fsmc-header-bg: #0b1120;          /* Deep Slate / Midnight Header */
    --fsmc-sidebar-bg: #f8fafc;         /* Clean Soft Off-White Sidebar */
    --fsmc-border: #e2e8f0;             /* Subtle Border */
    --fsmc-border-subtle: #f1f5f9;
    --fsmc-primary: #0284c7;            /* Sky 600 */
    --fsmc-primary-light: #f0f9ff;      /* Sky 50 */
    --fsmc-primary-hover: #e0f2fe;      /* Sky 100 */
    --fsmc-primary-dark: #0369a1;       /* Sky 700 */
    --fsmc-text: #0f172a;               /* Slate 900 */
    --fsmc-text-secondary: #475569;     /* Slate 600 */
    --fsmc-text-muted: #64748b;         /* Slate 500 */
    
    --md-primary-fg-color: #0b1120;
    --md-accent-fg-color: #0284c7;
    --md-typeset-a-color: #0284c7;
    --md-default-fg-color: #0f172a;
    --md-default-fg-color--light: #64748b;
    --md-default-bg-color: #ffffff;
}

[data-md-color-scheme="slate"] {
    --fsmc-header-bg: #060911;
    --fsmc-sidebar-bg: #0b0f17;
    --fsmc-border: #1e293b;
    --fsmc-border-subtle: #141b27;
    --fsmc-primary: #38bdf8;            /* Sky 400 */
    --fsmc-primary-light: rgba(56, 189, 248, 0.12);
    --fsmc-primary-hover: rgba(56, 189, 248, 0.18);
    --fsmc-primary-dark: #38bdf8;
    --fsmc-text: #f1f5f9;
    --fsmc-text-secondary: #cbd5e1;
    --fsmc-text-muted: #94a3b8;
    
    --md-primary-fg-color: #060911;
    --md-accent-fg-color: #38bdf8;
    --md-typeset-a-color: #38bdf8;
    --md-default-fg-color: #f1f5f9;
    --md-default-fg-color--light: #94a3b8;
    --md-default-bg-color: #0d121d;
}

/* --------------------------------------------------------------------------
   2. Grid Layout (Full-Width on Desktop, Safe Padding on Mobile)
   -------------------------------------------------------------------------- */
@media screen and (min-width: 76.25em) {
    .md-grid {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .md-main__inner {
        margin-top: 0 !important;
    }
}

/* --------------------------------------------------------------------------
   3. Top Navigation Header (Deep Slate with Vector Logo)
   -------------------------------------------------------------------------- */
.md-header {
    background-color: var(--fsmc-header-bg) !important;
    color: #ffffff !important;
    border-bottom: 1px solid var(--fsmc-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.md-header__title {
    color: #ffffff !important;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-size: 1.05rem;
}

.md-header__button {
    color: #cbd5e1 !important;
    transition: color 0.15s ease;
}

.md-header__button:hover {
    color: #ffffff !important;
}

/* Logo: Pure Transparent Vector Rendering */
.md-header__button.md-logo {
    margin-right: 0.85rem;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
}

.md-header__button.md-logo img,
.md-header__button.md-logo svg {
    height: 2.0rem;
    width: auto;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* Search Bar */
.md-search__input {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    font-size: 0.82rem;
    transition: all 0.2s ease;
}

.md-search__input:focus {
    background-color: rgba(255, 255, 255, 0.18) !important;
    border-color: var(--fsmc-primary) !important;
}

.md-search__input::placeholder {
    color: rgba(255, 255, 255, 0.65) !important;
}

/* --------------------------------------------------------------------------
   4. Left Sidebar Navigation
   -------------------------------------------------------------------------- */

/* Desktop-only Sidebar Layout */
@media screen and (min-width: 76.25em) {
    .md-sidebar--primary {
        position: sticky;
        top: 48px;
        width: 18.5rem !important;
        flex-shrink: 0;
        background-color: var(--fsmc-sidebar-bg) !important;
        border-right: 1px solid var(--fsmc-border) !important;
    }

    .md-sidebar--primary .md-sidebar__scrollwrap {
        background-color: var(--fsmc-sidebar-bg) !important;
        padding: 1.25rem 0.85rem !important;
    }

    /* Hide redundant root nav title and TOC label on desktop */
    .md-sidebar--primary .md-nav--primary > .md-nav__title,
    .md-sidebar--primary label.md-nav__link[for="__toc"],
    .md-sidebar--primary .md-nav__item > label.md-nav__link[for="__toc"] {
        display: none !important;
    }
}

/* Mobile Drawer Responsive Layout */
@media screen and (max-width: 76.1875em) {
    .md-sidebar--primary {
        background-color: var(--md-default-bg-color) !important;
    }

    .md-sidebar--primary .md-sidebar__scrollwrap {
        padding: 0.75rem 0.5rem !important;
        background-color: var(--md-default-bg-color) !important;
    }

    .md-sidebar--primary .md-nav--primary .md-nav__title {
        color: var(--fsmc-text);
        font-weight: 700;
        border-bottom: 1px solid var(--fsmc-border);
        padding: 0.75rem 1rem;
    }
}

/* Shared Chapter Navigation Styling */
.md-nav__container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0.15rem 0 !important;
    border-radius: 6px !important;
    background: transparent;
    transition: all 0.15s ease;
    border: none !important;
}

.md-nav__container:hover {
    background-color: rgba(2, 132, 199, 0.08) !important;
    color: var(--fsmc-primary) !important;
}

.md-nav__item--active > .md-nav__container {
    background-color: var(--fsmc-primary-light) !important;
    color: var(--fsmc-primary-dark) !important;
}

/* Text link inside container */
.md-nav__container > a.md-nav__link {
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    color: inherit !important;
    padding: 0.5rem 0.5rem 0.5rem 0.75rem !important;
    margin: 0 !important;
    background: transparent !important;
}

/* Expansion chevron label inside container */
.md-nav__container > label.md-nav__link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem 0.65rem !important;
    margin: 0 !important;
    cursor: pointer !important;
    color: var(--fsmc-text-muted) !important;
    background: transparent !important;
    height: 100% !important;
}

.md-nav__container > label.md-nav__link:hover {
    color: var(--fsmc-primary) !important;
}

/* Expansion chevron icon centering & rotation */
.md-nav__icon.md-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 1.1rem !important;
    width: 1.1rem !important;
    line-height: 1 !important;
    position: static !important;
    top: auto !important;
    margin: 0 !important;
    transition: transform 0.2s ease !important;
}

.md-nav__item--active > .md-nav__container > label.md-nav__link .md-icon {
    transform: rotate(90deg);
}

.md-nav__icon.md-icon svg {
    display: block;
    height: 0.95rem;
    width: 0.95rem;
}

/* Standalone Top-Level Chapter Links (e.g., Overview, Playground) */
.md-nav > .md-nav__list > .md-nav__item > a.md-nav__link {
    display: flex !important;
    align-items: center !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    color: var(--fsmc-text) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 6px;
    margin: 0.15rem 0;
    transition: all 0.15s ease;
}

.md-nav > .md-nav__list > .md-nav__item > a.md-nav__link:hover {
    color: var(--fsmc-primary) !important;
    background-color: rgba(2, 132, 199, 0.08);
}

.md-nav > .md-nav__list > .md-nav__item--active > a.md-nav__link {
    color: var(--fsmc-primary-dark) !important;
    font-weight: 700 !important;
    background-color: var(--fsmc-primary-light) !important;
}

/* Subpages Container Under Expanded Chapter */
.md-nav__list .md-nav__list {
    border-left: 2px solid var(--fsmc-border);
    margin-left: 0.85rem;
    padding-left: 0.5rem;
    margin-top: 0.2rem;
    margin-bottom: 0.4rem;
}

/* Subpage Links */
.md-nav__list .md-nav__list .md-nav__link {
    font-size: 0.83rem !important;
    font-weight: 400 !important;
    color: var(--fsmc-text-secondary) !important;
    padding: 0.35rem 0.65rem !important;
    border-radius: 5px;
    margin: 0.08rem 0;
    transition: all 0.15s ease;
}

.md-nav__list .md-nav__list .md-nav__link:hover {
    color: var(--fsmc-primary) !important;
    background-color: rgba(2, 132, 199, 0.08);
}

/* Active Subpage Highlight */
.md-nav__list .md-nav__list .md-nav__item--active > .md-nav__link {
    color: var(--fsmc-primary-dark) !important;
    font-weight: 600 !important;
    background-color: var(--fsmc-primary-hover) !important;
    border-left: 3px solid var(--fsmc-primary) !important;
    border-radius: 0 5px 5px 0 !important;
    padding-left: calc(0.65rem - 3px) !important;
}

/* --------------------------------------------------------------------------
   5. Breadcrumbs Path (.md-path)
   -------------------------------------------------------------------------- */
.md-path {
    font-size: 0.78rem;
    color: var(--fsmc-text-muted);
    margin-bottom: 1.25rem;
}

.md-path__link {
    color: var(--fsmc-text-muted);
    transition: color 0.15s ease;
}

.md-path__link:hover {
    color: var(--fsmc-primary);
}

/* --------------------------------------------------------------------------
   6. Main Content Area & Responsive Typography
   -------------------------------------------------------------------------- */
.md-content {
    background-color: var(--md-default-bg-color);
    padding: 1.4rem 2.2rem 3rem !important;
    max-width: 60rem;
    box-sizing: border-box;
}

@media screen and (max-width: 60em) {
    .md-content {
        padding: 1rem 1rem 2.5rem !important;
        max-width: 100% !important;
    }
}

@media screen and (max-width: 40em) {
    .md-content {
        padding: 0.85rem 0.75rem 2rem !important;
    }
}

.md-typeset {
    font-family: var(--md-text-font-family, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-size: 0.84rem;
    line-height: 1.62;
    color: var(--fsmc-text);
    word-break: break-word;
}

.md-typeset h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--fsmc-text);
    letter-spacing: -0.02em;
    border-bottom: 2px solid var(--fsmc-border);
    padding-bottom: 0.35rem;
    margin-bottom: 1rem;
}

.md-typeset h2 {
    font-size: 1.18rem;
    font-weight: 600;
    color: var(--fsmc-text);
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--fsmc-border);
    padding-bottom: 0.25rem;
    margin-top: 1.6rem;
    margin-bottom: 0.65rem;
}

.md-typeset h3 {
    font-size: 1.00rem;
    font-weight: 600;
    color: var(--fsmc-text);
    margin-top: 1.25rem;
    margin-bottom: 0.45rem;
}

.md-typeset h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--fsmc-text);
    margin-top: 1rem;
    margin-bottom: 0.35rem;
}

@media screen and (max-width: 40em) {
    .md-typeset h1 {
        font-size: 1.30rem;
    }
    .md-typeset h2 {
        font-size: 1.08rem;
    }
    .md-typeset h3 {
        font-size: 0.95rem;
    }
}

/* List Styling & Nested Indentation */
.md-typeset ul, 
.md-typeset ol {
    margin-top: 0.35rem;
    margin-bottom: 0.55rem;
    padding-left: 1.5rem;
}

.md-typeset li {
    margin-bottom: 0.25rem;
}

.md-typeset li > ul, 
.md-typeset li > ol {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    padding-left: 1.5rem;
}

.md-typeset ul > li > ul {
    list-style-type: circle;
}

.md-typeset ul > li > ul > li > ul {
    list-style-type: square;
}

.md-typeset ol > li > ul {
    list-style-type: disc;
}

.md-typeset ol > li > ul > li > ul {
    list-style-type: circle;
}

/* Inline Code Snippets */
.md-typeset :not(pre) > code {

    background-color: rgba(2, 132, 199, 0.08);
    color: var(--fsmc-primary-dark);
    border: 1px solid rgba(2, 132, 199, 0.2);
    border-radius: 4px;
    padding: 0.10em 0.35em;
    font-size: 0.83em;
    font-family: var(--md-code-font-family, "JetBrains Mono", monospace);
    word-break: break-all;
}

[data-md-color-scheme="slate"] .md-typeset :not(pre) > code {
    background-color: rgba(56, 189, 248, 0.12);
    color: var(--fsmc-primary);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

/* Code Blocks & Highlights (Sleek, Compact Scale, Touch Scroll) */
.md-typeset pre {
    border-radius: 6px;
    border: 1px solid var(--fsmc-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    margin: 0.85rem 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.md-typeset pre > code {
    font-size: 0.78rem !important;
    line-height: 1.44 !important;
    padding: 0.70rem 0.95rem !important;
    font-family: var(--md-code-font-family, "JetBrains Mono", monospace) !important;
}

.md-typeset .highlighttable {
    margin: 0.85rem 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Multi-Format Tabbed Sets (=== "Tab") */
.md-typeset .tabbed-set {
    border-radius: 6px;
    border: 1px solid var(--fsmc-border);
    overflow: hidden;
    margin: 1.1rem 0;
    max-width: 100%;
}

.md-typeset .tabbed-labels {
    background-color: var(--fsmc-sidebar-bg);
    border-bottom: 1px solid var(--fsmc-border);
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.md-typeset .tabbed-labels > label {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.38rem 0.90rem;
    color: var(--fsmc-text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.md-typeset .tabbed-labels > label:hover {
    color: var(--fsmc-primary);
}

.md-typeset .tabbed-set > input:checked + label {
    color: var(--fsmc-primary-dark);
    border-bottom: 2px solid var(--fsmc-primary);
    background-color: var(--md-default-bg-color);
}

.md-typeset .tabbed-content {
    padding: 0.5rem !important;
    overflow-x: auto;
}

.md-typeset .tabbed-content pre {
    margin: 0 !important;
}

/* Tables (Compact with Responsive Touch Scroll) */
.md-typeset table:not([class]) {
    font-size: 0.80rem;
    border-radius: 5px;
    border: 1px solid var(--fsmc-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    margin: 1.1rem 0;
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
}

.md-typeset table:not([class]) th {
    background-color: var(--fsmc-sidebar-bg);
    color: var(--fsmc-text);
    font-weight: 600;
    border-bottom: 2px solid var(--fsmc-border);
    padding: 0.45rem 0.75rem;
    white-space: nowrap;
}

.md-typeset table:not([class]) td {
    padding: 0.40rem 0.75rem;
    border-bottom: 1px solid var(--fsmc-border-subtle);
}

/* Admonitions (Callout Cards) */
.md-typeset .admonition {
    border-radius: 6px;
    border-left-width: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    margin: 1.0rem 0;
    font-size: 0.82rem;
    padding: 0.55rem 0.85rem;
    max-width: 100%;
    overflow-x: auto;
}

/* Mermaid Diagrams Constrained Scale */
.md-typeset .mermaid {
    margin: 1.2rem 0;
    text-align: center;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.md-typeset .mermaid svg {
    max-height: 380px !important;
    max-width: 100% !important;
    height: auto;
}

/* Keyboard Keys (<kbd>) */
kbd {
    background-color: var(--fsmc-sidebar-bg);
    border: 1px solid var(--fsmc-border);
    border-bottom: 2px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.12em 0.35em;
    font-size: 0.75em;
    font-family: inherit;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Modern Right-Hand Table of Contents (TOC) & Sidebar Navigation
   ========================================================================== */
@media screen and (min-width: 60em) {
    .md-sidebar--secondary {
        padding-top: 1.25rem;
    }

    /* TOC Container & Title */
    .md-sidebar--secondary .md-nav__title {
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--fsmc-text-muted);
        margin-bottom: 0.5rem;
        padding-left: 0.6rem;
    }

    /* Hide mobile drawer back arrow on desktop */
    .md-sidebar--secondary .md-nav__title .md-nav__icon {
        display: none !important;
    }


    /* Base TOC link */
    .md-sidebar--secondary .md-nav__link {
        font-size: 0.78rem;
        line-height: 1.45;
        padding: 0.28rem 0.6rem;
        border-radius: 4px;
        color: var(--fsmc-text-muted);
        transition: all 0.15s ease-in-out;
        display: block;
        border-left: 2px solid transparent;
    }

    .md-sidebar--secondary .md-nav__link:hover {
        color: var(--fsmc-primary);
        background-color: var(--fsmc-code-bg);
    }

    /* Active TOC Link */
    .md-sidebar--secondary .md-nav__link--active,
    .md-sidebar--secondary .md-nav__item--active > .md-nav__link {
        color: var(--fsmc-primary) !important;
        font-weight: 600;
        background-color: rgba(37, 99, 235, 0.06);
        border-left: 2px solid var(--fsmc-primary) !important;
        padding-left: 0.6rem;
    }

    /* Nested Sub-headings (H3 / H4) */
    .md-sidebar--secondary .md-nav__list .md-nav__list {
        padding-left: 0.6rem;
        margin-left: 0.4rem;
        border-left: 1px solid var(--fsmc-border);
    }

    .md-sidebar--secondary .md-nav__list .md-nav__list .md-nav__link {
        font-size: 0.74rem;
        padding: 0.22rem 0.5rem;
    }
}


/* Interactive Playground Frame */
.playground-frame-container {
    width: 100%;
    height: 85vh;
    min-height: 520px;
    border: 1px solid var(--fsmc-border);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

@media screen and (max-width: 60em) {
    .playground-frame-container {
        height: 75vh;
        min-height: 440px;
    }
}

.playground-frame-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}
