/**
 * 图库相册 · 前台样式
 *
 * 元素结构与视觉参数对齐 ilogs 官方图库（album-page-shell 体系）。
 * 若主题自带同名样式，这里的规则与其一致，不会产生冲突。
 */

/* ---------- 页面外壳与标题区 ---------- */

.album-page-shell {
    width: 100%;
    padding: 34px 32px 48px;
    --ilg-album-cols: 3;
    --ilg-photo-cols: 6;
}

.album-page-heading,
.album-detail-title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.album-page-heading {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--bs-border-color);
}

.album-page-heading h1,
.album-detail-heading h1 {
    margin: 0;
    color: var(--bs-emphasis-color);
    font-size: 26px;
    line-height: 1.3;
    font-weight: 700;
}

.album-page-heading p,
.album-detail-heading p {
    margin: 5px 0 0;
    color: var(--bs-secondary-color);
    font-size: 13px;
    line-height: 1.6;
}

.album-page-heading > span,
.album-photo-count {
    flex: 0 0 auto;
    color: var(--bs-secondary-color);
    font-size: 12px;
}

/* ---------- 相册墙 ---------- */

.album-cover-grid {
    display: grid;
    grid-template-columns: repeat(var(--ilg-album-cols, 3), minmax(0, 1fr));
    gap: 14px;
}

.album-cover-item {
    display: block;
    min-width: 0;
    color: #fff !important;
}

.album-cover-media {
    position: relative;
    /* 4:3 区域用 padding 撑出，不依赖 aspect-ratio，
       防止主题重置 img 高度后封面变形 */
    height: 0;
    padding-top: 75%;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    background: var(--bs-tertiary-bg);
}

.album-cover-media > img {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease, opacity .3s ease, filter .3s ease !important;
}

.album-cover-item:hover .album-cover-media > img {
    transform: scale(1.035);
}

.album-cover-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--bs-secondary-color);
    background: var(--bs-tertiary-bg);
}

.album-cover-placeholder i {
    font-size: 34px;
}

.album-cover-shade {
    position: absolute;
    inset: 35% 0 0;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, .72));
    pointer-events: none;
}

.album-cover-copy {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 16px;
    color: #fff;
}

.album-cover-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.album-cover-title-row h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: #fff;
    font-size: 17px;
    line-height: 1.35;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-cover-title-row span {
    flex: 0 0 auto;
    color: rgba(255, 255, 255, .82);
    font-size: 11px;
}

.album-cover-copy p {
    max-height: 0;
    margin: 0;
    overflow: hidden;
    opacity: 0;
    color: rgba(255, 255, 255, .82);
    font-size: 12px;
    line-height: 1.5;
    transition: max-height .25s ease, margin-top .25s ease, opacity .2s ease;
}

.album-cover-item:hover .album-cover-copy p,
.album-cover-item:focus-visible .album-cover-copy p {
    max-height: 42px;
    margin-top: 5px;
    opacity: 1;
}

/* ---------- 照片墙（详情页） ---------- */

.album-detail-heading {
    margin-bottom: 22px;
}

.album-back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 18px;
    color: var(--bs-secondary-color) !important;
    font-size: 13px;
}

.album-back-link:hover {
    color: rgba(var(--primary-color-rgba, 13, 110, 253)) !important;
}

.album-detail-title-row {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--bs-border-color);
}

.album-photo-grid {
    display: grid;
    grid-template-columns: repeat(var(--ilg-photo-cols, 6), minmax(0, 1fr));
    gap: 8px;
}

.album-photo-item {
    position: relative;
    display: block;
    /* 1:1 区域用 padding 撑出，不依赖 aspect-ratio */
    height: 0;
    padding-top: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: 5px;
    background: var(--bs-tertiary-bg);
}

.album-photo-item img {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .28s ease, opacity .3s ease, filter .3s ease !important;
}

.album-photo-item:hover img {
    transform: scale(1.045);
}

/* ---------- 分页 ---------- */

.album-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}

.album-pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--bs-border-color);
    border-radius: 4px;
    color: var(--bs-secondary-color) !important;
    font-size: 12px;
}

