* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #DFD7CB;
}

/* Header Section */
.header {
    width: 100%;
    text-align: center;
    margin-top: 24px;
    background-repeat: repeat-x;
    padding: 24px 0;
}

.header.miaoli-taichung {
    background-image: url('../images/head-bg-miaoli-taichung.png');
}

.header.changhua-yunlin {
    background-image: url('../images/head-bg-changhua-yunlin.png');
}

.header.nantou {
    background-image: url('../images/head-bg-nantou.png');
}

/* 主要圖片 */
.main-image {
    position: relative;
    top: -35px;
    z-index: 2;
}

.navi {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 1rem;
}

.navi a {
    padding: 10px 14px;
    color: #A8A998;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.4rem;
    border-right: 3px solid #A8A998;
    line-height: .2;
}

.navi a:last-child {
    border-right: none;
}

.navi a:hover {
    color: #333;
}

/* 內容區塊 */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* 介紹文字區塊 */
.intro-section {
    padding: 30px;
    margin-right: auto;
    margin-left: auto;
}

.intro-section p {
    font-size: 1.4rem;
    line-height: 1.8;
    font-weight: bolder;
    color: #444;
    text-align: justify;
}

/* 文書展示區塊 */
.document-section {
    margin-bottom: 60px;
}

.document-title {
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
    color: #2c3e50;
    padding: 15px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease-in, transform 1s ease-in;
}

.document-title.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 輪播圖容器 */
.carousel-container {
    position: relative;
    max-width: 700px;
    /* 增加寬度來容納外側箭頭 */
    margin: 0 auto;
    padding: 0 70px;
    /* 左右預留箭頭空間 */
    padding-bottom: 50px;
    /* 為指示器預留空間 */
}

.carousel {
    position: relative;
    overflow: hidden;
    /* height: 500px; */
}

.carousel-inner {
    display: flex;
    transition: transform 0.5s ease;
    height: 100%;
}

.carousel-item {
    width: 100%;
    flex-shrink: 0;
    padding: 20px;
}

.carousel-item-image {
    margin-bottom: 20px;
}

/* 指示器用絕對定位在輪播下方 */
.carousel-indicators {
    position: absolute;
    top: 520px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    margin: 0;
}

.carousel-item img {
    width: 100%;
    height: 500px;
    display: block;
    border-radius: 10px;
}

/* 輪播控制按鈕 */
.carousel-nav {
    position: absolute;
    top: 40%;
    transform: translateY(-50%);
    border: none;
    width: 40px;
    height: 40px;
    cursor: pointer;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: all 0.3s ease;
    z-index: 10;
    opacity: 0.8;
}

.carousel-nav:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.carousel-prev {
    left: -60px;
    /* 移到輪播圖外側 */
    background-image: url('../images/left-arrow.png');
    background-color: transparent;
}

.carousel-next {
    right: -60px;
    /* 移到輪播圖外側 */
    background-image: url('../images/right-arrow.png');
    background-color: transparent;
}

/* 輪播指示器 */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 15px 0;
    padding: 0;
}

.carousel-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-indicator.active {
    background-color: #2c3e50;
    transform: scale(1.2);
}

.justify-content-center {
    justify-content: center !important;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col-md-6 {
    flex: 0 0 calc(50% - 20px);
    max-width: calc(50% - 20px);
    margin: 10px;
}

.col-md-6 .image {
    text-align: center;
}

.col-md-6 .image img {
    max-width: 100%;
    height: 500px;
    width: auto;
}

/* 文書資訊 */
.document-info {
    margin-top: 30px;
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.document-info .label {
    font-weight: bold;
    color: #333;
}

.text-bold {
    font-weight: bold;
}

/* 書契名粗體 */
.document-info p:first-child {
    font-weight: bold;
}

/* 說明文字對齐和缩进 */
.document-info p:nth-child(3) {
    text-align: justify;
    padding-left: 4em;
    text-indent: -4em;
    line-height: 1.8;
}

/* 向上箭頭按鈕 */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: url('../images/top.png?v=1') center/contain no-repeat;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
}


/* Responsive Design */
@media (max-width: 768px) {
    .content {
        padding: 20px 15px;
    }

    .intro-section {
        width: 100%;
    }

    .intro-section p {
        font-size: 1.2rem;
    }

    .navi a {
        font-size: 1rem;
    }

    .document-title {
        font-size: 1.5rem;
        padding: 12px;
    }

    .carousel-container {
        max-width: 90%;
        padding: 0 15px;
        /* 手機版也保留箭頭空間 */
    }

    .carousel-nav {
        top: 25%;
    }

    .carousel-prev {
        left: -25px;
        /* 手機版箭頭位置 */
    }

    .carousel-next {
        right: -25px;
        /* 手機版箭頭位置 */
    }

    /* 手機版 col-md-6 變成 100% 寬度 */
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* 手機版向上箭頭調整 */
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }

    /* 圖片高度調整 */
    .carousel-item img {
        width: auto;
        height: 240px;
        display: block;
        border-radius: 10px;
    }

    .carousel-indicators {
        top: 260px;
    }

    .col-md-6 .image img {
        height: 240px;
    }
}

/* 頁尾資訊 */
.footer {
    background-color: #DFD7CB;
    padding: 30px 20px;
    text-align: center;
}

.footer p {
    margin: 8px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.footer .copyright {
    font-weight: 500;
}

.footer .visitor-count {
    color: #555;
}