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

:root {
    --md-text-font-size: 1.125rem;
    --md-typeset-line-height: 1.7;
    --md-text-color: #1a1a2e;
    --md-accent-fg-color: #7c3aed; /* Darker purple for better contrast */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-blue-purple: linear-gradient(135deg, #4facfe 0%, #00f2fe 50%, #c084fc 100%);
}

/* Modern typography */
body {
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

[data-md-color-scheme="slate"] {
    --md-text-color: #e8e8f0;
    --md-accent-fg-color: #c084fc;
    --md-primary-bg-color: #0f0f23;
}

/* Gradient backgrounds */
.md-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #4c1d95 50%, #831843 100%) !important;
}

/* Improve header text accessibility with high contrast */
.md-header__title,
.md-header__button,
.md-header-nav__button,
.md-header-nav__topic,
.md-header__topic {
    color: #ffffff !important;
}

/* Repository name in header */
.md-source__repository,
.md-source__facts,
.md-source {
    color: #ffffff !important;
}

.md-source:hover {
    opacity: 0.9;
}

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

.md-tabs__link,
.md-tabs__link--active {
    color: #ffffff !important;
    opacity: 0.9;
}

.md-tabs__link:hover {
    color: #ffffff !important;
    opacity: 1;
}

.md-tabs__link--active {
    opacity: 1;
    font-weight: 600;
}

/* Navigation items in header */
.md-nav__item .md-nav__link {
    color: #ffffff !important;
}

.md-nav__item .md-nav__link:hover {
    color: #f3e8ff !important;
}

