/* 年表ページ固有スタイル */

.nenpyou-book {
    background-image: url('../img/nenpyou/nenpyou_book.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    width: 1400px;
    height: 700px;
    min-height: unset;
    position: relative;
    /* book-spread のデフォルト装飾を上書き */
    border: none;
    background-color: transparent;
}

.nenpyou-book .book-page-month,
.nenpyou-book .nenpyou-detail-page {
    height: 700px;
    min-height: unset;
    background: transparent;
}

/* book-page-month はタブが右にはみ出すので overflow: visible */
.nenpyou-book .book-page-month {
    overflow: visible;
}

/* インデックスタブ */
.nenpyou-tabs {
    position: absolute;
    top: 20px;
    left: -37px; /* 左にはみ出す量 */
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    z-index: 10;
}

.nenpyou-tab img {
    display: block;
    width: 25px;
    height: auto;
}

.nenpyou-tab.is-active img {
    filter: brightness(1.1);
}

/* タブごとの左オフセット調整 */
.nenpyou-tab--1  { margin-left: 0px; }
.nenpyou-tab--2  { margin-left: -2px; }
.nenpyou-tab--3  { margin-left: -4px; }
.nenpyou-tab--4  { margin-left: -5px; }
.nenpyou-tab--5  { margin-left: -6px; }
.nenpyou-tab--6  { margin-left: -7px; }
.nenpyou-tab--7  { margin-left: -8px; }
.nenpyou-tab--8  { margin-left: -9px; }
.nenpyou-tab--9  { margin-left: -10px; }
.nenpyou-tab--10 { margin-left: -11px; }
.nenpyou-tab--11 { margin-left: -12px; }
.nenpyou-tab--12 { margin-left: -13px; }
.nenpyou-tab--13 { margin-left: -14px; }

/* 上下装飾（年表専用） */
.nenpyou-book .book-page-month::before,
.nenpyou-book .book-page-month::after {
    content: '';
    display: block;
    width: 400px;
    height: 48px;
    background-size: 100% auto;
    background-repeat: no-repeat;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.nenpyou-book .book-page-month::before {
    top: 20px;
    background-image: url('../img/common/frame_top.png');
    background-position: top center;
    width: 350px;
}

.nenpyou-book .book-page-month::after {
    bottom: 20px;
    background-image: url('../img/common/frame_bottom.png');
    background-position: bottom center;
    width: 350px;
}

.nenpyou-book .nenpyou-detail-page::before,
.nenpyou-book .nenpyou-detail-page::after {
    content: '';
    display: block;
    width: 400px;
    height: 48px;
    background-size: 100% auto;
    background-repeat: no-repeat;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.nenpyou-book .nenpyou-detail-page::before {
    top: 20px;
    background-image: url('../img/nenpyou/detail_frame_top.png');
    background-position: top center;
    width: 350px;
}

.nenpyou-book .nenpyou-detail-page::after {
    bottom: 20px;
    background-image: url('../img/nenpyou/detail_frame_bottom.png');
    background-position: bottom center;
    width: 350px;
}

/* 右ページ左右フレーム装飾 */
.nenpyou-detail-frame {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    width: 50px;
    height: 500px;
    z-index: 10;
}

.nenpyou-detail-frame--left {
    left: 10px;
    background-image: url('../img/nenpyou/detail_frame_left.png');
    background-position: left center;
}

.nenpyou-detail-frame--right {
    right: 50px;
    background-image: url('../img/nenpyou/detail_frame_right.png');
    background-position: right center;
}

/* 左ページは右寄り、右ページは左寄り */
.nenpyou-book .book-page--left::before,
.nenpyou-book .book-page--left::after {
    left: 52%;
    width: 90%;
}

.nenpyou-book .book-page--right::before,
.nenpyou-book .book-page--right::after {
    left: 45%;
}

.nenpyou-deco {
    width: 100%;
    height: 48px;
    background-size: 100% auto;
    background-repeat: no-repeat;
}

.nenpyou-deco--top {
    /* background-image: url('../img/nenpyou/frame_top.png'); */
    background-position: top center;
    margin-bottom: 8px;
}

.nenpyou-deco--bottom {
    /* background-image: url('../img/nenpyou/frame_bottom.png'); */
    background-position: bottom center;
    margin-top: 8px;
}

/* ヘッダー */
.nenpyou-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 8px;
    border-bottom: 1px solid #c0a880;
    margin-top: -50px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.nenpyou-header__old {
    font-size: 0.75rem;
    color: #888;
}

.nenpyou-footer__new {
    font-size: 0.75rem;
    color: #888;
    padding-top: 4px;
    border-top: 1px solid #c0a880;
    margin-top: 4px;
}

/* タイムライン */
.nenpyou-timeline {
    height: 450px;
    overflow-y: auto;
}

.nenpyou-timeline__item.is-hidden-month {
    display: none;
}


.nenpyou-timeline__item {
    display: grid;
    grid-template-columns: 40px 1fr 16px;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dashed #c0a880;
    cursor: pointer;
    transition: background-color 0.2s;
}

.nenpyou-timeline__item:hover {
    background-color: rgba(176, 48, 112, 0.08);
}

.nenpyou-timeline__marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--color-secondary);
    display: block;
    flex-shrink: 0;
}

/* 月タブ（左端縦並び） */
.nenpyou-month-nav {
    position: absolute;
    left: -32px;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 28px;
}

.nenpyou-month-nav__item {
    font-size: 0.6rem;
    writing-mode: vertical-rl;
    padding: 4px 2px;
    border-radius: 4px 0 0 4px;
    border: 1px solid #c0a880;
    border-right: none;
    color: var(--color-text-dark);
    background-color: hsl(calc(var(--tab-index, 0) * 20), 60%, 75%);
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nenpyou-month-nav__item.is-active {
    background-color: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* TOPへ戻るボタン */
.nenpyou-home-btn {
    position: absolute;
    bottom: 0px;
    right: 0px;
    display: block;
    z-index: 200;
    transition: opacity 0.2s;
}

.nenpyou-home-btn:hover {
    opacity: 0.75;
}

.nenpyou-home-btn img {
    width: 80px;
    height: auto;
    display: block;
}

/* TOPへ戻るボタン（モバイル用は初期非表示） */
.nenpyou-home-btn--mobile {
    display: none;
}

.nenpyou-detail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 350px;
    padding-top: 30px;
    padding-left: 40px;
    padding-right: 40px;
}

.nenpyou-detail__summary {
    border: 1px solid #c0a880;
    padding: 12px;
    min-height: 80px;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* ============================================================
   レスポンシブ（768px 以下）
   ============================================================ */
@media screen and (max-width: 768px) {
    /* 右ページ（詳細）を非表示、左ページのみ表示 */
    .nenpyou-book {
        width: 100%;
        height: 520px;
        min-height: unset;
        grid-template-columns: 1fr;
        background-image: url('../img/nenpyou/nenpyou_book_sp.png');
        background-size: 100% 100%;
        background-color: transparent;
    }

    .nenpyou-book .book-page--left::before,
    .nenpyou-book .book-page--left::after {
        left: 55%;
        width: 80%;
    }

    .nenpyou-detail-page {
        display: none;
    }

    .nenpyou-book .book-page-month {
        width: 100% !important;
        left: 0 !important;
        height: 520px;
        min-height: unset;
        padding-left: 40px; /* タブ幅分を確保 */
    }

    /* タブを左端に上寄せで収める */
    .nenpyou-tabs {
        left: 15px;
        top: 20px;
        height: auto;
    }

    .nenpyou-tab img {
        display: block;
        width: auto;
        height: 30px;
    }
    /* タイムライン高さを他ページに合わせて調整 */
    .nenpyou-timeline {
        height: 310px;
    }

    /* モバイル用ボタンを表示、PC用は非表示 */
    .nenpyou-home-btn--mobile {
        display: block;
        position: absolute;
        right: 4px;
        bottom: -40px;
        z-index: 10;
    }

    .nenpyou-detail-page .nenpyou-home-btn:not(.nenpyou-home-btn--mobile) {
        display: none;
    }

    .nenpyou-home-btn img {
        width: 65px;
    }
}
