/* Base layout */

body {
    margin: 0;
    padding: 0;
    background: #050509;
    font-family: Verdana, Arial, sans-serif;
    color: #e4e4e9;
    overflow-x: hidden;
}

@font-face {
    font-family: "VikingRunes";
    src: url("https://fonts.cdnfonts.com/s/20833/NordicaBlack-8MaJ.otf") format("opentype");
}

/* Background canvas */

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
}

/* Reading progress bar (Fixed + updated) */

#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    width: 0%;
    background: #ff4c6b;
    z-index: 9999;
    pointer-events: none;
    transition: width 0.12s linear;
    box-shadow: 0 0 8px #ff4c6b;
}

/* Sidebar */

.sidebar {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 190px;
    background: radial-gradient(circle at top left, #241129 0, #09060c 60%);
    border: 1px solid #3e3044;
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.9);
    padding: 10px 12px 12px 12px;
    z-index: 3;
    font-size: 12px;
}

.sidebar-title {
    font-family: "VikingRunes", serif;
    font-size: 18px;
    color: #f0dde9;
    text-shadow: 0 0 6px #b02a3d;
    margin-bottom: 6px;
}

.sidebar-links a {
    display: block;
    text-decoration: none;
    color: #f0e6ff;
    padding: 4px 0;
    font-size: 12px;
}

/* Smooth interactive transitions */

.nav-link,
.share-btn,
.reader-toggle,
.sidebar-links a,
.back-link a {
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.12s ease,
        box-shadow 0.12s ease;
}

.sidebar-links a:hover {
    color: #ff4c6b;
    transform: translateX(2px);
}

.sidebar-note {
    margin-top: 8px;
    font-size: 11px;
    color: #a89fba;
}

/* Main content panel */

.page-wrap {
    position: relative;
    z-index: 2;
    width: 900px;
    margin: 20px auto;
    background: #101018;
    border: 1px solid #3e3044;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
}

/* Top bar */

