/* /the-perfection-paradox/database-styles.css */
html {
    scroll-behavior: smooth;
}
/* --- Main Landing Page (/database/) --- */
.database-container {
    padding: 120px 40px 40px;
    max-width: 1400px;
    margin: 0 auto;
    margin-bottom: 50px;
}

.database-header {
    text-align: center;
    margin-bottom: 50px;
}

.database-header h1 {
    font-size: 3rem;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.database-header p {
    font-size: 1.1rem;
    color: #ccc;
    font-style: italic;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.category-card {
    display: block;
    position: relative;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #1a1c29;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.category-card-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 70%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #fff;
}

.category-card-overlay h3 {
    margin: 0 0 5px 0;
    font-size: 1.5rem;
}

.category-card-overlay p {
    margin: 0;
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.4;
}

.error-message {
    color: #f56c6c;
    text-align: center;
    grid-column: 1 / -1; /* Span all columns */
    background: rgba(220, 53, 69, 0.1);
    padding: 20px;
    border-radius: 8px;
}


/* --- Single Entry Page (/database/entry-slug/) --- */
.lore-entry-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    padding: 120px 40px 40px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: start;
}

/* Left Panel: Index */
.lore-index-panel {
    background: rgba(15, 17, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    position: sticky;
    top: 120px; /* Stick below the header */
}

.index-header {
    margin: 0 0 0px 0; /* Change 15px to 10px */
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.2rem;
    color: #ccc;
}

.index-list {
    max-height: 65vh;
    overflow-y: auto;
}

.index-item {
    display: block;
    padding: 10px;
    text-decoration: none;
    color: #f1f1f1;
    border-radius: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background-color 0.2s;
}

.index-list > a:last-child {
    border-bottom: none;
}

.index-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.index-item.is-active {
    background-color: rgba(74, 144, 226, 0.2);
    color: #fff;
    font-weight: bold;
}

/* Right Panel: Content */
.lore-content-panel {
    min-height: 50vh;
}

.lore-article {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    align-items: start;
}

.lore-article-header {
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 20px;
}

.lore-article-header h1 {
    font-size: 2.8rem;
    margin: 0;
}

.lore-article-content {
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #ddd;
}

/* Right sidebar stays in place while article content scrolls */
.lore-article-sidebar {
    position: sticky;
    top: 90px;
    align-self: start;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}
.lore-article-sidebar::-webkit-scrollbar { width: 4px; }
.lore-article-sidebar::-webkit-scrollbar-track { background: transparent; }
.lore-article-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 2px; }
.lore-article-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

.infobox-container {
    background: rgba(15, 17, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
}

.infobox-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.infobox-item:last-child {
    border-bottom: none;
}

.infobox-key {
    color: #ccc;
    font-weight: bold;
}

.infobox-value {
    color: #fff;
    text-align: right;
}
/* --- Styles for Lore Entry Primary Image --- */
.lore-primary-image {
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.lore-primary-image img {
    display: block;
    width: 100%;
    height: auto;
}
/* --- Styles for new Back to Top button --- */
#back-to-top-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px; /* Set vertical padding to 0 when hidden */
    text-decoration: none;
    color: #a9b3c1;
    border-radius: 4px;
    border-bottom: 1px solid transparent; /* Make border transparent when hidden */
    overflow: hidden;

    /* Transition properties */
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    margin-bottom: 0; /* Set margin to 0 when hidden */
    transition: all 0.4s ease-in-out;
}

#back-to-top-btn.is-visible {
    opacity: 1;
    visibility: visible;
    max-height: 45px;
    padding: 10px; /* Restore padding when visible */
    margin-bottom: 10px; /* Restore margin when visible */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Restore border when visible */
}

#back-to-top-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

#back-to-top-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
/* --- REFACTORED: Unified Skeleton Loader Styles --- */

/* 1. Common base styles for ALL skeleton elements */
.skeleton-card,
.skeleton-line,
.skeleton-block,
.skeleton-image,
.skeleton-infobox-item {
    background-color: #1a1c29;
    position: relative;
    overflow: hidden;
    border-radius: 8px; /* A consistent default radius */
}

/* 2. Specific layout styles for each type of skeleton element */
.skeleton-card {
    display: block;
    height: 180px;
}

.skeleton-line,
.skeleton-block,
.skeleton-infobox-item {
    margin-bottom: 10px;
    border-radius: 4px; /* Override for smaller elements */
}

.skeleton-image {
    width: 100%;
    height: 250px;
    margin-bottom: 20px;
}

.skeleton-infobox-item {
    width: 100%;
    height: 2.5em;
}

/* 3. The shimmer effect applied to ALL skeleton elements at once */
.skeleton-card::after,
.skeleton-line::after,
.skeleton-block::after,
.skeleton-image::after,
.skeleton-infobox-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(to right, transparent 0%, rgba(255, 255, 255, 0.08) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}

/* 4. A SINGLE keyframe definition for the animation */
@keyframes shimmer {
    0% {
        left: -150%;
    }
    100% {
        left: 150%;
    }
}

/* --- NEW: Hierarchical TOC Styles --- */

.index-item.toc-level-1 {
    padding-left: 10px; /* Base level */
    font-weight: bold;  /* Make top-level items stand out */
    color: #fff;
}

.index-item.toc-level-2 {
    padding-left: 25px; /* Indent level 2 */
}

.index-item.toc-level-3 {
    padding-left: 40px; /* Indent level 3 */
    font-size: 0.9rem;  /* Make smaller sub-headings slightly smaller */
    color: #ccc;
}
/* --- NEW: Styles for Advanced Content Blocks --- */

/* For single Image blocks */
.lore-image {
    margin: 2em 0;
}
.lore-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}
.lore-caption {
    text-align: center;
    font-size: 0.9rem;
    color: #ccc;
    margin-top: 10px;
    font-style: italic;
}

