/* 基本重置與全域設定 */
body, h1, h2, p, div, img, footer, header, main, select, label {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- 基礎風格 --- */
body {
    font-family: 'Noto Sans TC', sans-serif;
    line-height: 1.6;
    /* 水墨風格背景 - 使用多層次的灰色漸層 */
    background:
        radial-gradient(ellipse at top left,     rgba(180, 180, 180, 0.2) 0%, rgba(180, 180, 180, 0) 50%),
        radial-gradient(ellipse at bottom right, rgba(150, 150, 150, 0.2) 0%, rgba(150, 150, 150, 0) 40%),
        linear-gradient(to bottom, rgba(200, 200, 200, 0.1) 0%, rgba(220, 220, 220, 0.1) 100%),
        #d8d8d8; /* 更深的灰色底色 */
    background-attachment: fixed; /* 固定背景 */
    color: #3a3a3a; /* 更深的灰色文字 */
    /* 添加一點模糊效果到背景上 (可選) */
    /* backdrop-filter: blur(2px); */
    transition: margin-left 0.3s ease; /* 添加過渡效果 */
}

body.sidebar-open {
    margin-left: 250px; /* 側邊欄打開時，內容向右移動 */
}


a {
    text-decoration: none;
    transition: color 0.3s ease;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 頁首 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 5%;
    border-bottom: 1px solid #b0b0b0; /* 更深的灰色邊框 */
    margin-bottom: 40px;
    background-color: rgba(230, 230, 230, 0.8); /* 半透明淺灰背景 */
    backdrop-filter: blur(5px); /* 模糊效果 */
}

header h1 {
    font-size: 2.5em;
    font-weight: 600;
    letter-spacing: 1px;
    margin: 0 auto;
    color: #2a2a2a; /* 非常深的灰色標題 */
}

/* 畫廊容器與 Masonry 佈局 */
.gallery-container {
    padding: 0 5%;
    max-width: 1600px;
    margin: 0 auto 40px auto;
    transition: margin-left 0.3s ease; /* 添加過渡效果 */
}

.gallery {
    margin: 0 auto;
}

.artwork {
    width: calc(33.333% - 20px);
    margin-bottom: 30px;
    /* --- 簡潔卡片樣式 (基於灰色主題) --- */
    padding: 20px;
    /* background-color: #bdb76d; 使用者指定的顏色 */
    background-color: rgb(77, 104, 117); /* 使用者指定的顏色 */
    border: 1px solid #c0c0c0; /* 灰色主題邊框 */
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1); /* 灰色主題陰影 */
    backdrop-filter: blur(3px); /* 模糊效果 */
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease; /* 簡化過渡 */
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.artwork:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); /* 灰色主題懸停陰影 */
    border-color: #a0a0a0; /* 灰色主題懸停邊框顏色 */
}

.artwork img {
    margin-bottom: 10px;
    display: block;
    width: 100%;
    height: auto;
}

.artwork .title {
    font-size: 1.5em;
    margin-bottom: 5px;
    font-weight: bold;
    color: rgb(245,245,245); /* 非常深的灰色標題 */
}

/* 新增：類型樣式 */
.artwork .type {
    font-size: 0.85em;
    color: rgb(230, 230, 230); /* 灰色主題下的類型顏色 */
    margin-bottom: 8px;
    font-style: italic;
}

.artwork .size {
    font-size: 0.85em;
    color: rgb(230, 230, 230); /* 灰色主題下的類型顏色 */
    margin-bottom: 8px;
    font-style: italic;
}

.artwork .price {
    font-size: 1.05em;
    margin-bottom: 5px;
    font-weight: bold;
    color: rgb(245,245,245); /* 非常深的灰色標題 */
}

/* 頁尾 */
footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 60px;
    border-top: 1px solid #a0a0a0; /* 頁尾邊框 */
    background-color: rgba(230, 230, 230, 0.8); /* 半透明淺灰背景 */
    backdrop-filter: blur(5px); /* 模糊效果 */
}

footer h2 {
    margin-bottom: 15px;
    font-weight: 500;
}

footer p {
    margin-bottom: 5px;
    font-size: 0.95em;
}

footer a {
    text-decoration: none;
    color: #4a4a4a; /* 深灰色連結 */
}

footer a:hover {
    color: #1a1a1a;
    text-decoration: underline;
}


/* --- 自訂 Lightbox 樣式 (保持不變) --- */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    cursor: pointer;
    box-sizing: border-box;
    touch-action: manipulation;
}
.lightbox-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
}
.lightbox-content {
    position: relative;
    cursor: default;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10vh 10vw;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}
