/* CSS Reset and Base Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 1rem;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    line-height: 1.2;
    color: #333;
    background-color: #FFFFFF;
    background: url('../RWD/icon/banner.png') center top no-repeat;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

html.noscroll,
body.noscroll {
    overflow: hidden;
    height: 100%;
}


/* Focus styles for accessibility */

a:focus,
button:focus,
input:focus {
    outline: 0.3rem solid #ea4e25;
    outline-offset: 0.125rem;
}


/* Container */

.container {
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
}


/* 區塊1: Header */

.site-header {
    position: relative;
    height: 320px;
}


/* B: top-menu-bar */

.top-nav {
    display: inline-flex; /* 讓背景只包內容 */
    justify-content: flex-end; /* 將裡面元素往右靠 */
    background: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    border-radius: 3rem;
    color: #20634d;
    height: 30px;
    line-height: 30px;
    padding: 0px 5px;
    margin-top: 20px;
}

.top-nav a {
    color: #20634d;
    padding: 0 0.5rem;
    transition: color 0.3s ease;
}

.top-nav a:hover {
    color: #ea8125;
}

.separator {
    color: #20634d;
    margin: 0 0.1rem;
}


/* A: 網頁LOGO */

.site-logo img {
    max-width: 100%;
    height: auto;
    display: block;
}


/* C: 主選單NAV */

