/* Dark theme (default) */
:root {
    --bg-main: #0d1117;
    --bg-card: #161b22;
    --bg-code: #0a0d10;
    --border: #30363d;
    --text-primary: #ffffff;
    --text-secondary: #b0b8c0;
    --text-link: #ff6600;
    --accent: #ff6600;
    --accent-dim: #ff8800;
}

/* Light theme */
[data-theme="light"] {
    --bg-main: #ffffff;
    --bg-card: #f6f8fa;
    --bg-code: #f8f8f8;
    --border: #d1d9e0;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-link: #0969da;
    --accent: #ff6600;
    --accent-dim: #ff8800;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 500;
    text-decoration: none;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    position: relative;
    display: inline-block;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    background: #000000;
    color: #00ff00;
    text-shadow: 
        0 0 10px #00ff00,
        0 0 20px #00ff0080;
    border: 1px solid #00ff00;
    border-radius: 2px;
}

.logo::before {
    content: '> ';
    color: #00ff00;
}

/* Blinking cursor */
.logo::after {
    content: '_';
    color: #00ff00;
    animation: cursorBlink 1s infinite;
    font-weight: 700;
    display: inline-block;
    margin-left: 2px;
}

/* Cursor blink animation */
@keyframes cursorBlink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

/* On hover, make the glow brighter */
.logo:hover {
    text-shadow: 
        0 0 15px #00ff00,
        0 0 30px #00ff0080,
        0 0 40px #00ff0040;
    box-shadow: 
        0 0 20px #00ff0040 inset,
        0 0 20px #00ff0040;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    font-size: 0.95rem;
}

nav a:hover {
    color: var(--text-primary);
}

nav a.active {
    color: var(--accent);
}

/* Theme toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--bg-code);
    color: var(--accent);
    border-color: var(--accent-dim);
}

/* Main Content */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-link);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.breadcrumb a:hover {
    color: var(--accent-dim);
    text-shadow: 0 0 8px var(--accent);
}

.breadcrumb span {
    margin: 0 0.5rem;
    color: var(--text-secondary);
}

/* Article Typography */
article h1, h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--accent);
}

article h2, h2 {
    font-size: 1.75rem;
    margin: 2.5rem 0 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

article h3, h3 {
    font-size: 1.35rem;
    margin: 2rem 0 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

article p, p {
    margin-bottom: 1.5rem;
    line-height: 1.7;
    color: var(--text-primary);
}

article a, a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    display: inline-block;
}

article a:hover, a:hover {
    color: var(--accent-dim);
    transform: translateY(-1px);
    text-shadow: 0 0 10px var(--accent);
}

article a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s;
}

article a:hover::after {
    width: 100%;
}

article code:not(.code-block), code {
    background: var(--bg-card);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'JetBrains Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Lists */
ul.dash, .dash-list {
    list-style: none;
    margin: 1.5rem 0;
    padding-left: 1.5rem;
}

ul.dash li, .dash-list li {
    margin-bottom: 0.75rem;
    position: relative;
    color: var(--text-primary);
}

ul.dash li::before, .dash-list li::before {
    content: '—';
    position: absolute;
    left: -1.5rem;
    color: var(--accent-dim);
}

/* Regular lists */
article ul:not(.dash):not(.dash-list), article ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
    color: var(--text-primary);
}

article ul:not(.dash):not(.dash-list) li, article ol li {
    margin-bottom: 0.5rem;
}

/* Definition Lists - Two column layout */
dl.dl-horizontal {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem 2rem;
    align-items: start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    margin: 2rem 0;
}

dl.dl-horizontal dt {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', Monaco, monospace;
    font-size: 0.9rem;
    text-align: right;
    white-space: nowrap;
}

dl.dl-horizontal dd {
    font-family: 'JetBrains Mono', Monaco, monospace;
    color: var(--accent);
    background: transparent;
    padding: 0;
    border-radius: 0;
    margin: 0;
}

dl.dl-horizontal dd code {
    background: transparent !important;
    padding: 0 !important;
}

/* Regular definition lists (for history on index page) */
article dl:not(.dl-horizontal) {
    margin: 2rem 0;
}

article dl:not(.dl-horizontal) dt {
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    margin-top: 1.5rem !important;
    margin-bottom: 0.5rem !important;
    font-size: 1rem !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

article dl:not(.dl-horizontal) dd {
    margin-left: 2rem !important;
    margin-bottom: 1rem !important;
    color: var(--text-primary) !important;
    line-height: 1.7 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    display: block !important;
}

/* Code Blocks */
pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    position: relative;
}

pre code, .code-block {
    font-family: 'JetBrains Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-primary);
    background: none;
    padding: 0;
}

/* Syntax highlighting colors for dark theme */
.hl-comment {
    color: #8b949e;
    font-style: italic;
}

.hl-string {
    color: #a5d6ff;
}

.hl-keyword {
    color: #ff7b72;
}

.hl-macro {
    color: #ffa657;
}

.hl-function {
    color: #d2a8ff;
}

.hl-number {
    color: #79c0ff;
}

.hl-operator {
    color: #ff7b72;
}

