/* ----------------------------------------------------------------
	Custom CSS

	Add all your Custom Styled CSS here for New Styles or
	Overwriting Default Theme Styles for Better Handling Updates
-----------------------------------------------------------------*/

:root {
    --cnvs-themecolor: #006699;
    --cnvs-themecolor-rgb: 0, 102, 153;
}

/* Footer column colors */
.footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(1) .widget_links a,
.footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(2) .widget_links a,
.footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(3) .widget_links a {
    color: #bcbec0 !important;
}

.footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(4) .widget_links a {
    color: #FFF !important;
}

/* Footer column borders */
.footer-col-border {
    border-left: 1px solid #bcbec0;
}

.footer-col-border-white {
    border-left: 1px solid #FFF !important;
}

/* Cancel widget_links li::before in footer */
#footer .widget_links:not(.widget-li-noicon) li::before {
    display: none !important;
}

/* Footer first three columns only show on desktop */
@media (max-width: 991.98px) {

    .footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(1),
    .footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(2),
    .footer-widgets-wrap .row>div>.row>.col-md-3:nth-child(3) {
        display: none !important;
    }
}

/* Fix header alignment issue between 992px and 1123px */
@media (min-width: 992px) {
    #header .container,
    #copyrights .container {
        max-width: 1040px !important;
    }

    #header .header-row {
        flex-wrap: nowrap !important;
        align-items: center !important;
    }

    #header .header-row.top-search-parent {
        justify-content: flex-end !important;
    }

    #header .primary-menu .menu-container {
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
    }

    #header .primary-menu .menu-item {
        margin-left: 0.58rem !important;
        margin-right: 0.59rem !important;
    }

    #header .primary-menu .menu-link {
        font-size: 18px !important;
        padding: 0.9rem 1rem !important;
    }

    #header .header-misc {
        margin-left: 0.5rem !important;
    }

    #header #logo {
        flex-shrink: 0 !important;
    }
}

/* Mobile menu item padding */
@media (max-width: 991.98px) {
    #header .primary-menu .menu-item > .menu-link {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
}

/* Top Advert - 水平和垂直居中 */
/* 默认显示，所有屏幕尺寸 */
.top-advert {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 250px;
    padding: 20px 0;
    border: none;
}

.top-advert a {
    display: block;
    max-width: 970px;
    width: 100%;
}

.top-advert img {
    max-width: 970px;
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* 屏幕小于970px时隐藏 */
@media (max-width: 969px) {
    .top-advert {
        display: none !important;
    }
}

/* 让文章内容与側欄分开拉伸高度 */
.row.gx-5.col-mb-80 {
    align-items: stretch;
}

/* Sidebar - 固定宽度 350px，padding 与主内容对齐 */
/* 平板和桌面尺寸 - 固定宽度并对齐 padding */
@media (min-width: 768px) {
    .sidebar.col-lg-3 {
        /* 保持与 .postcontent 相同的左右 padding (gx-5 = 1.5rem) */
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
}

@media (min-width: 992px) {
    .sidebar.col-lg-3 {
        flex: 0 0 350px !important;
        max-width: 350px !important;
        width: 350px !important;
        /* 保持与 .postcontent 相同的左右 padding (gx-5 = 1.5rem) */
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    /* 调整主内容区域宽度以适应固定的 sidebar */
    .postcontent.col-lg-9 {
        flex: 1 1 auto !important;
        max-width: calc(100% - 350px) !important;
    }
}

/* Sidebar 热门文章标题 - 两行省略 */
.sidebar .sidebar-title-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    max-height: 2.8em;
    /* 1.4 * 2 行 */
}

.sidebar .sidebar-title-clamp a {
    display: inline;
}

/* Sidebar 图片宽度优化 */
.sidebar .entry-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 4/3;
}


/* Sidebar 熱門文章區塊設計 */
.sidebar .widget-hot-posts {
    padding: 15px 12px 10px;
}

.sidebar .widget-hot-posts-title {
    margin-bottom: 12px !important;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--cnvs-themecolor);
}

.sidebar .custom-hot-posts-widget {
    width: 100%;
}

.sidebar .hot-post-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #e5e5e5;
}

.sidebar .hot-post-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sidebar .hot-post-rank {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: var(--cnvs-themecolor);
    color: #fff;
    font-size: 12px;
    line-height: 22px;
    text-align: center;
    font-weight: 600;
}

