
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,700;1,400&family=Cinzel:wght@700&display=swap');

* { box-sizing: border-box; }

body {
    font-family: 'Crimson Text', serif;
    background-color: #f4e4bc;
    color: #2b2b2b;
    margin: 0;
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 280px;
    background-color: #3e3328;
    color: #d4c5a3;
    overflow: hidden;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#menuItems {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

#sidebar h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.4em;
    text-align: center;
    border-bottom: 2px solid #8c7b64;
    padding-bottom: 15px;
    margin-bottom: 20px;
    color: #e8dcc5;
}

#sidebar h1 a {
    color: inherit;
    text-decoration: none;
}

.menu-category {
    font-weight: bold;
    text-transform: uppercase;
    margin-top: 20px;
    margin-bottom: 8px;
    color: #c9b085;
    font-size: 0.85em;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    user-select: none;
}

.menu-category:hover {
    color: #e8dcc5;
}

.menu-category::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.menu-category.collapsed::after {
    transform: rotate(-90deg);
}

.menu-section {
    overflow: hidden;
    max-height: 5000px;
    transition: max-height 0.3s ease;
}

.menu-section.collapsed {
    max-height: 0;
}

.menu-subcategory {
    font-weight: normal;
    text-transform: none;
    margin-top: 8px;
    margin-bottom: 4px;
    margin-left: 10px;
    color: #a8976f;
    font-size: 0.78em;
    letter-spacing: 0.3px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    user-select: none;
    border-left: 2px solid #5a4a36;
}

.menu-subcategory:hover {
    color: #d4c5a3;
    border-left-color: #c9b085;
}

.menu-subcategory::after {
    content: '▼';
    font-size: 0.6em;
    margin-left: 6px;
    transition: transform 0.3s ease;
}

.menu-subcategory.collapsed::after {
    transform: rotate(-90deg);
}

.menu-subsection {
    margin-left: 10px;
    border-left: 1px dashed #4a3e2f;
}

.menu-subsection .menu-item {
    margin-left: 18px;
    font-size: 0.92em;
}

.menu-item {
    display: block;
    padding: 6px 10px;
    margin-left: 10px;
    color: #d4c5a3;
    text-decoration: none;
    border-radius: 4px;
    font-size: 1em;
    border-left: 2px solid transparent;
}

.menu-item:hover {
    background-color: #5a4a3a;
    color: #fff;
    border-left-color: #8c7b64;
}

.menu-item.active {
    background-color: #8c2f2f;
    color: #fff;
    border-left-color: #d4c5a3;
}

.sidebar-footer {
    flex-shrink: 0;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #8c7b64;
}

.sidebar-footer a {
    display: block;
    padding: 8px 10px;
    color: #c9b085;
    text-decoration: none;
    border-radius: 4px;
}

.sidebar-footer a:hover {
    background: #5a4a3a;
}

#content-wrapper {
    flex-grow: 1;
    margin-left: 280px;
    overflow-y: auto;
    padding: 40px 60px;
    background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png');
    min-height: 100vh;
}

#content {
    max-width: 800px;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 50px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    border: 1px solid #d4c5a3;
}

h1, h2, h3 {
    font-family: 'Cinzel', serif;
    color: #4a3b2a;
}