/* --- UPDATED: Styles for two-column Layout blocks (using float) --- */

/* 1. The main container. 'display: flow-root' contains the floated image. */
.lore-layout {
    margin: 2.5em 0;
    display: flow-root; 
}

/* 2. Styling for the floating image and its caption */
.lore-layout-image {
    width: 45%;
    max-width: 400px; /* Prevents the image from becoming too large on wide screens */
    margin-bottom: 1em; 
}

/* 3. Logic for floating the image to the RIGHT */
.lore-layout.image-right .lore-layout-image {
    float: right;
    margin-left: 30px; /* Creates space between the image and the text */
}

/* 4. Logic for floating the image to the LEFT */
.lore-layout.image-left .lore-layout-image {
    float: left;
    margin-right: 30px; /* Creates space between the image and the text */
}

/* 5. General styles for the image and text */
.lore-layout img {
    width: 100%;
    border-radius: 8px;
}
.lore-layout-text p {
    margin-top: 0;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    /* On mobile, we stop floating and make the image a full-width block */
    .lore-layout.image-right .lore-layout-image,
    .lore-layout.image-left .lore-layout-image {
        float: none;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}
/* For Video blocks */
.lore-video {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    background: #000;
    margin: 2em auto;
    border-radius: 8px;
}
.lore-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* For Spacer blocks */
.lore-spacer {
    text-align: center;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.4);
    margin: 2.5em auto;
    letter-spacing: 0.5em;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .lore-article {
        grid-template-columns: 1fr; /* Stack to single column on mobile */
    }
    .lore-article-sidebar {
        position: static; /* Remove sticky on mobile */
        max-height: none;
        overflow-y: visible;
    }
    .lore-layout, .lore-layout.image-right {
        grid-template-columns: 1fr; /* Stack columns on mobile */
    }
    .lore-layout.image-right .lore-layout-image {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
    }
}