/* ==========================================================================
   wikiview.css — DOA6 Wiki Character Pages
   デザイン統一版: analysis.css / top.css のデザイン言語に準拠
   フォントサイズ全体的に底上げ済み
   ========================================================================== */

/* ── Variables (analysis.cssと共通化) ── */
:root {
    --accent-color:   #e60012;
    --cyber-purple:   #8e2de2;
    --cyber-pink:     #ff00ff;
    --bg-dark:        rgba(10, 10, 15, 0.97);
    --bg-glass:       rgba(255, 255, 255, 0.04);
    --text-main:      #ffffff;
    --cyber-border:   rgba(142, 45, 226, 0.5);

    /* analysis.css 由来のトークン */
    --wv-gold:        #c8a96e;
    --wv-gold-line:   rgba(200, 169, 110, 0.32);
    --wv-gold-bg:     rgba(200, 169, 110, 0.08);
    --wv-border:      rgba(255, 255, 255, 0.08);
    --wv-text:        #f0ece4;
    --wv-text-sub:    rgba(240, 236, 228, 0.70);
    --wv-text-dim:    rgba(240, 236, 228, 0.38);
}

/* ==========================================================================
   1. LAYOUT RESET & PAGE TITLE
   ========================================================================== */
.page-container {
    position: relative;
    z-index: 1;
}

.page-title {
    font-family: "Orbitron", "Exo 2", sans-serif !important;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3.2rem); /* ← 旧設定より大きく */
    line-height: 1.1;
    text-transform: uppercase;
    background: linear-gradient(180deg, #ffffff 45%, #bbbbbb 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 0 8px rgba(142, 45, 226, 0.40));
    text-shadow: none !important;
    margin-bottom: 20px !important;
}

/* ==========================================================================
   2. WIKI CONTENT WRAPPER
   ========================================================================== */
.wiki-content-wrapper {
    display: block;
    padding: 48px 64px 100px;
    margin: 0 auto 40px;
    max-width: 1300px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;

    /* フェードエッジ */
    mask-image:
        linear-gradient(to bottom, transparent, black 30px, black calc(100% - 30px), transparent 100%),
        linear-gradient(to right,  transparent, black 80px,  black calc(100% - 80px),  transparent 100%);
    mask-composite: intersect;
    -webkit-mask-image:
        linear-gradient(to bottom, transparent, black 30px, black calc(100% - 30px), transparent 100%),
        linear-gradient(to right,  transparent, black 80px,  black calc(100% - 80px),  transparent 100%);
    -webkit-mask-composite: source-in;
}

.wiki-content-wrapper img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    border-radius: 4px;
}

/* ==========================================================================
   3. FLOATING CYBER TOC (目次)
   ========================================================================== */
section.wiki-section.is-intro {
    position: fixed !important;
    bottom: 30px !important;
    left: 30px !important;
    z-index: 100001 !important;
    width: 60px;
    height: 60px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background: var(--bg-dark);
    border: 2px solid var(--cyber-purple);
    border-radius: 30px;
    backdrop-filter: blur(10px);
    transition: width 0.2s ease-out, height 0.2s ease-out, bottom 0.2s, left 0.2s, border-radius 0.2s !important;
    box-shadow: 0 0 20px rgba(142, 45, 226, 0.4);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
}

section.wiki-section.is-intro.is-active {
    width: 360px;
    height: auto;
    max-height: 75vh;
    border-radius: 12px;
    bottom: 40px !important;
    left: 40px !important;
    border-color: var(--cyber-pink);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(255, 0, 255, 0.3);
    cursor: default;
    z-index: 100005 !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: var(--cyber-purple) transparent;
}

section.wiki-section.is-intro.is-active::-webkit-scrollbar { width: 4px; }
section.wiki-section.is-intro.is-active::-webkit-scrollbar-thumb {
    background: var(--cyber-purple);
    border-radius: 10px;
}

section.wiki-section.is-intro::before {
    content: 'INDEX';
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    color: #fff;
    font-weight: bold;
    letter-spacing: 1px;
    transition: 0.3s;
    z-index: 10;
}

section.wiki-section.is-intro:not(.is-active):has(ul)::before {
    content: '';
    width: 20px;
    height: 2px;
    background: #fff;
    box-shadow: 0 6px 0 #fff, 0 -6px 0 #fff;
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translate(-50%, -50%);
}

