/* Import Roboto font from Google Fonts */
@import url('assets/external/fonts.googleapis.com/css2.16d18cc6.css');

/* --- Base Typography and Layout --- */

/* Set a base font-size for the document for better scalability */
html {
    font-size: 100%; /* Corresponds to 16px in most browsers */
}

/* General body styling for enhanced readability */
body {
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    color: #2c3e50;
    line-height: 1.6; /* Optimized for better readability */
    font-size: 1rem; /* 1rem = 16px */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header and navigation bar */
.md-header {
    background: linear-gradient(135deg, #1967C0 0%, #1557A0 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.md-header__title {
    font-weight: 500;
    font-size: 1.1rem;
}

/* Links and interactive elements */
a {
    color: #2980b9;
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: #1967C0;
    text-decoration: underline;
}

.md-nav__link--active {
    color: #1967C0;
    font-weight: 500;
}

/* --- Improved Typographic Scale (1.2 ratio, more balanced) --- */

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
    color: #2c3e50;
}

/* h1: Page titles - 2.25rem (36px) */
.md-typeset h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: #1967C0;
    border-bottom: 3px solid #e3f2fd;
    padding-bottom: 0.5rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

/* h2: Major sections - 1.875rem (30px) */
.md-typeset h2 {
    font-size: 1.875rem;
    font-weight: 600;
    color: #1976d2;
    border-bottom: 2px solid #f0f8ff;
    padding-bottom: 0.3rem;
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
}

/* h3: Subsections - 1.5rem (24px) */
.md-typeset h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #34495e;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* h4: Sub-subsections - 1.25rem (20px) */
.md-typeset h4 {
    font-size: 1.25rem;
    font-weight: 500;
    color: #34495e;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

/* h5: Minor headings - 1.125rem (18px) */
.md-typeset h5 {
    font-size: 1.125rem;
    font-weight: 500;
    color: #5d6d7e;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* h6: Smallest headings - 1rem (16px) */
.md-typeset h6 {
    font-size: 1rem;
    font-weight: 500;
    color: #7b8794;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* --- Improved Content Styling --- */

/* Paragraph styling for improved legibility */
.md-typeset p {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1.25rem;
    color: #2c3e50;
}

/* Lead paragraphs (first paragraph after headings) */
.md-typeset h1 + p,
.md-typeset h2 + p {
    font-size: 1rem;
    color: #34495e;
    margin-bottom: 1.5rem;
}

/* Strong and emphasis styling */
.md-typeset strong {
    font-weight: 600;
    color: #2c3e50;
}

.md-typeset em {
    font-style: italic;
    color: #34495e;
}

/* --- Improved Lists --- */
.md-typeset ul, .md-typeset ol {
    margin-bottom: 1.5rem;
    padding-left: 0;
}

.md-typeset ul {
    list-style: none;
}

.md-typeset ul > li {
    position: relative;
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    font-size: 1rem;
    line-height: 1.7;
    color: #2c3e50;
}

.md-typeset ul > li::before {
    content: "•";
    color: #2980b9;
    font-weight: 600;
    position: absolute;
    left: 0;
    top: 0;
}

.md-typeset ol {
    counter-reset: ol-counter;
    padding-left: 0;
    list-style: none;
}

.md-typeset ol > li {
    position: relative;
    margin-bottom: 0.75rem;
    padding-left: 2rem;
    counter-increment: ol-counter;
    font-size: 1rem;
    line-height: 1.7;
    color: #2c3e50;
}

.md-typeset ol > li::before {
    content: counter(ol-counter) ".";
    color: #2980b9;
    font-weight: 600;
    position: absolute;
    left: 0;
    top: 0;
    width: 1.5rem;
}

/* Nested lists */
.md-typeset ul ul,
.md-typeset ol ol,
.md-typeset ul ol,
.md-typeset ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Additional styling for strong tags within list items */
.md-typeset li strong {
    margin-right: 0.3em;
    font-weight: 600;
}

/* --- Enhanced Blockquotes --- */
.md-typeset blockquote {
    border-left: 4px solid #2980b9;
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    background: linear-gradient(135deg, #f8fbff 0%, #e3f2fd 100%);
    border-radius: 0 8px 8px 0;
    position: relative;
    color: #2c3e50;
    font-style: normal;
    box-shadow: 0 2px 8px rgba(41, 128, 185, 0.1);
}

.md-typeset blockquote::before {
    content: "\201C";
    font-size: 3rem;
    color: #2980b9;
    position: absolute;
    left: -0.5rem;
    top: -0.5rem;
    opacity: 0.3;
    font-family: Georgia, serif;
}

.md-typeset blockquote p {
    margin-bottom: 0;
    font-size: 1rem;
    line-height: 1.6;
}

.md-typeset blockquote p:last-child {
    margin-bottom: 0;
}

/* --- Improved Code Blocks and Inline Code --- */
.md-typeset pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.md-typeset code {
    font-family: 'Roboto Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    background-color: #f1f3f4;
    color: #d73502;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    border: 1px solid #e8eaed;
}

.md-typeset pre code {
    background-color: transparent;
    color: #2c3e50;
    padding: 0;
    border: none;
    font-size: 0.875rem;
}

/* --- Enhanced Tables --- */
.md-typeset table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.md-typeset th {
    background: linear-gradient(135deg, #2980b9 0%, #1967C0 100%);
    color: white;
    font-weight: 500;
    padding: 1rem;
    text-align: left;
    border: none;
}

.md-typeset td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    border-right: none;
    border-left: none;
}

.md-typeset tr:nth-child(even) {
    background-color: #f8f9fa;
}

.md-typeset tr:hover {
    background-color: #e3f2fd;
    transition: background-color 0.2s ease;
}

/* --- Enhanced Navigation and Sidebar --- */

.md-nav__item--active > .md-nav__link {
    background: linear-gradient(135deg, #2980b9 0%, #1967C0 100%);
    color: #ffffff !important;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(41, 128, 185, 0.3);
}

.md-nav__link:hover {
    background-color: #f8fbff;
    color: #1967C0;
}

/* --- Additional Enhancements --- */

/* Focus states for accessibility */
.md-nav__link:focus,
.md-typeset a:focus {
    outline: 2px solid #2980b9;
    outline-offset: 2px;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Enhanced selection styling */
::selection {
    background-color: #e3f2fd;
    color: #1967C0;
}

/* Loading animation for better UX */
.md-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Enhanced Print Styles --- */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    body {
        font-size: 11pt;
        line-height: 1.4;
        color: #000;
        background: white;
    }
    
    .md-header,
    .md-sidebar,
    .md-footer,
    .md-content__button,
    .md-nav {
        display: none !important;
    }
    
    .md-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 1cm !important;
    }
    
    .md-typeset h1 {
        font-size: 18pt;
        color: #000 !important;
        border-bottom: 2pt solid #000 !important;
        page-break-after: avoid;
        margin-top: 0;
    }
    
    .md-typeset h2 {
        font-size: 16pt;
        color: #000 !important;
        border-bottom: 1pt solid #666 !important;
        page-break-after: avoid;
    }
    
    .md-typeset h3,
    .md-typeset h4,
    .md-typeset h5,
    .md-typeset h6 {
        color: #000 !important;
        page-break-after: avoid;
    }
    
    .md-typeset p {
        orphans: 3;
        widows: 3;
    }
    
    .md-typeset pre,
    .md-typeset blockquote,
    .md-typeset table {
        border: 1pt solid #000;
        background-color: #fff !important;
        page-break-inside: avoid;
    }
    
    .md-typeset a {
        text-decoration: underline;
        color: #000;
    }
    
    .md-typeset a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }
}

/* --- Abbreviation Tooltips --- */

/* Style for abbreviation elements */
.md-typeset abbr {
    position: relative;
    cursor: help;
    text-decoration: none;
    border-bottom: 1px dotted #2980b9;
    color: #2980b9;
    font-weight: 500;
}

.md-typeset abbr:hover {
    color: #1967C0;
    border-bottom-color: #1967C0;
}

/* Disable native browser tooltips to prevent multiple tooltips */
.md-typeset abbr[title] {
    cursor: help;
}

/* Custom CSS tooltip implementation - wider and single tooltip */
.md-typeset abbr[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    max-width: 500px;
    min-width: 200px;
    text-align: left;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
    margin-bottom: 0.5rem;
}

.md-typeset abbr[title]:hover::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
    z-index: 1001;
    margin-bottom: -0.25rem;
}

/* Responsive tooltip adjustments */
@media screen and (max-width: 76.1875em) {
    .md-typeset abbr[title]:hover::after {
        position: fixed;
        bottom: auto;
        top: 50%;
        left: 1rem;
        right: 1rem;
        transform: translateY(-50%);
        max-width: none;
        width: auto;
        min-width: auto;
    }
    
    .md-typeset abbr[title]:hover::before {
        display: none;
    }
}

/* --- First-occurrence-only abbreviation styling --- */

/* Style subsequent occurrences as plain text */
.md-typeset abbr.abbr-subsequent {
    cursor: default !important;
    text-decoration: none !important;
    border-bottom: none !important;
    color: inherit !important;
    font-weight: inherit !important;
}

/* Ensure first occurrences maintain proper styling */
.md-typeset abbr.abbr-first {
    cursor: help;
    text-decoration: none;
    border-bottom: 1px dotted #2980b9;
    color: #2980b9;
    font-weight: 500;
}

.md-typeset abbr.abbr-first:hover {
    color: #1967C0;
    border-bottom-color: #1967C0;
}
/* --- Custom Font Size for Sidebars --- */
.md-nav--primary .md-nav__link,
.md-sidebar--secondary .md-nav__link {
    font-size: 1rem;
}