.main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.nav-wrapper {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 0 25px;
    background: linear-gradient(90deg, #197eb0 0%, #00874a 100%);
    border-radius: 2rem 2rem 0 0;
    min-height: 85px;
    box-shadow: 0px 5px 10px rgba(0, 1, 0, 0.3);
}

.hamburger {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger span {
    width: 1.5rem;
    height: 0.2rem;
    background: #20634d;
    margin: 0.125rem 0;
    transition: 0.3s;
}

.close-drawer {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.nav-menu {
    display: flex;
    width: 100%;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    flex: 1;
    text-align: center;
}

.nav-link {
    display: block;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.1rem;
    height: 55px;
    position: relative;
    line-height: 55px;
}

    .nav-link:hover,
    .nav-link:focus,
    .nav-link:active {
        color: #806f38;
        transform: translateY(-2px);
    }

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #ffde66;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link:focus::after,
.nav-link:active::after {
    width: 60%;
}

.nav-link:focus {
    outline: none;
}


/* 區塊2: Main */

.main-content {
    min-height: 400px;
    padding-bottom: 20px;
    margin-bottom: -50px;
    position: relative;
    z-index: 2;
}

.main-content .container {
    background-color: #fffce8;
    border-radius: 0 0 2rem 2rem;
    padding: 40px 10px;
    box-shadow: 0px 5px 10px rgba(0, 1, 0, 0.3);
}

.bg-info {
    --bs-bg-opacity: 1;
    background-color: #257c8e !important
}
/* D: 含圖含文字的資訊卡片 */
.service-cards {
    margin-bottom: 3rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
}

.service-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: #4d4d4d;
    position: relative;
    overflow: hidden;
    transition: color 0.3s ease-in-out;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffe387;
    clip-path: polygon(0 0, 0 0, 0 0, 0 0);
    transition: clip-path 0.4s ease-in-out;
    z-index: 0;
}

.service-card:hover::before {
    clip-path: polygon( 0% 0%, /* 左上角 */
    100% 0%, /* 右上角 */
    100% 100%, /* 右下角 */
    0% 100%/* 左下角 */
    );
}

.card-odd {
    background: linear-gradient(to bottom, #f2f9ff 0%, #e3f2ff 100%);
}

.card-even {
    background: linear-gradient(to bottom, #edfff9 0%, #efffd9 100%);
}

.card-icon {
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.card-icon img {
    width: 140px;
    height: 140px;
    transition: filter 0.3s ease-in-out;
}

.card-content {
    position: relative;
    z-index: 1;
}

    .card-content h2 {
        font-size: 1.2rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
        color: #252122;
    }


/* EFG: 新聞、搜尋、下載區塊 */

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 0.6fr;
    gap: 1.2rem;
    margin-bottom: 3rem;
}

.section-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    background-color: #2779b8;
    height: 4rem;
    border-radius: 0.8rem;
}

.section-title {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 500;
    color: white;
    padding-right: 30px;
}

    .section-title::before {
        content: "";
        display: inline-block;
        width: 1.5rem;
        height: 1.5rem;
        margin: 0 1rem;
        background: url("../RWD/icon/section-titleICON.svg") no-repeat center/contain;
    }

.section-header::after {
    content: "";
    position: absolute;
    top: 32px;
    right: 0;
    width: 45px;
    height: 62px;
    background: url("../RWD/icon/section-title-design.svg") no-repeat top right;
    pointer-events: none;
}

.more-btn {
    background: #ffde66;
    color: black;
    padding: 0.3rem 0.8rem;
    border-radius: 5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.3s ease;
    margin-inline-end: 45px;
}

.more-btn:hover {
    color: white;
    background: #ea8125;
}


/* E: 新聞區塊 */

.news-section {
    background: linear-gradient(to bottom, #ffffff 0%, #f4f4f4 93%, #e2e2e2 100%);
    border-radius: 0.5rem;
    overflow: hidden;
}

.news-list {
    width: 96%;
    margin: -5px auto 10px auto;
}

.news-item,
.download-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 0.0625rem dashed #b3b3b3;
    transition: background 0.3s ease;
    color: #000;
}

.news-item:hover,
.download-item:hover {
    color: #ea8125;
    background: #fff5d4;
}

.news-date {
    font-size: 0.875rem;
    color: #666;
    white-space: nowrap;
}

.news-tag {
    color: #ea4e25;
    margin-right: -0.8rem;
}

.news-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.3s ease;
}


/* F: 搜尋區塊 */

.search-box {
    display: flex;
    width: 90%;
    margin: -8px auto 15px auto;
    flex-direction: column;
}

.search-box form {
    display: flex;
}

.search-input {
    display: flex;
    padding: 0.75rem;
    border: 0.0625rem solid #ddd;
    border-radius: 0.25rem 0 0 0.25rem;
    font-size: 1rem;
    width: 100%;
}

.search-btn {
    background: #2779b8;
    color: white;
    border: none;
    border-radius: 0 0.25rem 0.25rem 0;
    cursor: pointer;
    transition: background 0.3s ease;
    padding: 0.63rem 1rem;
}

.search-btn:hover {
    background: #ea8125;
}

.search-keywords {
    margin-top: 15px;
    font-size: 0.875rem;
    color: #666;
}

.keywords-label {
    margin-right: 0.5rem;
}

.keyword-link {
    color: #2c5aa0;
    margin: 0 0.25rem;
    transition: color 0.3s ease;
}

.keyword-link:hover {
    color: #ea8125;
}


/* G: 下載區塊 */

.download-link {
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    transition: color 0.3s ease;
    font-size: 1rem;
}

.download-link::before {
    content: '📄 ';
    margin-right: 0.5rem;
}

.sidebarmb {
    margin-bottom: 1.2rem;
}

.download-list {
    width: 96%;
    margin: -5px auto 10px auto;
}


/* H: 含圖含文字的資訊卡片 */

.cards-container {
    display: flex;
    flex-wrap: nowrap; /* 預設小螢幕：不換行，橫向捲動 */
    overflow-x: auto;
    gap: 1rem;
    padding: 0 1rem;
    box-sizing: border-box;
    justify-content: flex-start;
    scroll-padding-left: 1rem;
}

.system-card {
    flex: 0 0 auto; /* 小螢幕時：固定寬度，才能捲動 */
    width: 220px;
}

@media (min-width: 1900px) {
    .cards-container {
        flex-wrap: wrap; /* 換行排版 */
        overflow-x: visible; /* 取消卷軸 */
        justify-content: center; /* 或 flex-start，看設計需求 */
    }

    .system-card {
        flex: 1 1 calc(25% - 1rem); /* 四欄 */
        max-width: 300px; /* 限制最大寬度 */
    }
}

.system-card {
    flex: 1 0 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url(../RWD/icon/systemBG.svg) center top no-repeat;
    overflow: hidden;
    text-decoration: none;
    width: 320px;
    height: 104px;
    font-size: 1.2rem;
    padding-bottom: 6px;
    gap: 3px;
    color: #31756b;
}

    .system-card:hover {
        color: #856124 !important;
        background: url("../RWD/icon/systemBGhover.svg") center no-repeat;
    }

.card-image {
    display: block;
    margin: 0px 6px;
    width: 80px;
    height: 77px;
    overflow: hidden;
}

.card-title {
    display: block;
    width: 185px;
    font-size: 1.2rem;
    font-weight: 500;
}

.card-title:hover {
    color: #856124;
}


/* 區塊3: Footer */

.site-footer {
    color: white;
    position: relative;
    z-index: 1;
    padding-top: 65px;
    background: #176663;
}

.footer-top {
    background: #176663;
    padding-bottom: 1.5rem;
}

.footer-columns {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    text-align: center;
}

.footer-column h3 {
    font-size: 1.2rem;
    font-weight: 500;
    color: #ffe482;
    text-align: center;
    display: block;
    width: 100%;
    margin: 0 auto 0.5rem auto;
}

.footer-column {
    display: flex;
    flex-direction: column;
    align-items: center;
}

    .footer-column ul, .footer-bottom-content ul {
        list-style: none;
        padding: 0;
        text-align: center;
    }

.footer-column ul li {
    margin-bottom: 0.5rem;
}

.footer-column ul li a {
    color: #e6f3ff;
    font-size: 1rem;
    transition: color 0.3s ease;
}

.footer-column ul li a:hover {
    color: #87ceeb;
}

.footer-bottom {
    background: #034735;
    padding: 2rem 0;
}

.footer-bottom-content {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr;
    gap: 2em;
    align-items: center;
    font-size: 0.85rem;
    line-height: 0.7;
}

.footer-bottom-content a {
    color: #a8ffff;
}

.footer-bottom-content a:hover {
    color: #e67e22;
}

.footer-logo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a:hover {
    opacity: 0.5;
}

.accessibility-logo {
    width: 6rem;
    margin-bottom: 1rem;
}


/* 區塊4: 按鈕選單 (固定定位) */

.floating-buttons {
    position: fixed;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.floating-buttons ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.floating-buttons a {
    display: block;
    width: 56px;
    height: 56px;
    background-size: cover;
    background-repeat: no-repeat;
    transition: background-image 0.3s ease;
}

a.floatFB {
    background-image: url("../RWD/icon/icon-fb.svg");
}

    a.floatFB:hover {
        background-image: url("../RWD/icon/icon-fb-hover.svg");
    }

a.floatLN {
    background-image: url("../RWD/icon/icon-share-line.svg");
}

    a.floatLN:hover {
        background-image: url("../RWD/icon/icon-share-line-hover.svg");
    }

.visually-hidden {
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    border: 0;
}

.main-content .container {
    min-height: 600px;
}

.top-menu-bar .container {
    display: flex;
    justify-content: flex-end; /* 把裡面的 nav 推到右邊 */
}


/* 響應式設計 */

@media (min-width: 1921px) {
    body {
        background: url('../RWD/icon/BANNER.png') center top repeat-x;
    }
}


/* 1535px-769px */

@media (max-width: 1535px) and (min-width: 769px) {
    .container {
        width: 96%;
    }
    .site-header {
        min-height: 290px;
    }
    .nav-link {
        font-size: 1.2rem;
    }
    .nav-link:hover::after,
    .nav-link:focus::after,
    .nav-link:active::after {
        width: 90%;
    }
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }
    .service-card {
        padding: 0.8rem 1rem
    }
    .card-icon {
        margin-bottom: 0rem;
        position: relative;
        z-index: 1;
    }
}


/* 1200px 以下 - EFG 單欄排列 */

@media (max-width: 1201px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }
    .news-section {
        width: 100%;
    }
    .cards-container {
        width: 98%;
        justify-content: start;
    }
}


/* 768px 以下 */

@media (max-width: 900px) {
    .site-header {
        height: 220px;
    }
    .container {
        width: 98%;
    }
    .site-logo {
        display: flex;
        justify-content: center;
        margin-top: 40px;
    }
    /* Header RWD */
    .top-menu-bar {
        display: none;
    }
    .site-logo {
        justify-content: center;
        text-align: center;
    }
    .logo-text {
        align-items: center;
    }
    .hamburger {
        display: flex;
        position: absolute;
        left: 4.5rem;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 0.5rem;
        padding: 0.75rem;
        z-index: 100;
    }
    a:focus,
    button:focus,
    input:focus {
        outline: none;
        outline-offset: 0rem;
    }
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 60%;
        height: 100vh;
        flex-direction: column;
        padding: 4rem 2rem 2rem;
        transition: right 0.3s ease;
        box-shadow: -0.25rem 0 0.625rem rgba(0, 0, 0, 0.1);
        justify-content: flex-start;
        gap: 0;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        z-index: 99;
    }
    .nav-menu.active {
        right: 0;
    }
    .nav-menu .nav-link {
        width: 100%;
        text-align: left;
        padding: 1rem;
        border-bottom: 0.0625rem solid rgba(255, 255, 255, 0.1);
    }
    .nav-menu .nav-link,
    .nav-menu .drawer-top-menu a,
    .nav-menu .top-menu-bar a {
        display: block;
        width: 100%;
        text-align: center;
        font-size: 1rem!important;
        font-weight: 700;
        color: #001f1e;
        text-decoration: none;
        padding: 0.5rem 0;
        height: 40px;
        line-height: 40px;
    }
    .main-nav {
        position: static;
        top: auto;
        z-index: auto;
    }
    /* Service Cards RWD */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .service-card {
        flex-direction: row;
        justify-content: center;
        padding: 1rem;
    }
    .card-icon {
        margin-bottom: 0;
        margin-right: 1rem;
    }
    .card-icon img {
        width: 110px;
        height: 110px;
    }
    .card-content h2 {
        font-size: 1.1rem;
    }
    /* Footer RWD */
    .footer-columns {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    .footer-bottom-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }
    /* Floating buttons adjustment */
    .floating-buttons {
        display: none;
    }
    .br-desktop {
        display: none;
    }
}