/* Search box in header */
.md-search__input {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

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

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

/* All icons in header should be white */
.md-header .md-icon,
.md-header svg {
    color: #ffffff !important;
    fill: currentColor;
}

/* Sidebar navigation styling for better visibility */
.md-nav--primary .md-nav__title {
    background-color: #8b5cf6 !important;
    color: #ffffff !important;
    font-weight: 600;
}

.md-nav--primary .md-nav__item {
    border-left: 2px solid transparent;
}

.md-nav--primary .md-nav__link {
    color: #1a1a2e !important;
    font-weight: 500;
    padding: 0.6rem 1rem;
    transition: all 0.2s ease;
}

.md-nav--primary .md-nav__link:hover {
    background-color: rgba(109, 40, 217, 0.1) !important;
    color: #5b21b6 !important; /* Darker purple for better contrast */
    border-left-color: #5b21b6;
}

.md-nav--primary .md-nav__link--active {
    background-color: rgba(109, 40, 217, 0.15) !important;
    color: #5b21b6 !important; /* Darker purple for better contrast */
    font-weight: 600;
    border-left: 3px solid #5b21b6 !important;
}

/* Dark mode sidebar */
[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link {
    color: #e8e8f0 !important;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link:hover {
    background-color: rgba(192, 132, 252, 0.15) !important;
    color: #c084fc !important;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link--active {
    background-color: rgba(192, 132, 252, 0.2) !important;
    color: #c084fc !important;
    border-left: 3px solid #c084fc !important;
}

/* Secondary navigation (nested items) */
.md-nav--secondary .md-nav__link {
    color: #374151 !important; /* Darker gray for better contrast (9.74:1) */
}

.md-nav--secondary .md-nav__link:hover {
    color: #5b21b6 !important; /* Darker purple */
}

[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link {
    color: #d1d5db !important;
}

[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link:hover {
    color: #c084fc !important;
}

.md-typeset h1 {
    font-weight: 700;
    font-size: 3rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
    background: linear-gradient(135deg, #667eea 0%, #c084fc 50%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
}

.md-typeset h2 {
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: -0.01em;
    color: #6d28d9; /* Darker purple for WCAG AA compliance (4.52:1 contrast) */
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.md-typeset h3 {
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
    color: #6d28d9; /* Darker purple for WCAG AA compliance */
}

[data-md-color-scheme="slate"] .md-typeset h2,
[data-md-color-scheme="slate"] .md-typeset h3 {
    color: #c084fc;
}

/* Modern paragraph styling */
.md-typeset p {
    font-size: 1.125rem;
    line-height: 1.7;
    margin-bottom: 1.25rem;
    color: #1a1a2e; /* Full opacity for maximum contrast */
}

[data-md-color-scheme="slate"] .md-typeset p {
    color: #e8e8f0; /* Full opacity for dark mode */
}

/* Modern list styling */
.md-typeset ul li, .md-typeset ol li {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.md-typeset strong {
    font-weight: 600;
    color: #1a1a2e;
}

[data-md-color-scheme="slate"] .md-typeset strong {
    color: #e8e8f0;
}

.md-typeset code {
    background: rgba(109, 40, 217, 0.1); /* Lighter background */
    border: 1px solid rgba(109, 40, 217, 0.3);
    border-radius: 6px;
    padding: 3px 8px;
    color: #5b21b6; /* Darker purple for better contrast (7.15:1) */
    font-size: 0.9em;
    font-weight: 500;
}

[data-md-color-scheme="slate"] .md-typeset code {
    background: rgba(192, 132, 252, 0.2); /* Slightly darker background */
    border-color: rgba(192, 132, 252, 0.4);
    color: #e9d5ff; /* Lighter purple for dark mode (11.6:1 contrast) */
}

:focus-visible {
    outline: 3px solid #6d28d9; /* Darker, more visible focus outline */
    outline-offset: 2px;
}

a {
    text-decoration: none;
    color: #6d28d9; /* Darker purple for WCAG AA (4.52:1) */
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

a:hover {
    color: #be185d; /* Darker pink for better contrast (5.38:1) */
    border-bottom: 2px solid #be185d;
}

[data-md-color-scheme="slate"] a {
    color: #c084fc;
}

[data-md-color-scheme="slate"] a:hover {
    color: #f472b6;
    border-bottom: 2px solid #f472b6;
}

/* Navigation links */
.md-nav__link {
    font-weight: 500;
    letter-spacing: -0.01em;
}

.md-nav__link--active {
    font-weight: 600;
}

/* Image styling - Responsive and accessible */
.md-typeset img {
    max-width: 100%;
    height: auto;
    width: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Video styling - Match image styling */
.md-typeset video {
    max-width: 100%;
    height: auto;
    width: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Hero images (first image after h1) - smaller, more contained */
.md-typeset h1 + p img {
    max-width: min(40%, 500px);
    min-width: 250px;
}

/* Hero videos (first video after h1) - same size as hero images */
.md-typeset h1 + p video {
    max-width: min(40%, 500px);
    min-width: 250px;
}

/* Standard content images - same size as hero images for consistency */
.md-typeset p img,
.md-typeset h2 + p img,
.md-typeset h3 + p img {
    max-width: min(40%, 500px);
    min-width: 250px;
}

/* Standard content videos - match image sizing */
.md-typeset p video,
.md-typeset h2 + p video,
.md-typeset h3 + p video {
    max-width: min(40%, 500px);
    min-width: 250px;
}

/* GIF images: by default treat like normal images/hero sizing.
   If you need a full-width animated GIF, add class "gif-full" in markdown:
   ![Alt text](assets/example.gif){ .gif-full }
*/
.md-typeset img.gif-full {
    max-width: 100% !important;
    width: 100%;
}

/* Small images - for images that need to be constrained to specific size */
.md-typeset .small-image {
    text-align: center;
    margin: 1.5rem auto;
}

.md-typeset .small-image img {
    max-width: 400px !important;
    width: 100%;
    height: auto;
}

.md-typeset img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}

.md-typeset video:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}

/* Ensure images don't break layout on small screens */
@media (max-width: 768px) {
    .md-typeset img,
    .md-typeset p img,
    .md-typeset h1 + p img {
        max-width: 100% !important;
        min-width: 100px;
    }
    
    .md-typeset video,
    .md-typeset p video,
    .md-typeset h1 + p video {
        max-width: 100% !important;
        min-width: 100px;
    }
}

/* Content area gradient accent */
.md-content {
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.02) 0%, transparent 100%);
}

[data-md-color-scheme="slate"] .md-content {
    background: linear-gradient(180deg, rgba(192, 132, 252, 0.05) 0%, transparent 100%);
}

/* Blockquote styling */
.md-typeset blockquote {
    border-left: 4px solid #7c3aed; /* Darker border */
    background: rgba(109, 40, 217, 0.08); /* Lighter background for better text contrast */
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    font-style: italic;
    font-size: 1.1rem;
    color: #1a1a2e; /* Explicit dark text color for contrast */
}

[data-md-color-scheme="slate"] .md-typeset blockquote {
    background: rgba(192, 132, 252, 0.15);
    color: #e8e8f0; /* Light text for dark mode */
}

@media (max-width: 600px) {
    .md-typeset h1 {
        font-size: 2.25rem;
    }
    .md-typeset h2 {
        font-size: 1.75rem;
    }
    .md-typeset h3 {
        font-size: 1.35rem;
    }
    .md-typeset p,
    .md-typeset ul li,
    .md-typeset ol li {
        font-size: 1rem;
    }
}

@media (forced-colors: active) {
    :root {
        --md-text-color: WindowText;
        --md-accent-fg-color: Highlight;
    }
}

/* Hero GIF figure styling - now full width */
.hero-figure {
    width: 100%;
    max-width: 100%;
    margin: 1.5rem 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

[data-md-color-scheme="slate"] .hero-figure {
    background: none;
    border: none;
    box-shadow: none;
}

.hero-gif {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 0;
    image-rendering: auto;
}

.hero-gif:hover {
    transform: none;
}

.visually-hidden {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

/* Global GIF styling: make all non-hero GIFs full width of content area */
.md-typeset img[src$=".gif"]:not(.hero-gif) {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 2rem 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.md-typeset img[src$=".gif"]:not(.hero-gif):hover {
    transform: none;
}
