﻿/* 基本版面設置，白色背景和大範圍間距 */
.main-content {
    padding: 0px;
}

h2 {
    text-align: center;
    font-size: 3rem; /* 字體大小增加，讓標題更突出 */
    font-weight: 800; /* 加粗標題 */
    text-transform: uppercase; /* 全大寫，提升視覺層級 */
    letter-spacing: 2px; /* 增加字母間距 */
    padding: 20px 0; /* 上下留白 */
    position: relative;
    background: linear-gradient(180deg, rgba(34, 139, 34, 0.7), rgba(0, 0, 139, 0.7), rgba(255, 0, 0, 1)); /* 明显的深绿、深蓝、红色渐变 */
    background-size: 60%; /* 增加渐变的重复性 */
    color: transparent;
    -webkit-background-clip: text; /* 讓漸變應用於文字 */
    background-clip: text;
    text-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2); /* 添加陰影，增強立體感 */
}

/* 查詢 */
/* 使用 CSS Grid 布局來替代 Bootstrap 的 row col */
.sdg-items-container {
    display: flex;
    flex-wrap: wrap; /* 超出時自動換行 */
    justify-content: center; /* 項目置中對齊 */
    max-width: 100%; /* 不超出容器範圍 */
    /*         display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); */
}

/* ✅ 讓 item-thumbnail-container 保持彈性布局 */
.item-thumbnail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
/*    padding-top: 10px;
    padding-left: 5px;
    padding-right: 5px;*/
    border-radius: 10px;
    transition: all 0.2s ease-in-out;
    position: relative;
    width: 120px;
    height: 120px;
    overflow: hidden;
    cursor: pointer; /* 讓滑鼠變成手指 */
}

    /* 🎯 **關鍵！讓父層 item-thumbnail-container 在選取時加上外框** */
    .item-thumbnail-container:has(.item-checkbox:checked) {
        display: grid;
        place-items: center; /* 讓內容在 grid 中完全置中 */
        border: 2px solid rgba(0, 162, 196, 1) !important; /* 設定外框顏色 */
        border-radius: 12px; /* 圓角 */
        box-shadow: 0px 0px 10px rgba(0, 123, 255, 0.8); /* 發光效果 */
    }

/* ✅ 讓圖片有圓角 */
.item-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 5px;
}

/* ✅ 選取時讓圖片變半透明 */
.item-thumbnail-container:has(.item-checkbox:checked) .item-thumbnail {
    opacity: 0.1; /* 設定透明度為 50% */
    position: absolute;
    z-index: 1; /* 層級較低 */
}

/* ✅ 勾選&文字框 */
.checkbox-text-group {
}

/* ✅ 讓勾選&文字框較高層級 */
.item-thumbnail-container:has(.item-checkbox:checked) .checkbox-text-group {
    position: absolute;
    z-index: 2; /* 層級較高 */
    transition: transform 0.1s ease-in-out, color 0.1s ease-in-out;
}

/* 文字設置 */
.sdg-text {
    font-size: 14px;
    font-weight: 550;
    color: #333;
    text-align: center;
    word-wrap: break-word;
    white-space: normal;
}

/* ✅ 讓勾選時的文字變色 + 上移 */
.item-thumbnail-container:has(.item-checkbox:checked) .sdg-text {
    color: rgba(0, 100, 100, 1) !important;
    font-size: 15px;
    font-weight: 900;
}

/* ✅ 隱藏 checkbox */
.item-checkbox {
    display: none;
}

