/* ===== 卡片容器 ===== */
.hero-card {
    width: var(--card-width);
    height: var(--card-height);
    perspective: 1200px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(139, 69, 19, 0.25);
}

/* ===== 卡片翻转 ===== */
.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.hero-card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* ===== 正反面共用 ===== */
.card-front,
.card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--border-radius);
    border: 3px solid var(--color-border);
    overflow: hidden;
    box-shadow:
        inset 0 0 40px rgba(139,69,19,0.08),
        0 6px 20px rgba(0,0,0,0.12);
}

/* 边框装饰 */
.card-front::before,
.card-back::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px solid rgba(139,69,19,0.2);
    border-radius: 6px;
    pointer-events: none;
    z-index: 10;
}

/* ===== 正面 - 图片填充设计 ===== */
.card-front {
    background: var(--color-paper);
    position: relative;
}

.card-front-content {
    width: 100%;
    height: 100%;
    position: relative;
}

/* 图片容器 - 填充整张卡片 */
.card-image-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

.card-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* ===== 锁定卡片正面样式 ===== */
.locked-front {
    position: relative;
    width: 100%;
    height: 100%;
}

.locked-front .card-image-container {
    width: 100%;
    height: 100%;
}

.locked-front .locked-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    filter: grayscale(0.3);
}

