* {
    box-sizing: border-box;
}

body {
    /* padding: 16px; */
    height: 100%;
}

.container {
    /* padding: 16px; */
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 16px;
    height: 100%;
}

/*----- Menu -----*/

/* 灰色背景遮罩 (預設隱藏) */
#overlay,
#overlayGallery {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    visibility: hidden;
    opacity: 0;
    /* transition: opacity 0.1s ease-in-out; */

    z-index: 5;
}

/* 右下角浮動按鈕 */
#menuBtn {
    position: fixed;
    bottom: 36px;
    right: 24px;

    background-image: url(../images/menu_Btn.png);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;

    height: 100px;
    width: 100px;

    color: white;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    line-height: 50px;
    cursor: pointer;
    box-shadow: 0px 0px 11.6px 6px rgba(255, 255, 255, 0.3), 0px 0px 20px rgba(255, 255, 255, 0.8);
    user-select: none;
    transition: opacity 0.1s ease-in-out;

    border-radius: 36px;

    z-index: 10;

}

#floatingBtn:hover {
    background-color: #0056b3;
}

/* 彈出的長方形區塊 (預設隱藏) */
#popup {
    position: fixed;
    bottom: 144px; /* 與按鈕間距 */
    right: 24px;

    width: 250px;
    height: 186px;
    gap: 4px;

    padding: 4px;
    background: white;
    border-radius: 20px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 10;
    /* transition: background 0.1s; */
}

.menu_item {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0px;
    gap: 18px;

    width: 242px;
    height: 87px;

    /* 漸層 主色 */
    background: linear-gradient(180deg, #C58D67 0%, #A66C44 100%);
    /* M3/Elevation Light/1 */
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 0px rgba(0, 0, 0, 0.15);
    border-radius: 16px;

    color: #FFFFFF;
    font-weight: 700;
    font-size: 28px;
    line-height: 150%;

    /* transition: opacity 0.05s ease-in-out; */
}

/*----- Header -----*/

.indexHeader {
    margin-top: 12px;

    padding-left: 16px;
    padding-right: 16px;

    position: sticky;
    top: 16px;
    z-index: 2;

    /* display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0px;
    gap: 12px; */

    width: 100%;
    height: 48px;

    margin-bottom: 12px;
}

#default_Header {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0px;
    gap: 12px;

    width: 100%;
}

/* Search */

.searchBtn {
    display: flex;
    /* flex-direction: column; */
    justify-content: center;
    align-items: center;
    padding: 0px;

    flex-grow: 1; /* 讓左邊按鈕佔滿剩餘空間 */
    min-width: 0; /* 防止內容撐開 */
    height: 48px;

    /* UI/輔色 */
    background: #FFFFFF;
    /* M3/Elevation Light/1 */
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    border-radius: 16px;

    /* 文字 */
    font-weight: 700;
    font-size: 20px;
    line-height: 24px;

    /* UI/主色 */
    color: #A66C44;
}

.searchBtn:hover, .searchBtn:focus {
    background-color: #F0F0F0;
}

.layout-toggle,
.backToIndexBtn {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0px;

    width: 48px;
    height: 48px;
    flex-shrink: 0; /* 確保大小固定 */

    /* UI/輔色 */
    background: #FFFFFF;
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    border-radius: 16px;
}

.layout-toggle:hover, 
.layout-toggle:focus {
    background-color: #FFFFFF;
}
.backToIndexBtn:hover, 
.backToIndexBtn:focus {
    background-color: #FFFFFF;
}

#search_Bar {
    display: none;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0px;
    gap: 12px;

    width: 100%;
}

.search_input_div {
    box-sizing: border-box;

    /* Auto layout */
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding-left: 11px;
    padding-right: 11px;

    flex-grow: 1; /* 讓左邊按鈕佔滿剩餘空間 */
    min-width: 0; /* 防止內容撐開 */
    height: 48px;

    /* UI/輔色 */
    background: #FFFFFF;

    background: linear-gradient(white, white) padding-box,
                linear-gradient(to bottom, #C58D67, #A66C44) border-box;
    border-radius: 16px;
    border: 2px solid transparent;
}

.search-input {
    background-color: transparent;
    border: 0px;
    outline: none;

    width: 100%;

    font-weight: 400;
    font-size: 16px;
    line-height: 150%;

    /* UI/主色 深 */
    color: #753911;

}

.search-input:focus {
    border: 0px;
}

.closeSearchBtn {
    display: none;
}

.closeSearchBtn:hover, 
.closeSearchBtn:focus {
    background-color: #FFFFFF;
}

#searchHistoryList {
    display: none;
    width: 100%;
    padding: 0;
}

