/* ============================================================
   components.css — 角色属性表、卷轴卡片、图像画廊、密文档案
   梦初雪 (Yume Hatsuyuki) 角色档案卷轴
   ============================================================ */

/* ── 角色属性表格 ─────────────────────────────────────────── */
.profile-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.profile-table th {
    text-align: left;
    padding: 0.8rem 1rem;
    background: linear-gradient(135deg, var(--parchment-burnt), var(--parchment-dark));
    color: var(--ink-iron);
    font-weight: 700;
    border: 1px solid var(--ink-sepia);
    position: relative;
    min-width: 120px;
}

.profile-table th::before {
    content: "†";
    position: absolute;
    right: 8px;
    color: var(--ink-gold);
}

.profile-table td {
    padding: 0.8rem 1rem;
    background: rgba(240, 230, 210, 0.7);
    border: 1px solid var(--ink-sepia);
    color: var(--ink-sepia);
    vertical-align: top;
    font-family: 'New Tegomin', 'STSong', 'SimSun', var(--font-body);
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    line-height: 1.7;
}

/* 颜色样本 — 魔法宝石 */
.pigment-sample {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--parchment-old);
    border-radius: 3px;
    margin-right: 8px;
    vertical-align: middle;
    box-shadow:
        0 2px 4px var(--shadow-light),
        inset 0 0 4px rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.pigment-sample:hover {
    transform: scale(1.3) rotate(15deg);
    box-shadow:
        0 0 8px var(--glow-gold),
        0 0 12px var(--glow-gold);
}

/* ── 能力卷轴卡片 ─────────────────────────────────────────── */
.spell-scroll {
    background:
        linear-gradient(135deg,
            rgba(240, 230, 210, 0.95) 0%,
            rgba(232, 216, 182, 0.95) 100%);
    border: 2px solid var(--ink-iron);
    border-radius: 1px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    box-shadow:
        0 4px 12px var(--shadow-light),
        inset 0 0 20px rgba(212, 196, 160, 0.4);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    animation: borderPulse 8s ease-in-out infinite;
}

.spell-scroll:hover {
    transform: translateY(-2px) rotate(0.2deg);
    box-shadow:
        0 6px 20px var(--shadow-heavy),
        inset 0 0 30px rgba(212, 196, 160, 0.6);
}

@keyframes borderPulse {
    0%, 100% {
        box-shadow:
            0 4px 12px var(--shadow-light),
            inset 0 0 20px rgba(212, 196, 160, 0.4);
    }
    50% {
        box-shadow:
            0 4px 12px var(--shadow-light),
            inset 0 0 20px rgba(212, 196, 160, 0.4),
            0 0 5px rgba(184, 134, 11, 0.3);
    }
}

/* 顶部流光条 — 各类型颜色 */
.spell-scroll.root-definition::before,
.spell-scroll.core-power::before,
.spell-scroll.base-ability::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-size: 200% 100%;
}

.spell-scroll.root-definition::before {
    background: linear-gradient(90deg,
        var(--flow-blood-start) 0%,
        var(--flow-blood-mid) 25%,
        var(--flow-blood-end) 50%,
        var(--flow-blood-mid) 75%,
        var(--flow-blood-start) 100%);
    animation: flowBlood var(--magic-flow-duration) linear infinite;
}

.spell-scroll.core-power::before {
    background: linear-gradient(90deg,
        var(--flow-gold-start) 0%,
        var(--flow-gold-mid) 25%,
        var(--flow-gold-end) 50%,
        var(--flow-gold-mid) 75%,
        var(--flow-gold-start) 100%);
    animation: flowGold var(--magic-flow-duration) linear infinite;
}

.spell-scroll.base-ability::before {
    background: linear-gradient(90deg,
        var(--flow-purple-start) 0%,
        var(--flow-purple-mid) 25%,
        var(--flow-purple-end) 50%,
        var(--flow-purple-mid) 75%,
        var(--flow-purple-start) 100%);
    animation: flowPurple var(--magic-flow-duration) linear infinite;
}

/* 悬停时暂停动画 */
.spell-scroll:hover::before { animation-play-state: paused; }

.spell-scroll.root-definition:hover::before {
    box-shadow: 0 0 10px var(--flow-blood-end), 0 0 20px var(--flow-blood-end);
}
.spell-scroll.core-power:hover::before {
    box-shadow: 0 0 10px var(--flow-gold-end), 0 0 20px var(--flow-gold-end);
}
.spell-scroll.base-ability:hover::before {
    box-shadow: 0 0 10px var(--flow-purple-end), 0 0 20px var(--flow-purple-end);
}

/* 流光动画定义 */
@keyframes flowGold {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes flowPurple {
    0%   { background-position: 200% 0; filter: brightness(1) hue-rotate(0deg); }
    50%  { filter: brightness(1.2) hue-rotate(10deg); }
    100% { background-position: -200% 0; filter: brightness(1) hue-rotate(0deg); }
}

@keyframes flowBlood {
    0%   { background-position: 200% 0; filter: brightness(1); }
    50%  { filter: brightness(1.3); }
    100% { background-position: -200% 0; filter: brightness(1); }
}

/* 卷轴头部 */
.spell-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex-shrink: 0;
}

