/* ==========================================================================
   Brand colours (pydata-sphinx-theme variable names, used by sphinx-book-theme)
   ========================================================================== */

html {
    --pst-color-primary: #2563eb;
    --pst-color-secondary: #1d4ed8;
    --pst-color-link: #1d4ed8;
    --pst-color-link-hover: #1e3a8a;
}

html[data-theme="dark"] {
    --pst-color-primary: #60a5fa;
    --pst-color-secondary: #93c5fd;
    --pst-color-link: #93c5fd;
    --pst-color-link-hover: #bfdbfe;
}

/* ==========================================================================
   Typography polish
   ========================================================================== */

article h1, article h2, article h3, article h4 {
    letter-spacing: -0.01em;
}

article h2 {
    font-size: 1.35em;
    margin-top: 2.2em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--pst-color-border, #dee2e6);
}

article h3 {
    font-size: 1.1em;
    margin-top: 1.6em;
}

/* ==========================================================================
   Tables: tighter, clearer
   ========================================================================== */

article table.docutils {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.92em;
}

article table.docutils th,
article table.docutils td {
    padding: 0.55em 0.8em;
    vertical-align: top;
}

article table.docutils thead th {
    background: var(--pst-color-surface, rgba(0, 0, 0, 0.04));
    border-bottom: 2px solid var(--pst-color-primary);
}

article table.docutils tbody tr:nth-child(even) {
    background: var(--pst-color-table-row-hover-bg, rgba(0, 0, 0, 0.025));
}

/* ==========================================================================
   Captions: always bottom, for both figures and tables
   ========================================================================== */

article table.docutils caption,
article .table-wrapper caption,
article table caption {
    caption-side: bottom;
    padding-top: 0.6em;
    padding-bottom: 0.2em;
    text-align: left;
    font-size: 0.92em;
    color: var(--pst-color-text-muted, #5f6368);
}

article figure.table,
article figure.align-default:has(> table) {
    display: flex;
    flex-direction: column;
}

article figure.table > figcaption,
article figure.align-default:has(> table) > figcaption {
    order: 2;
    padding-top: 0.6em;
    font-size: 0.92em;
    color: var(--pst-color-text-muted, #5f6368);
}

article figure.table > table,
article figure.align-default:has(> table) > table {
    order: 1;
}

article figure > figcaption {
    font-size: 0.92em;
    color: var(--pst-color-text-muted, #5f6368);
    padding-top: 0.4em;
}

/* ==========================================================================
   Grid cards (sphinx-design) polish
   ========================================================================== */

.sd-card {
    border-radius: 0.5rem !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sd-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sd-card-title {
    font-weight: 600;
}

/* ==========================================================================
   Inline code
   ========================================================================== */

article p code.literal,
article li code.literal {
    background: var(--pst-color-surface, rgba(125, 125, 125, 0.08));
    padding: 0.1em 0.35em;
    border-radius: 0.25em;
    font-size: 0.9em;
}

/* ==========================================================================
   MathJax: hide scrollbar on display equations
   ========================================================================== */

article mjx-container[display="true"] {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

article mjx-container[display="true"]::-webkit-scrollbar {
    height: 0;
    background: transparent;
}

/* ==========================================================================
   Primary sidebar: hide the scrollbar. Theme padding and gap push the
   computed height just past the viewport, triggering an unneeded scrollbar.
   ========================================================================== */

.bd-sidebar-primary {
    scrollbar-width: none;
}

.bd-sidebar-primary::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* ==========================================================================
   Margin notes: small italic notes sphinx-book-theme floats into the right
   gutter via the `{margin}` directive (and inline `[^x]` sidenotes).
   ========================================================================== */

article .margin,
article aside.margin,
article aside.sidebar {
    font-size: 0.82em;
    line-height: 1.5;
    color: var(--pst-color-text-muted, #5f6368);
    font-style: italic;
}

article .margin strong,
article aside.margin strong,
article aside.sidebar strong {
    font-style: normal;
}

article .margin > p:first-child,
article aside.margin > p:first-child,
article aside.sidebar > p:first-child {
    margin-top: 0;
}

article .margin > p:last-child,
article aside.margin > p:last-child,
article aside.sidebar > p:last-child {
    margin-bottom: 0;
}

/* sphinx-book-theme inserts an empty <p class="sidebar-title"> at the top of
   each `{margin}` block. Hide it when blank so the note doesn't gain a gap. */
article .margin > p.sidebar-title:empty,
article aside.margin > p.sidebar-title:empty,
article aside.sidebar > p.sidebar-title:empty {
    display: none;
}