#lightbox-img {
    display: block;
    max-width: 100%;
    max-height: calc(100% - 60px);
    width: auto;
    height: auto;
    border: 5px solid white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    object-fit: contain;
    margin-bottom: 15px;
    cursor: grab;
    transition: transform 0.2s ease-out;
    transform-origin: center center;
    touch-action: auto;
}
#lightbox-img.dragging {
    cursor: grabbing;
    transition: none;
}
.lightbox-caption {
    color: #fff;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    line-height: 1.5;
    max-width: 80%;
    left: 50%;
    transform: translateX(-50%);
    position: absolute;
}
.lightbox-close-btn {
    position: fixed;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 1010;
}
.lightbox-close-btn:hover {
    color: #bbb;
}
.lightbox-zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1010;
    display: flex;
    gap: 10px;
}
.lightbox-zoom-btn {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 38px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    user-select: none;
}
.lightbox-zoom-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}
.lightbox-zoom-btn:active {
    background-color: rgba(0, 0, 0, 1);
}


/* --- 響應式調整 --- */
@media (max-width: 1200px) {
    .artwork {
        width: calc(50% - 15px);
        margin-bottom: 25px;
    }
}
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 20px 3%;
    }
    header h1 {
        margin-bottom: 15px;
        font-size: 2em;
    }
    .artwork {
        width: calc(100% - 10px);
        margin-bottom: 20px;
        padding: 15px;
    }
    .lightbox-close-btn {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }
    .lightbox-caption {
        font-size: 14px;
        padding: 8px 15px;
        max-width: 90%;
    }
    .lightbox-zoom-controls {
        bottom: 15px;
        right: 15px;
    }
    .lightbox-zoom-btn {
        width: 35px;
        height: 35px;
        font-size: 20px;
        line-height: 33px;
    }
}
@media (max-width: 480px) {
    header h1 {
        font-size: 1.8em;
    }
    .artwork {
        padding: 10px;
    }
    footer {
        padding: 20px 15px;
    }
}

/* Masonry 載入時隱藏，避免閃爍 */
.gallery.are-images-unloaded .artwork {
  opacity: 0;
} /* End of .gallery.are-images-unloaded .artwork */

/* --- 海報燈箱樣式 --- */
.poster-lightbox-overlay {
    display: none; /* 預設隱藏 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75); /* 半透明背景 */
    z-index: 1050; /* 比一般 lightbox 高一點 */
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0; /* 添加透明度以實現淡入效果 */
    visibility: hidden; /* 配合 opacity 使用 */
    transition: opacity 0.3s ease, visibility 0.3s ease; /* 添加過渡效果 */
}
.poster-lightbox-overlay.active {
    display: flex; /* 顯示時使用 flex 佈局 */
    opacity: 1;
    visibility: visible;
}
.poster-lightbox-wrapper {
    display: flex;
    /* Default: Mobile/Portrait layout */
    flex-direction: column;
    width: 90vw; /* Use 90% viewport width */
    /* max-width: 600px; /* Removed max-width */
    height: 90vh; /* Use 90% viewport height */
    /* max-height: 700px; /* Removed max-height */
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* Important: Let children handle scroll */
    position: relative;
    cursor: default;
    transform: scale(0.9);
    transition: transform 0.3s ease, width 0.3s ease, height 0.3s ease; /* Add transitions */
}
.poster-lightbox-overlay.active .poster-lightbox-wrapper {
    transform: scale(1);
}
.poster-lightbox-content { /* This holds the image */
    padding: 0;
    flex-shrink: 1; /* Allow shrinking */
    flex-grow: 1; /* Allow growing */
    /* Default (Portrait): Allocate more height */
    flex-basis: 65%; /* Approx 65% height */
    overflow: hidden; /* Hide overflow */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e9e9e9; /* Slightly different background */
    position: relative; /* Needed if adding anything over the image */
    min-height: 0; /* Fix flexbox overflow issue in some browsers */
}
#poster-lightbox-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}
.poster-lightbox-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    line-height: 30px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    z-index: 1060;
}
.poster-lightbox-close-btn:hover {
    background-color: rgba(255, 0, 0, 0.8);
    color: #fff;
    transform: scale(1.1);
}

/* 確保 artwork-error 樣式存在 */
.artwork-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 10px;
    text-align: center;
    margin-bottom: 10px;
}
.artwork-error p {
    margin: 2px 0;
}
.error-filename {
    font-size: 0.8em;
    color: #888;
}

