/* --- Variable Definitions --- */
:root {
    --primary-color: #0d6efd;
    --text-color-light: #212529;
    --bg-color-light: #f8f9fa;
    /* Changed opacity to ~50% for frosted glass effect */
    --card-bg-light: rgba(255, 255, 255, 0.55); 
    --border-color-light: #dee2e6;
    --input-bg-light: #fff;

    --text-color-dark: #e9ecef;
    --bg-color-dark: #121212;
    /* Changed opacity to ~50% for frosted glass effect */
    --card-bg-dark: rgba(30, 30, 30, 0.5); 
    --border-color-dark: #495057;
    --input-bg-dark: #2a2a2a;
    
    --body-font: -apple-system, BlinkMacSystemFont, "Funnel Display", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 0.5rem;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* --- Global Styles & Background --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--body-font);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
    position: relative;
    min-height: 100vh;
    padding-top: 70px; /* Reduced space for navbar */
}
.bg-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://4kwallpapers.com/images/wallpapers/starry-sky-purple-sky-astronomical-stars-5k-3840x2160-1022.jpg'); /* You can change this image URL */
    background-size: cover;
    background-position: center;
    filter: blur(8px);
    z-index: -1;
}

.light-mode { background-color: var(--bg-color-light); color: var(--text-color-light); }
.dark-mode { background-color: var(--bg-color-dark); color: var(--text-color-dark); }
.dark-mode .bg-image { filter: blur(8px) brightness(0.7); }

/* --- 页面布局调整 --- */
.container { max-width: 1440px; margin: 0 auto; padding: 0 15px; } /* 增加页面宽度 */
.row { display: flex; flex-wrap: wrap; margin: 0 -15px; }
.col-lg-8 { flex: 0 0 80%; max-width: 80%; padding: 0 15px; } /* 主内容区加宽 */
.col-lg-4 { flex: 0 0 20%; max-width: 20%; padding: 0 15px; } /* 侧边栏变窄 */