/* 480px 以下 */

@media (max-width: 480px) {
    .site-header {
        height: 110px;
    }
    .service-card {
        padding: 1rem;
    }
    .section-title {
        font-size: 1rem;
    }
    .cards-container {
        gap: 1rem;
    }
    .site-logo {
        margin-top: 50px;
    }
    .card-icon img {
        width: 95px;
        height: 95px;
    }
    .card-content h2 {
        font-size: 1rem;
    }
}


/* 動畫效果 */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(2rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.service-card,
.news-item,
.system-card {
    animation: fadeInUp 0.6s ease-out;
}


/* 滾動條樣式 */

.cards-container::-webkit-scrollbar {
    height: 0.5rem;
}

.cards-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0.25rem;
}

.cards-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 0.25rem;
}

.cards-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* High contrast mode support */

@media (prefers-contrast: high) {
    .service-card,
    .system-card {
        border: 0.125rem solid #000;
    }
    .nav-link:hover,
    .nav-link.active {
        background: #000;
        color: #fff;
    }
}
a {
    color: #039;
    text-decoration: none;
    background-color: transparent;
}

    .list-group-item {
    position: relative;
    display: block;
    padding: .75rem 1.25rem;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, .125);
    color: #5d5d5d;
}

.news-list li a {
    font-size:1.2rem;
}