/* 美化篩選框外觀 */
.filter-container {
    display: flex;
    flex-wrap: wrap; /* 小螢幕自動換行 */
    align-items: center;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

    /* 下拉選單 */
    .filter-container select {
        width: 100%;
        height: 45px;
        border-radius: 8px;
        border: 1px solid #ddd;
        padding: 8px 12px;
        font-size: 16px;
        transition: all 0.3s ease;
    }

        /* 當滑鼠移上去時的效果 */
        .filter-container select:hover,
        .filter-container select:focus {
            border-color: rgba(0, 162, 196, 1);
            box-shadow: 0 0 5px rgba(0, 162, 196, 0.5);
        }

    /* 日期輸入框 */
    .filter-container input[type="text"] {
        width: 100%;
        height: 45px;
        border-radius: 8px;
        border: 1px solid #ddd;
        padding: 8px 12px;
        font-size: 16px;
        transition: all 0.3s ease;
    }

        /* 日期框 hover 效果 */
        .filter-container input[type="text"]:hover,
        .filter-container input[type="text"]:focus {
            border-color: rgba(0, 162, 196, 1);
            box-shadow: 0 0 5px rgba(0, 162, 196, 0.5);
        }

    /* 查詢按鈕 */
    .filter-container button {
        background: rgba(0, 162, 196, 1);
        color: white;
        font-size: 16px;
        padding: 10px 20px;
        border: none;
        border-radius: 8px;
        transition: all 0.3s ease;
        width: 100%;
    }

        /* 按鈕 hover */
        .filter-container button:hover {
            background: rgba(0, 140, 170, 1);
            box-shadow: 0px 4px 10px rgba(0, 140, 170, 0.4);
        }

/* 列表 */
/* 設置主要容器的樣式 */
.container-lg {
    max-width: 1200px; /* 最大寬度 1200px，避免過寬造成閱讀困難 */
    margin: 0 auto; /* 自動左右居中對齊 */
}

/* 設置卡片容器的網格布局 */
.news-card-container {
    display: grid; /* 使用 CSS Grid 排版 */
    grid-template-columns: repeat(3, 1fr); /* 設置三列的網格布局 */
    gap: 30px; /* 每個卡片之間的間距為 30px */
    padding: 0; /* 移除內邊距 */
}

/* 设置卡片容器的相对定位，方便子元素的绝对定位 */
.news-card {
    background-color: #fff; /* 设置卡片背景颜色为白色，保持简洁、干净的外观 */
    border-radius: 5px; /* 使卡片的四个角变圆，增强现代感和柔和感 */
    overflow: hidden; /* 防止内容溢出卡片边缘，例如图片或文字超出 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); /* 设置卡片的阴影效果，使卡片看起来有浮动感，提升层次感 */
    transition: all 0.3s ease; /* 设定卡片的动画过渡效果，让所有样式变化在 0.3 秒内平滑过渡 */
    cursor: pointer; /* 当鼠标悬停在卡片上时，显示为可点击状态 */
    display: flex; /* 使用 flexbox 布局模型，使卡片内的内容自动调整 */
    flex-direction: column; /* 设置内容在卡片内纵向排列 */
    /* padding: 15px; 为卡片添加 20px 的内边距，确保内容不会紧贴边缘 */
    position: relative; /* 设置卡片容器为相对定位，以便其子元素可以使用绝对定位 */
    height: 500px; /* 固定圖片高度為 240px */
}

    /* 設置卡片懸停效果 */
    .news-card:hover {
        box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2); /* 懸停時加深陰影，增強立體感 */
        /* transform: translateY(-5px); 懸停時卡片輕微上移，形成浮動效果 */
    }

.post-thumbnail-container {
    position: relative; /* 保持 Bootstrap 原本的樣式 */
    overflow: hidden; /* 防止長標題內容超出容器範圍 */
    height: 320px; /* 固定圖片高度為 240px */
}

/* 設置封面圖片的樣式 */
.post-thumbnail {
    width: 100%; /* 寬度設置為 100%，讓圖片自動適應父元素 */
    height: 100%; /* 固定圖片高度為 240px */
    object-fit: cover; /* 保持圖片比例，並且裁切圖片讓其填滿父元素 */
    transition: transform 0.3s ease; /* 在懸停時加入動畫過渡，讓圖片產生縮放效果 */
}