/* --- Navbar --- */
.navbar {
    background-color: var(--card-bg-light);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0.75rem 0;
    position: fixed; /* Changed to fixed for constant presence */
    top: 0;
    width: 100%;
    z-index: 1000;
    transition: background-color 0.3s;
}
.dark-mode .navbar { background-color: var(--card-bg-dark); }
.navbar .container { display: flex; justify-content: space-between; align-items: center; }
.navbar-brand, .nav-links a, .nav-action-btn { color: var(--text-color-light); text-decoration: none; transition: color 0.2s; }
.dark-mode .navbar-brand, .dark-mode .nav-links a, .dark-mode .nav-action-btn { color: var(--text-color-dark); }
.navbar-brand { font-size: 1.5rem; font-weight: bold; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a:hover, .nav-action-btn:hover { color: var(--primary-color); }
.nav-actions { display: flex; gap: 1rem; }
.nav-action-btn { background: none; border: none; cursor: pointer; font-size: 1.2rem; }

/* --- Main Content & Cards --- */
.main-container { padding-top: 2rem; }
.card {
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    transition: all 0.3s;
    background-color: var(--card-bg-light);
    backdrop-filter: blur(5px);
    /* Card fade-in animation */
    opacity: 0;
    transform: translateY(20px);
    animation: card-fade-in 0.5s forwards;
}
.dark-mode .card { background-color: var(--card-bg-dark); border-color: var(--border-color-dark); }

@keyframes card-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Staggering animation for cards */
.post-card:nth-child(1) { animation-delay: 0.1s; }
.post-card:nth-child(2) { animation-delay: 0.2s; }
.post-card:nth-child(3) { animation-delay: 0.3s; }
/* Add more if you have more posts per page */

.post-card .card-img-top { width: 100%; border-top-left-radius: var(--border-radius); border-top-right-radius: var(--border-radius); max-height: 250px; object-fit: cover; }
.card-body { padding: 2rem; }
.card-title a { color: inherit; text-decoration: none; font-weight: bold; }
.card-title a:hover { color: var(--primary-color); }
.post-meta { font-size: 0.9rem; color: #6c757d; margin-bottom: 1rem; }
.dark-mode .post-meta { color: #adb5bd; }
.read-more-btn { background-color: var(--primary-color); color: #fff; border: none; padding: 0.5rem 1rem; border-radius: 50px; text-decoration: none; transition: background-color 0.2s; }

/* --- Hitokoto Card --- */
.hitokoto-card {
    text-align: center;
    padding: 0.8rem 1.5rem; /* Reduced vertical padding */
    font-size: 1rem;   /* Slightly smaller font */
    font-style: italic;
    margin-bottom: 1.5rem; /* Reduced margin bottom */
}


/* --- Sidebar --- */
.sidebar-inner { position: sticky; top: 90px; } /* Adjusted for fixed navbar */
.sidebar-widget .card-body { padding: 1.5rem; }
.widget-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 1rem; padding-bottom: 0.5rem; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; display: block; margin: 0 auto; }
#recent-posts-container, .sidebar-widget ul { list-style: none; padding-left: 0; }
#recent-posts-container li a, .sidebar-widget ul li a { text-decoration: none; color: inherit; }
#recent-posts-container li a:hover, .sidebar-widget ul li a:hover { color: var(--primary-color); }
#tag-cloud-container a { display: inline-block; padding: 0.3rem 0.6rem; margin: 0.2rem; background-color: #e9ecef; color: var(--text-color-light); border-radius: 5px; text-decoration: none; font-size: 0.9rem; }
.dark-mode #tag-cloud-container a { background-color: #343a40; color: var(--text-color-dark); }

/* --- Comment Form Styling --- */
.form-group { margin-bottom: 1rem; }
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color-light);
    background-color: var(--input-bg-light);
    color: var(--text-color-light);
    border-radius: var(--border-radius);
    transition: border-color 0.2s, background-color 0.2s;
}
.dark-mode .form-control {
    border-color: var(--border-color-dark);
    background-color: var(--input-bg-dark);
    color: var(--text-color-dark);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}
.btn-primary { background-color: var(--primary-color); color: white; border: none; padding: 0.6rem 1rem; border-radius: 5px; cursor: pointer; }

/* --- Post/Page Detail --- */
.post-featured-image { width: 100%; border-radius: var(--border-radius); margin-bottom: 2rem; }
.post-content, .page-content { line-height: 1.8; }
.post-content img { max-width: 100%; height: auto; border-radius: var(--border-radius); margin: 1rem 0; }
.post-content pre { padding: 1rem; border-radius: var(--border-radius); overflow-x: auto; background-color: rgba(0,0,0,0.05); }
.dark-mode .post-content pre { background-color: rgba(255,255,255,0.05); }
.toc-widget { position: sticky; top: 90px; } /* Adjusted for fixed navbar */
.toc ul { list-style: none; padding-left: 0; }
.toc a { text-decoration: none; color: #6c757d; display: block; padding: 0.2rem 0; }
.dark-mode .toc a { color: #adb5bd; }
.toc a:hover { color: var(--primary-color); }

/* --- Search Modal --- */
.search-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.7); display: flex; justify-content: center; align-items: flex-start; padding-top: 15vh; opacity: 0; visibility: hidden; transition: opacity 0.3s; z-index: 2000; }
.search-modal.visible { opacity: 1; visibility: visible; }
.search-modal-content { background-color: var(--card-bg-dark); padding: 2rem; border-radius: var(--border-radius); width: 90%; max-width: 600px; display: flex; }
.search-modal-content input { flex-grow: 1; background: transparent; border: none; border-bottom: 2px solid var(--text-color-dark); color: var(--text-color-dark); font-size: 1.5rem; padding: 0.5rem; outline: none; }
.search-modal-content button { background: none; border: none; color: var(--text-color-dark); font-size: 1.5rem; cursor: pointer; }
.close-search-btn { position: absolute; top: 2rem; right: 2rem; font-size: 2rem; color: #fff; background: none; border: none; cursor: pointer; }

/* --- Widgets --- */
.music-widget { position: fixed; bottom: 20px; left: 20px; z-index: 1010; }
.music-toggle-btn { 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    background-color: #808080; /* Silver-gray color */
    color: white; 
    border: none; 
    font-size: 1.2rem; 
    cursor: pointer; 
    box-shadow: var(--shadow); 
}
.music-player-container { transform: translateY(100%) scale(0.8); opacity: 0; visibility: hidden; transition: all 0.3s ease; position: absolute; bottom: 65px; left: 0; }
.music-widget.open .music-player-container { transform: translateY(0) scale(1); opacity: 1; visibility: visible; }
.live2d { position: fixed; right: 0; bottom: 0; z-index: 1009; pointer-events: none; }

/* --- Footer & Other --- */
.footer { text-align: center; padding: 2rem 0; margin-top: 2rem; color: #fff; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); }
.hidden { display: none !important; }

/* --- MODIFICATION START: Loading Overlay --- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Changed to solid background color */
    background-color: var(--bg-color-dark, #121212); 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* Smoother transition */
    transition: opacity 0.5s ease, visibility 0s linear 0.5s; 
    opacity: 1;
    visibility: visible;
    /* Block clicks when visible */
    pointer-events: auto; 
}
#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    /* Allow clicks to pass through when hidden */
    pointer-events: none; 
    transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}
/* --- MODIFICATION END --- */

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #fff;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .col-lg-8, .col-lg-4 { flex: 0 0 100%; max-width: 100%; }
    #sidebar { margin-top: 2rem; }
    .nav-links { display: none; }
}

/* Link Styling */
.post-content a, .page-content a {
    color: #9e9e9e; 
    text-decoration: underline;
    transition: color 0.2s ease;
}
.post-content a:hover, .page-content a:hover {
    color: var(--primary-color);
}
.card-title a {
    color: inherit !important; 
    text-decoration: none !important;
}
#recent-posts-container li a, .sidebar-widget ul li a, .toc a {
    color: #9e9e9e;
    text-decoration: none;
}
.card-title a:hover,
#recent-posts-container li a:hover, 
.sidebar-widget ul li a:hover, 
.toc a:hover {
    color: var(--primary-color) !important;
}

