/* Base styles */
body {
    position: relative;
    background-color: #14202e; /* Darker blue */
    color: #f8f4e8; /* Lighter cream */
    font-family: 'Lato', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 400; /* Regular weight */
    line-height: 1.7; /* Increased line height for better readability */
    margin: 0;
    padding: 0;
    font-size: 18px; /* Base font size */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Contact icon in top right - Luxe library aesthetic */
.contact-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,
        rgba(200, 160, 90, 0.15),
        rgba(228, 204, 160, 0.1)
    );
    border-radius: 50%;
    color: #c8a05a;
    transition: all 0.3s ease;
    z-index: 100;
    border: 2px solid rgba(200, 160, 90, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(228, 204, 160, 0.2);
}

.contact-icon:hover {
    background: linear-gradient(135deg,
        rgba(228, 204, 160, 0.25),
        rgba(200, 160, 90, 0.2)
    );
    color: #e4cca0;
    border-color: rgba(228, 204, 160, 0.5);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(200, 160, 90, 0.3),
                inset 0 1px 0 rgba(228, 204, 160, 0.3);
}

.contact-icon svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Custom scrollbar styling */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(200, 160, 90, 0.5) rgba(20, 32, 46, 0.5);
}

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(20, 32, 46, 0.5);
    border-left: 1px solid rgba(228, 204, 160, 0.1);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg,
        rgba(228, 204, 160, 0.3),
        rgba(180, 140, 70, 0.4),
        rgba(228, 204, 160, 0.3)
    );
    border-radius: 6px;
    border: 2px solid rgba(20, 32, 46, 0.3);
    box-shadow: inset 0 0 6px rgba(228, 204, 160, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg,
        rgba(228, 204, 160, 0.5),
        rgba(200, 160, 90, 0.6),
        rgba(228, 204, 160, 0.5)
    );
    box-shadow: inset 0 0 8px rgba(228, 204, 160, 0.3);
}

::-webkit-scrollbar-corner {
    background: rgba(20, 32, 46, 0.5);
}

progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: none;
    background-color: transparent;
    color: #8fe2e1;
    z-index: 1000;
}

progress::-webkit-progress-bar {
    background-color: transparent;
}

progress::-webkit-progress-value {
    background-color: #8fe2e1;
}

progress::-moz-progress-bar {
    background-color: #8fe2e1;
}

.container {
    padding-top: 20px; /* Add some space at the top for the progress bar */
    max-width: 700px; /* Slightly narrower for optimal line length */
    margin: 0 auto;
    padding: 40px 20px;
}

/* Typography */
h1, h2, h3, h4 {
    font-family: 'Merriweather', 'Georgia', serif;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
    letter-spacing: -0.02em; /* Slight negative letter-spacing for headers */
}

h1 {
    font-size: 2.5em;
    color: #f0e0be;
    font-weight: 700; /* Bold */
}

h2 {
    font-size: 2em;
    color: #e4cca0;
    font-weight: 600; /* Semi-bold */
}

h3 {
    font-size: 1.5em;
    color: #d8b882;
    font-weight: 600; /* Semi-bold */
}

h4 {
    font-size: 1.25em;
    color: #cca464;
    font-weight: 600; /* Semi-bold */
}

p {
    margin-bottom: 1.5em;
    max-width: 70ch; /* Optimal line length for readability */
}

/* Links */
a {
    color: #8fe2e1;
    text-decoration: none;
    border-bottom: 1px solid rgba(143, 226, 225, 0.3);
    transition: border-color 0.2s ease-in-out;
}

a:hover {
    border-color: #8fe2e1;
}

/* Reading enhancements */
@media (min-width: 768px) {
    body {
        font-size: 20px; /* Slightly larger font on bigger screens */
    }
    
    .container {
        padding: 60px 40px;
    }
}

/* Optional: Add a subtle texture to the background for more visual interest */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy+kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcm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YgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==');
    opacity: 0.02;
    z-index: -1;
}

/* Footer styles */
.footer {
    margin-top: 3em;
    padding-top: 1.5em;
    padding-bottom: 1.5em;
    border-top: 1px solid rgba(248, 244, 232, 0.2);
    text-align: center;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer a {
    color: #8fe2e1;
    text-decoration: none;
    transition: color 0.3s ease;
    margin-bottom: 1em;
}

.footer a:hover {
    color: #b0eded;
    text-decoration: underline;
}

.footer-contact {
    margin-bottom: 1em;
    font-size: 0.95em;
    color: #c8b898;
}

.copyright {
    font-size: 0.85em;
    color: #9e9889; /* A pleasing dark gray with good contrast */
    font-weight: 300; /* Light weight for subtlety */
    letter-spacing: 0.02em; /* Slight letter spacing for readability */
}

/* Writing samples list */
.writing-samples {
    padding-left: 0;
    list-style-type: none;
}

.writing-samples li {
    margin-bottom: 1.2em;
    display: flex;
    align-items: baseline;
    gap: 1.5em;
    position: relative;
}

.story-date {
    font-size: 0.75em;
    color: #9e9889;
    font-weight: 300;
    text-align: right;
    white-space: nowrap;
    position: absolute;
    left: -10em;
    width: 9em;
    padding-top: 0.5em;
}

@media (max-width: 950px) {
    .story-date {
        display: none;
    }
}

.writing-samples a {
    font-size: 1.1em;
    text-decoration: none;
    border-bottom: none;
    color: #8fe2e1;
    transition: color 0.3s ease;
    flex: 1;
}

.writing-samples a:hover {
    color: #b0eded;
    border-bottom: none;
}

/* Tag filtering */
.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-bottom: 1.5em;
}

