/* ============================================
   CSS Variables for Theme Management
   ============================================ */
:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --text-primary: #f4f1e8;
    --text-secondary: #c4c1b8;
    --text-muted: #8a8780;
    --accent-highlight: #00ff41;
    --link-color: #ff4444;
    --border-color: #2a2a2a;
    --header-bg: #0f0f0f;
    --code-bg: #1a1a1a;
    --toolbar-bg: #000000;
}

[data-theme="light"] {
    --bg-primary: #f4f1e8;
    --bg-secondary: #fefcf7;
    --text-primary: #1a1a1a;
    --text-secondary: #3a3a3a;
    --text-muted: #6a6a6a;
    --accent-highlight: #0088ff;
    --link-color: #0066cc;
    --border-color: #d4d1c8;
    --header-bg: #e8e5dc;
    --code-bg: #eae7de;
    --toolbar-bg: #fefcf7;
}

/* ============================================
   Reset and Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    font-size: 16px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

a:hover {
    opacity: 0.7;
}

code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

/* ============================================
   Top Toolbar
   ============================================ */
.top-toolbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    height: 50px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    font-size: 1rem;
}

.toolbar-btn i {
    font-size: 1.1rem;
}

.toolbar-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent-highlight);
}

.toolbar-btn.active {
    background-color: var(--accent-highlight);
    color: var(--bg-primary);
    border-color: var(--accent-highlight);
}

.toolbar-btn .icon {
    display: block;
    line-height: 1;
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 400px;
    max-height: 500px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-dropdown.hidden {
    display: none;
}

#topSearchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
}

#topSearchInput::placeholder {
    color: var(--text-muted);
}

.search-results {
    padding: 0.5rem;
}

.search-result-item {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.search-result-item h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    color: var(--accent-highlight);
}

.search-result-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.search-result-item time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   Header - Adjusted for Toolbar
   ============================================ */
header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: sticky;
    top: 50px;
    z-index: 100;
    margin-top: 50px;
}

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

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

header nav {
    display: flex;
    gap: 2rem;
}

header nav a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

header nav a:hover {
    color: var(--accent-highlight);
}

/* ============================================
   Layout Container
   ============================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.profile-image {
    width: 100%;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    aspect-ratio: 1/1;
    object-fit: cover;
}

.profile-info h2 {
    font-size: 1.25rem;
    margin: 0;
}

.profile-info .subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   Search Section
   ============================================ */
.search-section {
    margin: 1rem 0;
}

#searchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
}

#searchInput::placeholder {
    color: var(--text-muted);
}

#searchInput:focus {
    border-color: var(--accent-highlight);
}

/* ============================================
   Sidebar Navigation
   ============================================ */
.sidebar-nav h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.sidebar-nav ul {
    list-style: none;
    margin-bottom: 1.5rem;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
}

.sidebar-nav a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: block;
    padding: 0.25rem 0;
}

.sidebar-nav a:hover {
    color: var(--accent-highlight);
}

/* ============================================
   Theme Toggle
   ============================================ */
.theme-controls {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

#themeToggle {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

#themeToggle:hover {
    background-color: var(--code-bg);
}

.theme-icon {
    font-size: 1.2rem;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    max-width: 800px;
}

.intro-section {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.intro-section h2 {
    margin-bottom: 1rem;
}

/* ============================================
   Articles Section
   ============================================ */
.articles-section h2 {
    margin-bottom: 1.5rem;
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.article-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.article-item:last-child {
    border-bottom: none;
}

.article-item time {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.article-item h3 {
    margin: 0;
    font-size: 1.15rem;
}

.article-item h3 a {
    color: var(--text-primary);
}

.article-item h3 a:hover {
    color: var(--accent-highlight);
}

.article-meta {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
}

.no-results {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* ============================================
   Footer
   ============================================ */
footer {
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    margin-top: 3rem;
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
}

.social-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.social-links a {
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-secondary);
    transition: all 0.2s ease;
}

.social-links a:hover {
    color: var(--accent-highlight);
    border-color: var(--accent-highlight);
    background-color: var(--code-bg);
}

.social-links i {
    font-size: 1.1rem;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .sidebar {
        position: static;
        max-width: 400px;
        margin: 0 auto;
    }

    .main-content {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    header nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .container {
        padding: 1rem;
    }

    .sidebar {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    header nav {
        gap: 0.75rem;
    }

    header nav a {
        font-size: 0.8rem;
    }

    .site-title {
        font-size: 1.25rem;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.highlight {
    color: var(--accent-highlight);
    font-weight: 600;
}

.loading-message,
.error-message,
.no-articles-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.error-message {
    color: #ff4444;
}

/* Text Highlighting Feature */
.user-highlight {
    background-color: var(--accent-highlight);
    color: var(--bg-primary);
    padding: 0 2px;
    border-radius: 2px;
}

/* Magnification Feature */
body.magnified {
    font-size: 20px;
}

body.magnified h1 { font-size: 2.5rem; }
body.magnified h2 { font-size: 2rem; }
body.magnified h3 { font-size: 1.5rem; }

/* ============================================
   Page Layout (About, Notes pages)
   ============================================ */
.page-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

.page-content {
    max-width: 900px;
    margin: 0 auto;
}

.content-article {
    background-color: var(--bg-secondary);
    padding: 4rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.page-header {
    margin-bottom: 3rem;
    padding: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    background-color: var(--bg-primary);
    margin: -4rem -4rem 3rem -4rem;
    padding: 3rem 4rem 2rem 4rem;
    border-radius: 8px 8px 0 0;
}

.page-header h1 {
    font-size: 2.5rem;
    margin: 0;
}

.page-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 0 0;
    font-weight: 400;
}

.about-section,
.notes-section {
    margin-bottom: 3rem;
}

.about-section h2,
.notes-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.about-section ul {
    list-style: none;
    padding-left: 0;
}

.about-section li {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    position: relative;
}

.about-section li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent-highlight);
}

.contact-links {
    margin-top: 1.5rem;
}

.contact-links p {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.contact-links i {
    color: var(--accent-highlight);
    font-size: 1.2rem;
}

/* Notes Page Styling */
.notes-list {
    display: grid;
    gap: 1.5rem;
}

.note-item {
    background-color: var(--code-bg);
    padding: 1.5rem;
    border-radius: 6px;
    border-left: 4px solid var(--accent-highlight);
    transition: transform 0.2s ease;
}

.note-item:hover {
    transform: translateX(5px);
}

.note-item h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.note-item h3 i {
    color: var(--accent-highlight);
}

.note-item p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.resource-links h3 {
    font-size: 1.25rem;
    margin: 2rem 0 1rem 0;
    color: var(--text-primary);
}

.resource-links ul {
    list-style: none;
    padding-left: 0;
}

.resource-links li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.resource-links li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent-highlight);
}

@media (max-width: 768px) {
    .page-container {
        padding: 1rem;
    }

    .content-article {
        padding: 2rem;
    }

    .page-header {
        margin: -2rem -2rem 2rem -2rem;
        padding: 2rem;
    }

    .page-header h1 {
        font-size: 2rem;
    }
}

/* ============================================
   Accessibility
   ============================================ */
:focus-visible {
    outline: 2px solid var(--accent-highlight);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