section.wiki-section.is-intro.is-active::before {
    content: none !important;
    display: none !important;
}

section.wiki-section.is-intro h2 { display: none !important; }

section.wiki-section.is-intro.is-active h2 {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    background: var(--cyber-purple) !important;
    padding: 0 0 0 25px !important;
    margin: 0 !important;
    height: 60px !important;
    border-bottom: 2px solid var(--cyber-pink) !important;
    border-top: none !important;
    position: relative !important;
    box-sizing: border-box !important;
    font-size: 1.15rem !important;
    color: #fff !important;
    font-family: 'Orbitron', sans-serif !important;
    letter-spacing: 2px !important;
    font-weight: 800 !important;
    text-shadow: none !important;
    -webkit-font-smoothing: none !important;
}

section.wiki-section.is-intro.is-active h2::before,
section.wiki-section.is-intro.is-active h2::after,
section.wiki-section.is-intro.is-active h2 span {
    content: none !important;
    display: none !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

section.wiki-section.is-intro.is-active h2::after {
    content: 'CONTENTS' !important;
    display: inline-block !important;
    width: auto !important;
    height: auto !important;
    background: none !important;
    font-size: 1.5rem !important;
    color: #fff !important;
    font-family: 'Orbitron', sans-serif !important;
    letter-spacing: 1px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    text-shadow: none !important;
    position: static !important;
    transform: none !important;
    margin: 0 !important;
}

section.wiki-section.is-intro ul {
    display: none;
    list-style: none;
    padding: 10px 0;
    margin: 0;
    flex-grow: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

section.wiki-section.is-intro.is-active ul {
    display: block;
    opacity: 1;
}

section.wiki-section.is-intro li {
    position: relative !important;
    display: block;
    width: 100%;
}

/* TOCリンク — フォント大きめに */
section.wiki-section.is-intro a {
    position: relative;
    display: block;
    padding: 13px 65px 13px 35px;
    color: var(--wv-text-sub);
    text-decoration: none;
    font-size: 1.05rem;   /* ← 旧1.2remから微調整（TOCはやや小さめで見やすく） */
    font-weight: 600;
    transition: all 0.3s;
    line-height: 1.5;
}

section.wiki-section.is-intro a:hover {
    background: rgba(142, 45, 226, 0.35);
    color: #fff;
}

section.wiki-section.is-intro a::before {
    content: '>';
    position: absolute;
    left: 15px;
    top: 13px;
    color: var(--cyber-pink);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
}

.toc-accordion-toggle {
    position: absolute !important;
    right: 25px !important;
    top: 10px !important;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--cyber-purple);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(142, 45, 226, 0.6) !important;
    transition: all 0.3s;
    z-index: 20;
    cursor: pointer;
}

section.wiki-section.is-intro.is-active h2 .toc-accordion-toggle {
    top: 50% !important;
    transform: translateY(-50%) !important;
}

.toc-accordion-toggle::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #fff;
    transition: transform 0.3s;
}

li.has-sub.sub-open > .toc-accordion-toggle::after {
    transform: rotate(180deg) !important;
}

section.wiki-section.is-intro li.has-sub > ul {
    background: rgba(0, 0, 0, 0.4);
    margin-left: 10px;
    border-left: 1px solid var(--cyber-purple);
    padding: 0;
    display: none;
}

#mw-toc-heading {
    font-size: 0 !important;
    color: transparent !important;
    line-height: 0 !important;
}

/* ==========================================================================
   4. SECTION HEADING STRUCTURE
   ========================================================================== */

/* 見出し行コンテナ */
.wiki-section-h2heading {
    width: 100% !important;
    display: block !important;
    margin-bottom: 0 !important; /* h2自体のmarginで制御 */
}

/* セクション全体をブロックに */
.wiki-content-wrapper > .wiki-section {
    display: block !important;
}

/* 画像がある時のコンテンツ段組み */
.wiki-section-h2content:has(img),
.wiki-section-h2content:has(figure) {
    display: flex !important;
    flex-wrap: wrap;
    gap: 40px;
    align-items: stretch !important;
}

.wiki-section-h2content:has(img) > table,
.wiki-section-h2content:has(img) > *:not(img):not(figure):not(p) {
    flex: 1 !important;
    min-width: 320px;
}