.history_item {
    display: flex;
    align-items: center;
    width: 100%; /* 確保佔滿 parent */
    height: 50px;
    padding: 8px; /* 增加 padding 讓 hover 效果更好 */
    box-sizing: border-box; /* 防止 padding 影響寬度 */
}

.history_item img {
    width: 20px; /* 修正 `width: max-content;` 避免影響佈局 */
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0; /* 防止縮小 */
}

.history_item span {
    font-size: 18px;
    flex-grow: 1; /* 讓 span 佔滿剩餘空間 */
    white-space: nowrap; /* 防止換行 */
    overflow: hidden; /* 超出時隱藏 */
    text-overflow: ellipsis; /* 文字超出時顯示省略號 */
    text-align: left;
}

.history_item:hover, 
.history_item:focus {
    background-color: #F9E8DC;
}

#backToIndexBtn,
.search_input_div {
    display: none;
}

/* Category */

#category {
    padding-top: 14px;
    display: grid;
    gap: 16px;

    display: none;
}

.category_item {
    box-sizing: border-box;

    /* UI/彈窗底色 深 */
    border: solid #E3C1AA;
    border-width: 2px 3px 3px 3px;
    border-radius: 20px;
    box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
}

.category_item_Btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0px 8px 0px 0px;
    gap: 8px;

    width: 100%;
    height: 120px;

    color: #9A5E32;
    font-weight: bold;
    /* font-size: 25px; */

    /* 漸層 白 */
    background: linear-gradient(180deg, #FFFFFF 0%, #FFF3EB 100%);

    border: none;
    border-radius: 20px;
}

.category_item:hover, 
.category_item:focus {
    background: linear-gradient(180deg, #F0F0F0 0%, #F9E8DC 100%);
}

.category_item img {
    height: 120px;
    width: 120px;

    border-radius: 18px 0px 0px 18px;
}

.cateqory_content {

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 0px;
    gap: 4px;

    width: 188px;
    height: 41px;


    /* Inside auto layout */
    flex: none;
    order: 0;
    flex-grow: 1;

}

.cateqory_content_title {

    /* UI/副標題 20 Bold */
    font-family: 'Noto Sans TC';
    font-style: normal;
    font-weight: 700;
    font-size: 20px;
    line-height: 150%;
    letter-spacing: 0.04em;

    /* UI/主色 */
    color: #A66C44;
}

.cateqory_content_txt {

    margin: 0;

    /* UI/內文 14 Bold */
    font-family: 'Noto Sans TC';
    font-style: normal;
    font-weight: 700;
    font-size: 14px;
    line-height: 150%;
    align-items: center;
    letter-spacing: 0.04em;

    /* UI/主色 */
    color: #A66C44;
}

.noMoreCategory {
    margin-top: 16px;
    
    font-weight: 400;
    font-size: 16px;
    line-height: 150%;

    color: #E3C1AA;
}

#tagGroup {
    display: none;
}

/*----- Gallery -----*/

.grid {
    position: relative;
    margin: 0 auto;
    display: grid;
    justify-content: space-between;
    transition: all 0.5s ease-in-out; /* 平滑動畫 */
}

.grid-sizer,
.grid-item {
    width: 100%; /* 單列佈局，佔滿全版面 */
}

.grid-item {
    margin-bottom: 12px;
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    /* transition: width 0.4s ease, transform 0.4s ease; */
    transition: width 0.4s ease, all 0.4s ease-in-out; /* 平滑動畫 */
    
}

.double-column .grid-sizer,
.double-column .grid-item {
    width: 48%; /* 兩列佈局，每列佔比 */
}

.grid-item img {
    width: 100%;
    display: block;
    height: auto;
}

.grid-item-content {
    padding: 15px;
}

.grid-item-title {
    font-size: 18px;
    margin-bottom: 8px;
}

.grid-item-description {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

.loading-indicator,
.noMoreImg-indicator,
.noMoreSearchResults {
    text-align: center;
    padding: 20px;

    font-weight: 400;
    font-size: 16px;
    line-height: 150%;

    color: #E3C1AA;
}

.no-results {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #9A5E32;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: none;
}

.noMoreSearchResults,
.noMoreImg-indicator {
    display: none;
}

/* 響應式設計*/
@media (max-width: 768px) {
    /* .header {
        flex-direction: column;
    }
    
    .search-container {
        margin-right: 0;
        margin-bottom: 10px;
        width: 100%;
    } */
    
    /* body {
        padding: 16px;
    } */
}

@media (max-width: 380px) {
    .container {
        padding: 12px;
    }
}

/* popupPhotoWindow */

#overlayGallery {
    z-index: 15;

    display: flex;
    justify-content: center;
    align-content: center;
    flex-wrap: wrap;
}