h1 { border-bottom: 2px solid #8c2f2f; padding-bottom: 10px; }

a { color: #8c2f2f; }

blockquote {
    border-left: 4px solid #8c2f2f;
    margin: 20px 0;
    padding: 10px 20px;
    font-style: italic;
    color: #554;
    background-color: rgba(0,0,0,0.05);
}

code {
    background-color: #e0d0b0;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: monospace;
}

hr { border: 0; border-top: 1px solid #8c7b64; margin: 30px 0; }

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

th, td {
    border: 1px solid #8c7b64;
    padding: 10px;
    text-align: left;
}

th {
    background: #3e3328;
    color: #d4c5a3;
}

.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.gallery-item {
    border: 4px solid #d4c5a3;
    background: #fff;
    padding: 4px;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-caption {
    font-size: 0.85em;
    text-align: center;
    padding: 5px;
    font-style: italic;
    color: #554;
}

.nav-links {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #8c7b64;
}

.nav-links a {
    color: #8c2f2f;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid #8c2f2f;
    border-radius: 4px;
}

.nav-links a:hover {
    background: #8c2f2f;
    color: #fff;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #3e3328; }
::-webkit-scrollbar-thumb { background: #8c7b64; }
::-webkit-scrollbar-thumb:hover { background: #a69279; }

/* === READING PROGRESS BAR === */
#readingProgress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #8c2f2f, #c9b085);
    z-index: 9999;
    transition: width 0.1s ease-out;
}

/* === BACK TO TOP BUTTON === */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #3e3328;
    color: #d4c5a3;
    border: 2px solid #8c7b64;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
}

#backToTop:hover {
    background: #8c2f2f;
    border-color: #c9b085;
}

/* === DARK MODE === */
body.dark-mode {
    background-color: #1a1a1a;
    color: #d4c5a3;
}

body.dark-mode #content-wrapper {
    background-color: #1a1a1a;
    background-image: none;
}

body.dark-mode #content {
    background-color: rgba(30, 30, 30, 0.95);
    border-color: #444;
}

body.dark-mode h1, body.dark-mode h2, body.dark-mode h3 {
    color: #c9b085;
}

body.dark-mode blockquote {
    background-color: rgba(255,255,255,0.05);
    color: #aaa;
}

body.dark-mode th {
    background: #2a2a2a;
}

body.dark-mode td, body.dark-mode th {
    border-color: #444;
}

#darkModeToggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 20px);
    margin: 10px;
    padding: 8px;
    background: #2e2820;
    color: #d4c5a3;
    border: 1px solid #8c7b64;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#darkModeToggle:hover {
    background: #5a4a3a;
}

/* === TABLE OF CONTENTS === */
#toc {
    background: rgba(62, 51, 40, 0.1);
    border: 1px solid #8c7b64;
    border-radius: 6px;
    padding: 15px 20px;
    margin-bottom: 30px;
}

body.dark-mode #toc {
    background: rgba(255,255,255,0.05);
}

#toc h4 {
    margin: 0 0 10px 0;
    color: #8c2f2f;
    font-family: 'Cinzel', serif;
}

#toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc li {
    padding: 4px 0;
}

#toc a {
    color: #4a3b2a;
    text-decoration: none;
    font-size: 0.95em;
}

body.dark-mode #toc a {
    color: #c9b085;
}

#toc a:hover {
    color: #8c2f2f;
    text-decoration: underline;
}

#toc .toc-h3 {
    margin-left: 15px;
    font-size: 0.9em;
}

/* === READING TIME === */
.reading-time {
    display: inline-block;
    background: #3e3328;
    color: #d4c5a3;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-bottom: 20px;
}

/* === LIGHTBOX === */
#lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

#lightbox.show {
    display: flex;
}

#lightbox img {
    max-width: 90%;
    max-height: 90%;
    border: 4px solid #d4c5a3;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

#lightbox .close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
}

/* Make content images clickable */
#content img {
    cursor: pointer;
    transition: transform 0.2s;
}

#content img:hover {
    transform: scale(1.02);
}

/* Mobile hamburger button */
#mobileMenuBtn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background: #3e3328;
    color: #d4c5a3;
    border: none;
    padding: 10px 14px;
    font-size: 24px;
    border-radius: 4px;
    cursor: pointer;
}

#mobileMenuBtn:hover {
    background: #5a4a3a;
}

/* Mobile overlay */
#sidebarOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    #mobileMenuBtn {
        display: block;
    }

    #sidebar {
        position: fixed;
        left: -300px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    #sidebar.open {
        left: 0;
    }

    #sidebarOverlay.show {
        display: block;
    }

    #content-wrapper {
        margin-left: 0;
        padding: 60px 15px 20px 15px;
    }

    #content {
        padding: 20px;
    }

    body {
        flex-direction: column;
    }

    .nav-links {
        flex-direction: column;
        gap: 10px;
    }

    .nav-links a {
        text-align: center;
    }
}
