@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap");

/* ================================
   CSS CUSTOM PROPERTIES
   ================================ */

:root {
    /* Primary colors */
    --ifm-color-primary: #5275d3;
    --ifm-color-primary-dark: #4662ab;
    --ifm-color-primary-darker: #3a5084;
    --ifm-color-primary-darkest: #2d3c5d;
    --ifm-color-primary-light: #6089f7;
    --ifm-color-primary-lighter: #7c9df9;
    --ifm-color-primary-lightest: #97b2fc;

    /* Typography */
    --ifm-font-family-base:
        "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, sans-serif;
    --ifm-font-family-monospace:
        "JetBrains Mono", "Fira Code", "Monaco", Consolas, "Liberation Mono",
        "Courier New", monospace;
    --ifm-code-font-size: 95%;
    --ifm-font-size-base: clamp(14px, 2.5vw, 16px);
    --ifm-line-height-base: 1.6;

    /* Layout */
    --ifm-spacing-horizontal: clamp(1rem, 4vw, 1.5rem);
    --ifm-navbar-height: clamp(3.5rem, 8vw, 4rem);
    --ifm-global-radius: 8px;
    --ifm-button-border-radius: 6px;

    /* Shadows */
    --ifm-global-shadow-lw:
        0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --ifm-global-shadow-md:
        0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ifm-global-shadow-tl:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Code highlighting */
    --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);

    /* Emphasis colors (slate scale) */
    --ifm-color-emphasis-0: #f8fafc;
    --ifm-color-emphasis-100: #f1f5f9;
    --ifm-color-emphasis-200: #e2e8f0;
    --ifm-color-emphasis-300: #cbd5e1;
    --ifm-color-emphasis-400: #94a3b8;
    --ifm-color-emphasis-500: #64748b;
    --ifm-color-emphasis-600: #475569;
    --ifm-color-emphasis-700: #334155;
    --ifm-color-emphasis-800: #1e293b;
    --ifm-color-emphasis-900: #0f172a;

    /* Mobile optimizations */
    --ifm-container-width: 100%;
    --ifm-container-width-xl: 1280px;
}

[data-theme="dark"] {
    --ifm-color-primary: #7c9df9;
    --ifm-color-primary-dark: #5275d3;
    --ifm-color-primary-darker: #4662ab;
    --ifm-color-primary-darkest: #3a5084;
    --ifm-color-primary-light: #97b2fc;
    --ifm-color-primary-lighter: #b6c7fb;
    --ifm-color-primary-lightest: #d2ddfd;

    /* Dark mode shadows */
    --ifm-global-shadow-lw:
        0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --ifm-global-shadow-md:
        0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --ifm-global-shadow-tl:
        0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);

    --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);

    /* Dark mode emphasis colors (inverted) */
    --ifm-color-emphasis-0: #0f172a;
    --ifm-color-emphasis-100: #1e293b;
    --ifm-color-emphasis-200: #334155;
    --ifm-color-emphasis-300: #475569;
    --ifm-color-emphasis-400: #64748b;
    --ifm-color-emphasis-500: #94a3b8;
    --ifm-color-emphasis-600: #cbd5e1;
    --ifm-color-emphasis-700: #e2e8f0;
    --ifm-color-emphasis-800: #f1f5f9;
    --ifm-color-emphasis-900: #f8fafc;
}

/* ================================
   GLOBAL STYLES
   ================================ */

html {
    scroll-behavior: smooth;
    font-size: clamp(14px, 2.5vw, 16px);
}

body {
    font-feature-settings:
        "kern" 1,
        "liga" 1,
        "ss01" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: var(--ifm-font-size-base);
    line-height: var(--ifm-line-height-base);
}

/* Container improvements */
.container {
    max-width: var(--ifm-container-width-xl);
    padding-left: var(--ifm-spacing-horizontal);
    padding-right: var(--ifm-spacing-horizontal);
}

/* ================================
   NAVBAR
   ================================ */

.navbar {
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--ifm-global-shadow-lw);
    padding: 0 var(--ifm-spacing-horizontal);
    height: var(--ifm-navbar-height);
}

.navbar__inner {
    max-width: var(--ifm-container-width-xl);
    margin: 0 auto;
}

.navbar__title {
    font-weight: 700;
    font-size: clamp(1.125rem, 3vw, 1.25rem);
}

.navbar__brand {
    margin-right: clamp(1rem, 3vw, 2rem);
}