.wiki-section-h2content img,
.wiki-section-h2content figure {
    width: 420px !important;
    flex-shrink: 0;
    order: 2;
    display: flex !important;
}

.wiki-section-h2content img {
    width: 100% !important;
    height: auto !important;
    max-height: 100% !important;
    object-fit: contain;
    object-position: center top;
}

.wiki-section-h2content p {
    flex: none !important;
    width: 100% !important;
    order: 3;
}

/* ==========================================================================
   5. MAIN SECTION CARDS
   analysis.css の .an-card に寄せたデザイン
   ========================================================================== */
.wiki-content-wrapper > .wiki-section {
    position: relative;
    background: rgba(10, 10, 18, 0.95) !important;
    border: 1px solid var(--wv-border) !important;
    border-left: 4px solid var(--cyber-purple) !important;
    padding: 0 0 40px !important;  /* h2が上端を占有するのでtop padding=0 */
    margin-bottom: 36px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow: hidden;
}

/* ── H2 見出し (analysis.css のカードタイトルに寄せる) ── */
.wiki-section h2 {
    width: 100% !important;
    display: block !important;
    order: -1;
    margin: 0 0 28px 0 !important;
    padding: 20px 36px !important;

    font-family: 'Orbitron', sans-serif !important;
    font-size: clamp(1.4rem, 2.5vw, 2rem) !important;  /* ← 読みやすいサイズ */
    font-weight: 900 !important;
    color: var(--wv-text) !important;
    letter-spacing: 0.12em !important;
    text-transform: uppercase;
    line-height: 1.2;

    background: linear-gradient(
        90deg,
        rgba(142, 45, 226, 0.75) 0%,
        rgba(142, 45, 226, 0.18) 60%,
        transparent 100%
    ) !important;
    border-bottom: 1px solid var(--wv-border) !important;
    border-left: none !important;
    border-top: none !important;
    box-shadow: none;

    /* 疑似要素による下線（analysis.css のカードタイトルアンダーライン） */
    position: relative;
}

.wiki-section h2::after {
    content: '' !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 36px !important;
    width: 36px !important;
    height: 2px !important;
    background: var(--wv-gold) !important;
    transition: width 0.4s cubic-bezier(.165,.84,.44,1) !important;
    display: block !important;
}

.wiki-section:hover h2::after {
    width: 72px !important;
}

/* ── H3 見出し ── */
.wiki-section h3 {
    width: 100% !important;
    font-family: 'Orbitron', sans-serif !important;
    font-size: 1.35rem !important;  /* ← 旧1.7remより少し抑えてバランス良く */
    font-weight: 800 !important;
    color: var(--wv-text) !important;
    margin: 36px 36px 16px !important;
    padding: 8px 16px 8px 20px !important;
    position: relative !important;
    border-bottom: 1px solid rgba(255, 0, 255, 0.4) !important;
    letter-spacing: 0.1em;
    width: calc(100% - 72px) !important;
}

.wiki-section h3::before {
    content: "" !important;
    position: absolute !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 4px !important;
    height: 70% !important;
    background: var(--cyber-pink) !important;
    box-shadow: 0 0 8px var(--cyber-pink) !important;
}

/* ── 本文テキスト ── */
.wiki-section p,
.wiki-section li {
    color: var(--wv-text-sub) !important;
    font-size: 1.1rem !important;    /* ← 旧1.45remから整理。読みやすい本文サイズ */
    line-height: 1.95 !important;
    padding-left: 0;
}

/* セクション内のp/ulをpaddingで字下げ */
.wiki-section-h2content > p,
.wiki-section-h2content > ul,
.wiki-section-h2content > ol {
    padding-left: 36px !important;
    padding-right: 36px !important;
    box-sizing: border-box;
    width: 100% !important;
}

/* ── TABLE DESIGN ── */
.wiki-section table {
    width: calc(100% - 72px);
    margin: 20px 36px 28px !important;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid var(--wv-border) !important;
    table-layout: auto;
    font-size: 1rem;  /* テーブルのベースフォントサイズ */
}

