/**
 * WYH Download — Frontend Styles
 */

.wyh-download-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: gap 0.5s ease;
    overflow: hidden;
    position: relative;
}

.wyh-download-grid--selected {
    gap: 0;
}

.wyh-download-page:empty {
    display: none;
}

.wyh-download-page {
    overflow: hidden;
}

.wyh-download__row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    min-width: 0;
    margin-bottom: 20px;
    transition: gap 0.5s ease, margin-bottom 0.5s ease;
}

.wyh-download-page > .wyh-download__row:last-child {
    margin-bottom: 0;
}

.wyh-download-grid > .wyh-download__row {
    margin-bottom: 0;
}

.wyh-download-grid--selected .wyh-download__row {
    gap: 0;
    flex-wrap: nowrap;
    margin-bottom: 0;
}

/* 动画期间禁止点击其他卡片，只保留关闭按钮可点 */
.wyh-download-grid--busy .wyh-download__item {
    pointer-events: none;
}
.wyh-download-grid--busy .wyh-download__close {
    pointer-events: auto;
}

.wyh-download__item {
    border: none;
    border-radius: 8px;
    overflow: hidden;
    background: #fcfcfc;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease, transform 0.5s ease, margin 0.5s ease, padding 0.5s ease;
    position: relative;
}

.wyh-download__item--placeholder {
    visibility: hidden;
    pointer-events: none;
}

.wyh-download__item--dim {
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

/* 动画期间灰色占位 - 内容立即隐藏 */
.wyh-download__item--animating > *:not(.wyh-download__placeholder) {
    opacity: 0;
}

.wyh-download__placeholder {
    position: absolute;
    inset: 0;
    background: #e8e8e8;
    border-radius: 8px;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.wyh-download__item--animating .wyh-download__placeholder {
    opacity: 1;
}

.wyh-download__item:not(.wyh-download__item--animating) .wyh-download__placeholder {
    opacity: 0;
}

/* ── Close button on selected card ── */
.wyh-download__close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    padding: 0;
    transition: background 0.2s;
}

.wyh-download__close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.wyh-download__close:active {
    background: rgba(0, 0, 0, 0.85);
}


.wyh-download-cols-2 .wyh-download__item { width: calc((100% - 20px) / 2); }
.wyh-download-cols-3 .wyh-download__item { width: calc((100% - 40px) / 3); }
.wyh-download-cols-4 .wyh-download__item { width: calc((100% - 60px) / 4); }

.wyh-download__item {
    border: none;
    border-radius: 8px;
    overflow: hidden;
    background: #fcfcfc;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.wyh-download__image-wrap {
    width: 100%;
    overflow: hidden;
}

.wyh-download__thumb {
    width: 100%;
    aspect-ratio: 1.5;
    object-fit: cover;
    display: block;
}

.wyh-download__thumb-placeholder {
    width: 100%;
    height: 100%;
    min-height: 120px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 14px;
}

.wyh-download__body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.wyh-download__title {
    margin: 8px 0;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.4;
    text-align: center;
}

.wyh-download__desc {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
}

.wyh-download__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.5s ease, color 0.5s ease;
    align-self: flex-start;
    background-color: #007cba;
    color: #fff;
    padding: 6px 16px;
}

.wyh-download__btn:hover {
    text-decoration: none;
    background-color: #005a87;
}

/* Responsive */
@media (max-width: 768px) {
    .wyh-download-cols-2 .wyh-download__item,
    .wyh-download-cols-3 .wyh-download__item,
    .wyh-download-cols-4 .wyh-download__item {
        width: calc((100% - 20px) / 2);
    }

    .wyh-download-pagination {
        display: none !important;
    }

    .wyh-download-page {
        display: block !important;
    }
}

@media (max-width: 480px) {
    .wyh-download-cols-2 .wyh-download__item,
    .wyh-download-cols-3 .wyh-download__item,
    .wyh-download-cols-4 .wyh-download__item {
        width: calc((100% - 20px) / 2);
    }
}

/* ── Tabs (Sliding Pill) ── */
.wyh-download-tabs {
    display: inline-flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 4px 4px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    overflow: hidden;
    max-width: 100%;
    transition: opacity 0.5s ease, height 0.35s ease, width 0.35s ease;
    position: relative;
}

.wyh-download-tabs--expanded {
    flex-wrap: wrap;
    transition: opacity 0.5s ease, height 0.35s ease, width 0.35s ease, max-width 0.35s ease;
}



.wyh-download-tab--collapsed {
    display: none;
}

.wyh-download-tabs--hidden {
    opacity: 0;
    pointer-events: none;
}

.wyh-download-tabs__slider {
    position: absolute;
    left: 0;
    top: 4px;
    height: 35px;
    border-radius: 20px;
    transition: left 0.3s ease, width 0.3s ease, top 0.3s ease, height 0.3s ease;
    z-index: 0;
    pointer-events: none;
}

.wyh-download-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    color: #888;
    white-space: nowrap;
    transition: color 0.3s ease;
    outline: none;
    position: relative;
    z-index: 1;
}

.wyh-download-tab:hover {
    color: #333;
}

.wyh-download-tab--active {
    color: #333;
}

.wyh-download-tab--active:hover {
    color: #333;
}

.wyh-download-tab--more::after {
    content: '▸';
    font-size: 18px;
    line-height: 1;
    margin-left: 4px;
    vertical-align: middle;
}

.wyh-download-tab--more,
.wyh-download-tab--more:hover,
.wyh-download-tab--more:focus {
    color: #888;
}

