/* ===================== 法术大全 — 黑白水墨 ===================== */

.spell-view {
    --sp-ink: #f2f2f0;
    --sp-muted: rgba(230, 230, 225, 0.62);
    --sp-line: rgba(255, 255, 255, 0.16);
    --sp-panel: #121212;
    --sp-paper: #e8e6e1;
    --sp-ink-dark: #141414;
    --sp-font: "Noto Serif SC", "Songti SC", "SimSun", "Cormorant Garamond", serif;
}

.spell-view:not(.active) {
    display: none !important;
}

.spell-view.active {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: transparent;
    overflow: hidden;
}

body.spell-mode #particle-bg {
    background:
        radial-gradient(ellipse at 18% 12%, rgba(255, 255, 255, 0.05), transparent 42%),
        radial-gradient(ellipse at 82% 88%, rgba(255, 255, 255, 0.03), transparent 40%),
        #000;
}

.spell-scroll {
    height: 100%;
    overflow: hidden;
    padding: 18px 18px 20px;
    box-sizing: border-box;
}

.spell-shell {
    width: min(1180px, 100%);
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.spell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.spell-title {
    margin: 0;
    font-family: var(--sp-font);
    font-size: clamp(22px, 2.8vw, 28px);
    font-weight: 700;
    color: var(--sp-ink);
    letter-spacing: 0.18em;
    line-height: 1.2;
}

.spell-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-width: 0;
}

.spell-cats {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    flex: 1 1 auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
    -webkit-overflow-scrolling: touch;
}

.spell-cat {
    flex: 0 0 auto;
    padding: 6px 11px;
    border: 1px solid var(--sp-line);
    border-radius: 2px;
    background: transparent;
    color: var(--sp-muted);
    font-family: var(--sp-font);
    font-size: 12px;
    letter-spacing: 0.06em;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    transition:
        background 0.14s ease,
        color 0.14s ease,
        border-color 0.14s ease,
        transform 0.12s ease,
        filter 0.12s ease,
        box-shadow 0.14s ease;
}

.spell-cat:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.spell-cat:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.55);
    outline-offset: 2px;
}

.spell-cat:active,
.spell-cat.is-pressed {
    transform: scale(0.97);
    filter: brightness(1.06);
    transition-duration: 80ms;
}

.spell-cat.is-active {
    background: var(--sp-paper);
    border-color: var(--sp-paper);
    color: var(--sp-ink-dark);
    font-weight: 700;
}

.spell-cat.is-active:active,
.spell-cat.is-active.is-pressed {
    transform: scale(0.97);
    filter: brightness(0.97);
}

.spell-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 320px;
    min-width: 180px;
}

.spell-search {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    border-radius: 2px;
    border: 1px solid var(--sp-line);
    background: rgba(0, 0, 0, 0.45);
    color: var(--sp-ink);
    font-family: var(--sp-font);
    font-size: 13px;
    letter-spacing: 0.04em;
}

.spell-search:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
}

.spell-search::placeholder {
    color: rgba(230, 230, 225, 0.35);
}

.spell-count {
    color: var(--sp-muted);
    font-size: 12px;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}

.spell-learn-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    flex-shrink: 0;
    padding: 0 2px 2px;
}

.spell-learn-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: rgba(230, 230, 225, 0.55);
}

.spell-learn-legend-item i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.spell-learn-legend-item.is-library i {
    background: #5eb6ff;
    box-shadow: 0 0 8px rgba(94, 182, 255, 0.45);
}

.spell-learn-legend-item.is-auth i {
    background: #6ddf8a;
    box-shadow: 0 0 8px rgba(109, 223, 138, 0.4);
}

.spell-learn-legend-item.is-forbidden i {
    background: #ff8a8a;
    box-shadow: 0 0 8px rgba(255, 138, 138, 0.4);
}

.spell-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.38fr) minmax(320px, 0.62fr);
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
}

