/* --- Global Variables & Base Styles --- */
:root {
    --primary-font: 'Poppins', 'Helvetica Neue', Arial, 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --serif-font: 'Noto Serif SC', serif;
    --background-fade-duration: 1.5s;
    --card-bg-color: rgba(255, 255, 255, 0.1);
    --card-border-color: rgba(255, 255, 255, 0.2);
    --sidebar-bg-color: rgba(255, 255, 255, 0.08);
    --text-color: #f0f0f0;
    --text-muted-color: rgba(240, 240, 240, 0.7);
    --accent-color: #87CEEB; /* Sky Blue for highlights */
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    --card-hover-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.25);
    --border-radius-main: 12px;
}

body {
    font-family: var(--primary-font);
    color: var(--text-color);
    background-color: #121212; /* Fallback background */
    line-height: 1.7;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity var(--background-fade-duration) ease-in-out;
    z-index: -1;
}

.background-layer.active {
    opacity: 1;
}


/* --- Reusable Components & Helpers --- */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    flex-direction: column;
    color: var(--text-muted-color);
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top: 4px solid var(--accent-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tag-badge {
    display: inline-block;
    background-color: rgba(135, 206, 235, 0.15);
    color: var(--accent-color);
    padding: 0.25em 0.6em;
    border-radius: 1em;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 2px;
    border: 1px solid rgba(135, 206, 235, 0.3);
    transition: all 0.2s ease;
}
.tag-badge:hover {
    background-color: rgba(135, 206, 235, 0.3);
    transform: translateY(-1px);
}


/* --- Navbar --- */
.navbar {
    background: rgba(28, 28, 38, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    transition: background 0.3s ease;
}

.navbar-brand {
    font-family: var(--serif-font);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-color) !important;
}

.nav-link {
    color: var(--text-muted-color) !important;
    font-weight: 500;
    transition: color 0.3s ease;
    margin: 0 0.5rem;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-color) !important;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.2);
}
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}


/* --- Hero Section --- */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: none;
    transition: background 0.5s ease-in-out;
}

.hero.hero-overlay-hidden::before {
    background: none;
}

.hero-title {
    font-family: var(--serif-font);
    font-size: 4rem;
    font-weight: 700;
}

.hero-subtitle {
    font-size: 1.25rem;
    font-weight: 300;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .hero-title { font-size: 2.5rem; }
    .hero-subtitle { font-size: 1rem; }
}


/* --- Main Content & Tabs --- */
.main-content {
    margin-top: -100px;
    padding-top: 100px;
    position: relative;
    z-index: 2;
    padding-bottom: 4rem;
}

.content-wrapper {
    background: rgba(18, 18, 18, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius-main);
    padding: 2rem;
    border: 1px solid var(--card-border-color);
    box-shadow: 0 16px 60px rgba(0,0,0,0.3);
}

.main-tabs {
    border-bottom: 1px solid var(--card-border-color);
    margin-bottom: 2rem;
}

.main-tabs .nav-link {
    background: none;
    border: none !important;
    color: var(--text-muted-color) !important;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    border-bottom: 3px solid transparent !important;
    transition: all 0.3s ease;
    margin-bottom: -1px; /* Overlap border */
}

.main-tabs .nav-link:hover {
    color: var(--text-color) !important;
}

.main-tabs .nav-link.active {
    color: var(--accent-color) !important;
    background-color: transparent !important;
    border-color: var(--accent-color) !important;
}


/* --- Universal Card Base Style --- */
.post-card-vertical, .link-card, .album-card {
    display: flex;
    flex-direction: column;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: var(--border-radius-main);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.post-card-vertical:hover, .link-card:hover, .album-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-hover-shadow);
    color: var(--text-color);
}

.card-tags {
    min-height: 28px;
}

/* --- Masonry (Waterfall) Layout Container --- */
.posts-list, .links-list, .albums-grid {
    column-count: 3;
    column-gap: 1.5rem;
}
@media (max-width: 992px) {
    .posts-list, .links-list, .albums-grid {
        column-count: 2;
    }
}
@media (max-width: 768px) {
    .posts-list, .links-list, .albums-grid {
        column-count: 1;
    }
}

/* --- Masonry Item Wrapper --- */
.post-card-wrapper, .link-card-wrapper, .album-card {
    break-inside: avoid; /* Prevents cards from splitting across columns */
    margin-bottom: 1.5rem;
    display: inline-block; /* Required for column layout */
    width: 100%;
}
/* For albums, the anchor IS the card, so we need to target it directly */
#albums-list-content > .album-card {
    margin-bottom: 1.5rem;
}


