/* Hide in-page heading TOC from sidebar (keep chapter sub-entries) */
.chapter li:not(.chapter-item) {
    display: none;
}

/* PDF container */
.pdf {
    width: 100%;
}

/* Embedded PDF iframe */
.pdf__frame {
    display: block;          /* avoid inline gap */
    width: 100%;             /* responsive width on all screens */
    height: 80vh;            /* default height (desktop-ish) */
    border: none;
}

/* "Open PDF" link – on larger screens */
.pdf__link {
    display: block;
    margin-top: 0.75rem;
}

/* Small screens: adjust height + show link */
@media (max-width: 768px) {
    .pdf__frame {
        height: 60vh;        /* slightly shorter on mobile */
    }

    .pdf__link {
        display: block;      /* show "Open PDF" on mobile */
    }
}

.mermaid {
    margin: 1.5rem 0;
    text-align: center;
    overflow-x: auto;
    overflow-y: hidden;
}

.mermaid svg {
    display: block;
    height: auto;
    margin: 0 auto;
    max-width: none;
}

.python-playground .buttons {
    display: flex;
    gap: 0.25rem;
}

.python-playground .play-button.is-loading {
    opacity: 0.7;
}

.python-playground .result {
    display: block;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    white-space: pre-wrap;
    background: var(--quote-bg);
}

.python-playground .result.result-error {
    border-left: 4px solid #c2410c;
}

.python-playground .result.result-no-output {
    opacity: 0.8;
}

.sql-playground .buttons {
    display: flex;
    gap: 0.25rem;
}

.sql-playground .result {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: var(--quote-bg);
    overflow-x: auto;
}

.sql-playground .result.result-error {
    border-left: 4px solid #c2410c;
    white-space: pre-wrap;
}

.sql-playground .result.result-no-output {
    opacity: 0.8;
}

.sql-playground .result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

.sql-playground .result-table:first-child {
    margin-top: 0;
}

.sql-playground .result-table th,
.sql-playground .result-table td {
    border: 1px solid var(--table-border-color);
    padding: 0.4rem 0.55rem;
    text-align: left;
    vertical-align: top;
}

.sql-playground .result-table th {
    background: var(--table-header-bg);
}

.sql-playground .result-label {
    display: inline-block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

/* =========================================================
   Lang Tabs — multi-language tabbed code blocks
   ========================================================= */

.lang-tabs {
    margin: 1.25rem 0;
    border-radius: 16px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
        var(--code-block-bg);
    border: 1px solid color-mix(in srgb, var(--table-border-color) 78%, transparent);
    box-shadow:
        0 10px 30px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Tab bar sits directly above the code block */
.lang-tabs__bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    padding: 0.7rem 0.8rem 0.55rem;
    background:
        linear-gradient(180deg, rgba(148, 163, 184, 0.10), rgba(148, 163, 184, 0.04));
    border-bottom: 1px solid color-mix(in srgb, var(--table-border-color) 84%, transparent);
    overflow-x: auto;
    scrollbar-width: thin;
}

/* Individual tab button */
.lang-tabs__tab {
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid transparent;
    border-radius: 999px;
    color: color-mix(in srgb, var(--fg) 72%, var(--icons) 28%);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    line-height: 1;
    outline: none;
    padding: 0.6rem 0.95rem;
    transition:
        color 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
    white-space: nowrap;
}

.lang-tabs__tab:hover {
    color: var(--fg);
    background: rgba(148, 163, 184, 0.15);
    border-color: color-mix(in srgb, var(--table-border-color) 68%, transparent);
    transform: translateY(-1px);
}

.lang-tabs__tab:focus-visible {
    border-color: color-mix(in srgb, var(--links) 55%, white 10%);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--links) 18%, transparent);
}

/* Active tab: accent-coloured bottom border as the indicator */
.lang-tabs__tab--active {
    color: var(--fg);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--links) 20%, white 2%), color-mix(in srgb, var(--links) 10%, transparent));
    border-color: color-mix(in srgb, var(--links) 35%, var(--table-border-color) 65%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 6px 16px rgba(59, 130, 246, 0.12);
}

/* Panes: display is managed by JS (style.display = '' / 'none') */
.lang-tabs__pane {
    display: block;
    padding: 0.1rem;
}

/* Remove top radius on inner <pre> so it merges flush with the tab bar */
.lang-tabs__pane > pre {
    margin-top: 0;
    border-radius: 12px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@media (max-width: 768px) {
    .lang-tabs {
        border-radius: 14px;
    }

    .lang-tabs__bar {
        flex-wrap: nowrap;
        padding: 0.65rem 0.7rem 0.5rem;
    }

    .lang-tabs__tab {
        font-size: 0.94rem;
        padding: 0.56rem 0.82rem;
    }

    .lang-tabs__pane {
        padding: 0;
    }

    .lang-tabs__pane > pre {
        border-radius: 0 0 14px 14px;
    }
}

/* =========================================================
   Shared result-block styles for js / ts / piston playgrounds
   ========================================================= */

.js-playground .buttons,
.ts-playground .buttons,
.piston-playground .buttons {
    display: flex;
    gap: 0.25rem;
}

.js-playground .play-button.is-loading,
.ts-playground .play-button.is-loading,
.piston-playground .play-button.is-loading {
    opacity: 0.7;
}

.js-playground .result,
.ts-playground .result,
.piston-playground .result {
    display: block;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    white-space: pre-wrap;
    background: var(--quote-bg);
}

.js-playground .result.result-error,
.ts-playground .result.result-error,
.piston-playground .result.result-error {
    border-left: 4px solid #c2410c;
}

.js-playground .result.result-no-output,
.ts-playground .result.result-no-output,
.piston-playground .result.result-no-output {
    opacity: 0.8;
}