.wiki-section th {
    background: rgba(40, 8, 72, 0.95) !important;
    color: var(--wv-text) !important;
    font-size: 0.95rem !important;
    font-weight: 800 !important;
    padding: 14px 18px !important;
    text-align: left;
    letter-spacing: 0.05em;
    border-right: 1px solid var(--wv-border) !important;
    border-bottom: 2px solid var(--cyber-pink) !important;
}

.wiki-section td {
    padding: 12px 18px !important;
    color: var(--wv-text-sub) !important;
    font-size: 1rem !important;     /* ← 旧1.35remから整理 */
    line-height: 1.65;
    vertical-align: middle;
    border-bottom: 1px solid var(--wv-border) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.wiki-section tr:hover td {
    background: rgba(142, 45, 226, 0.15) !important;
    transition: background 0.12s ease;
}

.wiki-section th:last-child,
.wiki-section td:last-child {
    border-right: none !important;
}

.wiki-section tr:last-child td {
    border-bottom: none !important;
}

/* ── IMAGE (セクション内単体) ── */
.wiki-section > img,
.wiki-section-h2content > img {
    order: 2;
    max-width: 420px !important;
    width: 100%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 2px;
}

/* ── YouTube PLAYER ── */
.youtube-player-wrapper {
    width: calc(100% - 72px) !important;
    margin: 20px 36px 28px !important;
    position: relative;
    padding-top: 56.25%;
    border: 1px solid var(--wv-border);
    order: 3;
}

.youtube-player-wrapper iframe {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border: none;
}

/* ==========================================================================
   6. PAGE TOP BUTTON
   ========================================================================== */
#page-top {
    position: fixed !important;
    right: 30px;
    bottom: 30px;
    width: 46px;
    height: 46px;
    background-color: #5a0000 !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100002 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#page-top.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==========================================================================
   7. SCROLL MARGIN (アンカーリンク対応)
   ========================================================================== */
.wiki-section [id],
.wiki-section {
    scroll-margin-top: calc(100px + 50px + 10px);
}

/* ==========================================================================
   8. RESPONSIVE
   ========================================================================== */
@media screen and (max-width: 1024px) {
    .wiki-content-wrapper {
        padding: 36px 36px 80px;
    }

    .wiki-section h3 {
        margin: 28px 24px 14px !important;
        width: calc(100% - 48px) !important;
    }

    .wiki-section table {
        width: calc(100% - 48px);
        margin: 16px 24px 24px !important;
    }

    .youtube-player-wrapper {
        width: calc(100% - 48px) !important;
        margin: 16px 24px 24px !important;
    }

    .wiki-section-h2content > p,
    .wiki-section-h2content > ul,
    .wiki-section-h2content > ol {
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
}

@media screen and (max-width: 768px) {
    .wiki-content-wrapper {
        padding: 24px 12px 60px;
        width: 98%;
    }

    .wiki-section h2 {
        font-size: 1.15rem !important;
        padding: 16px 20px !important;
        letter-spacing: 0.06em !important;
    }

    .wiki-section h2::after {
        left: 20px !important;
    }

    .wiki-section h3 {
        font-size: 1.05rem !important;
        margin: 24px 16px 12px !important;
        width: calc(100% - 32px) !important;
    }

    .wiki-section p,
    .wiki-section li {
        font-size: 1rem !important;
    }

    .wiki-section td {
        font-size: 0.9rem !important;
        padding: 10px 12px !important;
    }

    .wiki-section table {
        width: calc(100% - 32px);
        margin: 12px 16px 20px !important;
    }

    .wiki-section-h2content:has(img),
    .wiki-section-h2content:has(figure) {
        flex-direction: column;
        gap: 16px;
    }

    .wiki-section-h2content img,
    .wiki-section-h2content figure {
        width: 100% !important;
        order: -1;
    }

    .wiki-section-h2content > p,
    .wiki-section-h2content > ul,
    .wiki-section-h2content > ol {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .youtube-player-wrapper {
        width: calc(100% - 32px) !important;
        margin: 12px 16px 20px !important;
    }

    section.wiki-section.is-intro.is-active {
        width: 92vw !important;
        max-height: 75vh !important;
        left: 4vw !important;
        bottom: 20px !important;
        border-radius: 16px;
    }
}

@media (max-width: 768px) {
    .wiki-section [id],
    .wiki-section {
        scroll-margin-top: calc(60px + 45px + 10px);
    }
}