/* Base styles */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #4a9eff;
    --accent-hover: #6bb1ff;
    --border: #404040;
    --code-bg: #1e1e1e;
    --code-color: #f8f8f2;
}

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

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    padding-top: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s, box-shadow 0.2s;
	box-shadow: 0 1px 0 0 rgba(224, 224, 224, 0.2);
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
	box-shadow: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    padding: 8px 0;
    position: sticky;
    top: 0;
    z-index: 100;
	padding: 8px 0;
    height: 50px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    font-size: 24px;
    font-weight: bold;
}

.logo span {
    color: var(--text-secondary);
    font-size: 14px;
    display: block;
}

nav a {
    margin-left: 20px;
    color: var(--text-primary);
}

/* Article Content Styles */
.article-container {
    background: var(--bg-secondary);
    margin: 70px auto 20px auto; /* Added top margin to account for sticky header */
    max-width: 1200px;
    border: 1px solid var(--border);
    border-radius: 4px;
    position: relative; /* Added for proper stacking context */
    z-index: 1; /* Ensure it stays below the sticky header */
}

.article-header {
    padding: 5px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
	position: static;
    text-align: center;
}

.article-header h1 {
    font-size: 32px;
    margin-bottom: 20px;
    color: var(--text-primary);
    line-height: 1.3;
}

.article-header .meta {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.article-content {
    /* Sets top padding to 40px, left/right to 30px, bottom to 30px */
    padding: 40px 30px 30px 30px;
    line-height: 1.8;
}

.article-content h2 {
    font-size: 28px;
    margin: 30px 0 15px 0;
    color: var(--text-primary);
    border-left: 3px solid var(--accent);
    padding-left: 15px;
}

.article-content h3 {
    font-size: 24;
    margin: 20px 0 10px 0;
    color: var(--text-primary);
}

.article-content p {
    margin-bottom: 15px;
}

.article-content ul, .article-content ol {
    margin: 15px 0 15px 30px;
}

.article-content li {
    margin-bottom: 5px;
}

.article-content code {
	font-family: "Courier New", Courier, monospace;
    background: var(--code-bg);
    color: var(--code-color);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

.article-content pre {
    background: var(--code-bg);
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 15px 0;
}

.article-content pre code {
    padding: 0;
    background: none;
}

.article-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 20px;
    margin: 20px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 15px 0;
}

.article-content figure {
    margin: 20px 0;
    text-align: center;
}

.article-content figcaption {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 5px;
}

/* Table Styling */
.article-content table {
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.article-content th,
.article-content td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.article-content th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.article-content tr:hover {
    background: rgba(74, 158, 255, 0.1);
}

.article-content tr:last-child td {
    border-bottom: none;
}

/* Table responsive wrapper */
.article-content .table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.article-content .table-wrapper table {
    margin: 0;
    border: none;
    border-radius: 0;
}

/* Small screens */
@media (max-width: 768px) {
    .article-content th,
    .article-content td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .article-content th {
        font-size: 12px;
    }
}

/* Anchor links for headings */
.anchor {
    display: block;
    position: relative;
    top: -60px;
    visibility: hidden;
}

/* More Like This Section */
.more-like-this {
    background: var(--bg-secondary);
    margin: 20px auto;
    max-width: 900px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.more-like-this h2 {
    font-size: 20px;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    margin: 0;
}

.mlt-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 30px;
}

.mlt-gallery-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s;
}

.mlt-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    border-color: var(--accent);
}

.mlt-gallery-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.mlt-gallery-content {
    padding: 15px;
}

.mlt-gallery-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
}

.mlt-gallery-desc {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 30px 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: 40px;
}

footer a {
    color: var(--text-secondary);
}

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

/* Hero Section */
.hero {
    background: var(--bg-secondary);
    padding: 40px 0;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: 36px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.hero p {
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto 30px;
}

/* Search Box */
.search-container {
    max-width: 500px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.search-box input {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
}

.search-box button {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--accent-hover);
}

/* Filter Buttons */
.filter-section {
    padding: 30px 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 40px 0;
}

.gallery-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s;
    display: none;
}