/* 锁定文字 - 位于图片上半部分留白处，横向上下结构，书法水墨风格（优化 iOS） */
.locked-text {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: 'KaiTi', 'STKaiti', 'BiauKai', 'Xingkai SC', 'Hiragino Sans GB', 'PingFang SC', serif;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.locked-text-top {
    font-size: 26px;
    letter-spacing: 6px;
    font-weight: 600;
    color: #1a1a1a;
    text-shadow: 
        1px 1px 2px rgba(255,255,255,0.9),
        2px 2px 4px rgba(255,255,255,0.6),
        0 0 15px rgba(0,0,0,0.08);
    -webkit-text-stroke: 0.3px rgba(139, 69, 19, 0.2);
}

.locked-text-bottom {
    font-size: 20px;
    letter-spacing: 4px;
    color: #4a3728;
    text-shadow: 
        1px 1px 2px rgba(255,255,255,0.95),
        1px 1px 4px rgba(255,255,255,0.7),
        0 0 10px rgba(0,0,0,0.05);
}

/* 响应式调整 - 优化 iOS 移动端 */
@media (max-width: 768px) {
    .locked-text {
        top: 8%;
        gap: 4px;
    }
    .locked-text-top {
        font-size: 22px;
        letter-spacing: 4px;
        font-weight: 600;
    }
    .locked-text-bottom {
        font-size: 16px;
        letter-spacing: 3px;
    }
}

@media (max-width: 480px) {
    .locked-text {
        top: 6%;
        gap: 2px;
    }
    .locked-text-top {
        font-size: 18px;
        letter-spacing: 3px;
        font-weight: 600;
        -webkit-text-stroke: 0.2px rgba(139, 69, 19, 0.15);
    }
    .locked-text-bottom {
        font-size: 14px;
        letter-spacing: 2px;
    }
}

/* iOS 设备专用优化 */
@supports (-webkit-touch-callout: none) {
    .locked-text {
        font-family: 'Xingkai SC', 'KaiTi', 'STKaiti', 'PingFang SC', serif;
    }
    .locked-text-top {
        font-weight: 500;
        -webkit-text-stroke: 0.2px rgba(60, 60, 60, 0.15);
    }
}

/* ===== 左上角：星级竖排 ===== */
.front-stars-vertical {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 14px;
    color: #FFD700;
    letter-spacing: 3px;
    /* 去除底色，改用文字阴影 */
    background: transparent;
    padding: 8px 5px;
    border-radius: 0;
    /* 书法体 + 多重阴影增强可读性 */
    font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', 'STXingkai', 'KaiTi', '楷体', serif;
    font-weight: 600;
    line-height: 1;
    text-shadow: 
        0 0 4px rgba(0,0,0,0.9),
        0 0 8px rgba(0,0,0,0.7),
        2px 2px 4px rgba(0,0,0,0.8),
        -1px -1px 2px rgba(0,0,0,0.5);
}

/* ===== 右上角：两列布局 ===== */
.front-info-two-columns {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 2px;
}

/* 单列容器 */
.info-column {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
}

/* 统一文字大小和样式 - 中国风书法体 */
.v-text {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 18px;
    letter-spacing: 2px;
    color: #fff;
    /* 去除底色，纯文字阴影 */
    background: transparent;
    padding: 6px 4px;
    border-radius: 0;
    /* 书法体优先 */
    font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', 'STXingkai', 'KaiTi', '楷体', serif;
    font-weight: 600;
    line-height: 1;
    /* 多重阴影确保在各种背景上可读 */
    text-shadow: 
        0 0 4px rgba(0,0,0,0.9),
        0 0 8px rgba(0,0,0,0.7),
        0 0 12px rgba(0,0,0,0.5),
        2px 2px 4px rgba(0,0,0,0.8),
        -1px -1px 2px rgba(0,0,0,0.6);
}

/* ===== 背面 ===== */
.card-back {
    background: linear-gradient(180deg, #faf8f0 0%, #f8f4e8 100%);
    transform: rotateY(180deg);
}

.card-back-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* ===== 背面主体 - 可滚动区域 ===== */
.back-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

/* 自定义滚动条 */
.back-body::-webkit-scrollbar {
    width: 4px;
}

.back-body::-webkit-scrollbar-track {
    background: rgba(139,69,19,0.05);
    border-radius: 2px;
}

.back-body::-webkit-scrollbar-thumb {
    background: rgba(139,69,19,0.2);
    border-radius: 2px;
}

/* ===== 紧凑基本信息 ===== */
.basic-info-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(139,69,19,0.15);
    flex-shrink: 0;
}

.basic-info-compact .info-item {
    font-size: 10px;
}

.info-item {
    font-size: 10px;
    color: var(--color-text);
}

.info-label {
    color: var(--color-primary);
    font-weight: 500;
}

/* ===== 生平事迹 ===== */
.story-section {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.story-section h4 {
    font-size: 11px;
    color: var(--color-primary);
    margin: 0 0 4px 0;
    letter-spacing: 2px;
    font-weight: 600;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(139,69,19,0.12);
    flex-shrink: 0;
}

.story-text {
    font-size: 13px;
    line-height: 1.7;
    color: #444;
    text-align: justify;
}

/* 首行缩进2字符 - 应用于第一个ruby元素或文本节点 */
.story-text ruby:first-child,
.story-text::first-letter {
    margin-left: 2em;
}

/* ===== 结局 - 确保可见 ===== */
.ending-section {
    padding: 8px 10px;
    background: rgba(139,0,0,0.05);
    border-radius: 6px;
    border-left: 3px solid var(--color-red);
    flex-shrink: 0;
    margin-top: 6px;
}

.ending-section h4 {
    font-size: 11px;
    color: var(--color-red);
    margin: 0 0 4px 0;
    letter-spacing: 2px;
    font-weight: 600;
}

.ending-text {
    font-size: 11px;
    color: #555;
    line-height: 1.6;
}

/* 长文本自适应字体 */
.story-text.long-text {
    font-size: 12px;
    line-height: 1.65;
}

.story-text.very-long-text {
    font-size: 11px;
    line-height: 1.6;
}

/* ===== 拼音注音样式 ===== */
.pinyin-char {
    display: inline-ruby;
    ruby-align: center;
}

.pinyin-char rt {
    font-size: 0.45em;
    color: #8b4513;
    opacity: 0.8;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 拼音显示/隐藏状态 */
body.pinyin-hidden .pinyin-char rt {
    display: none;
}

/* 卡片背面拼音优化 */
.card-back .pinyin-char rt {
    font-size: 0.42em;
    color: #a0522d;
}

/* 悬停显示拼音提示 */
.pinyin-char:hover rt {
    opacity: 1;
    color: #d2691e;
}

/* ===== 正面图片放大模态框 ===== */
.front-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.front-image-modal.active {
    opacity: 1;
    visibility: visible;
}

.front-image-modal-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.front-image-modal img {
    max-width: 100%;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.front-image-modal-title {
    margin-top: 15px;
    color: #fff;
    font-size: 20px;
    font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', 'STXingkai', 'KaiTi', '楷体', serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.front-image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.front-image-modal-close:hover,
.front-image-modal-close:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* 移动端模态框适配 */
@media (max-width: 768px) {
    .front-image-modal {
        padding: 10px;
    }
    
    .front-image-modal-content {
        max-width: 95vw;
    }
    
    .front-image-modal img {
        max-height: 70vh;
    }
    
    .front-image-modal-close {
        top: -45px;
        right: 0;
        width: 40px;
        height: 40px;
        font-size: 28px;
        background: rgba(255, 255, 255, 0.25);
    }
    
    .front-image-modal-title {
        font-size: 18px;
        margin-top: 10px;
    }
}

/* ===== 解锁卡片刷新动画 ===== */
@keyframes cardRefresh {
    0% {
        transform: scale(0.3) rotateY(180deg);
        opacity: 0;
        filter: brightness(3) saturate(0);
    }
    30% {
        transform: scale(1.15) rotateY(0deg);
        opacity: 1;
        filter: brightness(2) saturate(0.3);
    }
    50% {
        transform: scale(0.9);
        filter: brightness(1.5) saturate(0.6);
    }
    70% {
        transform: scale(1.05);
        filter: brightness(1.2) saturate(0.8);
    }
    85% {
        transform: scale(0.98);
        filter: brightness(1.1) saturate(0.9);
    }
    100% {
        transform: scale(1);
        filter: brightness(1) saturate(1);
    }
}

.hero-card.card-refresh {
    animation: cardRefresh 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    z-index: 10;
}

/* 解锁成功金色光晕 */
.hero-card.card-refresh::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 12px;
    background: linear-gradient(45deg, #ffd700, #ff8c00, #ffd700, #ffeb3b);
    background-size: 300% 300%;
    animation: goldenGlow 1s ease-out forwards;
    z-index: -1;
    pointer-events: none;
}

@keyframes goldenGlow {
    0% {
        opacity: 1;
        background-position: 0% 50%;
    }
    100% {
        opacity: 0;
        background-position: 100% 50%;
    }
}