/* 設置卡片懸停時封面圖片的縮放效果 */
.news-card:hover .post-thumbnail {
    transform: scale(1.2); /* 在懸停時，圖片稍微放大 5% */
}

/* 設置 SDGs 圖示容器 */
.sdg-icons-container {
    width: 100%; /* 寬度設置為 100% */
    position: absolute; /* 絕對定位於父容器中 */
    bottom: 0; /* 固定在父容器的底部 */
    right: 0; /* 靠右對齊 */
    display: flex; /* 使用彈性布局 */
    flex-wrap: wrap; /* 讓圖標自動換行 */
    gap: 0px; /* 圖標之間的間距 */
    z-index: 10; /* 確保它顯示在圖片上層 */
    max-height: 90px; /* 限制容器的最大高度，兩行圖標大概 80px */
    overflow: hidden; /* 隱藏超出部分 */
}

/* 設置 SDGs 圖示樣式 */
.sdg-icon {
    width: 40px; /* 圖標寬度為 40px */
    height: 40px; /* 圖標高度為 40px */
    object-fit: cover; /* 保持圖片比例並填滿圖標容器 */
}

.card-body {
    display: flex;
    flex-direction: column;
    padding: 10px;
    height: 180px;
}

/* 設置標題樣式 */
.news-title {
    font-size: 20px;
    font-weight: 600; /* 加粗標題文字 */
    color: #333; /* 深色字體，保證可讀性 */
    line-height: 1.5; /* 增加行高，讓標題文字不會顯得擁擠 */
    height: calc(20px * 1.4 * 3); /* 計算兩行高度：字體大小 * 行高 * 行數 */
    overflow: hidden; /* 防止長標題內容超出容器範圍 */
    text-overflow: ellipsis; /* 當標題過長時，顯示省略號 */
    display: -webkit-box; /* 使文字顯示為多行 */
    -webkit-line-clamp: 3; /* 限制標題顯示兩行 */
    -webkit-box-orient: vertical; /* 垂直排列多行文字 */
}

/* 在整個卡片懸停時改變標題樣式 */
.news-card:hover .news-title {
    color: #d4a64f;
}

/* 設置卡片底部的資訊區塊 */
.news-info-container {
    display: flex; /* 使用彈性布局 */
    justify-content: space-between; /* 讓內容兩側對齊，並在中間分配空間 */
    align-items: center; /* 垂直居中對齊 */
    margin-top: auto; /* 將這個區塊推到最底部 */
}

/* 設置活動日期的樣式 */
.news-info {
    font-size: 18px;
    color: #444444;
}

/* 在整個卡片懸停時改變標題樣式 */
.news-card:hover .news-info {
    color: #d4a64f;
}

/* 類別書籤 */
.category-badge {
    position: absolute; /* 絕對定位，使其相對於最近的相對定位祖先（即卡片容器）来定位 */
    top: 0px; /* 设置标签距离卡片顶部 0px */
    left: 0px; /* 设置标签距离卡片左边 0px */
    font-size: 1.2rem; /* 设置标签的字体大小为 1rem（大约 16px），使其适合卡片 */
    font-weight: 600; /* 加粗標題文字 */
    padding: 6px 16px; /* 设置标签的内边距，水平 16px，垂直 8px，使标签内文字不至于贴边 */
    border-radius: 5px; /* 设置标签的圆角半径，使标签更圆润，外观更柔和 */
    background-color: rgba(0, 162, 196, 0.8); /* 设置标签的背景颜色为苹果绿，增加清新感和现代感 */
    color: white; /* 设置标签中文字颜色为白色，和背景形成强烈对比，提升可读性 */
    text-transform: uppercase; /* 将标签文字转换为大写字母，增强视觉冲击力 */
    letter-spacing: 1px; /* 设置字母之间的间距，使文字更具可读性并显得更加舒展 */
    width: 120px; /* 圖標寬度為 40px */
    text-align: center; /* 字居中 */
    clip-path: polygon(0% 0%, 100% 0%, 90% 50%, 100% 100%, 0% 100%); /* 右侧倒三角形*/
}