/* --- 邀請函文字樣式 --- */
.invitation-text {
    padding: 15px 20px;
    background-color: #ffffff;
    color: #333;
    font-size: 15px;
    line-height: 1.6;
    text-align: left;
    box-sizing: border-box;
    flex-shrink: 1;
    flex-grow: 1;
    flex-basis: 35%;
    overflow-y: auto;
    min-height: 0;
}
.invitation-text p {
    margin-bottom: 10px;
}
.invitation-text p:last-child {
    margin-bottom: 0;
}

/* Media Query for Desktop/Landscape Layout */
@media (min-width: 769px) {
    .poster-lightbox-wrapper {
        flex-direction: row; /* Change to horizontal layout */
        width: 90vw; /* Use 90% viewport width */
        /* max-width: 1200px; /* Removed max-width */
        height: 90vh; /* Use 90% viewport height */
        /* max-height: 600px; /* Removed max-height */
    }
    .poster-lightbox-content { /* Image container */
        flex-basis: 60%; /* Approx 60% width */
        height: 100%; /* Take full height of wrapper */
    }
    .invitation-text { /* Text container */
        flex-basis: 40%; /* Approx 40% width */
        height: 100%; /* Take full height of wrapper */
        padding: 50px 30px 25px 30px; /* 增加頂部內邊距，使其往下 */
    }
}

/* --- 側邊欄樣式 --- */
.sidebar {
    height: 100%;
    width: 250px; /* 側邊欄寬度 */
    position: fixed;
    top: 0;
    left: -250px; /* 初始狀態：隱藏在視窗左側外 */
    background-color: #f1f1f1; /* 淺灰色背景 */
    padding-top: 60px; /* 留出頂部空間 */
    transition: left 0.3s ease; /* 滑動動畫 */
    z-index: 999; /* 確保在內容上方 */
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    overflow-y: auto; /* 如果內容過多，允許滾動 */
}

.sidebar.active { /* 將 .open 改為 .active */
    left: 0; /* 打開時滑入視窗 */
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
}

.sidebar li:last-child {
    border-bottom: none;
}

.sidebar a {
    color: #333;
    display: block;
    text-decoration: none;
    font-size: 1.1em;
}

.sidebar a:hover {
    background-color: #ddd;
}

.close-sidebar-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 30px;
    margin-left: 50px;
    cursor: pointer;
    color: #aaa;
    background: none;
    border: none;
}

.close-sidebar-btn:hover {
    color: #777;
}

/* --- 漢堡圖標按鈕樣式 --- */
.sidebar-toggle {
    font-size: 30px;
    cursor: pointer;
    background: none;
    border: none;
    color: #333; /* 漢堡圖標顏色 */
    position: absolute; /* 絕對定位 */
    top: 15px; /* 距離頂部 */
    left: 15px; /* 距離左側 */
    z-index: 1000; /* 確保在最上層 */
}

.sidebar-toggle:hover {
    color: #000;
}

/* --- 疊加層樣式 --- */
.overlay {
    display: none; /* 預設隱藏 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色 */
    z-index: 998; /* 在側邊欄下方，內容上方 */
    transition: opacity 0.3s ease; /* 添加過渡效果 */
    opacity: 0; /* 初始透明度為 0 */
    pointer-events: none; /* 預設不接收滑鼠事件 */
}

.overlay.active {
    display: block; /* 側邊欄打開時顯示 */
    opacity: 1; /* 顯示時完全不透明 */
    pointer-events: auto; /* 顯示時接收滑鼠事件 */
}

/* --- 內容區域樣式 --- */
.content-area {
    padding: 20px;
    margin-top: 20px; /* 與 header 底部留白 */
    background-color: #fff; /* 白色背景 */
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    max-width: 80%; /* 最大寬度 */
    margin-left: auto;
    margin-right: auto;
    transition: margin-left 0.3s ease; /* 添加過渡效果 */
}

/* 當側邊欄打開時，內容區域向右移動 */
body.sidebar-open .content-area {
    margin-left: calc(250px + 20px); /* 側邊欄寬度 + 一些間距 */
    margin-right: 20px; /* 保持右側間距 */
    max-width: calc(800px - 250px - 20px); /* 調整最大寬度 */
}

/* 針對畫廊容器的特殊調整 */
body.sidebar-open .gallery-container {
     margin-left: 250px; /* 側邊欄寬度 */
     padding-left: 20px; /* 保持左側內邊距 */
}

#experience-content h2 {
    margin-bottom: 15px;
    color: #333;
}

#experience-textarea {
    width: 100%;
    min-height: 300px; /* 最小高度 */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    line-height: 1.5;
    resize: vertical; /* 只允許垂直調整大小 */
}