.top-nav a,
.footer-contact p,
.footer-contact p a,
.footer-info p,
.footer-info p a {
    font-size: 1rem;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important
}


.bg-light {
    background-color: #f8f9fa !important;
}

.form-control:disabled, .form-control[readonly] {
    background-color: #e9ecef;
    opacity: 1;
}

@media (min-width: 576px) {
    .mr-sm-2, .mx-sm-2 {
        margin-right: .5rem !important;
    }
}

.form-control {
    display: block;
    width: 80%;
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .25rem;
}

.small, small {
    font-weight: 400;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: .375rem .75rem;
    margin-bottom: 0;
    font-weight: 400;
    color: #495057;
    text-align: center;
    white-space: nowrap;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
}

.table .thead-dark th {
    color: #fff;
    background-color: #343a40;
    border-color: #454d55;
}

.nav-link {
    display: block;
    padding: .5rem 1rem;
}

.pager .pagenum {
    padding: 3px 6px;
    font-family: Arial;
}

.pager span {
    border: 1px solid #666666;
    padding: 3px;
    font-weight: bold;
    margin: 3px;
}

.pager a {
    border: 1px solid #CACAE4;
    padding: 3px;
    margin: 3px;
}

.pager td {
    padding: 5px;
    text-align: center;
    line-height: 35px;
    height: 35px;
}

