html {
    height: 100%;
    scroll-behavior: smooth;
}
body {
    min-height: 100vh; /* Ensures body takes at least full viewport height */
    display: flex;
    flex-direction: column; /* Stacks children vertically (header, main content, footer) */
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa; /* Softer background color */
    color: #2c3e50;
    margin: 0; /* Reset default margin */
    line-height: 1.6;
}

.main-content-wrapper {
    flex-grow: 1; /* Allows this wrapper to grow and push the footer down */
    padding: 2rem 0;
}

h1, h2, h3, h4, h5, h6,
.font-weight-bold.spanborder span, /* For section titles */
.card-body h2.h4 a.text-dark, /* For article titles in cards */
.list-unstyled h6 a.text-dark /* For popular article titles */
{
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: -0.02em;
}

/* Enhanced card shadow for 3D effect */
.card.box-shadow {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.05);
    overflow: hidden;
}

.card.box-shadow:hover {
    box-shadow: 0 12px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.06);
    transform: translateY(-4px);
}

.card-body {
    padding: 1.5rem;
}

/* Carousel enhancements */
#carouselExampleCaptions {
    height: 400px;
    margin-bottom: 2rem;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}
#carouselExampleCaptions .carousel-inner,
#carouselExampleCaptions .carousel-item {
    height: 100%;
}
#carouselExampleCaptions .carousel-item img {
    object-fit: cover;
    height: 100%;
    filter: brightness(0.7);
    transform: scale(1.01);
    transition: transform 6s ease-in-out;
}
.carousel-item.active img {
    transform: scale(1.08);
}
.carousel-caption {
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    border-radius: 0;
    padding: 2rem 1.5rem 1.5rem;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: left;
}
.carousel-caption h5 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.carousel-caption p {
    font-size: 1.1rem;
    margin-bottom: 0;
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.spanborder span { /* This rule might need review if it conflicts with h5.font-weight-bold.spanborder span */
    border-bottom: 0;
    display: inline-block;
    padding-bottom: 20px; /* This padding seems large for an inline-block span if it's just text */
    margin-bottom: -1px; /* This might be for alignment with its parent's border */
}
/* Section title beautification */
h5.font-weight-bold.spanborder {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    position: relative;
}
h5.font-weight-bold.spanborder span {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
    padding-bottom: 0.5rem;
}
h5.font-weight-bold.spanborder span::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 0;
    width: 3rem;
    height: 3px;
    background-color: #ffda58;
    transition: width 0.3s ease;
}
h5.font-weight-bold.spanborder:hover span::after {
    width: 5rem;
}

.card-body h2.h4 a.text-dark {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.2s ease;
}
.card-body h2.h4 a.text-dark:hover {
    color: #ffda58;
}

/* Popular articles list item styling */
.col-md-4.pl-4 ol.list-unstyled li.mb-3 {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}
.col-md-4.pl-4 ol.list-unstyled li.mb-3:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Pagination styling - subtle improvements */
.pagination .page-item.active .page-link {
    background-color: #ffda58;
    border-color: #ffda58;
    color: white; /* Text color for active page, ensure contrast */
}
.pagination .page-link {
    color: #ffda58;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.pagination .page-link:hover {
    background-color: #e9ecef;
    color: #ffda58; /* Keep color or change to a darker shade for better feedback */
}
.pagination .page-item.disabled .page-link {
    color: #6c757d;
}
/* 确保最外层轮播容器的高度设置生效，并隐藏任何可能溢出的内容 */
#carouselExampleCaptions {
    /* 您已经在HTML中通过 style="height: 300px" 设置了高度 */
    /* overflow: hidden; /* 确保任何超出部分被隐藏，避免出现滚动条 */
}

/* 设置轮播图内部容器占据其父容器（#carouselExampleCaptions）的全部高度 */
.carousel-inner {
    height: 100%;
    overflow: hidden; /* 再次确认隐藏溢出内容，这对于 object-fit: cover 很重要 */
}

/* 设置每个轮播项目（图片的直接父容器）也占据其父容器（.carousel-inner）的全部高度 */
.carousel-item {
    height: 100%;
}

/* 针对轮播图片的样式 */
.carousel-item img {
    /* Bootstrap 的 w-100 class 已经应用了 width: 100% !important; */
    /* display: block; Bootstrap 的 d-block class 已经应用了 */
    height: 100%;             /* 使图片高度填满 .carousel-item 的高度 */
    object-fit: cover;        /* 核心属性：保持图片原始宽高比，缩放图片以完全覆盖容器。如果图片宽高比与容器不同，则会裁剪图片多余的部分。 */
    object-position: center;  /* 可选：当 object-fit: cover 裁剪图片时，决定图片如何定位。'center' 会使图片居中显示，您也可以使用 'top', 'bottom', 'left', 'right' 或具体的百分比/像素值。 */
}

