/**
 * 圖鑑頁面主樣式
 * Catalog Main Styles
 */

/* ===== 基礎佈局 ===== */
html {
    scrollbar-gutter: stable;
}

body {
    overflow-y: auto;
    overflow-x: hidden;
}

/* 防止 Modal 打開時頁面偏移 */
body.modal-open {
    padding-right: 0 !important;
}

.container {
    max-width: 1400px;
}

main .container,
#content .container,
.catalog-main,
#itemsContainer {
    overflow-x: hidden;
}

/* ===== 卡片比例 ===== */
.card-ratio {
    width: 100%;
    height: auto;
    aspect-ratio: 63 / 88;
    object-fit: cover;
}

.card-ratio.card-horizontal {
    aspect-ratio: 88 / 63;
}

.card-cut {
    /* 水平半徑 4.76% (3mm/63mm)，垂直半徑 3.39% (3mm/88mm) => 正圓角 */
    border-radius: 5.3% / 4%;
}

.card-cut.card-horizontal {
    /* 橫向卡片圓角比例相反 */
    border-radius: 4% / 5.3%;
}

.card-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: #e9ecef;
    color: #adb5bd;
    font-size: 2rem;
}

/* ===== 作品類型圖示 ===== */
.entity-type-icon {
    width: 106.19px;
    height: 55.8px;
    flex-shrink: 0;
    object-fit: contain;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 4px;
}

.entity-type-icon:hover {
    opacity: 1 !important;
    border-color: var(--bs-primary);
}

@media (hover: none) {
    .entity-type-icon:hover:not(.active) {
        opacity: 0.5 !important;
        border-color: transparent;
    }
}

.entity-type-icon.active {
    opacity: 1 !important;
    border-color: var(--bs-primary);
}

#mainEntityTypeContainer {
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#mainEntityTypeContainer::-webkit-scrollbar { display: none; }

/* ===== Hero Header Style ===== */
.catalog-header-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    margin-bottom: 30px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.catalog-header-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 193, 7, 0.15) 0%, transparent 70%);
    opacity: 0.8;
    pointer-events: none;
}

.catalog-title {
    font-size: 1.25rem;
    line-height: 1.2;
    white-space: normal;
    font-weight: 800;
    margin-bottom: 10px;
    color: #212529;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: relative;
}

.catalog-title i {
    color: #ffc107;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.catalog-subtitle {
    color: #6c757d;
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

/* ===== 搜尋列 ===== */
.catalog-search {
    flex: 0 1 420px;
    min-width: 220px;
}

@media (max-width: 576px) {
    .catalog-search {
        flex: 1 1 100%;
        min-width: 0;
    }
    #searchInput {
        font-size: 16px;
    }
}

/* ===== Compact Header ===== */
.compact-header {
    padding-top: 0.35rem;
    padding-bottom: 0.15rem;
}

.compact-header-row {
    margin-bottom: 0.35rem;
}

.compact-title {
    font-size: 1.1rem;
}

.compact-tags-row {
    overflow: hidden;
}

.compact-tags-scroll {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
}

.compact-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 0.15rem;
}

.compact-tags-scroll::-webkit-scrollbar {
    height: 6px;
}

/* ===== 分頁控制 (Inventory 風格) ===== */
.pagination-section {
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

@media (min-width: 768px) {
    .pagination-section {
        flex-wrap: nowrap;
    }
}

.pagination-btn-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.pagination-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    background-color: #f1f3f5;
    border: 1px solid transparent;
    color: #495057;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.9rem;
}

.pagination-btn:hover:not(:disabled):not(.active) {
    background-color: #e9ecef;
    color: #212529;
    transform: translateY(-1px);
}

.pagination-btn.active {
    background-color: #ffc107 !important;
    color: #000 !important;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: transparent;
    color: #adb5bd;
}

.pagination-info-text {
    white-space: nowrap;
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 500;
}

.pagination-login-hint {
    margin-top: 8px;
    color: #6c757d;
    font-size: 0.85rem;
}

/* ===== 卡片項目 ===== */
.card-item {
    transition: transform 0.2s;
    cursor: pointer;
    background-color: var(--bs-card-bg);
}

.card-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.card-item img {
    border-radius: 8px;
}

/* ===== Custom Dropdown Styling ===== */
#setFilterDropdown {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    min-height: 48px;
}

#setFilterMenu {
    max-height: 400px;
    overflow-y: auto;
}

/* ===== 電腦版：側邊廣告時限制主內容區寬度 ===== */
@media (min-width: 1200px) {
    .catalog-main {
        max-width: calc(100% - 320px);
    }
}

/* ===== 桌面版：固定標題/搜尋列 ===== */
@media (min-width: 992px) {
    .catalog-main {
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-x: hidden;
    }

    .catalog-sticky-header {
        position: sticky;
        top: 0;
        z-index: 101;
        padding-bottom: 0.75rem;
        background: transparent;
        border-bottom: none;
    }

    #itemsContainer {
        flex: 1 1 auto;
        min-height: 0;
    }
}

/* Modal Card Image Mobile Sizing */
@media (max-width: 767.98px) {
    .card-image-col img {
        max-width: 75% !important;
        margin: 0 auto;
        display: block;
    }
}

/* Finish (閃法) overlay label */
.finish-overlay-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 5;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

/* Finish tabs fixed-height placeholder to prevent modal resize */
.finish-tabs-placeholder {
    min-height: 30px;
    margin-bottom: 0.35rem;
}