.spell-name {
    font-family: var(--font-header);
    font-size: 1.3rem;
    color: var(--ink-iron);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.spell-type {
    font-family: var(--font-monogram);
    font-size: 0.8rem;
    color: var(--ink-blood);
    background: rgba(139, 0, 0, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
    border: 1px solid var(--ink-blood);
}

.spell-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--ink-sepia);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.ability-priority {
    color: var(--ink-gold);
    font-weight: 700;
}

/* 描述文本 */
.spell-description {
    line-height: 1.7;
    color: var(--ink-sepia);
    padding-left: 1rem;
    border-left: 2px solid var(--ink-gold);
    position: relative;
    overflow: hidden;
    transition: max-height 1s cubic-bezier(.44,.14,.17,.86);
    will-change: max-height;
    flex-grow: 1;
    font-family: 'STSong', 'SimSun', var(--font-body);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-top: 0.3em;
    margin-bottom: 0.3em;
    tab-size: 4;
    -moz-tab-size: 4;
}

.spell-description p    { margin-bottom: 0.8em; }
.spell-description .indent { margin-left: 2em; }

.spell-description.expandable {
    max-height: calc(1.7em * 4);
    overflow: hidden;
}

.spell-description.expandable::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 1rem;
    right: 0;
    height: 1.5em;
    background: linear-gradient(to bottom,
        transparent,
        rgba(240, 230, 210, 0.95) 80%);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.spell-description.no-fade::after {
    display: none;
}

.spell-description.expanded           { max-height: none; }
.spell-description.expanded::after    { opacity: 0; }

/* 展开/收起按钮 */
.expand-indicator {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.expand-btn {
    color: var(--ink-gold);
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-monogram);
    transition: all 0.3s ease;
    background: rgba(184, 134, 11, 0.1);
    padding: 0.3rem 0.8rem;
    border-radius: 2px;
    border: 1px solid rgba(184, 134, 11, 0.3);
    user-select: none;
}

.expand-btn:hover {
    color: var(--ink-blood);
    background: rgba(184, 134, 11, 0.2);
    transform: translateY(-1px);
}

/* ── 图像画廊 ─────────────────────────────────────────────── */
.character-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.tapestry-frame {
    position: relative;
    border: 8px solid var(--ink-iron);
    border-image:
        linear-gradient(45deg,
            var(--ink-iron) 20%,
            var(--parchment-burnt) 40%,
            var(--ink-iron) 60%,
            var(--parchment-burnt) 80%) 1;
    background: var(--parchment-dark);
    padding: 8px;
    box-shadow:
        0 4px 12px var(--shadow-heavy),
        inset 0 0 20px rgba(42, 32, 18, 0.3);
    transition: all 0.3s ease;
    cursor: zoom-in;
}

.tapestry-frame:hover {
    transform: translateY(-5px) rotate(0.5deg);
    box-shadow:
        0 8px 24px var(--shadow-heavy),
        0 0 15px var(--glow-gold);
}

.tapestry-frame img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    filter: sepia(0.3) contrast(1.1);
    transition: filter 0.3s ease;
}

.tapestry-frame:hover img { filter: sepia(0.1) contrast(1.2); }

.tapestry-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top,
        rgba(58, 44, 28, 0.9) 0%,
        transparent 100%);
    color: var(--parchment-old);
    padding: 0.8rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-style: italic;
}

/* ── 原始档案密文 ─────────────────────────────────────────── */
.arcane-codex {
    background:
        linear-gradient(135deg,
            #1a1206 0%,
            #2a2012 50%,
            #1a1206 100%);
    border: 4px double var(--ink-gold);
    border-radius: 2px;
    margin-top: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.6),
        inset 0 0 30px rgba(184, 134, 11, 0.1);
}

.arcane-codex::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(184, 134, 11, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 0, 0, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.codex-header {
    background: linear-gradient(135deg, #2a2012 0%, #3a2c1c 100%);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ink-gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.codex-title {
    font-family: 'New Tegomin', 'STZhongsong', '华文中宋', var(--font-illuminated);
    font-size: 1.5rem;
    color: var(--ink-gold);
    letter-spacing: 1px;
    font-weight: 700;
}

.ritual-button {
    background: linear-gradient(135deg, var(--ink-gold) 0%, #8B7500 100%);
    color: var(--ink-iron);
    border: none;
    padding: 0.5rem 1.5rem;
    font-family: var(--font-monogram);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 1px;
}

.ritual-button:hover {
    background: linear-gradient(135deg, #B8860B 0%, #A67500 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.4);
}

.ritual-button.copied {
    background: var(--ink-verdant);
    color: var(--parchment-old);
}

.codex-content {
    padding: 1.5rem;
    overflow-x: auto;
}

.arcane-script {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #D4C4A0;
    margin: 0;
    white-space: pre;
}

/* 语法高亮 */
.arcane-key     { color: #DAA520; }
.arcane-string  { color: #DEB887; }
.arcane-number  { color: #F4A460; }
.arcane-boolean { color: #90EE90; font-weight: bold; }
.arcane-null    { color: #778899; font-style: italic; }
