/* 角色实体卡牌系统 (Front Frame + Portrait + Back + 3D Flip) */

/* 卡牌总容器 - 用于控制尺寸、定位及点击区域 */
.character-card-visual {
    width: 100%;
    height: 100%;
    position: relative;
    perspective: 1000px; /* 3D 翻转的景深 */
}

/* 翻转核心件，正反面依附在此 */
.card-flipper {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

/* 添加此 class 时卡牌展示背面（默认展示正面，如果要先看背面加上 .flipped） */
.character-card-visual.flipped .card-flipper {
    transform: rotateY(180deg);
}

/* 卡面基础设定 */
.card-face {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    backface-visibility: hidden; /* 翻转后隐藏背面 */
    -webkit-backface-visibility: hidden;
    border-radius: 8px; /* 根据需要调整圆角，其实边缘透明框可以处理掉 */
    overflow: visible; /* FIXED: MUST BE VISIBLE so HP/Shield bars can show! */
}

/* 卡背：默认朝后，转 180 度。当外层 .flipped 时，转回 0 度显示 */
.card-back {
    transform: rotateY(180deg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1; 
}

/* 卡牌正面 */
.card-front {
    transform: rotateY(0deg);
    z-index: 2;
    position: relative;
    overflow: visible; /* Ensure front face also allows overflow */
}

/* 底层：角色立绘 */
.card-portrait {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    object-fit: cover;
    z-index: 1;
    border-radius: 4px; /* 防止边缘过硬超出太多 */
}

/* 中层：空心外框 */
.card-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none; /* 让点击穿透给立绘或外层 */
}

/* 顶层：数据UI层（如 HP 条，星星等），覆盖在外框之上 */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999 !important; /* FIXED: Must be top level */
    pointer-events: none; /* 让点击穿透，或者如果内部有按钮则需要 auto */
    overflow: visible; /* Ensure inner elements can pop out */
}

/* 当我们单独在背包等不需要翻转的地方用纯正面结构时 */
.character-portrait-layered {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* FIXED: Maintain the 1732x1971 aspect ratio strictly */
.card-aspect-inner {
    position: relative;
    height: 100%;
    aspect-ratio: 1732 / 1971;
    max-width: 100%;
    max-height: 100%;
}

/* Handle the tiny sidebar icons */
.roster-list-item .card-aspect-inner {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

/* For small square icons, we want the portrait to fill, or constrain to aspect ratio */
.roster-list-item .layer-portrait {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
    border-radius: 6px;
}

.roster-list-item .layer-frame {
    position: absolute;
    top: -5%; left: -5%;
    width: 110%; height: 110%;
    z-index: 2;
    pointer-events: none;
}

/* For the large portrait on the right */
.roster-portrait-container .layer-portrait {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    object-fit: cover;
    z-index: 1;
    border-radius: 4px;
}
.roster-portrait-container .layer-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* 抽卡全屏展示特效容器 */
#gacha-fullscreen-card-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

#gacha-fullscreen-card-container.active {
    opacity: 1;
    pointer-events: auto;
}

.gacha-card-wrapper {
    width: 250px;
    height: 350px;
    cursor: pointer;
}

.gacha-tip-text {
    margin-top: 20px;
    color: white;
    font-size: 1.2rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}
