/* BobCAD-CAM Help System Styles */

:root {
    --primary-color: #0066cc;
    --primary-dark: #004d99;
    --secondary-color: #1a1a2e;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --text-color: #333;
    --text-muted: #666;
    --border-color: #e0e0e0;
    --bg-light: #f8f9fa;
    --sidebar-width: 280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden; /* prevent horizontal overflow on mobile */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background: var(--bg-light);
}

/* Header */
.site-header {
    background: var(--secondary-color);
    color: white;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1000; /* must be above sidebar drawer (900) and overlay (800) */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
}

.logo img {
    height: 32px;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: white;
}

.search-box {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    width: 250px;
    font-size: 0.9rem;
}

.search-box button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.search-box button:hover {
    background: var(--primary-dark);
}

/* Page Container */
.page-container {
    display: flex;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    min-height: calc(100vh - 60px - 60px);
    /* Do NOT use overflow-x: hidden here — it clips scroll wrappers inside */
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    overflow-y: auto;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
}

.sidebar-nav .nav-list {
    list-style: none;
}

/* Expand / Collapse All controls row */
.sidebar-controls {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 1rem 0.4rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.25rem;
}

.sidebar-controls a {
    font-size: 0.72rem;
    color: var(--primary-color);
    text-decoration: none;
    opacity: 0.75;
    white-space: nowrap;
}

.sidebar-controls a:hover {
    opacity: 1;
    text-decoration: underline;
}

.sidebar-controls-sep {
    color: var(--border-color);
    font-size: 0.75rem;
    user-select: none;
}