#popupPhotoWindow {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 0px 16px 16px;
    gap: 18px;
    isolation: isolate;
    z-index: 20;

    position: relative;
    width: 364px;
    height: 507px;
    
    /* left: calc(50% - 364px/2); */
    /* top: calc(50% - 552px/2 + 0.5px); */

    /* UI/背景色 */
    background: #FFF3EB;
    /* UI/輔色 */
    border: 2px solid #FFFFFF;
    /* M3/Elevation Light/1 */
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    border-radius: 20px;

    font-weight: bold;

}

#popupPhotoWindow_img {
    width: 360px;
    height: 360px;

    border-radius: 20px 20px 0px 0px;
}

.popupTagArea{
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: flex-start;
    padding: 0px;
    gap: 8px;

    width: 100%;
    height: 28px;
}

#popupTagGroup {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    padding: 0px;
    gap: 8px;

    width: 100%;
    height: 28px;
}

.photoTag {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0px 12px;
    gap: 10px;

    width: max-content;
    height: 28px;

    /* UI/彈窗底色 */
    background: #F9E8DC;
    border-radius: 8px;
}

#closePopPhotoBtn {
    position: absolute;
    width: 42px;
    height: 42px;
    left: 306px;
    top: 16px;

    /* UI/輔色 */
    background: #FFFFFF;
    box-shadow: 0px 1.05px 2.1px rgba(0, 0, 0, 0.3), 0px 1.05px 3.15px 1.05px rgba(0, 0, 0, 0.15);
    border-radius: 148.235px;

    flex-wrap: wrap;

    display: flex;
    justify-content: center;
    align-content: center;
}

.closePopPhotoBtn:hover, .closePopPhotoBtn:focus {
    background-color: #FFFFFF;
}

.popPhotoBtnGroup {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    padding: 0px;
    gap: 12px;

    width: 100%;
}

.popPhotoBtnGroup_item_left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 0px;
    gap: 12px;

    width: 87px;
    height: 109px;


    /* Inside auto layout */
    flex: none;
    order: 0;
    align-self: stretch;
    flex-grow: 0;
}

#Btn_shareCard {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 10px;
    /* gap: 8px; */

    width: 87px;
    height: 109px;

    /* UI/輔色 */
    background: #FFFFFF;
    /* M3/Elevation Light/1 */
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    border-radius: 16px;

    /* Inside auto layout */
    flex: none;
    order: 0;
    flex-grow: 1;
}

#Btn_shareCard img{
    width: 32px;
    height: 32px;


    /* Inside auto layout */
    flex: none;
    order: 0;
    flex-grow: 0;
}

#Btn_shareCard span{

    /* UI/副標題 25 Bold */
    font-family: 'Noto Sans TC';
    font-style: normal;
    font-weight: 700;
    font-size: 25px;
    line-height: 150%;
    letter-spacing: 0.04em;

    /* UI/主色 */
    color: #A66C44;


    /* Inside auto layout */
    flex: none;
    order: 1;
    flex-grow: 0;

}

#Btn_generateNewCard {

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 18px;
    gap: 8px;

    width: 233px;
    height: 109px;

    /* 漸層 綠 */
    background: linear-gradient(180deg, #B1BF34 0%, #3F8243 100%);
    /* M3/Elevation Light/1 */
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    border-radius: 16px;

    /* Inside auto layout */
    flex: none;
    order: 1;
    align-self: stretch;
    flex-grow: 1;

}

#Btn_generateNewCard img {
    
    width: 36.59px;
    height: 36.59px;


    /* Inside auto layout */
    flex: none;
    order: 1;
    flex-grow: 0;

}

#Btn_generateNewCard span {

    /* UI/標題 32 Bold */
    font-family: 'Noto Sans TC';
    font-style: normal;
    font-weight: 700;
    font-size: 25px;
    line-height: 150%;
    text-align: center;
    letter-spacing: 0.04em;

    /* UI/輔色 */
    color: #FFFFFF;


    /* Inside auto layout */
    flex: none;
    order: 2;
    flex-grow: 0;

}

.animate__zoomIn {
    --animate-duration: 0.3s;
}

.animate__slideInRight {
    --animate-duration: 0.3s;
}