.sidebar .hot-post-link {
    display: block;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.sidebar .hot-post-link:hover {
    color: var(--cnvs-themecolor);
    text-decoration: underline;
}

.sidebar .hot-post-empty {
    font-size: 14px;
    color: #666;
    padding: 6px 0 0;
}

/* 移除 cnvs-article-share 的边框 */
#cnvs-article-share.card {
    border: none !important;
    box-shadow: none !important;
}

#cnvs-article-share .card-body {
    border: none !important;
}

/* Widget h3 margin-bottom 强制为 10px */
.widget h3 {
    margin-bottom: 10px !important;
}

.is-expanded-menu .full-header .primary-menu .menu-container {
    border-right: 0px solid var(--cnvs-header-border-color) !important;
}

.is-expanded-menu.stretched .full-header #header-wrap > .container {
    padding: 0 !important;
}

/* 响应式 Slider 背景图片 - 使用单个元素切换背景 */
/* 手机尺寸 - 显示竖图，针对 iPhone 13 Pro (390x844) 优化 */
@media (max-width: 767px) {
    .responsive-slider-bg {
        background-image: url('../images/homepage-background-mobile-v3.png') !important;
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
    }

    /* 确保 slider 在手机上全屏显示 */
    #slider.slider-element {
        min-height: 100vh !important;
        height: 100vh !important;
    }

    #slider .swiper-slide-bg {
        width: 100% !important;
        height: 100% !important;
    }
}

/* 平板和桌面尺寸 - 显示横图 */
@media (min-width: 768px) {
    .responsive-slider-bg {
        background-image: url('../images/homepage-background-v3.jpg') !important;
        background-size: cover !important;
        background-position: center center !important;
    }
}

/* Homepage Articles and DFP Banner Layout */
/* 统一文章和banner的尺寸为300x250，使同一行对齐 */


/* 调整整体容器间距 */
.row.col-mb-50 {
    row-gap: 30px !important;
    /* 减少行间距 */
}

/* 统一feature-box的宽度和样式 */
.feature-box.media-box {
    width: 300px;
    max-width: 100%;
    margin: 0 auto;
    /* 居中显示 */
}

.dfp-banner-container,
.article-media-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 300px;
    height: 250px;
    max-width: 100%;
    overflow: hidden;
}

/* DFP Banner - 保持300x250固定尺寸 */
.homepage-article {
    margin-top: 20px !important;
}

.dfp-banner-container {
    background-color: #fefefe;
    /* 浅灰色背景，方便识别广告位 */
}

.dfp-banner-container img {
    width: 300px !important;
    height: 250px !important;
    max-width: 100%;
    object-fit: contain;
}

.dfp-banner:before {
    content: '贊助商連結';
    font-size: 12px;
    line-height: 15px;
    color: #000000;
    text-align: left;
    letter-spacing: normal;
}

/* Billboard 970x250 DFP container */
.dfp-banner.dfp-billboard {
    display: block;
    width: 100%;
    max-width: 970px;
    height: 250px;
    margin: 0 auto;
    /* background-color: #fefefe; */
    /* 方便識別位置 */
}

/* Halfpage 300x600 DFP container */
.dfp-banner.dfp-halfpage {
    display: block;
    width: 300px;
    max-width: 100%;
    height: 600px;
    margin: 0 auto;
    /* background-color: #fefefe; */
}

/* 文章图片 - 固定300x250尺寸 */
.article-media-container {
    position: relative;
}

.article-media-container img {
    width: 300px;
    height: 250px;
    max-width: 100%;
    object-fit: cover;
}

/* 文章标题容器 - 固定宽度300px */
.feature-box.media-box .fbox-content {
    width: 300px;
    max-width: 100%;
}

/* 响应式调整 - 屏幕小于991px */
@media (max-width: 990.98px) {

    .feature-box.media-box {
        width: 100% !important;
    }

    .feature-box.media-box .fbox-content {
        width: 100% !important;
    }

    .fbox-content.px-0 h3 {
        width: 100% !important;
    }

    .fbox-media.dfp-banner-container {
        width: 300px !important;
        margin: 0 auto !important;
        /* display: flex !important;*/
        align-items: center !important;
        justify-content: center !important;
    }

    .dfp-banner-container img {
        width: 300px !important;
        height: 250px !important;
        margin: 0 auto !important;
    }

    .heading-block {
        padding: 0 12px;
    }

    /* sidebar padding*/
    .sidebar-widgets-wrap {
        padding-left: 1.5rem;
        padding-right: 1.5rem;

    }
}

/* 响应式调整 - 576px到991px区间：在平板寬度下交錯排版文章與300x250廣告
   使用額外 class 來控制交錯排版，避免 :nth-child(of S) 相容性問題 */
