/* 卡片基础样式 */
.card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 卡片图标通用样式 */
.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* 当图片加载失败时，显示首字母 */
.card-icon img:not([src*=".png"]):not([src*=".jpg"]):not([src*=".jpeg"]):not([src*=".gif"]):not([src*=".svg"]):not([src*=".ico"]) {
    display: none;
}

.card-icon.fallback {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 20px;
    text-transform: uppercase;
}

/* 正方形卡片样式 */
.card.square {
    grid-row-end: span 1;
    grid-column-end: span 1;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.card.square .card-icon {
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card.square .card-icon.fallback {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.card.square .card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.card.square .card-title {
    font-size: 12px;
    margin: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
}

.card.square .card-description,
.card.square .card-category {
    display: none;
}

/* 长方形卡片样式 - 水平布局 */
.card.rectangle {
    grid-row-end: span 1;
    grid-column-end: span 2;
    aspect-ratio: 260/120;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

.card.rectangle .card-icon {
    width: 60px;
    height: 60px;
    font-size: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card.rectangle .card-icon.fallback {
    width: 60px;
    height: 60px;
    font-size: 24px;
}

.card.rectangle .card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.card.rectangle .card-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card.rectangle .card-description {
    font-size: 12px;
    color: #616161;
    margin: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}

.card.rectangle .card-category {
    font-size: 10px;
    color: #616161;
    margin: 0;
    text-align: left;
    display: inline-block;
}

/* 大高度长方形卡片样式 */
.card.tall {
    grid-row-end: span 2;
    grid-column-end: span 2;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.card.tall .card-icon {
    width: 60px;
    height: 60px;
    font-size: 32px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card.tall .card-icon.fallback {
    width: 60px;
    height: 60px;
    font-size: 24px;
    margin-top: 10px;
}

.card.tall .card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.card.tall .card-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0;
    text-align: left;
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card.tall .card-description {
    font-size: 12px;
    color: #616161;
    margin: 0;
    text-align: left;
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    white-space: normal;
    flex: 1;
}

.card.tall .card-category {
    font-size: 10px;
    color: #616161;
    margin: 0;
    text-align: left;
    display: inline-block;
    padding: 0 5px;
}

/* 竖长方形卡片样式 */
.card.portrait {
    grid-row-end: span 2;
    grid-column-end: span 1;
    aspect-ratio: 120/260;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 120px;
    height: 260px;
}

.card.portrait .card-icon {
    width: 60px;
    height: 60px;
    font-size: 32px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card.portrait .card-icon.fallback {
    width: 60px;
    height: 60px;
    font-size: 24px;
    margin-top: 10px;
}

.card.portrait .card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.card.portrait .card-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0;
    text-align: left;
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card.portrait .card-description {
    font-size: 12px;
    color: #616161;
    margin: 0;
    text-align: left;
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    white-space: normal;
    flex: 1;
}

.card.portrait .card-category {
    font-size: 10px;
    color: #616161;
    margin: 0;
    text-align: left;
    display: inline-block;
    padding: 0 5px;
}

/* 响应式卡片调整 */
@media (max-width: 768px) {
    .card.rectangle {
        grid-column-end: span 1;
        flex-direction: row;
    }

    .card.tall {
        grid-column-end: span 1;
    }

    .card {
        width: 100% !important;
        max-width: 260px;
    }

    .card.square {
        width: 120px !important;
        height: 120px !important;
    }

    .card.portrait {
        grid-row-end: span 1;
        grid-column-end: span 1;
        aspect-ratio: 1;
        width: 120px;
        height: 120px;
    }

    .card.portrait .card-description {
        -webkit-line-clamp: 2;
    }
}