.tag-pill {
    padding: 0.4em 0.9em;
    border-radius: 1.5em;
    font-size: 0.85em;
    background-color: rgba(228, 204, 160, 0.15);
    border: 1px solid rgba(228, 204, 160, 0.4);
    color: #e4cca0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
}

.tag-pill:hover {
    background-color: rgba(228, 204, 160, 0.25);
    border-color: rgba(228, 204, 160, 0.6);
}

.tag-pill.active {
    background-color: rgba(228, 204, 160, 0.35);
    border-color: #e4cca0;
    font-weight: 600;
}

.story-tags {
    display: flex;
    gap: 0.4em;
    flex-shrink: 0;
    margin-left: auto;
}

.story-tags .tag-pill {
    font-size: 0.65em;
    padding: 0.2em 0.5em;
    background-color: rgba(228, 204, 160, 0.08);
    border: 1px solid rgba(228, 204, 160, 0.2);
    color: #9e9889;
    font-weight: 400;
}

.story-item {
    opacity: 1;
    max-height: 100px;
    overflow: visible;
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
}

.story-item.hidden {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        font-size: 14px;
        padding: 10px;
    }

    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .writing-samples a {
        font-size: 1em;
    }

    .footer {
        font-size: 0.8em;
    }
}

/* Section Break */
.section-break {
    border: none;
    height: 2px;
    background-image: linear-gradient(
        90deg,
        transparent,
        transparent 20%,
        #e4cca0 20%,
        #e4cca0 80%,
        transparent 80%,
        transparent 100%
    );
    position: relative;
    margin: 2em 0;
    overflow: visible;
}

.section-break::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    background-color: #14202e; /* Background color */
    border: 2px solid #e4cca0; /* Diamond color */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Additional refinements */
blockquote {
    border-left: 3px solid #8fe2e1;
    margin: 1.5em 0;
    padding-left: 1em;
    font-style: italic;
    color: #d1c7b7;
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
    background-color: rgba(248, 244, 232, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

pre {
    background-color: rgba(248, 244, 232, 0.1);
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 0.9em;
}

pre code {
    background-color: transparent;
    padding: 0;
}

/* Improved list styling */
ul, ol {
    padding-left: 1.5em;
    margin-bottom: 1.5em;
}

li {
    margin-bottom: 0.5em;
}

/* Table styling */
table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1.5em;
}

th, td {
    border: 1px solid rgba(248, 244, 232, 0.2);
    padding: 0.5em;
    text-align: left;
}

th {
    background-color: rgba(248, 244, 232, 0.1);
    font-weight: 600;
}

/* Date styling */
.date {
    font-family: 'Lato', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9em;
    color: #b0a08a;
    margin-bottom: 0.5em;
}

/* Chapter navigation - Desktop */
.chapter-nav {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
}

.chapter-nav-indicator {
    position: absolute;
    left: 0;
    top: 0;
    width: 50px;
    height: 100%;
    cursor: pointer;
}

.chapter-nav-indicator::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    border: 2px solid #e4cca0;
    border-right: none;
    border-top: none;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.chapter-nav:hover .chapter-nav-indicator::before {
    left: 14px;
    opacity: 0.8;
}

.chapter-nav-content {
    background-color: rgba(20, 32, 46, 0.95);
    border: 1px solid rgba(228, 204, 160, 0.3);
    border-left: none;
    border-radius: 0 8px 8px 0;
    min-width: 200px;
    max-width: 250px;
    height: 70vh;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
}

.chapter-nav:hover .chapter-nav-content {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Mobile chapter navigation */
.chapter-nav-mobile-toggle {
    display: none;
}

.chapter-nav-mobile-overlay {
    display: none;
}

@media (max-width: 768px) {
    .chapter-nav-indicator {
        display: none;
    }

    .chapter-nav-content {
        display: none;
    }

    .chapter-nav-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5em;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 50px;
        background: rgba(20, 32, 46, 0.95);
        border-top: 1px solid rgba(228, 204, 160, 0.3);
        cursor: pointer;
        z-index: 1000;
        backdrop-filter: blur(10px);
        transition: all 0.3s ease;
    }

    .chapter-nav-mobile-toggle::before {
        content: '';
        width: 8px;
        height: 8px;
        border: 2px solid #e4cca0;
        transform: rotate(45deg);
        background-color: transparent;
    }

    .chapter-nav-mobile-toggle::after {
        content: 'Contents';
        font-family: 'Merriweather', serif;
        font-size: 0.9em;
        color: #e4cca0;
        letter-spacing: 0.05em;
    }

    .chapter-nav-mobile-toggle:active {
        background: rgba(20, 32, 46, 1);
    }

    /* Add padding to body to account for fixed bottom bar */
    body {
        padding-bottom: 50px;
    }

    .chapter-nav-mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.8);
        z-index: 1001;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .chapter-nav-mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    .chapter-nav-mobile-overlay .chapter-nav-content {
        display: flex;
        position: absolute;
        bottom: 50px;
        left: 0;
        right: 0;
        height: 70vh;
        min-width: auto;
        max-width: none;
        border: none;
        border-top: 2px solid rgba(228, 204, 160, 0.5);
        border-radius: 16px 16px 0 0;
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        animation: slideUp 0.3s ease;
    }

    .chapter-nav-mobile-overlay .chapter-nav a {
        color: #b0a08a;
    }

    .chapter-nav-mobile-overlay .chapter-nav a:hover {
        color: #e4cca0;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .chapter-nav-mobile-close {
        position: sticky;
        top: 0;
        background: rgba(20, 32, 46, 0.95);
        padding: 1em;
        text-align: center;
        border-bottom: 1px solid rgba(228, 204, 160, 0.2);
        cursor: pointer;
        z-index: 10;
    }

    .chapter-nav-mobile-close::before {
        content: '';
        display: inline-block;
        width: 12px;
        height: 12px;
        border: 2px solid #e4cca0;
        transform: rotate(45deg);
        background-color: transparent;
    }
}

