@import url("https://fonts.googleapis.com/css2?family=Bitter:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Ubuntu+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");

@font-face {
    font-family: "TaraType";
    src: url("../fonts/TaraType.ttf") format("truetype");
}

:root {
    --border-radius: 0.5em;
    --color-brand-primary: #404040;
    --color-brand-content: #93774b;
    --color-foreground-primary: #404040;
    --color-background-primary: #f9f8f7;
    --color-background-secondary: #f3f2f1;
    --color-admonition-background: #eeeeee;
    --color-table-border: #e1e4e5;
    --color-background-border: #dddddd;
    --color-guilabel-background: #f3f2f1;
    --color-guilabel-border: #dddddd;
    --color-admonition-title--note: #93774b;
    --color-admonition-title-background--note: #e4e0d7;
    --color-admonition-title--seealso: #93774b;
    --color-admonition-title-background--seealso: #e4e0d7;
    --color-admonition-title: #93774b;
    --color-admonition-title-background: #e4e0d7;
    --color-border: #dddddd;
    --color-button: #f3f6f6;
    --color-background-highlight: #f3f2f1;
    --color-title: #303030;
    --color-link: #93774b;
    --color-link-underline: rgba(147, 119, 75, 0.4);
    --color-link-hover: #bf431d;
    --color-strong: #404040;
    --color-pyrogram-text: #3b3936;
    --color-green: darkgreen;
    --color-red: darkred;
    --color-code-background: #f0f0f0;
    --color-code-foreground: #000000;
    --font-size--small: 100%;
    --font-size--small--2: 97%;
    --font-size--small--3: 94%;
    --font-size--small--4: 91%;
    font-size: 16px;
    line-height: 1.7;
}

body[data-theme="dark"] {
    --color-brand-primary: #bfbcb9;
    --color-brand-content: #b7a280;
    --color-foreground-primary: #bfbcb9;
    --color-background-primary: #202020;
    --color-background-secondary: #181818;
    --color-admonition-background: #282828;
    --color-table-border: #707070;
    --color-background-border: #505050;
    --color-guilabel-background: #323232;
    --color-guilabel-border: #505050;
    --color-admonition-title--note: #b7a280;
    --color-admonition-title-background--note: #303030;
    --color-admonition-title--seealso: #b7a280;
    --color-admonition-title-background--seealso: #303030;
    --color-admonition-title: #b7a280;
    --color-admonition-title-background: #303030;
    --color-border: #505050;
    --color-button: #303030;
    --color-background-highlight: #323232;
    --color-title: #b9b9b9;
    --color-link: #b7a280;
    --color-link-underline: rgba(183, 162, 128, 0.45);
    --color-link-hover: #e85823;
    --color-strong: #cfccc9;
    --color-pyrogram-text: #b9b9b9;
    --color-green: green;
    --color-red: red;
    --color-code-background: #3f3f3f;
    --color-code-foreground: #dcdccc;
}

@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"]) {
        --color-brand-primary: #bfbcb9;
        --color-brand-content: #b7a280;
        --color-foreground-primary: #bfbcb9;
        --color-background-primary: #202020;
        --color-background-secondary: #181818;
        --color-admonition-background: #282828;
        --color-table-border: #707070;
        --color-background-border: #505050;
        --color-guilabel-background: #323232;
        --color-guilabel-border: #505050;
        --color-admonition-title--note: #b7a280;
        --color-admonition-title-background--note: #303030;
        --color-admonition-title--seealso: #b7a280;
        --color-admonition-title-background--seealso: #303030;
        --color-admonition-title: #b7a280;
        --color-admonition-title-background: #303030;
        --color-border: #505050;
        --color-button: #303030;
        --color-background-highlight: #323232;
        --color-title: #b9b9b9;
        --color-link: #b7a280;
        --color-link-underline: rgba(183, 162, 128, 0.45);
        --color-link-hover: #e85823;
        --color-strong: #cfccc9;
        --color-pyrogram-text: #b9b9b9;
        --color-green: green;
        --color-red: red;
        --color-code-background: #3f3f3f;
        --color-code-foreground: #dcdccc;
    }
}

/* --- Layout --- */

body {
    margin: 0;
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--color-background-primary);
    min-height: 100vh;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body::-webkit-scrollbar {
    display: none;
}

.page {
    display: flex;
}

.main {
    display: flex;
    flex: 1;
    min-width: 0;
    justify-content: center;
    background-color: var(--color-background-primary);
}

.content {
    flex: 0 1 56em;
    max-width: 56em;
    padding: 3rem 3rem 4rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
    min-width: 0;
}

@media (max-width: 82em) {
    .main {
        justify-content: flex-start;
    }
}

@media (min-width: 82em) {
    .main {
        justify-content: space-between;
    }
    .main::before {
        content: '';
    }
}