.navbar__item {
    font-size: clamp(0.875rem, 2.2vw, 1rem);
}

.navbar__link {
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.navbar__link:hover {
    background: var(--ifm-color-emphasis-100);
}

/* Homepage transparent navbar */
body[data-page="homepage"] .navbar {
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

[data-theme="dark"] .navbar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] body[data-page="homepage"] .navbar {
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.navbar-sidebar {
    z-index: 1001 !important;
    height: 100vh !important;
}

/* ================================
   BUTTONS
   ================================ */

.button {
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--ifm-button-border-radius);
    font-size: clamp(0.875rem, 2.2vw, 1rem);
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(1rem, 3vw, 1.5rem);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button:hover {
    transform: translateY(-1px);
}

.button--primary {
    background: linear-gradient(
        135deg,
        var(--ifm-color-primary) 0%,
        var(--ifm-color-primary-dark) 100%
    );
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button--primary:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.button--secondary {
    border: 2px solid var(--ifm-color-primary);
    background: transparent;
    color: var(--ifm-color-primary);
}

.button--secondary:hover {
    background: var(--ifm-color-primary);
    color: white;
}

/* ================================
   CODE BLOCKS
   ================================ */

.prism-code {
    border-radius: 12px;
    box-shadow: var(--ifm-global-shadow-md);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ifm-color-emphasis-300) var(--ifm-color-emphasis-100);
}

.prism-code::-webkit-scrollbar {
    height: 8px;
}

.prism-code::-webkit-scrollbar-track {
    background: var(--ifm-color-emphasis-100);
    border-radius: 4px;
}

.prism-code::-webkit-scrollbar-thumb {
    background: var(--ifm-color-emphasis-300);
    border-radius: 4px;
}

.prism-code::-webkit-scrollbar-thumb:hover {
    background: var(--ifm-color-emphasis-400);
}

.codeBlockTitle {
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(0.75rem, 2vw, 1rem);
}

.codeBlockContent {
    padding: clamp(0.75rem, 2vw, 1rem);
}

/* Syntax highlighting adjustments */
.token.title.class-name {
    color: #60a5fa;
}
.token.function {
    color: #a78bfa;
}
.token.string {
    color: #10b981;
}
.token.keyword {
    color: #f472b6;
}

/* ================================
   CARDS
   ================================ */

.card {
    border-radius: 16px;
    border: 1px solid var(--ifm-color-emphasis-200);
    box-shadow: var(--ifm-global-shadow-lw);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    padding: clamp(1rem, 3vw, 1.5rem);
}

[data-theme="dark"] .card {
    border: 1px solid var(--ifm-color-emphasis-200);
    background: var(--ifm-color-emphasis-100);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ifm-global-shadow-md);
}

.card__header {
    padding-bottom: clamp(0.75rem, 2vw, 1rem);
}

.card__body {
    padding: 0;
}

.card__footer {
    padding-top: clamp(0.75rem, 2vw, 1rem);
}

/* ================================
   CONTENT STYLES
   ================================ */

.markdown {
    font-size: var(--ifm-font-size-base);
    line-height: var(--ifm-line-height-base);
}

.markdown h1 {
    font-size: clamp(1.75rem, 5vw, 2.25rem);
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    line-height: 1.2;
}

.markdown h2 {
    font-size: clamp(1.5rem, 4vw, 1.875rem);
    margin-bottom: clamp(0.75rem, 2.5vw, 1.25rem);
    margin-top: clamp(2rem, 5vw, 3rem);
    line-height: 1.3;
}

.markdown h3 {
    font-size: clamp(1.25rem, 3.5vw, 1.5rem);
    margin-bottom: clamp(0.75rem, 2vw, 1rem);
    margin-top: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.3;
}

.markdown h4 {
    font-size: clamp(1.125rem, 3vw, 1.25rem);
    margin-bottom: clamp(0.5rem, 1.5vw, 0.75rem);
    margin-top: clamp(1rem, 3vw, 1.5rem);
}

.markdown p {
    margin-bottom: clamp(1rem, 2.5vw, 1.25rem);
}

.markdown ul,
.markdown ol {
    margin-bottom: clamp(1rem, 2.5vw, 1.25rem);
    padding-left: clamp(1.5rem, 4vw, 2rem);
}

.markdown li {
    margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
}

/* ================================
   TABLE OF CONTENTS
   ================================ */

.table-of-contents {
    border-left: 2px solid var(--ifm-color-emphasis-200);
    padding-left: clamp(0.75rem, 2vw, 1rem);
    font-size: clamp(0.875rem, 2vw, 0.9rem);
}

.table-of-contents__link {
    color: var(--ifm-color-emphasis-700);
    transition: color 0.2s ease;
    padding: clamp(0.25rem, 1vw, 0.375rem) 0;
    display: block;
    line-height: 1.4;
}

.table-of-contents__link:hover {
    color: var(--ifm-color-primary);
}

.table-of-contents__link--active {
    color: var(--ifm-color-primary);
    font-weight: 600;
}

/* ================================
   PAGINATION
   ================================ */

.pagination-nav {
    margin-top: clamp(2rem, 5vw, 3rem);
    gap: clamp(1rem, 3vw, 1.5rem);
}

.pagination-nav__link {
    border-radius: 12px;
    border: 1px solid var(--ifm-color-emphasis-200);
    transition: all 0.2s ease;
    padding: clamp(1rem, 3vw, 1.5rem);
    min-height: 44px;
}

.pagination-nav__link:hover {
    transform: translateY(-1px);
    box-shadow: var(--ifm-global-shadow-md);
}

.pagination-nav__label {
    font-size: clamp(0.875rem, 2vw, 1rem);
    margin-bottom: 0.25rem;
}

.pagination-nav__sublabel {
    font-size: clamp(0.75rem, 1.8vw, 0.875rem);
}

/* ================================
   ADMONITIONS
   ================================ */

.admonition {
    border-radius: 12px;
    border-left-width: 4px;
    box-shadow: var(--ifm-global-shadow-lw);
    margin: clamp(1rem, 3vw, 1.5rem) 0;
    padding: clamp(1rem, 3vw, 1.5rem);
}

.admonition-heading {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    margin-bottom: clamp(0.5rem, 1.5vw, 0.75rem);
}

.admonition-content {
    font-size: clamp(0.875rem, 2vw, 1rem);
}

/* ================================
   SIDEBAR
   ================================ */

.theme-doc-sidebar-container {
    border-right: 1px solid var(--ifm-color-emphasis-200);
}

.theme-doc-sidebar-item-category-level-1 > .menu__link {
    font-size: clamp(0.875rem, 2vw, 0.9rem);
    font-weight: 600;
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(0.75rem, 2vw, 1rem);
}

.theme-doc-sidebar-item-link-level-1 > .menu__link,
.theme-doc-sidebar-item-link-level-2 > .menu__link {
    font-size: clamp(0.8rem, 1.8vw, 0.875rem);
    padding: clamp(0.375rem, 1vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.menu__link:hover {
    background: var(--ifm-color-emphasis-100);
}

.menu__link--active {
    background: var(--ifm-color-primary);
    color: white;
}

/* ================================
   FOOTER
   ================================ */

.footer {
    padding: clamp(2rem, 5vw, 3rem) 0;
    font-size: clamp(0.875rem, 2vw, 0.9rem);
    text-align: left; /* Ensure left alignment by default */
}

.footer__title {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    margin-bottom: clamp(0.75rem, 2vw, 1rem);
}

.footer__item {
    padding: clamp(0.25rem, 1vw, 0.375rem) 0;
}

.footer__link-item {
    padding: clamp(0.25rem, 1vw, 0.375rem) 0;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.footer__links {
    text-align: left !important; /* Force left alignment */
}

.footer__col {
    text-align: left !important;
}

/* ================================
   SCROLLBAR
   ================================ */

::-webkit-scrollbar {
    width: clamp(6px, 1.5vw, 8px);
    height: clamp(6px, 1.5vw, 8px);
}

::-webkit-scrollbar-track {
    background: var(--ifm-color-emphasis-100);
}

::-webkit-scrollbar-thumb {
    background: var(--ifm-color-emphasis-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ifm-color-emphasis-400);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--ifm-color-emphasis-300) var(--ifm-color-emphasis-100);
}

/* ================================
   SEARCH
   ================================ */

.navbar__search-input {
    border-radius: 8px;
    border: 1px solid var(--ifm-color-emphasis-200);
    transition: all 0.2s ease;
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(0.75rem, 2vw, 1rem);
    font-size: clamp(0.875rem, 2vw, 0.9rem);
}

.navbar__search-input:focus {
    border-color: var(--ifm-color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ================================
   ACCESSIBILITY
   ================================ */

.button:focus,
.navbar__link:focus,
.menu__link:focus {
    outline: 2px solid var(--ifm-color-primary);
    outline-offset: 2px;
}

/* Improve focus visibility on mobile */
@media (max-width: 768px) {
    .button:focus,
    .navbar__link:focus {
        outline-width: 3px;
        outline-offset: 1px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .button,
    .card,
    .admonition {
        border-width: 2px;
    }

    .navbar__link:hover,
    .menu__link:hover {
        background: var(--ifm-color-emphasis-200);
    }
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

/* Large screens */
@media screen and (min-width: 1400px) {
    :root {
        --ifm-container-width-xl: 1400px;
    }
}

/* Tablet landscape */
@media screen and (max-width: 1024px) {
    .navbar__item {
        margin: 0 0.25rem;
    }

    .navbar__link {
        padding: 0.5rem 0.75rem;
    }
}

/* Tablet portrait and mobile */
@media screen and (max-width: 996px) {
    .navbar {
        padding: 0 1rem;
    }

    .navbar__toggle {
        margin-right: 0;
    }

    .navbar__brand {
        margin-right: auto;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .table-of-contents {
        display: none;
    }

    .theme-doc-sidebar-container {
        display: none;
    }
}

/* Mobile landscape */
@media screen and (max-width: 768px) {
    :root {
        --ifm-spacing-horizontal: 1rem;
        --ifm-navbar-height: 3.5rem;
    }

    .navbar {
        padding: 0 1rem;
    }

    .markdown h1 {
        margin-bottom: 1rem;
    }

    .markdown h2 {
        margin-top: 2rem;
        margin-bottom: 1rem;
    }

    .pagination-nav {
        flex-direction: column;
    }

    .pagination-nav__link {
        text-align: center;
    }

    .admonition {
        margin: 1rem -0.5rem;
        border-radius: 8px;
    }
}

/* Mobile portrait */
@media screen and (max-width: 480px) {
    :root {
        --ifm-spacing-horizontal: 0.75rem;
    }

    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .navbar {
        padding: 0 0.75rem;
    }

    .button {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .markdown ul,
    .markdown ol {
        padding-left: 1.5rem;
    }

    .admonition {
        margin: 1rem -0.25rem;
        padding: 1rem;
    }

    /* Keep footer left-aligned on mobile */
    .footer {
        text-align: left !important;
    }

    .footer__links {
        flex-direction: column;
        gap: 1.5rem;
        text-align: left !important;
    }

    .footer__col {
        text-align: left !important;
    }
}

/* Extra small screens */
@media screen and (max-width: 360px) {
    :root {
        --ifm-spacing-horizontal: 0.5rem;
    }

    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .navbar {
        padding: 0 0.5rem;
    }

    .navbar__title {
        font-size: 1rem;
    }
}

/* Landscape orientation on small screens */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .navbar {
        height: 3rem;
    }

    .navbar__title {
        font-size: 1rem;
    }

    .navbar__item {
        font-size: 0.875rem;
    }
}

/* Dark mode mobile optimizations */
[data-theme="dark"] {
    @media screen and (max-width: 768px) {
        .navbar-sidebar {
            background: rgba(15, 23, 42, 0.98);
        }
    }
}

/* ================================
   PRINT STYLES
   ================================ */

@media print {
    .navbar,
    .footer,
    .pagination-nav,
    .table-of-contents,
    .theme-doc-sidebar-container,
    .button {
        display: none !important;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .markdown {
        font-size: 12pt;
        line-height: 1.4;
    }

    .markdown h1 {
        font-size: 18pt;
        page-break-after: avoid;
    }

    .markdown h2 {
        font-size: 16pt;
        page-break-after: avoid;
    }

    .markdown h3 {
        font-size: 14pt;
        page-break-after: avoid;
    }

    .card,
    .admonition {
        page-break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .prism-code {
        font-size: 10pt;
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

/* ================================
   PERFORMANCE OPTIMIZATIONS
   ================================ */

/* Reduce motion for better performance on low-end devices */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* GPU acceleration for smooth animations */
.button,
.card,
.navbar__link,
.menu__link {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimize for touch devices */
@media (hover: none) and (pointer: coarse) {
    .button:hover,
    .card:hover,
    .navbar__link:hover,
    .menu__link:hover {
        transform: none;
    }

    .button:active,
    .navbar__link:active,
    .menu__link:active {
        transform: scale(0.98);
    }
}
