/* 版型散落在各頁 <style> 裡的自訂樣式，集中在這裡由 _Layout 全站載入。
   CSS 的 @media 若寫在 .cshtml 會被 Razor 當語法而必須跳脫成 @@media，容易出錯。 */

/* 自訂按鈕容器 */
.custom-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

/* 基礎按鈕樣式 */
.custom-buttons button {
    background-color: #fff;
    color: #333;
    border: 1px solid #ddd;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    outline: none;
}

/* 懸停效果 */
.custom-buttons button:hover {
    border-color: #d25d2f;
    color: #d25d2f;
}

/* 啟用中狀態 (Active) */
.custom-buttons button.active {
    background-color: #d25d2f;
    color: #fff;
}

@media only screen and (max-width: 640px) {

    /* 自訂按鈕容器 */
    .custom-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
        margin-bottom: 20px;
        justify-content: center;
    }

    /* 基礎按鈕樣式 */
    .custom-buttons button {
        background-color: #fff;
        color: #333;
        border: 1px solid #ddd;
        padding: 5px 5px;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-size: 16px;
        outline: none;
    }
}

/* 住戶手冊下載連結：預設黑色，滑鼠懸停變橘色。
   版型在 manual.html 內重複內嵌了 4 次，這裡收成一份。 */
.pdf-text-link {
    color: #000000 !important;
    font-size: 20px;
    text-decoration: none;
    transition: color 0.3s ease;
    display: inline-block;
}

.pdf-text-link:hover {
    color: #ff6600 !important;
}

/* 實品屋雙欄圖組（Type18 內容區塊與業績的實品屋實景共用）。
   原本只寫在版型 works0001.html 的 <style> 裡沒有搬過來，
   少了這段左右欄會塌成整排直向大圖。 */
.gallery {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 1920px;
    margin-left: auto;
    margin-right: auto;
}

.gallery.reverse {
    flex-direction: row-reverse;
}

.gallery-left,
.gallery-right {
    flex: 1;
    display: grid;
    aspect-ratio: 16 / 10;
}

/* 小圖固定兩欄，張數超過 4 就自己往下長一列，不會擠壓變形 */
.gallery-right {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 1fr;
    gap: 10px;
}

.gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 小圖不足 4 張時，格線跟著張數收，右邊才不會留白格。
   :has() 不支援的舊瀏覽器會退回 2x2，只是留空，不會壞版。 */
.gallery-right:has(> :last-child:nth-child(1)) {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.gallery-right:has(> :last-child:nth-child(2)) {
    grid-template-columns: 1fr;
}

.gallery-right:has(> :last-child:nth-child(3)) > :first-child {
    grid-column: span 2;
}

.img-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.img-container a {
    display: block;
    width: 100%;
    height: 100%;
}

/* 疊在大圖左上角的組名，pointer-events 關掉才不會擋住燈箱點擊 */
.overlay-text {
    position: absolute;
    top: 10px;
    left: 15px;
    font-family: 'Cinzel', serif !important;
    color: #fff;
    font-size: 25px;
    text-shadow: 0 0 10px #000;
    pointer-events: none;
    z-index: 10;
}

@media (max-width: 768px) {

    .gallery,
    .gallery.reverse {
        flex-direction: column;
    }

    .gallery-left,
    .gallery-right {
        aspect-ratio: auto;
    }

    .gallery-right {
        height: 300px;
    }
}

/* 年份／行政區篩選：資料一多選單會高到被固定表頭蓋住（父層 section 有
   z-index:0 建立堆疊環境，選單的 z-index 永遠壓不過表頭）。限高改內部捲動，
   搭配 toggle 的 data-flip="false" 讓它只往下開，就不會頂到表頭。 */
.mix-filter {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

/* 手機版標題與按鈕改成上下堆疊，按鈕位置較低，可用高度要再收一些 */
@media (max-width: 767px) {
    .mix-filter {
        max-height: calc(100vh - 400px);
    }
}