.top-bar {
    background: linear-gradient(to bottom, #231426, #130910);
    border-bottom: 1px solid #5b335f;
    padding: 10px 18px;
    height: 48px;
}

.top-table {
    width: 100%;
    border-collapse: collapse;
}

.logo-cell { text-align: left; }
.nav-cell { text-align: right; }

.site-title {
    font-family: "VikingRunes", serif;
    font-size: 30px;
    letter-spacing: 2px;
    color: #d93c4f;
    text-shadow: 0 0 6px #6b1031;
}

.nav-link {
    font-size: 13px;
    text-decoration: none;
    color: #f0e6ff;
    padding: 6px 14px;
    border: 1px solid #8e4ba3;
    background: linear-gradient(to bottom, #2c1834, #150b19);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    margin-left: 6px;
}

.nav-link:hover {
    background: #3a2046;
    border-color: #ff4c6b;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}

.nav-link:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Content frame */

.content-frame {
    margin: 0 12px 12px 12px;
    border: 1px solid #3e3044;
    background: #0c0c11;
}

.content-header {
    background: linear-gradient(to right, #251129, #130812);
    border-bottom: 1px solid #4a314f;
    padding: 10px 14px;
}

.content-header h1 {
    margin: 0;
    font-family: "VikingRunes", serif;
    font-size: 24px;
    color: #f0dde9;
    text-shadow: 0 0 5px #b02a3d;
}

.content-subtitle {
    font-size: 11px;
    color: #a89fba;
    margin-top: 4px;
}

/* Meta line & share bar */

.meta-line {
    margin-top: 6px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-count {
    color: #c8c3d3;
}

.reader-toggle {
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid #5b335f;
    background: #1a0f1f;
    color: #f0e6ff;
    cursor: pointer;
}

.reader-toggle:hover {
    background: #3a2046;
    border-color: #ff4c6b;
    transform: translateY(-1px);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

.reader-toggle:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.share-bar {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.share-btn {
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid #4a314f;
    background: #140b18;
    color: #f0e6ff;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
}

.share-btn:hover {
    background: #3a2046;
    border-color: #ff4c6b;
    transform: translateY(-1px);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

.share-btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Content */

.content-body {
    padding: 16px 18px 20px 18px;
    font-size: 13px;
    line-height: 1.7;
    color: #e0dde8;
}

.content-body h2 {
    font-size: 16px;
    margin: 18px 0 6px 0;
    color: #ff4c6b;
    border-bottom: 1px solid #39213f;
    padding-bottom: 3px;
}

.content-body h3 {
    font-size: 14px;
    margin: 14px 0 4px 0;
    color: #f28da1;
}

.content-body p {
    margin: 8px 0;
}

.content-body ul {
    margin: 6px 0 10px 18px;
    padding: 0;
}

.content-body li {
    margin: 4px 0;
}

/* Highlight and notes */

.highlight-box {
    border: 1px solid #5a395f;
    background: rgba(23, 10, 24, 0.9);
    padding: 10px 12px;
    margin: 10px 0 16px 0;
    font-size: 12px;
}

.highlight-title {
    font-weight: bold;
    color: #ff667a;
}

.note-box {
    border: 1px solid #5a395f;
    background: rgba(23, 10, 24, 0.9);
    padding: 10px 12px;
    margin: 10px 0 16px 0;
    font-size: 12px;
}

.note-title {
    font-weight: bold;
    color: #ff667a;
}

.back-link {
    font-size: 12px;
    margin-bottom: 10px;
}

.back-link a {
    color: #c581ff;
    text-decoration: none;
}

.back-link a:hover {
    color: #ff4c6b;
    transform: translateX(2px);
}

.back-link a:active {
    transform: translateX(0) scale(0.97);
}

/* Links */

a {
    color: #c581ff;
}

a:hover {
    color: #ff4c6b;
}

/* Search in Codex */

.search-container {
    margin: 15px 0;
}

.search-box {
    width: 100%;
    padding: 8px 10px;
    background: #0f0f16;
    border: 1px solid #4a314f;
    color: #e4e4e9;
    font-size: 13px;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

.search-box:focus {
    outline: none;
    border-color: #ff4c6b;
    background: #1a121e;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}

/* Post list */

.post-entry {
    border-bottom: 1px solid #3e3044;
    padding: 18px 0;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.post-entry:last-child {
    border-bottom: none;
}

.post-entry:hover {
    background: #11101a;
    border-color: #5b335f;
    transform: translateY(-1px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
}

.post-title {
    font-size: 18px;
    color: #ff4c6b;
    margin: 0 0 6px 0;
}

.post-title a {
    text-decoration: none;
    color: #ff4c6b;
}

.post-title a:hover {
    color: #ff6f88;
}

.post-date {
    font-size: 11px;
    color: #a59bb8;
    margin-bottom: 6px;
}

.post-snippet {
    font-size: 12px;
    color: #c8c3d3;
}

/* TOC panel */

.toc-panel {
    position: fixed;
    top: 110px;
    right: 30px;
    width: 200px;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(9, 7, 15, 0.94);
    border: 1px solid #3e3044;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.9);
    padding: 8px 10px;
    font-size: 12px;
    z-index: 3;
}

.toc-title {
    font-weight: bold;
    margin-bottom: 6px;
    color: #f0dde9;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin: 4px 0;
}

.toc-list a {
    text-decoration: none;
    color: #c8bbff;
    font-size: 11px;
    transition: color 0.2s ease, transform 0.12s ease;
}

.toc-list a:hover {
    color: #ff4c6b;
    transform: translateX(2px);
}

/* Glossary */

.glossary {
    border-bottom: 1px dotted #ff667a;
    cursor: help;
    position: relative;
}

.glossary:hover::after {
    content: attr(data-definition);
    position: absolute;
    left: 0;
    bottom: 130%;
    width: 220px;
    background: #120913;
    border: 1px solid #5a395f;
    padding: 6px 8px;
    font-size: 11px;
    color: #f0dde9;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.85);
    z-index: 5;
}

/* Comments block */

.comments-block {
    margin-top: 28px;
    padding-top: 12px;
    border-top: 1px solid #3e3044;
}

.comments-block h2 {
    margin: 0 0 6px 0;
    font-size: 15px;
    color: #ff4c6b;
    border-bottom: none;
    padding-bottom: 0;
}

.comments-block .giscus {
    margin-top: 6px;
}

/* Footer */

.footer {
    font-size: 10px;
    text-align: center;
    color: #88839b;
    padding: 8px 0 10px 0;
}

/* Reader Mode */

body.reader-mode .sidebar {
    display: none;
}

body.reader-mode .toc-panel {
    display: none;
}

body.reader-mode .page-wrap {
    width: 80%;
    max-width: 900px;
    margin: 20px auto;
}

body.reader-mode .content-body {
    font-size: 15px;
    line-height: 1.9;
}

body.reader-mode #bg-canvas {
    opacity: 0.4;
}

/* Basic mobile-ish tweak */

@media (max-width: 1100px) {
    .sidebar {
        display: none;
    }

    .toc-panel {
        display: none;
    }

    .page-wrap {
        width: 95%;
        margin: 10px auto;
    }
}