@media (min-width: 576px) and (max-width: 990.98px) {
    .feature-box.media-box .fbox-content h3 {
        font-size: 22px;
    }

    /* 恢復 576-991px 區間為傳統 2 欄排列（避免 Grid 留空位） */
    #content .section .row.col-mb-50 {
        display: flex;
        flex-wrap: wrap;
        row-gap: 30px !important;
    }

    #content .section .row.col-mb-50>[class*="col-"] {
        width: 50% !important;
        max-width: 50% !important;
    }

    #content .section .row.col-mb-50>.pair-md-full {
        width: 50% !important;
        max-width: 50% !important;
    }
}

/* 响应式调整 - 手机端 */
@media (max-width: 767px) {

    .row.col-mb-50 {
        row-gap: 20px !important;
        /* 手机端更小的间距 */
    }

    .media-box .fbox-media {
        margin: 1rem 0 1rem;
    }
}

/* 确保feature-box的标题部分高度一致 */
.feature-box.media-box .fbox-content h3 {
    min-height: 3em;
    /* 大约2行标题的高度 */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    margin-bottom: 0;
}

/* 调整列间距 - 使用更紧凑的布局 */
@media (min-width: 992px) {
    .row.col-mb-50>.col-lg-4 {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* 固定container最大宽度为980px */
#content .container {
    max-width: 990px !important;
}

#content {
    background-color: var(--cnvs-section-bg);
}

.single-post,
.sidebar {
    background: #FFF;
    padding: 20px;
}
@media (max-width: 767px) {
    .single-post,
    .sidebar {
        padding: 0;
    }
}

#cnvs-article-share .card-body {
    padding: 0px !important;
}

.content-caption {
    font-size: 14px !important;
    color: rgb(102, 102, 102);
    padding: 8px 0px;
    border-bottom: 1px dotted rgb(204, 204, 204);
}


/* Homepage Out-of-Page Desktop Popup Ad */
.homepage-oop-popup {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.homepage-oop-popup.is-visible {
    display: flex;
}

.homepage-oop-popup-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
}

.homepage-oop-popup-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    max-width: 100%;
}

.homepage-oop-popup-close {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: #fff;
    color: #000;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* Search page */
.search-page-results .search-result-item {
    padding-bottom: 0;
    border-bottom: none;
}

.search-page-results .search-result-item:last-of-type {
    border-bottom: none;
}

.search-page-results .homepage-featured-media img {
    min-height: 180px;
    object-fit: cover;
}

.search-page-results .search-result-excerpt {
    margin-top: 6px;
    margin-bottom: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-page-results .section-title.mb-4 {
    margin-bottom: 0.5rem !important;
}

.search-results-list .feature-box.media-box {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0;
    margin-right: 0;
}

.search-results-list .article-media-container {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
}

.search-results-list .article-media-container img {
    width: 100% !important;
    height: auto !important;
    min-height: 0;
    object-fit: cover;
}

.search-results-list .fbox-content {
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.search-results-list {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 30px;
    column-gap: 20px;
}

.search-results-list > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
}

@media (min-width: 768px) {
    .search-results-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.search-page-results .homepage-article {
    margin-top: 0 !important;
}

.primary-menu .sub-menu-container .menu-item {
    margin: 2px 0 !important;
}

/* 調整子選單文字內距，確保有可視間距 */
.primary-menu .sub-menu-container .menu-link > div {
    padding: 4px 8px !important;
}

/* 搜索/救災模板標題樣式 */
.section-title .section-title-heading {
    padding-bottom: 6px;
    border-bottom: 2px solid var(--cnvs-themecolor);
    margin: 0 0 12px 0;
}

.search-page-results {
    background: #fff;
    padding: 20px;
    padding-top: 20px;
    height: 100%;
}

.postcontent,
.sidebar {
    height: 100%;
}

.postcontent {
    display: flex;
    flex-direction: column;
}

.search-page-results {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Menu icons */
.primary-menu .menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-right: 5px;
}

.primary-menu .menu-icon img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}

.primary-menu .menu-link > div {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.top-search-form input {
    font-size: 1rem !important;
}

/* Article Title Link Styles for Homepage and Templates */
.homepage-article h3 a,
.homepage-article .homepage-featured-link {
    color: #31404B !important;
}

.homepage-article h3 a:hover,
.homepage-article .homepage-featured-link:hover {
    color: var(--cnvs-themecolor) !important;
}

/* Unified Font Family */
body, h1, h2, h3, h4, h5, h6, .font-primary, .font-secondary, p, a, div, span, input, button, select, textarea {
    font-family: "microsoft yahei", "新細明體", mingliu, Arial, Helvetica, sans-serif !important;
}