/* --- Post & Album Card Style --- */
.post-card-image-top-container, .album-card-image-top-container {
    overflow: hidden;
    background-color: #333;
    line-height: 0; /* Fix small gap under image */
}
.post-card-image-top, .album-card-image-top {
    width: 100%;
    height: auto; /* Allow image to define its own height */
    object-fit: cover;
    transition: transform 0.4s ease, filter 0.4s ease;
}
.post-card-vertical:hover .post-card-image-top, 
.album-card:hover .album-card-image-top {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.post-card-image-top-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    position: relative;
    overflow: hidden;
    min-height: 180px;
}
.album-card-image-top-placeholder {
    height: 180px;
}

.artistic-title-placeholder-text {
    font-family: var(--serif-font);
    color: var(--text-color);
    font-weight: 700;
    font-size: 1.6rem;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.post-card-content-vertical, .album-card-content {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.post-card-title-vertical {
    font-family: var(--serif-font);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.album-card-title {
    font-family: var(--serif-font);
    font-size: 1.2rem;
    font-weight: 700;
}
.post-card-description-vertical {
    font-size: 0.9rem;
    color: var(--text-muted-color);
    margin-top: 0.5rem;
    line-height: 1.6;
}
.post-card-meta-vertical {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted-color);
}
.post-card-footer-vertical {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--card-border-color);
}

/* --- Links Card Style (Redesigned) --- */
.link-card {
    position: relative;
}
.link-card-image-container {
    line-height: 0;
}
.link-card-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: filter 0.3s ease;
}
.link-card:hover .link-card-image {
    filter: brightness(1.1);
}
.link-card-image-placeholder {
    height: 150px;
    background: rgba(255,255,255,0.03);
    display: flex;
    align-items: center;
    justify-content: center;
}
.link-card-image-placeholder .fa-link {
    color: rgba(255,255,255,0.2);
    font-size: 3rem;
}
.link-card-content {
    padding: 1.25rem;
}
.link-card-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-family: var(--serif-font);
}
.link-card-description {
    font-size: 0.9rem;
    color: var(--text-muted-color);
    margin-bottom: 0;
}
.link-card-footer {
    padding: 0 1.25rem 1.25rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
}
.link-card-url {
    font-size: 0.8rem;
    color: var(--text-muted-color);
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    margin-top: auto;
    word-break: break-all;
}
.link-card-hover-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
}
.link-card:hover .link-card-hover-icon {
    opacity: 1;
    transform: scale(1);
}