.card {
    margin-bottom:1em;
}

.table {
    border-collapse: collapse;
    border: 1px solid #CACAE4;
    font-size: 0.8125rem;
}

    .table > tbody > tr > td {
        padding: 5px;
        border: 1px solid #CACAE4;
        height: 25px;
    }

    .table > tbody > tr > th {
        padding: 5px;
        color: #ffffff;
        background: #1F6CBD;
        border: 1px solid #1F6CBD;
        height: 25px;
    }

@media (max-width: 991px) {
    #navMenu .dropdown-menu {
        position: static !important; /* 取消絕對定位，避免被右邊卡掉 */
        float: none;
        width: 100% !important; /* 讓選單寬度佔滿螢幕 */
        max-width: 100% !important;
        box-sizing: border-box;
    }

        #navMenu .dropdown-menu .dropdown-item {
            white-space: normal; /* 允許換行 */
            word-break: break-word;
        }
}

#mainNav {
    position: sticky; 
    top: 0; 
    z-index: 1000; 
}
.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0; /* 放在背景圖片後面 */
    background: #004080;
    color: #fff;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s;
    /* 將元素稍微移出畫面 */
    transform: translateY(-200%);
}

    .skip-link:focus {
        z-index: 1000; /* 聚焦時提升到最上層 */
        transform: translateY(0); /* 顯示出來 */
    }

    #mainContent {
        scroll-margin-top: 100px; 
    }

/* 父容器自適應 */
@media (max-width: 768px) {
    .container {
        width: 100%;
        max-width: 100%;
        padding: 0 1rem;
        box-sizing: border-box;
    }

    .content-wrapper {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 1rem;
    }

    .news-section,
    .sidebar {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin: 0;
        padding: 0.5rem;
    }

    img, input, button, .news-list li, .download-list li {
        max-width: 100%;
        word-break: break-word;
    }

    .footer-contact p, .footer-info p {
        line-height: 1.6;
    }

    /* 允許表格內容換行，避免寬欄位導致表格超出 */
    .table td,
    .table th {
        white-space: normal !important;
        word-break: break-word;
    }

    /* 避免整張表格在小螢幕超出 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* 手機滑順滾動 */
    }

    /* 適當調整 pager 位置 */
    .pager {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
    }
}