/* 分頁容器樣式 */
.pagination {
    display: flex;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    list-style: none;
    margin: 1rem 0;
}

/* 分頁項目樣式 */
.page-item {
    margin: 0 0.2rem;
}

/* 分頁連結樣式 */
.page-link {
    border: 1px solid rgba(0, 162, 196, 1);
    color: rgba(0, 162, 196, 1);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    transition: background 0.2s, transform 0.2s;
}

    /* 懸停和點擊效果 */
    .page-link:hover {
        background: linear-gradient(145deg, rgba(0, 162, 196, 0.7), rgb(66, 213, 213, 0.7));
        color: rgba(0, 162, 196, 1);
        transform: translateY(-2px);
    }

/* 啟用頁面樣式 */
.page-item.active .page-link {
    background: linear-gradient(145deg, rgba(0, 162, 196, 0.7), rgb(66, 213, 213, 0.7));
    border: 1px solid rgba(0, 162, 196, 1);
    color: #fff;
}

/* 禁用項目樣式 */
.page-item.disabled .page-link {
    color: rgb(125, 125, 125, 0.70);
    pointer-events: none;
}

.page-item label {
    font-weight: bold;
    color: rgba(0, 162, 196, 1);
}
/* 輸入框樣式 */
#pageInput {
    border: 1px solid rgba(0, 162, 196, 1);
    border-radius: 1rem;
    text-align: center;
    color: #1b4332;
}

/* 跳轉按鈕樣式 */
.btn-primary {
    background: linear-gradient(145deg, rgba(0, 162, 196, 1), rgb(66, 213, 213, 1));
    border: none;
    border-radius: 1.5rem;
    font-weight: bold;
    color: #fff;
    padding: 0.3rem 1rem;
    transition: background 0.2s, transform 0.2s;
}

    /* 按鈕懸停效果 */
    .btn-primary:hover {
        background: linear-gradient(145deg, rgba(0, 162, 196, 0.7), rgb(66, 213, 213, 0.7));
        transform: translateY(-2px);
    }

@media (max-width: 1400px) {
    .news-card-container {
        margin: 0 50px;
    }

    .news-card {
        min-width: 200px;
    }

    .item-thumbnail-container {
        width: 100px;
        height: 100px;
    }

    .item-thumbnail {
        width: 60px;
        height: 60px;
    }
    /* 設置 SDGs 圖示容器 */
    .sdg-icons-container {
        max-height: 70px; /* 限制容器的最大高度，兩行圖標大概 80px */
    }

    /* 設置 SDGs 圖示樣式 */
    .sdg-icon {
        width: 35px; /* 圖標寬度為 40px */
        height: 35px; /* 圖標高度為 40px */
    }
}

@media (max-width: 1200px) {
    .news-card-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1080px) {
    .item-thumbnail-container {
        width: 70px;
        height: 70px;
    }

    .item-thumbnail {
        width: 40px;
        height: 40px;
    }

    .sdg-text {
        font-size: 10px;
    }
}

@media (max-width: 800px) {
    .news-card-container {
        grid-template-columns: 1fr;
    }

    .item-thumbnail-container {
        width: 40px;
        height: 40px;
    }

    .item-thumbnail {
        width: 40px;
        height: 40px;
    }
    /* ✅ 讓勾選時的文字變色 + 上移 */
    .item-thumbnail-container:has(.item-checkbox:checked) .sdg-text {
        font-size: 6px;
        font-weight: 900;
    }
}

@media (max-width: 450px) {
    .news-card {
        height: 450px;
        min-width: 280px;
    }

    .post-thumbnail-container {
        height: 220px;
    }

    .card-body {
        height: 230px;
    }

    .sdg-icons-container {
        max-height: 60px;
    }

    .sdg-icon {
        width: 30px;
        height: 30px;
    }

}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: rgba(0, 162, 196, 0.9); /* 跟你的主色一致 */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 10;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