/* --- 轮播图控制按钮通用样式 --- */
#carouselExampleCaptions .carousel-control-prev,
#carouselExampleCaptions .carousel-control-next {
    /* 1. 外观和尺寸调整 */
    width: 48px;  /* 设置按钮的宽度，例如48像素 */
    height: 48px; /* 设置按钮的高度，例如48像素 */
    background-color: rgba(0, 0, 0, 0.3); /* 给按钮一个半透明的背景色，使其看起来像一个实体按钮 */
    border-radius: 50%; /* 将按钮设置为圆形；如果想要圆角方形，可以使用例如 '4px' 或 '8px' */
    border: none; /* 移除浏览器或Bootstrap可能添加的默认边框 */

    /* 2. 定位调整 */
    top: 50%; /* 使按钮的顶部与轮播区域的垂直中心对齐 */
    transform: translateY(-50%); /* 精确地将按钮垂直居中 */
    bottom: auto; /* 如果Bootstrap默认有 bottom:0，覆盖它以确保固定高度生效 */
    /* Bootstrap的 z-index 通常是合理的，这里我们依赖它，确保按钮在图片之上 */

    /* 3. 初始状态：隐藏按钮，并设置过渡动画 */
    opacity: 0; /* 完全透明，即隐藏 */
    visibility: hidden; /* 彻底隐藏，不占据空间，对辅助功能友好 */
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, background-color 0.2s ease-in-out; /* 为显隐和背景色变化添加平滑过渡效果 */
}

/* --- "上一个"按钮的具体定位 --- */
#carouselExampleCaptions .carousel-control-prev {
    left: 20px; /* 按钮距离轮播区域左边缘的距离，可根据喜好调整 */
}

/* --- "下一个"按钮的具体定位 --- */
#carouselExampleCaptions .carousel-control-next {
    right: 20px; /* 按钮距离轮播区域右边缘的距离，可根据喜好调整 */
}

/* --- 悬停效果 --- */

/* 1. 当鼠标悬停在整个轮播区域 (#carouselExampleCaptions) 时，显示控制按钮 */
#carouselExampleCaptions:hover .carousel-control-prev,
#carouselExampleCaptions:hover .carousel-control-next {
    opacity: 0.7; /* 设置按钮为半透明可见 */
    visibility: visible; /* 使按钮可见 */
}

/* 2. 当鼠标直接悬停在已经显示的控制按钮上时，进一步改变按钮样式（例如变得更不透明） */
#carouselExampleCaptions .carousel-control-prev:hover,
#carouselExampleCaptions .carousel-control-next:hover {
    background-color: rgba(0, 0, 0, 0.6); /* 鼠标悬停时按钮背景色加深 */
    opacity: 1; /* 鼠标悬停时按钮完全不透明 */
}

/* 标签云容器美化 */
.tag-cloud-container {
    overflow: hidden; /* 防止泡泡跑到容器外面 */
    background-color: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
    padding: 10px;
    position: relative;
}

.tag-cloud-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: #ffda58;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* 标签泡泡美化 */
.tag-bubble {
    /* 圆形和基本外观已在HTML的style中部分定义，这里可以补充或覆盖 */
    color: white; /* 假设多数泡泡用深色背景 */
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    /* 确保文本不会超出泡泡太多 */
    white-space: normal; /* 允许换行 */
    word-break: break-word; /* 单词内换行 */
    border: 1px solid rgba(255,255,255,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tag-bubble:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 10;
}

/* 添加标签云标题样式 */
.tag-cloud-title {
    position: relative;
    display: inline-block;
    margin-bottom: 15px;
}

.tag-cloud-title::after {
    content: '🏷️';
    margin-left: 8px;
    font-size: 1.2em;
    vertical-align: middle;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .main-content-wrapper {
        padding: 1rem 0;
    }
    
    #carouselExampleCaptions {
        height: 300px;
        border-radius: 12px;
    }
    
    .carousel-caption h5 {
        font-size: 1.25rem;
    }
    
    .carousel-caption p {
        font-size: 1rem;
    }
    
    .card-body h2.h4 {
        font-size: 1.25rem;
    }
    
    .tag-cloud-container {
        height: 400px !important; /* 在移动设备上减小高度 */
    }
    
    .tag-bubble {
        font-size: 12px !important; /* 在移动设备上统一字体大小 */
    }
}

/* Animation Classes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card.box-shadow {
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.card.box-shadow:nth-child(n) {
    animation-delay: calc(0.1s * var(--animation-order, 0));
}