.album-pagination a:hover,
.album-pagination a.active {
    color: rgba(var(--primary-color-rgba, 13, 110, 253)) !important;
    border-color: rgba(var(--primary-color-rgba, 13, 110, 253), .55);
    background: rgba(var(--primary-bg-rgba, 13, 110, 253), .08);
}

/* ---------- 空状态 ---------- */

.album-empty-state {
    display: flex;
    min-height: 280px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--bs-secondary-color);
    border: 1px dashed var(--bs-border-color);
    border-radius: 6px;
}

.album-empty-state i {
    font-size: 32px;
}

.album-empty-state p {
    margin: 0;
    font-size: 13px;
}

/* ---------- 查看器 ---------- */

.album-viewer {
    width: 100%;
    padding: 24px 0 42px;
}

.album-viewer-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
}

.album-viewer-breadcrumb {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    color: var(--bs-secondary-color);
    font-size: 12px;
}

.album-viewer-breadcrumb a {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 5px;
    color: var(--bs-secondary-color) !important;
}

.album-viewer-breadcrumb a:last-child {
    overflow: hidden;
    color: var(--bs-emphasis-color) !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-viewer-heading {
    min-width: 0;
    text-align: right;
}

.album-viewer-heading h1 {
    max-width: 460px;
    margin: 0;
    overflow: hidden;
    color: var(--bs-emphasis-color);
    font-size: 18px;
    line-height: 1.35;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-viewer-heading p {
    margin: 4px 0 0;
    color: var(--bs-secondary-color);
    font-size: 11px;
}

.album-viewer-heading p small {
    font-size: 11px;
}

/* 舞台 */

.album-photo-stage {
    position: relative;
    height: clamp(460px, 66vh, 720px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 6px;
    background: #17191d;
}

.ilg-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.ilg-canvas.is-dragging {
    cursor: grabbing;
}

.ilg-canvas img {
    user-select: none;
    -webkit-user-drag: none;
}

.ilg-canvas img.is-zoomed {
    cursor: grab;
}

/* 工具按钮 */

.album-photo-tools {
    position: absolute;
    z-index: 12;
    top: 12px;
    right: 12px;
    display: flex;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 5px;
    background: rgba(12, 14, 17, .7);
    backdrop-filter: blur(8px);
}

.album-photo-tools button,
.album-photo-tools a {
    display: inline-flex;
    width: 36px;
    height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: rgba(255, 255, 255, .78);
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, .12);
    background: transparent;
}

.album-photo-tools button:last-child,
.album-photo-tools a:last-child {
    border-right: 0;
}

.album-photo-tools button:hover,
.album-photo-tools a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.album-photo-tools i {
    font-size: 17px;
}

/* 左右切换箭头 */

.album-stage-arrow {
    position: absolute;
    z-index: 11;
    top: 50%;
    display: flex;
    width: 42px;
    height: 58px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: rgba(255, 255, 255, .78);
    border: 0;
    background: rgba(12, 14, 17, .46);
    transform: translateY(-50%);
    transition: color .2s ease, background .2s ease;
}

.album-stage-arrow.is-prev {
    left: 0;
    border-radius: 0 5px 5px 0;
}

.album-stage-arrow.is-next {
    right: 0;
    border-radius: 5px 0 0 5px;
}

.album-stage-arrow:hover {
    color: #fff;
    background: rgba(12, 14, 17, .78);
}

.album-stage-arrow:disabled {
    opacity: .35;
}

.album-stage-arrow i {
    font-size: 25px;
}

/* 加载指示 */

.album-photo-loading {
    position: absolute;
    z-index: 10;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.album-photo-loading[hidden] {
    display: none !important;
}

.album-photo-loading span {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: rgba(255, 255, 255, .9);
    border-radius: 50%;
    animation: ilg-spin .8s linear infinite;
}

@keyframes ilg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 照片说明 / 标题浮层 */

.album-photo-article {
    position: absolute;
    z-index: 12;
    right: 14px;
    bottom: 14px;
    left: 14px;
    pointer-events: none;
}

.album-photo-article[hidden] {
    display: none !important;
}

.album-photo-article a,
.album-photo-article > span {
    position: relative;
    display: inline-flex;
    max-width: min(520px, 80%);
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    color: rgba(255, 255, 255, .88) !important;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 4px;
    background: rgba(12, 14, 17, .68);
    font-size: 12px;
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.album-photo-article > a > span,
.album-photo-article > span > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- 缩略图条 ---------- */

.album-filmstrip {
    margin-top: 16px;
}

.album-filmstrip-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--bs-secondary-color);
    font-size: 12px;
}

.album-filmstrip-track {
    position: relative;
}

.album-filmstrip-arrow {
    position: absolute;
    z-index: 3;
    top: 0;
    display: none;
    width: 28px;
    height: 64px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--bs-secondary-color);
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

.album-filmstrip-arrow.is-prev {
    left: 0;
    border-radius: 4px 0 0 4px;
}

.album-filmstrip-arrow.is-next {
    right: 0;
    border-radius: 0 4px 4px 0;
}

.album-filmstrip-arrow.is-visible {
    display: flex;
}

.album-filmstrip-arrow:hover {
    color: rgba(var(--primary-color-rgba, 13, 110, 253));
}

.photo-preview-container {
    overflow-x: auto;
    padding: 0 32px 4px;
    scrollbar-width: thin;
    scroll-behavior: smooth;
}

.photo-preview-items {
    display: flex;
    gap: 7px;
    min-height: 66px;
}

.photo-preview-item {
    position: relative;
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 4px;
    background: var(--bs-tertiary-bg);
    cursor: pointer;
    opacity: .64;
    padding: 0;
    transition: border-color .18s ease, opacity .18s ease;
}

.photo-preview-item:hover {
    opacity: 1;
}

.photo-preview-item.is-active {
    border-color: rgba(var(--primary-color-rgba, 13, 110, 253));
    opacity: 1;
}

.photo-preview-item img {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- 查看器打开时的显隐 ---------- */

#ilgPage.is-viewing .album-detail-heading,
#ilgPage.is-viewing .album-photo-grid,
#ilgPage.is-viewing .album-pagination {
    display: none;
}

#ilgPage:not(.is-viewing) .album-viewer {
    display: none;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1199.98px) {
    .album-cover-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .album-photo-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .album-page-shell {
        padding: 22px 14px 82px;
    }

    .album-page-heading,
    .album-detail-title-row {
        align-items: flex-start;
    }

    .album-page-heading h1,
    .album-detail-heading h1 {
        font-size: 22px;
    }

    .album-cover-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .album-cover-copy {
        padding: 10px;
    }

    .album-cover-title-row {
        display: block;
    }

    .album-cover-title-row h2 {
        font-size: 14px;
    }

    .album-cover-title-row span {
        display: block;
        margin-top: 2px;
    }

    .album-cover-copy p {
        display: none;
    }

    .album-photo-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .album-photo-count {
        margin-top: 6px;
    }

    .album-viewer {
        padding: 18px 0 80px;
    }

    .album-viewer-header {
        display: block;
        padding: 0 14px;
    }

    .album-viewer-heading {
        margin-top: 12px;
        text-align: left;
    }

    .album-viewer-heading h1 {
        max-width: 100%;
        font-size: 17px;
    }

    .album-photo-stage {
        height: min(68vh, 560px);
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .album-photo-tools {
        top: 8px;
        right: 8px;
    }

    .album-stage-arrow {
        width: 34px;
        height: 52px;
    }

    .album-photo-article {
        right: 10px;
        bottom: 10px;
        left: 10px;
    }

    .album-photo-article a,
    .album-photo-article > span {
        max-width: 100%;
    }

    .album-filmstrip {
        padding: 0 14px;
    }

    .album-filmstrip-arrow {
        display: none !important;
    }

    .photo-preview-container {
        padding: 0 0 5px;
    }

    .photo-preview-item {
        flex-basis: 58px;
        width: 58px;
        height: 58px;
    }
}