.nav-item a {
    display: block;
    padding: 0.5rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.nav-item a:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-item.active > a,
.nav-item a.active {
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
    background: rgba(0, 123, 255, 0.1);
}

.nav-children {
    list-style: none;
    padding-left: 0;
}

/* ========================================
   N-Level Hierarchical Navigation
   Supports up to 10 levels deep
   ======================================== */

/* Base styles for all navigation items */
.sidebar-nav .nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-list li {
    margin: 0;
}

/* =============================================
   OLD HELP SYSTEM STYLE - Dark Category Headers
   ============================================= */

/* Top-level category headers - dark block style like old help */
.nav-category {
    margin-bottom: 2px;
}

.nav-category > .category-title,
.nav-category > .nav-category-title {
    display: block;
    padding: 0.65rem 1rem;
    background: linear-gradient(180deg, #3d5a80 0%, #2d4a6e 100%);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    border-left: 3px solid #1d3557;
    transition: all 0.15s ease;
}

.nav-category > .category-title:hover,
.nav-category > .nav-category-title:hover {
    background: linear-gradient(180deg, #4d6a90 0%, #3d5a7e 100%);
    border-left-color: #f4a261;
}

/* Category expand indicator */
.nav-category > .category-title::before,
.nav-category > .nav-category-title::before {
    content: "▶";
    font-size: 0.6rem;
    margin-right: 0.5rem;
    display: inline-block;
    transition: transform 0.15s ease;
    opacity: 0.8;
}

.nav-category.expanded > .category-title::before,
.nav-category.expanded > .nav-category-title::before {
    transform: rotate(90deg);
}

/* Category children container */
.nav-category > ul {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f8f9fa;
    border-left: 3px solid #e0e0e0;
}

.nav-category.expanded > ul {
    display: block;
}

/* =============================================
   Folder toggles (nested categories/subcategories)
   ============================================= */
.nav-folder {
    display: block;
    padding: 0.5rem 1rem 0.5rem 1.25rem;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    background: transparent;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
    position: relative;
}

.nav-folder:hover {
    background: var(--bg-light);
    border-left-color: var(--primary-color);
}

/* Expand/collapse arrow */
.nav-folder::before {
    content: "▶";
    font-size: 0.6rem;
    margin-right: 0.5rem;
    display: inline-block;
    transition: transform 0.15s ease;
    opacity: 0.7;
}

/* =============================================
   Links inside navigation
   ============================================= */
.sidebar-nav .nav-list a {
    display: block;
    padding: 0.4rem 1rem 0.4rem 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-list a:hover {
    background: #e8f4fc;
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.sidebar-nav .nav-list a.active {
    background: rgba(0, 102, 204, 0.1);
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

/* =============================================
   Hierarchical nesting - Items with children
   ============================================= */
.has-children > .nav-children {
    display: none;
    margin-left: 0;
    border-left: 1px solid #e0e0e0;
    padding-left: 0.5rem;
}

/* Expanded state */
.has-children.expanded > .nav-children,
.has-children.open > .nav-children {
    display: block;
}

.has-children.expanded > .nav-folder::before,
.has-children.open > .nav-folder::before {
    transform: rotate(90deg);
}

/* =============================================
   Depth-based styling
   ============================================= */
.nav-children { padding-left: 0.5rem; }
.nav-children .nav-children { padding-left: 0.5rem; }

/* Adjust font size at deeper levels */
.nav-children .nav-folder,
.nav-children a { font-size: 0.84rem; }
.nav-children .nav-children .nav-folder,
.nav-children .nav-children a { font-size: 0.82rem; }
.nav-children .nav-children .nav-children .nav-folder,
.nav-children .nav-children .nav-children a { font-size: 0.8rem; }

/* Visual hierarchy for folder colors */
.nav-children .nav-folder { font-weight: 500; }
.nav-children .nav-children .nav-folder { font-weight: 500; color: #444; }
.nav-children .nav-children .nav-children .nav-folder { font-weight: 500; color: #555; }

/* Ancestor highlighting (path to current page) */
.has-children.expanded > .nav-folder {
    color: var(--primary-color);
    font-weight: 600;
}

/* Legacy category/subcategory support (for backward compatibility) */
.nav-category {
    margin-bottom: 0.25rem;
}

.nav-category-title {
    display: block;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--secondary-color);
    background: var(--bg-light);
    cursor: pointer;
    user-select: none;
    border-left: 3px solid var(--primary-color);
    transition: all 0.2s;
}

.nav-category-title:hover {
    background: #e8e8e8;
}

.nav-category-title::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s;
    font-size: 0.85rem;
    color: var(--primary-color);
}

.nav-category.open > .nav-category-title::before {
    transform: rotate(90deg);
}

.nav-category > .nav-children {
    display: none;
    padding-left: 0;
}

.nav-category.open > .nav-children {
    display: block;
}

/* Subcategories */
.nav-subcategory {
    margin: 0.125rem 0;
}

.nav-subcat-title {
    display: block;
    padding: 0.5rem 1.5rem 0.5rem 2rem;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.nav-subcat-title:hover {
    color: var(--primary-color);
    background: var(--bg-light);
}

.nav-subcat-title::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s;
    font-size: 0.7rem;
    color: var(--primary-color);
    opacity: 0.8;
}

.nav-subcategory.open > .nav-subcat-title::before,
.nav-subcategory.expanded > .nav-subcat-title::before {
    transform: rotate(90deg);
}

.nav-subcategory > .nav-children {
    display: none;
    padding-left: 0.5rem;
}

.nav-subcategory.open > .nav-children,
.nav-subcategory.expanded > .nav-children {
    display: block;
}

.nav-subcategory .nav-item a {
    padding-left: 2.5rem;
    font-size: 0.85rem;
}

/* More indicator */
.nav-more {
    padding: 0.25rem 1.5rem 0.25rem 2.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.has-children > a::after {
    content: '›';
    float: right;
    margin-right: 1rem;
    transition: transform 0.2s;
}

.has-children.open > a::after {
    transform: rotate(90deg);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    background: white;
    min-width: 0;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 1.5rem;
}

.breadcrumb ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb li {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.breadcrumb li:not(:last-child)::after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--border-color);
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Article Styles */
.help-page {
    max-width: 800px;
}

.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.ai-badge .badge,
.version-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.ai-badge .badge {
    background: #e9ecef;
    color: var(--text-muted);
}

.version-badge {
    background: #cce5ff;
    color: #004085;
}

.page-content {
    font-size: 1rem;
    line-height: 1.8;
}

/* Section headers with underline border like old help system */
/* Target .article-content and account for nested body tag from MadCap content */
.page-content h2,
.article-content h2,
.article-content body h2,
.content-article h2 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    padding: 0.5rem 0;
    border-bottom: 3px solid #5ba3c7;
    color: var(--text-color);
    font-weight: 600;
}

.page-content h3,
.article-content h3,
.article-content body h3,
.content-article h3 {
    font-size: 1.25rem;
    margin: 1.75rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #7bb8d4;
    color: var(--text-color);
    font-weight: 600;
}

.page-content h4,
.article-content h4,
.article-content body h4,
.content-article h4 {
    font-size: 1.1rem;
    margin: 1.25rem 0 0.5rem;
    color: #444;
    font-weight: 600;
}

/* Main section wrapper boxes (like "Operation Parameters", "Cycle Type" sections) */
/* SplitDecision1 = outer section wrapper with white/light background */
.article-content .SplitDecision1,
.article-content body .SplitDecision1 {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

/* Subsection boxes inside main sections (like "Hole Groups") */
/* SplitDecision2 = nested subsection with slightly different background */
.article-content .SplitDecision2,
.article-content body .SplitDecision2,
.page-content .content-box,
.page-content .info-box {
    background: #e8f4f8;
    border-left: 4px solid #5ba3c7;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    border-radius: 0 4px 4px 0;
}

/* Headers inside main section boxes - keep the underline */
.article-content .SplitDecision1 > h3,
.article-content body .SplitDecision1 > h3 {
    margin-top: 0;
}

/* Headers inside subsection boxes - no border needed */
.article-content .SplitDecision2 h3,
.article-content .SplitDecision2 h4,
.article-content body .SplitDecision2 h3,
.article-content body .SplitDecision2 h4 {
    margin-top: 0;
    color: #2c5a7c;
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 0;
}

/* Indented content blocks */
.page-content blockquote,
.article-content blockquote,
.page-content .indent-block {
    background: #f0f7fa;
    border-left: 4px solid #5ba3c7;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-style: normal;
    color: var(--text-color);
}

.page-content p {
    margin-bottom: 1rem;
}

.page-content ul,
.page-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.page-content li {
    margin-bottom: 0.5rem;
}

.page-content code {
    background: #f4f4f4;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.page-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1.5rem 0;
    position: relative;
}

.page-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.copy-code {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255,255,255,0.1);
    color: #888;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
}

.copy-code:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* Global image containment — !important overrides inline width/height attrs from imported HTML */
.page-content img,
.article-content img,
.content-article img,
.topic-content img,
.main-content img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 6px;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: zoom-in;
    display: block;
}

/* blockquote styling moved to content box section above */

.page-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.page-content th,
.page-content td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.page-content th {
    background: var(--bg-light);
    font-weight: 600;
}

.page-content tr:hover {
    background: var(--bg-light);
}

/* Related Content */
.related-content {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: 6px;
}

.related-content h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.related-content ul {
    list-style: none;
    padding: 0;
}

.related-content li {
    margin-bottom: 0.5rem;
}

.related-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.related-content a:hover {
    text-decoration: underline;
}

/* Page Footer */
.page-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.keywords {
    margin-bottom: 0.5rem;
}

.keyword {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--bg-light);
    border-radius: 3px;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Table of Contents */
.table-of-contents {
    position: fixed;
    right: 2rem;
    top: 80px;
    width: 200px;
    padding: 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
}

.table-of-contents h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.table-of-contents ul {
    list-style: none;
}

.table-of-contents a {
    color: var(--text-muted);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.5rem;
}

.table-of-contents a:hover,
.table-of-contents a.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

/* Footer */
.site-footer {
    background: var(--secondary-color);
    color: rgba(255,255,255,0.7);
    padding: 1.5rem 2rem;
    text-align: center;
    font-size: 0.875rem;
}

.build-info {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}

/* Home Page */
.home-page {
    max-width: 1200px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #16213e 100%);
    color: white;
    margin: -2rem -2rem 1.5rem -2rem;
}

.hero h1 {
    font-size: 1.75rem;
    margin-bottom: 0.35rem;
}

.hero p {
    font-size: 0.95rem;
    opacity: 0.9;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.search-hero {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
    gap: 0.5rem;
}

.search-hero input {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
}

.search-hero button {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

.products {
    margin-bottom: 3rem;
}

.products h2 {
    text-align: center;
    margin-bottom: 2rem;
}

/* Product Grid - supports both class names */
.product-grid,
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
    padding: 0 1.5rem;
}

@media (max-width: 1200px) {
    .product-grid,
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .product-grid,
    .products-grid {
        grid-template-columns: 1fr;
    }
}

.product-card {
    background: white;
    padding: 1.25rem 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
}

.product-icon {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.product-card h3 {
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
    font-size: 1rem;
}

.product-card .product-desc {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.4;
}

.product-card .topic-count {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.product-card .product-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.2s;
    margin-top: auto;
}

.product-card .product-btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.page-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.product-link {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

.product-link:hover {
    background: var(--primary-dark);
}

.quick-links h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.link-group {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.link-group h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.link-group ul {
    list-style: none;
}

.link-group li {
    margin-bottom: 0.5rem;
}

.link-group a {
    color: var(--primary-color);
    text-decoration: none;
}

.link-group a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 1024px) {
    .table-of-contents {
        display: none;
    }
}

/* Home Page Search Section */
.search-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 3rem 2rem;
    border-radius: 12px;
    text-align: center;
    margin-top: 2rem;
}

.search-section h2 {
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.search-section .search-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.global-search {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    gap: 0.5rem;
}

.global-search input {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.global-search input:focus {
    border-color: var(--primary-color);
}

.global-search button {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.global-search button:hover {
    background: var(--primary-dark);
}

/* =============================================
   MOBILE UI COMPONENTS
   (overlay, hamburger buttons, table scroll)
   ============================================= */

/* Dark backdrop that dims content when sidebar drawer is open */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 800;
    cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* Sidebar drawer toggle button (☰) — hidden on desktop */
.sidebar-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.13);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
    line-height: 1;
}
.sidebar-toggle-btn:hover { background: rgba(255, 255, 255, 0.22); }

/* Nav hamburger button — hidden on desktop, shown on phones ≤ 480px */
.nav-hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.13);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
    transition: background 0.2s;
    line-height: 1;
}
.nav-hamburger-btn:hover { background: rgba(255, 255, 255, 0.22); }

/* Prevent body scroll when a drawer is open */
body.nav-drawer-open { overflow: hidden; }

/* Scrollable table wrapper (added by JS on mobile) */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin: 1rem 0;
}
.table-scroll-wrapper table { margin: 0; }

/* =============================================
   TABLET + PHONE  ≤ 1024px  — sidebar drawer
   ============================================= */
@media (max-width: 1024px) {
    /* Show the sidebar hamburger toggle button */
    .sidebar-toggle-btn { display: flex; }

    /* Sidebar becomes an off-canvas drawer */
    .sidebar {
        position: fixed;
        top: 60px;                      /* sit below the sticky header */
        left: -300px;                   /* hidden off-screen */
        width: 280px;
        height: calc(100vh - 60px);
        z-index: 900;
        background: white;
        border-right: 1px solid var(--border-color);
        box-shadow: none;
        transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0.75rem 0;
    }
    .sidebar.open {
        left: 0;
        box-shadow: 6px 0 28px rgba(0, 0, 0, 0.22);
    }

    /* Page container: single column, full width */
    .page-container {
        flex-direction: column;
        max-width: 100%;
    }
    .main-content {
        padding: 1.5rem 1.25rem;
        width: 100%;
    }

    /* Content: images always contained on mobile — !important beats inline attrs */
    .article-content img,
    .content-article img,
    .topic-content img,
    .page-content img,
    .main-content img {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
    }

    /* Touch-friendly nav links (min 44 px tap target) */
    .sidebar-nav .nav-list a {
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .nav-folder {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Long words / URLs: break to avoid overflow */
    .main-content,
    .article-content,
    .content-article,
    .topic-content {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Make the article content area itself scrollable horizontally as a
       last-resort fallback for any wide content the JS wrapper doesn't catch */
    .article-content,
    .topic-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure the table scroll wrapper is always visible on mobile */
    .table-scroll-wrapper {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        border-radius: 4px;
    }
}

/* =============================================
   TABLET  769 – 1024px  — header stays 1 row
   ============================================= */
@media (max-width: 1024px) and (min-width: 769px) {
    .header-content {
        height: 60px;
        flex-wrap: nowrap;
    }
    /* Sidebar toggle on the left, next to logo */
    .sidebar-toggle-btn { order: 1; margin-right: 0.5rem; }
    .logo             { order: 2; }
    .main-nav         { order: 3; }
    .search-box       { order: 4; }
}

/* =============================================
   PHONE  ≤ 768px  — header wraps, padding down
   ============================================= */
@media (max-width: 768px) {
    .site-header { padding: 0 1rem; }

    .header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 0.6rem 0;
        gap: 0.5rem;
    }
    /* Row 1: toggle btn + logo */
    .sidebar-toggle-btn { order: 1; }
    .logo               { order: 2; flex: 1; }
    /* Row 2 (phones ≤ 480 only): nav hamburger pushed to row 1 end */
    /* Row 2: search box */
    .search-box {
        order: 3;
        width: 100%;
        margin-left: 0;
    }
    .search-box input { flex: 1; width: auto; }
    /* Row 3: nav links */
    .main-nav {
        order: 4;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.25rem 0;
    }

    .main-content { padding: 1rem; }

    .hero { padding: 1.5rem 1rem; }
    .hero h1 { font-size: 1.6rem; }
    .search-hero { flex-direction: column; }
}

/* =============================================
   PHONE  ≤ 480px  — nav collapses to hamburger
   ============================================= */
@media (max-width: 480px) {
    /* Show the nav hamburger, hide the nav link list */
    .nav-hamburger-btn { display: flex; }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;           /* drop below header */
        left: 0;
        right: 0;
        background: var(--secondary-color);
        padding: 0.5rem 1rem 1rem;
        flex-direction: column;
        gap: 0;
        z-index: 990;
        box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    }
    .main-nav.nav-open { display: flex; }
    .main-nav a {
        padding: 0.75rem 0.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        font-size: 0.95rem;
    }
    .main-nav a:last-child { border-bottom: none; }

    /* Header: position:relative so dropdown positions correctly */
    .site-header { position: sticky; }
    .header-content {
        position: relative;
        flex-wrap: nowrap;
        height: 60px;
        padding: 0 0.75rem;
        gap: 0.5rem;
    }
    .sidebar-toggle-btn { order: 1; }
    .logo               { order: 2; flex: 1; }
    .nav-hamburger-btn  { order: 3; margin-left: 0; }
    /* Hide search from header on small phones; search is on the search page */
    .search-box         { display: none; }

    .main-content { padding: 0.875rem; }
    .hero h1 { font-size: 1.4rem; }

    /* Search page: stack filter above results */
    .search-filter-sidebar {
        width: 100% !important;
        position: static !important;
        height: auto !important;
        border-right: none !important;
        border-bottom: 1px solid #e2e8f0;
    }
}


/* ── Image Lightbox ──────────────────────────────────────────────────────── */
#img-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-top: 4rem; /* room for the controls bar */
}
#img-lightbox.active {
    display: flex;
}
body.lightbox-open {
    overflow: hidden;
}
#img-lightbox #lb-img {
    max-width: 95vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
    cursor: default;
    transition: transform 0.2s ease;
    user-select: none;
}

/* Controls bar: [−] [+] [×] — fixed at top-right */
#lb-controls {
    position: fixed;
    top: 0.75rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 10001;
}

/* Shared styles for all three lightbox buttons */
#lb-zoom-out,
#lb-zoom-in,
#lb-close {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    padding: 0;
}
#lb-zoom-out:hover,
#lb-zoom-in:hover,
#lb-close:hover  { background: rgba(255, 255, 255, 0.32); }

#lb-zoom-out:disabled,
#lb-zoom-in:disabled { opacity: 0.35; cursor: not-allowed; }

/* Close button is slightly larger and has no border to distinguish it */
#lb-close {
    font-size: 1.75rem;
    border-color: transparent;
    margin-left: 0.25rem; /* small gap between zoom and close */
}

/* Mobile: tighter layout */
@media (max-width: 480px) {
    #lb-controls { top: 0.5rem; right: 0.5rem; gap: 0.3rem; }
    #lb-zoom-out, #lb-zoom-in, #lb-close { width: 2.2rem; height: 2.2rem; font-size: 1.25rem; }
    #lb-close { font-size: 1.5rem; }
}

/* ── Mobile table scroll (applied by JS on all screen sizes) ─────────────── */