/* Light theme syntax colors */
[data-theme="light"] .hl-comment {
    color: #6a737d;
}

[data-theme="light"] .hl-string {
    color: #032f62;
}

[data-theme="light"] .hl-keyword {
    color: #d73a49;
}

[data-theme="light"] .hl-macro {
    color: #e36209;
}

[data-theme="light"] .hl-function {
    color: #6f42c1;
}

[data-theme="light"] .hl-number {
    color: #005cc5;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--border);
}

th {
    background: var(--bg-card);
    font-weight: 600;
    color: var(--text-primary);
}

td {
    background: var(--bg-main);
    color: var(--text-secondary);
}

/* Info/Warning boxes */
.info-box, .warning-box {
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    border-radius: 0 6px 6px 0;
}

.info-box h3, .warning-box h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Historical Note */
.historical-note {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 1.5rem;
    margin-top: 3rem;
    margin-bottom: 2rem;
}

.historical-note h3 {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.historical-note p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.historical-note a {
    color: var(--accent);
    text-decoration: none;
}

.historical-note a:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    border-top: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s;
}

footer a:hover {
    color: var(--accent-dim);
    text-shadow: 0 0 8px var(--accent);
}

/* Optional: Retro terminal effect (subtle, dark mode only) */
@keyframes flicker {
    0% { opacity: 0.97; }
    100% { opacity: 1; }
}

[data-theme="dark"] body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 107, 53, 0.01) 2px,
            rgba(255, 107, 53, 0.01) 4px
        );
    pointer-events: none;
    animation: flicker 0.15s infinite;
    z-index: 1;
}

.container {
    position: relative;
    z-index: 2;
}

/* Dropdown Navigation */
nav ul {
    list-style: none;
    display: flex;
    gap: 0;
    align-items: center;
}

nav li {
    position: relative;
}

nav > ul > li > a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

nav > ul > li > a:hover,
nav > ul > li.active > a {
    color: var(--text-primary);
    background: var(--bg-code);
}

/* Dropdown menu container */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease-in-out;
    z-index: 1000;
    margin-top: 0.25rem;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    list-style: none;
    gap: 0 !important;
}

/* Show dropdown on hover (desktop) or when active (mobile) */
nav li:hover .dropdown-menu,
nav li.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown items */
.dropdown-menu li {
    margin: 0;
    text-align: left;
}

.dropdown-menu a {
    display: block;
    padding: 0.6rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
    font-size: 0.9rem;
    text-align: left;
}

.dropdown-menu a:hover {
    background: var(--bg-code);
    color: var(--accent);
    padding-left: 1.5rem;
}

.dropdown-menu a b {
    color: var(--text-primary);
    font-weight: 600;
}

.dropdown-menu a:hover b {
    color: var(--accent);
}

/* Dropdown headers */
.dropdown-header {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 0.5rem;
    text-align: left;
}

.dropdown-header:first-child {
    margin-top: 0;
}

/* Dropdown dividers */
.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
    list-style: none;
    padding: 0;
}

/* Dropdown header items shouldn't be clickable */
.dropdown-header {
    list-style: none;
}

/* Caret/arrow indicator */
nav > ul > li > a::after {
    content: '▼';
    font-size: 0.65rem;
    margin-left: 0.4rem;
    opacity: 0.6;
    transition: transform 0.2s;
}

nav > ul > li:hover > a::after,
nav > ul > li.active > a::after {
    transform: rotate(180deg);
}

/* Mobile hamburger menu button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle:hover {
    background: var(--bg-code);
    color: var(--accent);
    border-color: var(--accent-dim);
}

/* Responsive */
@media (max-width: 968px) {
    .mobile-menu-toggle {
        display: flex;
    }

    nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
    }

    nav.mobile-menu-open {
        max-height: 80vh;
        overflow-y: auto;
    }

    nav ul {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    nav > ul > li {
        width: 100%;
        border-bottom: 1px solid var(--border);
    }

    nav > ul > li > a {
        padding: 1rem 1.5rem;
    }

    /* Mobile dropdown behavior - click to toggle */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--border);
        border-radius: 0;
        background: var(--bg-code);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
        padding: 0;
    }

    nav li.active .dropdown-menu {
        max-height: 1000px;
        padding: 0.5rem 0;
    }

    nav li:hover .dropdown-menu {
        max-height: 0;
        padding: 0;
    }

    nav li.active:hover .dropdown-menu {
        max-height: 1000px;
        padding: 0.5rem 0;
    }

    .dropdown-menu a {
        padding-left: 2.5rem;
    }

    .dropdown-menu a:hover {
        padding-left: 3rem;
    }

    nav > ul > li > a::after {
        float: right;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        position: relative;
    }

    article h1, h1 {
        font-size: 2rem;
    }

    .container {
        padding: 2rem 1rem;
    }

    .theme-toggle {
        order: 3;
    }

    .logo {
        order: 1;
    }

    .mobile-menu-toggle {
        order: 2;
    }

    nav {
        order: 4;
        width: 100%;
    }

    dl.dl-horizontal {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    dl.dl-horizontal dt {
        text-align: left;
    }
}