.wyh-download-tabs--expanded .wyh-download-tab--more::after {
    content: '▴';
}

.wyh-download-tab-panels {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    transition: width 0.5s ease, height 0.5s ease;
}

.wyh-download-tab-panel {
    display: none;
}

.wyh-download-tab-panel--active {
    display: block;
}

/* ── Download Resources Widget ── */
.wyh-resources-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.wyh-resource__item {
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    border: none;
}

.wyh-resource__header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 12px;
    line-height: 1.4;
}

.wyh-resource__desc {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    flex: 1;
}

.wyh-resource__links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.wyh-resource__link {
    color: #007cba;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.8;
}

.wyh-resource__link:hover {
    text-decoration: underline;
    color: #005a87;
}

/* ── Download List card: button stays left ── */
.wyh-download__body .wyh-download__btn {
    align-self: flex-start;
}

@media (max-width: 1024px) {
    .wyh-resources-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .wyh-resources-grid {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* ── Download Resources: view switching with animation ── */
.wyh-resource-view {
    display: block;
    min-height: 300px;
    overflow: hidden;
}

/* 每个资源项默认隐藏，下方偏移 */
.wyh-resource__item {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* 退出时错开消失 */
.wyh-resource__item:nth-child(1) { transition-delay: 0.15s; }
.wyh-resource__item:nth-child(2) { transition-delay: 0.10s; }
.wyh-resource__item:nth-child(3) { transition-delay: 0.05s; }
.wyh-resource__item:nth-child(4) { transition-delay: 0s; }

/* 进入时渐现 + 滑入 */
.wyh-resource-view--active .wyh-resource__item {
    opacity: 1;
    transform: translateY(0);
}
.wyh-resource-view--active .wyh-resource__item:nth-child(1) { transition-delay: 0.25s; }
.wyh-resource-view--active .wyh-resource__item:nth-child(2) { transition-delay: 0.35s; }
.wyh-resource-view--active .wyh-resource__item:nth-child(3) { transition-delay: 0.45s; }
.wyh-resource-view--active .wyh-resource__item:nth-child(4) { transition-delay: 0.55s; }

.wyh-resources-placeholder {
    display: none;
}

.wyh-resources-placeholder--active {
    display: block;
}

.wyh-resources-placeholder p {
    font-size: 14px;
    color: #999;
    text-align: center;
    padding: 40px 20px;
}

/* ── Download Resources: empty state ── */
.wyh-resources-empty {
    display: none;
}

.wyh-resources-empty--active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.wyh-resources-empty .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #ccc;
    margin-bottom: 12px;
}

.wyh-resources-empty p {
    margin: 0;
    font-size: 14px;
    color: #999;
}

/* ── Download List: empty state ── */
.wyh-download-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.wyh-download-empty .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #ccc;
    margin-bottom: 12px;
}

.wyh-download-empty p {
    margin: 0;
    font-size: 14px;
}

/* ── Pagination ── */
.wyh-download-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    margin-top: 4px;
}

.wyh-download-pagination__btn {
    width: 52px;
    height: 34px;
    border: none;
    border-radius: 17px;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    user-select: none;
    /* 隐藏文本，由伪元素绘制箭头 */
    font-size: 0;
    line-height: 0;
    padding: 0;
}

.wyh-download-pagination__btn:disabled {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

.wyh-download-pagination__btn:not(:disabled):hover {
    background: #ddd;
}

/* 伪元素纯 CSS 绘制箭头，不依赖字体字形 */
.wyh-download-pagination__prev::after,
.wyh-download-pagination__next::after {
    content: '';
    display: block;
    width: 9px;
    height: 9px;
    border: solid #333;
    border-width: 0 2px 2px 0;
}

.wyh-download-pagination__prev::after {
    transform: rotate(135deg);
    margin-left: 3px;
}

.wyh-download-pagination__next::after {
    transform: rotate(-45deg);
    margin-right: 3px;
}

.wyh-download-pagination__dots {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 14px;
}

.wyh-download-pagination__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: background 0.2s;
}

.wyh-download-pagination__dot--active {
    background: #007cba;
}

.wyh-download-pagination__dot:hover {
    background: #999;
}

/* ── Pages Wrapper for Slide Animation ── */
@media (min-width: 769px) {
    .wyh-download-pages-wrap {
        display: flex;
        width: 100%;
        transition: transform 0.35s ease-out;
    }

    .wyh-download-pages-wrap .wyh-download-page {
        flex: 0 0 100%;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .wyh-download-pages-wrap {
        display: block;
        transform: none !important;
    }
}

/* ── Tab Panels Inner Slide ── */
@media (min-width: 769px) {
    .wyh-download-tab-panels {
        overflow: hidden;
    }

    .wyh-download-tab-panels-inner {
        display: flex;
        width: 100%;
        transition: transform 0.35s ease-out;
    }

    .wyh-download-tab-panels-inner .wyh-download-tab-panel {
        display: block;
        flex: 0 0 100%;
        box-sizing: border-box;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
    }

    .wyh-download-tab-panels-inner .wyh-download-tab-panel--active {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 768px) {
    .wyh-download-tab-panels {
        overflow: hidden;
    }

    .wyh-download-tab-panels-inner {
        display: flex;
        width: 100%;
        transition: transform 0.35s ease-out;
    }

    .wyh-download-tab-panels-inner .wyh-download-tab-panel {
        display: block;
        flex: 0 0 100%;
        box-sizing: border-box;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
    }

    .wyh-download-tab-panels-inner .wyh-download-tab-panel--active {
        opacity: 1;
        pointer-events: auto;
    }
}