@media (max-width: 67em) {
    .content {
        padding: 2rem 1.5rem 3rem;
    }
}

/* --- Mobile header --- */

.mobile-header {
    background-color: var(--color-background-primary);
    border-bottom: 1px solid var(--color-border);
    font-family: "TaraType", monospace;
    font-weight: bold;
    font-size: 1.45em;
    letter-spacing: .0425em;
    z-index: 60;
}

.mobile-header .brand {
    font-family: "TaraType", sans-serif;
    font-weight: 700;
    font-size: 1.45em;
}

/* --- Sidebar --- */

.sidebar-drawer {
    background-color: var(--color-background-secondary);
    border-right: 1px solid var(--color-border);
}

@media (max-width: 63em) {
    .sidebar-drawer {
        z-index: 65;
    }

    .sidebar-overlay {
        z-index: 61;
    }
}

@media (min-width: 63em) {
    .sidebar-drawer {
        width: auto;
        justify-content: initial;
        flex: 0 0 18em;
    }
}

.sidebar-container {
    width: 18em;
    background-color: var(--color-background-secondary);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-container::-webkit-scrollbar {
    display: none;
}

.sidebar-brand {
    padding: 0.5rem 1.5rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0 1.5rem 0.9rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-links a {
    color: var(--color-sidebar-link-text);
    display: inline-flex;
    transition: color 0.2s ease;
}

.sidebar-links a:hover {
    color: var(--color-brand-primary);
}

.sidebar-logo-container {
    margin: 0;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 36px;
    height: auto;
    display: block;
}

.sidebar-brand-text {
    font-family: "TaraType", sans-serif;
    font-weight: 700;
    font-size: calc(var(--font-size--normal) * 2.3);
    letter-spacing: 0.0425em;
    display: inline-flex;
    gap: 0.04em;
    line-height: 1;
    color: var(--color-pyrogram-text);
}

.sidebar-brand-text a {
    display: inline-flex;
    gap: 0.02em;
}

.brand-char {
    display: inline-block;
    transition: transform 0.2s ease, color 0.2s ease;
}

.brand-char:hover {
    transform: translateY(-4px);
    color: var(--color-link-hover);
}

@keyframes letterPop {
    0% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(-6px); opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

.brand-char {
    animation: letterPop 0.4s ease backwards;
}

.brand-char:nth-child(1) { animation-delay: 0.00s; }
.brand-char:nth-child(2) { animation-delay: 0.05s; }
.brand-char:nth-child(3) { animation-delay: 0.10s; }
.brand-char:nth-child(4) { animation-delay: 0.15s; }
.brand-char:nth-child(5) { animation-delay: 0.20s; }
.brand-char:nth-child(6) { animation-delay: 0.25s; }

.sidebar-tree {
    padding: 0 0.75rem;
}

.sidebar-tree li {
    margin: 0.15rem 0;
    position: relative;
}

/* Left-aligned collapsible chevron arrow */
.sidebar-tree label {
    position: absolute !important;
    left: 2px !important;
    right: auto !important;
    top: 0 !important;
    width: 1.4rem !important;
    height: 100% !important;
    max-height: 2.2rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 2 !important;
    background: transparent !important;
    border-radius: 3px !important;
    padding: 0 !important;
}

.sidebar-tree label .icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 14px !important;
    height: 14px !important;
}

.sidebar-tree label .icon svg {
    width: 12px !important;
    height: 12px !important;
    color: var(--color-foreground-secondary) !important;
    transition: transform 0.2s ease, color 0.15s ease !important;
}

.sidebar-tree label:hover .icon svg,
.sidebar-tree li:hover > label .icon svg {
    color: var(--color-brand-content) !important;
}

/* Collapsed: chevron points right */
.toctree-checkbox ~ label .icon svg {
    transform: rotate(0deg) !important;
}

/* Expanded: chevron points down */
.toctree-checkbox:checked ~ label .icon svg {
    transform: rotate(90deg) !important;
}

.sidebar-tree .reference {
    font-family: "Open Sans", sans-serif;
    font-size: 0.875rem;
    font-weight: 400;
    padding: 0.35rem 0.5rem 0.35rem 1.65rem !important;
    display: block;
    border-left: 2px solid transparent;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
    border-radius: 3px;
}

.sidebar-tree .current > .reference {
    border-left: 2px solid var(--color-title);
    font-weight: 600;
}

.sidebar-tree li > .reference:hover {
    border-left: 2px solid var(--color-border);
}

.sidebar-tree li.toctree-l1 > .reference,
.sidebar-tree li.toctree-l2 > .reference {
    padding: 0.35rem 0.5rem 0.35rem 1.65rem !important;
}

/* --- TOC drawer --- */

.toc-drawer {
    flex: 0 0 auto;
    width: 15em;
    border-left: 1px solid var(--color-border);
    background-color: var(--color-background-secondary);
    padding: 1.5rem 0 0 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

@media (min-width: 82em) {
    .toc-drawer {
        position: sticky;
        top: 0;
        align-self: start;
        max-height: 100vh;
        overflow-y: auto;
    }
}

.toc-drawer::-webkit-scrollbar {
    display: none;
}

@media (max-width: 63em) {
    .toc-drawer {
        position: fixed;
        right: -15em;
        top: 0;
        width: 15em;
        height: 100vh;
        z-index: 65;
        background-color: var(--color-background-secondary);
        border-left: 1px solid var(--color-border);
        display: block;
        transition: right 0.2s ease;
    }
}

@media (min-width: 82em) {
    .no-toc {
        display: block;
    }
}

.toc-tree {
    padding: 0 1rem;
}

.toc-tree .reference {
    font-family: "Open Sans", sans-serif;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--color-foreground-primary);
    padding: 0.2rem 0.5rem;
    display: block;
    border-left: 2px solid transparent;
    transition: border-left-color 0.15s ease;
}

.toc-tree .reference:hover {
    border-left-color: var(--color-border);
}

.toc-tree li.scroll-current > .reference {
    border-left-color: var(--color-title);
    font-weight: 600;
}

/* --- Headings --- */

h1, h2, h3, h4, h5, h6 {
    font-family: "Bitter", serif;
    font-weight: 600;
    color: var(--color-title);
    letter-spacing: -0.02em;
    line-height: 1.3;
    padding-bottom: 0.3rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h1:first-child, h2:first-child, h3:first-child {
    margin-top: 0;
}

h1 {
    font-size: 175%;
}

h2 {
    font-size: 150%;
}

h3 {
    font-size: 125%;
}

h4 {
    font-size: 115%;
}

h5 {
    font-size: 110%;
}

h6 {
    font-size: 100%;
}

/* --- Paragraphs & text --- */

p {
    margin: 0 0 1.2rem;
    line-height: 1.7;
}


article[role="main"] {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

article[role="main"] img {
    max-width: 100%;
    height: auto;
}

article p code.literal,
li p code.literal {
    font-family: "Ubuntu Mono", monospace;
    background-color: var(--color-background-highlight);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 0.1em 0.4em;
    font-size: 0.875em;
    font-weight: 500;
}

article[role=main] .highlight pre {
    font-family: "Ubuntu Mono", monospace;
    font-size: var(--font-size--normal);
    line-height: 1.2;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-background-highlight);
    padding: 1.2rem;
}

div[class*="highlight-"] {
    margin: 1.5rem 0;
    overflow-x: auto;
    max-width: 100%;
}
.highlight pre {
    overflow-x: auto;
    max-width: 100%;
}

/* --- Links --- */

a {
    text-decoration: none;
    color: var(--color-link);
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
    color: var(--color-link-hover);
}

a:visited {
    color: var(--color-link);
}

a:visited:hover {
    color: var(--color-link-hover);
}

a.sidebar-brand:hover,
a.sidebar-brand:focus {
    text-decoration: none;
}

/* Documentation article content links */
article a:not(.headerlink) {
    color: var(--color-link);
    text-decoration: underline;
    text-decoration-color: var(--color-link-underline);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

article a:not(.headerlink):hover {
    color: var(--color-link-hover);
    text-decoration: underline;
    text-decoration-color: var(--color-link-hover);
}

article a:not(.headerlink):visited {
    color: var(--color-link);
    text-decoration-color: var(--color-link-underline);
}

article a:not(.headerlink):visited:hover {
    color: var(--color-link-hover);
    text-decoration-color: var(--color-link-hover);
}

/* Exclude code literal badges and source buttons inside links from underline */
article a > code.literal,
article a > code.xref,
.viewcode-link {
    text-decoration: none !important;
    display: inline-block;
}

article a:hover > code.literal,
article a:hover > code.xref {
    border-color: var(--color-link-hover);
    color: var(--color-link-hover);
}

/* --- Admonitions --- */

.admonition {
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-brand-content);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
}

p.admonition-title {
    font-family: "Open Sans", sans-serif;
    font-weight: 650;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

/* --- Tables --- */

table.docutils {
    border: 1px solid var(--color-table-border);
    border-radius: var(--border-radius);
    border-collapse: separate;
    overflow: hidden;
    margin: 1.5rem 0;
    width: 100%;
    max-width: 100%;
}

table.docutils th {
    background-color: var(--color-background-highlight);
    border: 1px solid var(--color-table-border);
    padding: 0.6rem 0.8rem;
    font-family: "Open Sans", sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
}

table.docutils td {
    border: 1px solid var(--color-table-border);
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

table.docutils:not(.field-list) tr:nth-child(2n-1) td {
    background-color: var(--color-background-highlight);
}

.table-wrapper {
    overflow-x: auto;
    max-width: 100%;
}

/* --- Code signatures (function defs, class defs) --- */

dl.py {
    margin: 1rem 0;
}

dl.py dt {
    box-sizing: border-box !important;
    font-family: "Ubuntu Mono", monospace !important;
    background-color: var(--color-background-highlight) !important;
    border-radius: var(--border-radius) !important;
    border-left: 2px solid var(--color-brand-content) !important;
    padding: 4px 10px !important;
    margin: 0.75rem 0 !important;
    font-size: 0.9rem;
    width: fit-content !important;
    max-width: 100%;
    word-break: break-word;
    text-indent: 0 !important;
}

dl.py dd {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.sig-prename,
.sig-name,
.sig-param,
.sig-paren,
.sig-return,
.sig-return-typehint,
.sig-param .pre,
.property .pre,
em.property {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
}

.sig-prename,
.sig-name {
    font-family: "Ubuntu Mono", monospace;
    color: var(--color-foreground-primary);
}

/* --- Lists --- */

article[role=main] ul,
article[role=main] ol {
    margin: 0 0 1.2rem;
    padding-left: 1.5rem;
    line-height: 1.7;
}

article[role=main] li {
    margin-bottom: 0.3rem;
}

/* --- Navigation buttons --- */

.related-pages {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.related-pages a {
    background-color: var(--color-button);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 0.6rem 1rem;
    font-family: "Open Sans", sans-serif;
    font-size: 0.9rem;
    transition: background-color 0.15s ease;
}

.related-pages a:hover {
    background-color: var(--color-background-highlight);
}

/* --- Bottom of page --- */

.bottom-of-page {
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    margin-top: 3rem;
    font-size: 0.85rem;
    color: var(--color-foreground-primary);
}

/* --- Blockquotes --- */

blockquote {
    border-left: 3px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    margin: 1.5rem 0;
    color: var(--color-foreground-primary);
}

/* --- Usable-by badges --- */

.usable-by-container {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 0.35rem 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    background-color: var(--color-background-secondary);
}

.usable-by-label {
    font-weight: 600;
    color: var(--color-foreground-primary);
    margin-right: 0.25rem;
}

.usable-by-badge {
    display: inline-block;
    padding: 0.1em 0.5em;
    font-weight: 600;
    font-size: 0.85em;
}

.usable-by-badge.badge-yes {
    color: #0a0;
}

.usable-by-badge.badge-no {
    color: #c33;
}

@media (prefers-color-scheme: dark) {
    body:not([data-theme=light]) .usable-by-badge.badge-yes {
        color: #4c4;
    }
    body:not([data-theme=light]) .usable-by-badge.badge-no {
        color: #c66;
    }
}

/* --- Misc --- */

.content-icon-container {
    margin-top: 1.5rem;
    margin-bottom: 0;
}

.highlight button.copybtn svg {
    color: var(--color-foreground-primary);
    transition: color 0.15s ease;
}

.highlight button.copybtn:hover svg {
    color: var(--color-title);
}

.field-list {
    margin: 1.5rem 0;
}

.field-list dt {
    border-left: none !important;
    background: none !important;
    padding: 0 !important;
    font-weight: 600;
}

.field-list dd {
    margin: 0 0 0.5rem 1.5rem;
}

dl.py dd > dl.simple > dt,
dl.py dd dl:not([class]) > dt,
dl.py dd .field-list.simple > dt,
dl.py dd .field-list > dt {
    border: 1px solid var(--color-border) !important;
    border-left: 2px solid var(--color-border) !important;
    background: var(--color-background-highlight) !important;
    border-radius: var(--border-radius) !important;
    padding: 2px 8px !important;
    font-weight: 650;
    font-size: 0.9rem;
    white-space: nowrap;
    width: fit-content !important;
    display: table !important;
    margin-bottom: 0.5rem;
}

/* --- Buttons and inline elements --- */

kbd, .guilabel {
    font-family: "Ubuntu Mono", monospace;
    background-color: var(--color-guilabel-background);
    border: 1px solid var(--color-guilabel-border);
    border-radius: 2px;
    padding: 0.1em 0.4em;
    font-size: 0.875em;
}

/* --- Version and toctree captions --- */

.toctree-wrapper {
    margin: 1.5rem 0;
}

.toctree-wrapper .caption-text {
    font-family: "Bitter", serif;
    font-weight: 650;
    font-size: 1rem;
}

/* --- Homepage specific --- */

article[role=main] .code-block-caption {
    font-family: "Open Sans", sans-serif;
    font-size: 0.85rem;
    padding: 0.4rem 1.2rem;
    border: 1px solid var(--color-border);
    border-bottom: none;
    background-color: var(--color-background-highlight);
}

.view-this-page {
    display: none !important;
}