.spell-panel {
    border: 1px solid var(--sp-line);
    border-radius: 2px;
    background: var(--sp-panel);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.spell-panel-head {
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.spell-panel-title {
    margin: 0;
    font-family: var(--sp-font);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.16em;
    color: rgba(245, 245, 240, 0.88);
}

.spell-list {
    overflow: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.spell-item {
    display: grid;
    grid-template-columns: 2.4em minmax(0, 1fr) max-content;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-family: var(--sp-font);
    cursor: pointer;
    touch-action: manipulation;
    transition:
        background 0.12s ease,
        color 0.12s ease,
        transform 0.12s ease,
        filter 0.12s ease,
        box-shadow 0.12s ease;
}

.spell-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.spell-item:focus-visible {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.spell-item:active,
.spell-item.is-pressed {
    transform: scale(0.985);
    filter: brightness(1.04);
    transition-duration: 80ms;
}

.spell-item.is-active {
    background: var(--sp-paper);
    color: var(--sp-ink-dark);
}

.spell-item.is-active:active,
.spell-item.is-active.is-pressed {
    transform: scale(0.985);
    filter: brightness(0.98);
}

.spell-item.is-active .spell-item-index,
.spell-item.is-active .spell-item-name,
.spell-item.is-active .spell-item-tag {
    color: var(--sp-ink-dark);
}

.spell-item.is-active .spell-item-tag {
    opacity: 0.7;
}

.spell-item.is-active .spell-item-tag-sep {
    color: rgba(20, 20, 20, 0.35);
}

.spell-item-index {
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.38);
}

.spell-item-name {
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #f4f4f2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spell-item.is-learn-library .spell-item-name {
    color: #7ec8ff;
}

.spell-item.is-learn-auth .spell-item-name {
    color: #7ee59a;
}

.spell-item.is-learn-forbidden .spell-item-name {
    color: #ff9a9a;
}

.spell-item.is-active.is-learn-library .spell-item-name,
.spell-item.is-active.is-learn-auth .spell-item-name,
.spell-item.is-active.is-learn-forbidden .spell-item-name {
    color: var(--sp-ink-dark);
}

.spell-item.is-active.is-learn-library {
    box-shadow: inset 3px 0 0 #5eb6ff;
}

.spell-item.is-active.is-learn-auth {
    box-shadow: inset 3px 0 0 #6ddf8a;
}

.spell-item.is-active.is-learn-forbidden {
    box-shadow: inset 3px 0 0 #ff8a8a;
}

.spell-chip-learn.is-learn-library {
    color: #8fd0ff;
    border-color: rgba(94, 182, 255, 0.45);
    background: rgba(60, 140, 220, 0.12);
}

.spell-chip-learn.is-learn-auth {
    color: #8eebb0;
    border-color: rgba(109, 223, 138, 0.4);
    background: rgba(50, 160, 90, 0.12);
}

.spell-chip-learn.is-learn-forbidden {
    color: #ffb0b0;
    border-color: rgba(255, 138, 138, 0.45);
    background: rgba(180, 60, 60, 0.14);
}

.spell-item-tags {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    justify-content: flex-end;
}

.spell-item-tag {
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--sp-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.spell-item-tag-sep {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.spell-empty,
.spell-detail-empty {
    margin: 0;
    padding: 28px 18px;
    color: var(--sp-muted);
    text-align: center;
    font-size: 14px;
    letter-spacing: 0.06em;
}

.spell-detail {
    overflow: auto;
    padding: 16px 18px 20px;
    min-height: 0;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.spell-detail-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.spell-detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.spell-detail-kicker {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.14em;
    color: rgba(230, 230, 225, 0.5);
    font-variant-numeric: tabular-nums;
}

.spell-detail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.spell-chip {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 2px;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: rgba(235, 235, 230, 0.78);
    background: rgba(255, 255, 255, 0.04);
}

.spell-chip-cost {
    font-variant-numeric: tabular-nums;
}

.spell-detail-cost {
    padding-top: 2px;
}

.spell-detail-cost-text {
    color: rgba(230, 230, 225, 0.78);
    font-size: 13px;
    line-height: 1.7;
}

.spell-detail-title {
    margin: 0;
    font-family: var(--sp-font);
    font-size: clamp(24px, 2.6vw, 32px);
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #f6f6f4;
    line-height: 1.25;
}

.spell-detail-incant {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
    padding: 12px 0 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.spell-detail-incant .spell-detail-block {
    min-width: 0;
}

.spell-detail-condition {
    padding-top: 4px;
}

.spell-detail-label {
    margin: 0 0 6px;
    font-size: 11px;
    letter-spacing: 0.2em;
    color: rgba(220, 220, 215, 0.5);
}

.spell-detail-text {
    color: rgba(240, 240, 235, 0.88);
    font-size: 13px;
    line-height: 1.75;
    letter-spacing: 0.03em;
    white-space: pre-wrap;
    word-break: break-word;
}

.spell-detail-spell,
.spell-detail-translation {
    color: rgba(220, 220, 215, 0.72);
    font-size: 13px;
    line-height: 1.7;
}

.spell-detail-effect {
    margin-top: 2px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.spell-detail-effect-text {
    color: rgba(246, 246, 242, 0.96);
    font-size: 15px;
    line-height: 1.85;
    letter-spacing: 0.04em;
}

.spell-detail-note {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.spell-detail-note .spell-detail-label {
    color: rgba(200, 200, 195, 0.4);
}

.spell-detail-note-text {
    color: rgba(200, 200, 195, 0.55);
    font-size: 12px;
    line-height: 1.7;
}

@media (max-width: 980px) {
    .spell-toolbar {
        flex-wrap: wrap;
    }

    .spell-cats {
        flex: 1 1 100%;
        order: 1;
    }

    .spell-search-row {
        flex: 1 1 100%;
        order: 0;
        min-width: 0;
    }
}

@media (max-width: 860px) {
    .spell-scroll {
        overflow: auto;
        padding: 14px 14px 28px;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
    }

    .spell-shell {
        height: auto;
        min-height: 100%;
    }

    .spell-layout {
        grid-template-columns: 1fr;
        flex: none;
        min-height: 0;
    }

    .spell-panel:first-child .spell-list {
        max-height: min(36vh, 280px);
    }

    .spell-panel-detail {
        min-height: 42vh;
        scroll-margin-top: 12px;
    }

    .spell-detail-incant {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .spell-header .back-home-btn {
        padding-inline: 10px;
        font-size: 12px;
    }

    .spell-title {
        letter-spacing: 0.12em;
    }

    .spell-item {
        grid-template-columns: 2.2em minmax(0, 1fr) max-content;
        gap: 8px;
    }

    .spell-item-tag {
        font-size: 10px;
    }
}

/* 返回按钮：沿用角色卡按压手感 */
#spell-view .back-home-btn,
#spell-view .action-btn {
    touch-action: manipulation;
    transition:
        transform 0.12s ease,
        filter 0.12s ease,
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        color 0.2s ease;
}

#spell-view .back-home-btn:active,
#spell-view .back-home-btn.is-pressed,
#spell-view .action-btn:active,
#spell-view .action-btn.is-pressed {
    transform: scale(0.97);
    filter: brightness(1.04);
    transition-duration: 80ms;
}

@media (prefers-reduced-motion: reduce) {
    .spell-cat,
    .spell-item,
    #spell-view .back-home-btn,
    #spell-view .action-btn {
        transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease !important;
    }

    .spell-cat:active,
    .spell-cat.is-pressed,
    .spell-cat.is-active:active,
    .spell-cat.is-active.is-pressed,
    .spell-item:active,
    .spell-item.is-pressed,
    .spell-item.is-active:active,
    .spell-item.is-active.is-pressed,
    #spell-view .back-home-btn:active,
    #spell-view .back-home-btn.is-pressed,
    #spell-view .action-btn:active,
    #spell-view .action-btn.is-pressed {
        transform: none !important;
        filter: none !important;
        opacity: 0.82;
    }
}