.gallery-item.show {
    display: block;
    animation: fadeIn 0.3s;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    border-color: var(--accent);
}

.gallery-content {
    padding: 15px;
}

.gallery-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.gallery-desc {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.gallery-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

/* Responsive */
@media (max-width: 768px) {
    .article-container,
    .more-like-this {
        margin: 10px;
        max-width: none;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    nav {
        margin-top: 10px;
    }

    nav a {
        margin: 0 10px;
    }

    .article-header,
    .article-content {
        padding: 20px;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        padding: 20px;
    }
}

/* MathJax adjustments */
.MathJax {
    font-size: 14px !important;
}

mjx-container {
    margin: 15px 0 !important;
}

/* --- Form Element Styles --- */

/* Style for text inputs inside tables */
.article-content table input[type="text"] {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    width: 100px; /* Gives them a uniform size */
    box-sizing: border-box; /* Ensures padding doesn't break layout */
    transition: all 0.2s;
}

/* Add a focus state for inputs */
.article-content table input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

/* Style for buttons */
.article-content button {
    padding: 10px 20px;
    background: var(--accent);
    color: #ffffff; /* Explicitly white for contrast */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.2s;
    margin-top: 20px; /* Add space above the button */
}

/* Button hover state */
.article-content button:hover {
    background: var(--accent-hover);
}


/* --- New Form & Input Fixes --- */

/* Style for inputs and selects */
.article-content input[type="text"],
.article-content select {
    font-family: inherit;
    font-size: 14px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
    line-height: 1.4;
    box-sizing: border-box;
    display: inline-block;
    transition: all 0.2s;
    text-align: center; 
}

/* Focus state for user feedback */
.article-content input[type="text"]:focus,
.article-content select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

/* Specific size and alignment for the number entry text fields */
.article-content input[type="text"] {
    width: 80px;
    margin-left: 10px;
    vertical-align: middle;
}

.article-content select {
    padding-right: 30px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    text-align: left;
}

.article-content table input[type="text"] {
    width: 100%;
    margin: 0;
}

/* Header - mobile fix attempt */
@media (max-width: 768px) {
    header {
        height: auto !important; /* Override the fixed height */
        padding: 5px 0 !important; /* Reduce padding */
        border-bottom: 1px solid var(--border);
    }

    .header-content {
        flex-direction: row; /* Keep logo and nav on the same line */
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
    }

    .logo {
        font-size: 20px; /* Smaller logo */
        margin-bottom: 0;
        flex-shrink: 0; /* Prevent it from shrinking */
    }

    nav {
        display: flex;
        margin: 0;
        flex-shrink: 0; /* Prevent it from shrinking */
    }

    nav a {
        margin-left: 10px;
        font-size: 14px;
        white-space: nowrap; /* Prevent link text from wrapping */
    }

    /* Add a horizontal scroll if nav overflows */
    .header-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Article Header - mobile fix attempt */
@media (max-width: 768px) {
    .article-header {
        padding: 15px 20px;
    }

    .article-header h1 {
        font-size: 24px;
        margin-bottom: 15px;
        line-height: 1.3;
    }

    .article-header .meta {
        margin-bottom: 10px;
    }

    .article-content {
        padding: 20px;
    }

    .article-content h2 {
        font-size: 22px;
        margin-top: 25px;
        margin-bottom: 12px;
    }

    .article-content h3 {
        font-size: 20px;
        margin-top: 20px;
        margin-bottom: 10px;
    }
}

/* More responsive adjustments for very small screens */
@media (max-width: 480px) {
    .article-header h1 {
        font-size: 20px;
    }

    .article-header .meta {
        font-size: 12px;
    }

    .article-content h2 {
        font-size: 20px;
    }

    .article-content h3 {
        font-size: 18px;
    }
}