/* --- Sidebar --- */
.sidebar-column {
    position: sticky;
    top: 100px; /* Navbar height + offset */
}
.sidebar-section {
    background: var(--sidebar-bg-color);
    border-radius: var(--border-radius-main);
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    border: 1px solid var(--card-border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.sidebar-section-title {
    text-align: center;
    font-family: var(--serif-font);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border-color);
    color: var(--text-color);
    
}
.tags-list, .author-sidebar-section {
    padding: 0 !important;
}
.tag-filter-button {
    background: none;
    border: none;
    color: var(--text-muted-color);
    text-align: left;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.9rem;
}
.tag-filter-button:hover {
    background-color: rgba(135, 206, 235, 0.1);
    color: var(--accent-color);
}
.tag-filter-button.active {
    background-color: rgba(135, 206, 235, 0.2);
    color: var(--accent-color);
    font-weight: 600;
}
.author-card-item {
    text-align: center;
}
.author-avatar {
    width: 80px;
    height: 80px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.author-name {
    font-weight: 600;
    color: var(--text-color);
}
.author-description {
    color: var(--text-muted-color) !important;
}
.author-contact-links a {
    color: var(--text-muted-color);
    font-size: 1.2rem;
    transition: color 0.2s ease, transform 0.2s ease;
}
.author-contact-links a:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

/* --- Footer --- */
.footer {
    padding: 2rem 0;
    background: rgba(10, 10, 10, 0.5);
    color: var(--text-muted-color);
    font-size: 0.9rem;
}
.footer p { margin-bottom: 0; }
.footer-social-links a {
    color: var(--text-muted-color);
    font-size: 1.5rem;
    transition: color 0.3s ease;
}
.footer-social-links a:hover {
    color: var(--accent-color);
}

/* --- Post Page Specific --- */
.container-post {
    width: 100%;
    max-width: 1440px; /* Significantly wider than default. Adjust if needed. */
    padding-right: 1.5rem;
    padding-left: 1.5rem;
    margin-right: auto;
    margin-left: auto;
}
.post-hero-header {
    padding: 8rem 0;
    background-size: cover;
    background-position: center;
    position: relative;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.post-hero-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: none;
}
.post-hero-header.no-image {
    padding: 5rem 0;
    background: #1a1a1a;
}
.post-hero-content {
    position: relative;
    z-index: 1;
}
.post-hero-title {
    font-family: var(--serif-font);
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.post-hero-meta {
    font-size: 1rem;
    opacity: 0.8;
}
.post-hero-tags {
    margin-top: 1rem;
}
.header-tag {
    background-color: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

.actual-post-content-wrapper {
    background: rgba(28, 28, 38, 0.4);
    padding: 2rem;
}

/* --- Enhanced Table of Contents (TOC) Styles --- */
.toc-sidebar {
    /* Make it card-like for better visibility */
    background: var(--sidebar-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: var(--border-radius-main);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    
    /* Scroll Aesthetics */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Sticky behavior matches JS offset */
.toc-sidebar.sticky-top {
    top: 100px; 
    height: calc(100vh - 140px); /* Leave space for footer */
    overflow-y: auto;
}

/* Webkit Scrollbar Customization (Chrome, Safari, Edge) */
.toc-sidebar::-webkit-scrollbar {
    width: 4px; /* Very thin */
}
.toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.toc-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}
.toc-sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.toc-title {
    font-family: var(--serif-font);
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border-color);
    text-align: center;
    font-size: 1.2rem;
}

.toc-link {
    display: block;
    color: rgba(255, 255, 255, 0.65); /* Improved contrast */
    text-decoration: none;
    padding: 0.4rem 0.6rem; /* More padding */
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    margin-bottom: 2px;
    border-radius: 0 4px 4px 0;
}

.toc-link:hover {
    color: var(--accent-color); /* Highlight color */
    background-color: rgba(135, 206, 235, 0.1); /* Subtle background tint */
    border-left-color: var(--accent-color);
    padding-left: 1rem; /* Animation effect */
}

/* Indentation levels */
.toc-level-2 { margin-left: 0; font-weight: 500; }
.toc-level-3 { margin-left: 1rem; font-size: 0.9rem; }
.toc-level-4 { margin-left: 2rem; font-size: 0.85rem; }


#mobile-toc-button-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1030;
}
#mobile-toc-button-container .btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #121212;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.offcanvas {
    background: rgba(28, 28, 38, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-color);
    border-right: 1px solid var(--card-border-color);
}
.offcanvas-header {
    border-bottom: 1px solid var(--card-border-color);
}
.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.post-comments-section .btn {
    border-color: var(--accent-color);
    color: var(--accent-color);
    transition: all 0.3s ease;
}
.post-comments-section .btn:hover {
    background-color: var(--accent-color);
    color: #121212;
}

#photo-sphere-container {
    width: 100%;
    height: calc(100vh - 58px);
    position: relative;
    overflow: hidden;
    z-index: 1;
}
#photo-sphere-container .photo-navigation-controls {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.photo-nav-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    transition: all 0.3s ease;
}
.photo-nav-btn:hover {
    background: rgba(0,0,0,0.5);
    color: #fff;
    transform: scale(1.05);
}
.photo-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(0,0,0,0.2);
}

/* Photo Modal Styles (Corrected) */
.photo-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none; /* Block clicks when hidden */
    transition: opacity 0.3s ease-in-out;
}

.photo-modal-overlay.show {
    opacity: 1;
    pointer-events: auto; /* Allow clicks when shown */
}

.photo-modal-content {
    position: relative;
    background: none;
    box-shadow: none;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.95);
    transition: transform 0.3s ease-in-out;
}

.photo-modal-overlay.show .photo-modal-content {
    transform: scale(1);
}

#modal-image {
    border-radius: var(--border-radius-main);
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    max-width: 100%;
    max-height: calc(90vh - 120px); /* leave space for caption */
    object-fit: contain;
}

#modal-caption {
    color: #fff;
    text-shadow: 0 1px 5px rgba(0,0,0,0.8);
    margin-top: 1rem;
    text-align: center;
    max-width: 800px;
}

#modal-title {
    font-family: var(--serif-font);
}

.photo-modal-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    color: #fff;
    opacity: 0.8;
    font-size: 1.5rem; /* Adjusted for better fit in circle */
    line-height: 40px; /* Vertically center the 'x' */
    text-align: center;
    text-shadow: none;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1051;
}

.photo-modal-close:hover {
    opacity: 1;
    transform: scale(1.1);
}