/* Modern Responsive Design & Final Polish */

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

/* Better selection colors */
::selection {
    background-color: var(--accent);
    color: var(--bg-primary);
}

::-moz-selection {
    background-color: var(--accent);
    color: var(--bg-primary);
}

/* Enhanced scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--border-radius);
    transition: all var(--transition-medium);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fg-tertiary);
}

/* Better table styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-xl) 0;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-large);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

table th,
table td {
    padding: 0.35rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    color: var(--fg-primary);
    font-family: var(--font-heading);
}

table tr:hover {
    background-color: var(--bg-tertiary);
}

/* Enhanced list markers */
.org-ul li::marker {
    color: var(--fg-tertiary);
}

.org-ol li::marker {
    color: var(--fg-tertiary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    #content {
        width: 90%;
    }
    
    #table-of-contents {
        float: none;
        display: block;
        margin: var(--spacing-lg) 0;
        max-width: 100%;
    }
}

/* Hamburger menu - hidden on desktop */
#hamburger-btn {
    display: none;
}

@media (max-width: 768px) {
    /* Show hamburger button */
    #hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        position: absolute;
        right: var(--spacing-md);
        top: var(--spacing-md);
        z-index: 1001;
    }
    
    .hamburger-line {
        display: block;
        width: 24px;
        height: 2px;
        background-color: var(--fg-primary);
        margin: 3px 0;
        transition: all 0.2s ease;
        border-radius: 1px;
    }
    
    /* Animate to X when open */
    #hamburger-btn.is-open .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    #hamburger-btn.is-open .hamburger-line:nth-child(2) {
        opacity: 0;
    }
    #hamburger-btn.is-open .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
    
    /* Hide tabs by default on mobile */
    #tabs {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        background: #0a0a0a !important;
        z-index: 1000;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: var(--spacing-xl);
        border: none !important;
        border-radius: 0;
        margin: 0;
        float: none;
    }
    
    #tabs.is-open {
        display: flex;
    }
    
    #tabs li {
        float: none;
        margin: var(--spacing-sm) 0;
    }
    
    #tabs li a {
        font-size: 1.25rem;
        padding: var(--spacing-md);
        text-align: center;
        display: block;
    }
    
    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
    }
    
    /* Make room for hamburger button */
    .title {
        padding-right: 50px;
    }

    :root {
        --spacing-xs: 0.2rem;
        --spacing-sm: 0.4rem;
        --spacing-md: 0.8rem;
        --spacing-lg: 1.2rem;
        --spacing-xl: 1.6rem;
        --spacing-2xl: 2.4rem;
    }
    
    body {
        font-size: 15px;
        line-height: 1.65;
    }
    
    #content {
        width: 95%;
    }
    
    /* Horizontal scroll for tables on mobile */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: var(--spacing-lg) 0;
    }
    
    .table-wrapper table {
        margin: 0;
        min-width: max-content;
    }
    
    .table-wrapper td,
    .table-wrapper th {
        white-space: nowrap;
    }
    
    /* Prevent slight horizontal scrolling on mobile */
    html, body {
        overflow-x: hidden;
        max-width: 100%;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    
    pre {
        font-size: 0.8rem;
        padding: var(--spacing-sm);
        overflow-x: auto;
    }
    
    blockquote {
        margin: var(--spacing-lg) var(--spacing-xs);
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

@media (max-width: 480px) {
    #content {
        width: 98%;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --shadow-subtle: none;
        --shadow-medium: none;
        --shadow-large: none;
    }
    
    *,
    *::before,
    *::after {
        box-shadow: none !important;
    }
    
    a, button, input, textarea {
        border: 2px solid currentColor !important;
    }
}

/* Print styles */
@media print {
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
    }
    
    #tabs,
    #hamburger-btn,
    .buttons {
        display: none !important;
    }
    
    a {
        color: black !important;
        text-decoration: underline !important;
    }
    
    pre, code {
        background: #f5f5f5 !important;
        color: black !important;
        border: 1px solid #ccc !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
        page-break-after: avoid;
    }
    
    p, blockquote, ul, ol {
        page-break-inside: avoid;
    }
}
