/* ============================================
   PRISTINE - Modern Minimalist MkDocs Theme
   ============================================ */

/* CSS Custom Properties */
:root {
    /* Typography */
    --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Layout */
    --sidebar-width: 260px;
    --toc-width: 280px;
    --content-max-width: 900px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

/* Light Theme (Default) */
:root,
[data-theme="light"] {
    --color-bg: #ffffff;
    --color-bg-subtle: #f9fafb;
    --color-bg-muted: #f3f4f6;
    --color-bg-elevated: #ffffff;

    --color-text: #111827;
    --color-text-secondary: #4b5563;
    --color-text-muted: #9ca3af;
    --color-text-inverse: #ffffff;

    --color-border: #e5e7eb;
    --color-border-subtle: #f3f4f6;

    --color-accent: #2563eb;
    --color-accent-hover: #1d4ed8;
    --color-accent-subtle: rgba(37, 99, 235, 0.1);

    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;

    --color-code-bg: #f3f4f6;
    --color-code-border: #e5e7eb;

    --color-sidebar-bg: #f9fafb;
    --color-header-bg: rgba(255, 255, 255, 0.85);

    --color-highlight: rgba(37, 99, 235, 0.1);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Dark Theme */
[data-theme="dark"] {
    --color-bg: #0f0f0f;
    --color-bg-subtle: #171717;
    --color-bg-muted: #1f1f1f;
    --color-bg-elevated: #1a1a1a;

    --color-text: #fafafa;
    --color-text-secondary: #a3a3a3;
    --color-text-muted: #737373;
    --color-text-inverse: #0f0f0f;

    --color-border: #262626;
    --color-border-subtle: #1f1f1f;

    --color-accent: #3b82f6;
    --color-accent-hover: #60a5fa;
    --color-accent-subtle: rgba(59, 130, 246, 0.15);

    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-error: #f87171;

    --color-code-bg: #1a1a1a;
    --color-code-border: #262626;

    --color-sidebar-bg: #141414;
    --color-header-bg: rgba(15, 15, 15, 0.85);

    --color-highlight: rgba(59, 130, 246, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* ============================================
   Base Styles
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 1rem);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    padding: var(--space-2) var(--space-4);
    background: var(--color-accent);
    color: var(--color-text-inverse);
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    z-index: 9999;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-4);
}

/* ============================================
   Header
   ============================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    z-index: 100;
}

.header-container {
    max-width: 1440px;
    height: 100%;
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    flex-shrink: 0;
}

.logo img {
    height: 32px;
    width: auto;
}

.logo-text {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border: none;
    background: none;
    cursor: pointer;
}

.nav-link:hover {
    color: var(--color-text);
    background: var(--color-bg-muted);
}

.nav-link.active {
    color: var(--color-text);
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.dropdown-content {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    min-width: 180px;
    padding: var(--space-2);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.nav-dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-item {
    display: block;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    color: var(--color-text);
    background: var(--color-bg-muted);
}

.dropdown-item.active {
    color: var(--color-accent);
    background: var(--color-accent-subtle);
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
}

/* Search */
.search-wrapper {
    position: relative;
}

.search-input {
    width: 280px;
    height: 40px;
    padding: 0 var(--space-4) 0 44px;
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--color-text);
    outline: none;
    transition: all var(--transition-fast);
}

.search-input::placeholder {
    color: var(--color-text-muted);
}

.search-input:hover {
    background: var(--color-bg-subtle);
}

.search-input:focus {
    border-color: var(--color-accent);
    background: var(--color-bg);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-shortcut {
    padding: 2px 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-muted);
    pointer-events: none;
}

/* Search Trigger Button */
.search-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    min-width: 280px;
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.search-trigger::after {
    content: 'Search...';
    flex: 1;
    text-align: left;
}

.search-trigger:hover {
    background: var(--color-bg-subtle);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

@media (max-width: 900px) {
    .search-trigger {
        min-width: auto;
        padding: var(--space-2);
    }
    .search-trigger::after {
        display: none;
    }
    .search-trigger .search-shortcut {
        display: none;
    }
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--color-bg-subtle);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    color: var(--color-text-secondary);
}

[data-theme="light"] .theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: none; }