.chapter-section {
    padding: 1.5em 1.5em 1.5em 1em;
    flex-shrink: 0;
}

.chapter-home {
    padding: 1em 1.5em 1em 1em;
}

/* Tab navigation */
.chapter-tabs {
    display: flex;
    gap: 0.5em;
    padding: 0 1.5em 0 1em;
    border-bottom: 1px solid rgba(228, 204, 160, 0.2);
}

.chapter-tab {
    background: transparent;
    border: none;
    color: #9e9889;
    font-family: 'Merriweather', serif;
    font-size: 0.85em;
    font-weight: 600;
    padding: 0.75em 1em;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    bottom: -1px;
}

.chapter-tab:hover {
    color: #e4cca0;
}

.chapter-tab.active {
    color: #e4cca0;
    border-bottom-color: #e4cca0;
}

.chapter-tab-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.tab-panel {
    display: none;
    padding: 1em 1.5em 1.5em 1em;
}

.tab-panel.active {
    display: block;
}

.chapter-home-link {
    display: inline-block;
    color: #e4cca0;
    text-decoration: none;
    border-bottom: none;
    font-size: 0.9em;
    font-weight: 600;
    padding: 0.5em 0;
    transition: color 0.2s ease;
}

.chapter-home-link:hover {
    color: #8fe2e1;
    border-bottom: none;
}

.chapter-list,
.related-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-tab-content::-webkit-scrollbar {
    width: 6px;
}

.chapter-tab-content::-webkit-scrollbar-track {
    background: rgba(228, 204, 160, 0.1);
    border-radius: 3px;
}

.chapter-tab-content::-webkit-scrollbar-thumb {
    background: rgba(228, 204, 160, 0.3);
    border-radius: 3px;
}

.chapter-tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(228, 204, 160, 0.5);
}

.chapter-nav-title {
    font-family: 'Merriweather', serif;
    font-size: 0.9em;
    font-weight: 600;
    color: #e4cca0;
    margin-bottom: 0.75em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid rgba(228, 204, 160, 0.2);
}

.chapter-nav-divider {
    height: 1px;
    background: rgba(228, 204, 160, 0.2);
    margin: 0;
    flex-shrink: 0;
}

.chapter-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-nav li {
    margin-bottom: 0.5em;
}

.chapter-nav a {
    color: #b0a08a;
    text-decoration: none;
    border-bottom: none;
    font-size: 0.85em;
    line-height: 1.4;
    display: block;
    padding: 0.3em 0;
    transition: color 0.2s ease;
}

.chapter-nav a:hover {
    color: #e4cca0;
    border-bottom: none;
}

.current-story {
    color: #e4cca0;
    font-size: 0.85em;
    line-height: 1.4;
    padding: 0.3em 0;
    font-weight: 600;
    position: relative;
    padding-left: 1em;
}

.current-story::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 6px;
    height: 6px;
    border: 2px solid #e4cca0;
    transform: rotate(45deg);
    background-color: transparent;
}

/* Chat-style dialogue */
.chat-container {
    margin: 1.5em 0;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.chat-message {
    max-width: 70%;
    padding: 0.75em 1em;
    border-radius: 1em;
    line-height: 1.4;
}

.chat-left {
    align-self: flex-start;
    background-color: rgba(30, 60, 90, 0.4); /* Deep velvet blue */
    border: 1px solid rgba(70, 120, 170, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chat-right {
    align-self: flex-end;
    background-color: rgba(180, 140, 70, 0.3); /* Rich gold/brass */
    border: 1px solid rgba(200, 160, 90, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chat-username {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 0.25em;
    opacity: 0.8;
}

.chat-right .chat-username {
    text-align: right;
}