/* Mobile Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: var(--space-3);
    background: none;
    border: none;
    cursor: pointer;
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
    transition: all var(--transition-base);
}

/* ============================================
   Search Modal
   ============================================ */

.search-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
}

.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.search-modal-content {
    position: relative;
    width: 100%;
    max-width: 680px;
    margin: 0 var(--space-4);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: scale(0.95) translateY(-20px);
    transition: transform var(--transition-base);
}

.search-modal.active .search-modal-content {
    transform: scale(1) translateY(0);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.search-input-wrapper svg {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.search-input-wrapper input,
#search-input {
    flex: 1;
    width: 100%;
    padding: var(--space-1) 0;
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text);
    outline: none;
}

.search-input-wrapper input::placeholder,
#search-input::placeholder {
    color: var(--color-text-muted);
}

.search-esc {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-2);
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.search-empty {
    padding: var(--space-8) var(--space-5);
    text-align: center;
    color: var(--color-text-muted);
}

.search-empty p {
    margin: 0;
    font-size: var(--text-sm);
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: block;
    padding: var(--space-4) var(--space-5);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border-subtle);
    transition: background var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.selected {
    background: var(--color-bg-muted);
}

.search-result-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-1);
}

.search-result-text {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.search-result-text mark {
    background: var(--color-highlight);
    color: var(--color-accent);
    padding: 0 2px;
    border-radius: 2px;
}

/* ============================================
   Main Layout
   ============================================ */

.main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
    min-height: 100vh;
    padding-top: var(--header-height);
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    padding: var(--space-6);
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border-subtle);
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-title {
    display: block;
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.sidebar-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-link {
    display: block;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    line-height: 1.5;
}

.sidebar-link:hover {
    color: var(--color-text);
    background: var(--color-bg-muted);
}

.sidebar-link.active {
    color: var(--color-accent);
    background: var(--color-accent-subtle);
    font-weight: 500;
}

/* Same size as parent - hierarchy via indentation only */
.sidebar-sublist {
    list-style: none;
    padding-left: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar-sublist .sidebar-link {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.sidebar-sublist .sidebar-link:hover {
    color: var(--color-text-secondary);
}

/* ============================================
   Content
   ============================================ */

.content {
    min-width: 0;
    padding: var(--space-8) var(--space-6);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

.article {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    animation: fadeIn 0.4s ease-out;
    min-width: 0;
    overflow-wrap: break-word;
}

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

/* Typography */
.article h1,
.article h2,
.article h3,
.article h4,
.article h5,
.article h6 {
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: var(--color-text);
    margin-top: var(--space-10);
    margin-bottom: var(--space-4);
}

.article h1 {
    font-size: var(--text-4xl);
    margin-top: 0;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.article h2 {
    font-size: var(--text-2xl);
    margin-top: var(--space-12);
}

.article h3 {
    font-size: var(--text-xl);
    margin-top: var(--space-8);
}

.article h4 {
    font-size: var(--text-lg);
}

/* Target highlight animation */
@keyframes targetHighlight {
    0% { background-color: rgba(250, 180, 50, 0.3); }
    100% { background-color: transparent; }
}

.article h1:target,
.article h2:target,
.article h3:target,
.article h4:target,
.article h5:target,
.article h6:target {
    animation: targetHighlight 2s ease-out;
}

/* Permalink/headerlink styling */
.article .headerlink {
    margin-left: var(--space-2);
    color: var(--color-text-muted);
    text-decoration: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.article h1:hover .headerlink,
.article h2:hover .headerlink,
.article h3:hover .headerlink,
.article h4:hover .headerlink,
.article h5:hover .headerlink,
.article h6:hover .headerlink {
    opacity: 0.5;
}

.article .headerlink:hover {
    opacity: 1;
    color: var(--color-accent);
}

.article p {
    margin: 0 0 var(--space-4);
    color: var(--color-text-secondary);
}

/* Badges - reduce gaps for image-only paragraphs */
.article p.badges {
    font-size: 0 !important;
    line-height: 0 !important;
    margin: 0 0 var(--space-4) 0 !important;
}

.article p.badges a {
    font-size: 1rem !important;
    display: inline-block !important;
    margin: 0 6px 6px 0 !important;
    line-height: 1 !important;
}

.article p.badges img {
    vertical-align: top !important;
    margin: 0 !important;
}

.article p img {
    vertical-align: middle;
}

.article a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

.article strong {
    font-weight: 600;
    color: var(--color-text);
}

.article em {
    font-style: italic;
}

/* Lists */
.article ul,
.article ol {
    margin: 0 0 var(--space-4);
    padding-left: var(--space-6);
    color: var(--color-text-secondary);
}

.article li {
    margin-bottom: var(--space-2);
}

.article li::marker {
    color: var(--color-text-muted);
}

/* Blockquote */
.article blockquote {
    margin: var(--space-6) 0;
    padding: var(--space-4) var(--space-5);
    background: var(--color-bg-muted);
    border-left: 4px solid var(--color-accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.article blockquote p {
    margin: 0;
    color: var(--color-text-secondary);
}

/* Code */
.article code {
    padding: 0.2em 0.4em;
    background: var(--color-code-bg);
    border: 1px solid var(--color-code-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: var(--color-text);
    word-break: break-all;
}

.article pre {
    position: relative;
    margin: var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--color-code-bg);
    border: 1px solid var(--color-code-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.article pre::-webkit-scrollbar {
    display: none;
}

.article pre code {
    padding: 0;
    background: none;
    border: none;
    font-size: var(--text-sm);
    line-height: 1.5;
}

/* Copy button */
.copy-button {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 24px;
    height: 24px;
    padding: 4px;
    background: var(--color-bg-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.article pre:hover .copy-button {
    opacity: 0.7;
}

.copy-button:hover {
    opacity: 1;
    background: var(--color-bg-subtle);
    color: var(--color-text);
}

.copy-button svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* Tables */
.article table {
    width: 100%;
    margin: var(--space-6) 0;
    border-collapse: collapse;
    font-size: var(--text-sm);
    display: block;
    overflow-x: auto;
}

.article th,
.article td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.article th {
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-bg-muted);
}

.article td {
    color: var(--color-text-secondary);
}

.article tr:hover td {
    background: var(--color-bg-subtle);
}

/* Images */
.article img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin: var(--space-6) 0;
}

/* Horizontal Rule */
.article hr {
    margin: var(--space-10) 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

/* Admonitions */
.article .admonition {
    margin: var(--space-6) 0;
    padding: var(--space-4) var(--space-5);
    background: var(--color-bg-muted);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--color-accent);
}

.article .admonition-title {
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.article .admonition.warning {
    border-left-color: var(--color-warning);
}

.article .admonition.danger,
.article .admonition.error {
    border-left-color: var(--color-error);
}

.article .admonition.tip,
.article .admonition.success {
    border-left-color: var(--color-success);
}

/* ============================================
   Table of Contents
   ============================================ */

.toc {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    padding: var(--space-6);
    overflow-y: auto;
}

.toc-container {
    padding-left: var(--space-4);
    border-left: 1px solid var(--color-border-subtle);
}

.toc-title {
    display: block;
    margin-bottom: var(--space-4);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.toc-link {
    display: block;
    padding: var(--space-1) 0;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
    line-height: 1.5;
}

.toc-link:hover {
    color: var(--color-text);
}

.toc-link.active {
    color: var(--color-accent);
    font-weight: 500;
}

/* Same size, just indented - modern approach like Next.js docs */
.toc-link-nested {
    padding-left: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* ============================================
   Page Navigation
   ============================================ */

.page-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin-top: var(--space-12);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
    width: 100%;
}

.page-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-5);
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition-base);
}

.page-nav-link:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-subtle);
}

.page-nav-link.next {
    text-align: right;
}

.page-nav-direction {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.page-nav-link.next .page-nav-direction {
    justify-content: flex-end;
}

.page-nav-title {
    font-weight: 600;
    color: var(--color-text);
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
    margin-top: auto;
    padding: var(--space-8) 0;
    width: 100%;
}

.footer-content {
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border-subtle);
    text-align: center;
}

.footer-content p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.footer-content a {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-content a:hover {
    color: var(--color-accent);
}

/* ============================================
   Mobile Navigation
   ============================================ */

.mobile-nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg);
    z-index: 99;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
}

.mobile-nav.active {
    transform: translateX(0);
}

.mobile-nav-content {
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.mobile-nav-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.mobile-nav-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: 0 var(--space-2);
}

.mobile-nav-link {
    display: block;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.mobile-nav-link:hover {
    background: var(--color-bg-muted);
    color: var(--color-text);
}

.mobile-nav-link.active {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
}

.mobile-nav-link-nested {
    padding-left: var(--space-8);
    color: var(--color-text-muted);
}

/* Compact TOC styling in mobile menu */
.mobile-nav-toc .mobile-nav-link {
    padding: var(--space-1) var(--space-4);
    font-size: var(--text-sm);
}

.mobile-nav-toc .mobile-nav-link-nested {
    padding: var(--space-1) var(--space-4) var(--space-1) var(--space-8);
}

/* Hide mobile menu toggle when nothing to show */
.no-mobile-menu .mobile-menu-toggle,
.no-mobile-menu .mobile-nav {
    display: none !important;
}

/* ============================================
   Progress Bar
   ============================================ */

.page-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: var(--color-accent);
    z-index: 1001;
    transition: width 100ms ease-out;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1280px) {
    .main-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
    }

    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .mobile-nav {
        display: block;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .header-nav {
        display: none;
    }

    .search-wrapper {
        display: none;
    }

    .content {
        padding: var(--space-6) var(--space-4);
    }
}

@media (max-width: 600px) {
    .header-container {
        padding: 0 var(--space-4);
    }

    .page-nav {
        grid-template-columns: 1fr;
    }

    .page-nav-link.next {
        text-align: left;
    }

    .page-nav-link.next .page-nav-direction {
        justify-content: flex-start;
    }
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Selection */
::selection {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
}

/* ============================================
   Layout Variants
   ============================================ */

/* TOC on left: swap sidebar and toc positions */
.toc-left .main-layout {
    grid-template-columns: var(--toc-width) 1fr var(--sidebar-width);
}
.toc-left .sidebar { order: 1; }
.toc-left .toc { order: -1; }

/* Without sidebar */
.no-sidebar .main-layout {
    grid-template-columns: minmax(0, var(--content-max-width)) var(--toc-width);
    justify-content: center;
}
.no-sidebar.toc-left .main-layout {
    grid-template-columns: var(--toc-width) minmax(0, var(--content-max-width));
}
.no-sidebar .article {
    max-width: none;
    margin: 0;
}
.no-sidebar .header-container {
    box-sizing: content-box;
    max-width: calc(var(--toc-width) + var(--content-max-width) - var(--space-6) * 2);
}
.no-sidebar.toc-left .toc-container {
    padding-left: 0;
    border-left: none;
}

/* Without TOC */
.no-toc .main-layout {
    grid-template-columns: var(--sidebar-width) 1fr;
}
.no-toc.toc-left .main-layout {
    grid-template-columns: 1fr var(--sidebar-width);
}

/* Without both - content only */
.no-sidebar.no-toc .main-layout {
    grid-template-columns: 1fr;
}

/* Responsive: update media queries for layout variants */
@media (max-width: 1280px) {
    .no-sidebar .main-layout {
        grid-template-columns: 1fr;
    }
    .no-sidebar.toc-left .main-layout {
        grid-template-columns: 1fr;
    }
    .no-toc .main-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
    .no-toc.toc-left .main-layout {
        grid-template-columns: 1fr var(--sidebar-width);
    }
    .toc-left .main-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
    }
    .toc-left .sidebar { order: 0; }
    .toc-left .toc { order: 0; }
}

@media (max-width: 900px) {
    .no-sidebar .main-layout,
    .no-toc .main-layout,
    .no-sidebar.no-toc .main-layout,
    .toc-left .main-layout,
    .no-sidebar.toc-left .main-layout,
    .no-toc.toc-left .main-layout {
        grid-template-columns: 1fr;
    }
}

/* Print */
@media print {
    .site-header,
    .sidebar,
    .toc,
    .theme-toggle,
    .page-nav,
    .mobile-nav,
    .page-progress {
        display: none !important;
    }

    .main-layout {
        display: block;
    }

    .content {
        padding: 0;
    }
}
