
@charset "utf-8";
/* ========================================
   フリップブック CSS 完全版
   PC：1281px以上は見開き表示
   中間：1024～1280pxは1ページ＋PC版目次
   スマホ：1023px以下は1ページ＋開閉式目次
======================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #f0f0f0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    font-family: sans-serif;
}

/* ========================================
   戻るボタン
======================================== */

.back {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2000;
    display: inline-block;
    padding: 10px 15px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 0 0 4px 0;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    font-family: sans-serif;
}

.back-link {
    text-decoration: none;
}

/* ========================================
   目次：PC版
   1024px以上で常時表示
======================================== */

.toc-container {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background-color: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 60px 20px 20px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.toc-title {
    width: 100%;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
    color: #333;
}

.toc-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.toc-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    font-size: 14px;
    color: #555;
    margin-bottom: 4px;
}

.toc-item:hover {
    background-color: #f5f5f5;
    color: #000;
}

.toc-item.active {
    background-color: #007bff;
    color: #fff;
    font-weight: bold;
}

/* スマホ用目次ボタン：通常は非表示 */
.toc-toggle {
    display: none;
}

/* ========================================
   本全体の配置：PC見開き表示
   1281px以上
======================================== */

.book-wrapper {
    position: relative;
    height: 96vh;
    width: calc(96vh * (2384 / 1684));
    max-width: calc(96vw - 260px);
    max-height: calc((96vw - 260px) * (1684 / 2384));
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 240px;
    transition: all 0.3s ease;
}

.book-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ========================================
   ページ・見開き
======================================== */

.spread {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    overflow: visible;

    /* 拡大・移動はJavaScriptで設定 */
    transform: translate(0, 0) scale(1);
    transform-origin: center center;
}

.spread.active {
    pointer-events: auto;
    opacity: 1;
}

.page {
    height: 100%;
    flex: 1;
    aspect-ratio: 1192 / 1684;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

/* 1ページだけの表紙・裏表紙 */
.spread.single .page {
    position: absolute;
    height: 100%;
    width: 50%;
    left: 50%;
    transform: translateX(-50%);
}

/* ========================================
   前後ページ移動ボタン
======================================== */

.arrow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 45px;
    background-color: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s, opacity 0.2s;
    user-select: none;
}

.arrow-btn::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border-top: 2.5px solid #fff;
    border-left: 2.5px solid #fff;
}

#prevBtn {
    left: -31px;
    border-radius: 4px;
}

#prevBtn::before {
    transform: rotate(-45deg);
    margin-left: 4px;
}

#nextBtn {
    right: -31px;
    border-radius: 4px;
}

#nextBtn::before {
    transform: rotate(135deg);
    margin-right: 4px;
}

.arrow-btn:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.arrow-btn:disabled {
    opacity: 0.15;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.4);
}

/* ========================================
   中間サイズ・タブレット横向きなど
   1024～1280px
   1ページ表示＋PC版目次
======================================== */

@media (max-width: 1280px) {
    .book-wrapper {
        margin-left: 240px;
        height: 96vh;
        width: calc(96vh * (1192 / 1684));
        max-width: calc(100vw - 280px);
        max-height: calc((100vw - 280px) * (1684 / 1192));
    }

    .book-container {
        overflow: visible;
    }

    .spread {
        width: 100%;
        height: 100%;
    }

    /* 1ページずつ表示 */
    .page {
        display: none;
        width: 100% !important;
        height: 100% !important;
        left: 0 !important;
        transform: none !important;
        flex: none;
    }

    .page.mobile-active {
        display: block;
    }

    /* ページ送りボタンを本の内側に配置 */
    #prevBtn {
        left: 1px;
    }

    #nextBtn {
        right: 1px;
    }

    /* 目次は常時表示 */
    .toc-container {
        transform: translateX(0);
    }

    .toc-toggle {
        display: none;
    }
}

/* ========================================
   スマホ・小さいタブレット
   1023px以下
   1ページ表示＋開閉式目次
======================================== */

@media (max-width: 1023px) {
    body {
        width: 100%;
        height: 100vh;
        min-height: 0;
    }

    /* 目次を画面左外に隠す */
    .toc-container {
        top: 0;
        left: 0;
        width: 240px;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 2000;
    }

    .toc-container.open {
        transform: translateX(0);
    }

    /* 目次を開くボタン */
    .toc-toggle {
        display: block;
        position: fixed;
        left: 0;
        top: 45px;
        z-index: 2001;
        padding: 10px 15px;
        background-color: #333;
        color: #fff;
        border: none;
        border-radius: 0 4px 4px 0;
        cursor: pointer;
        font-size: 14px;
        font-family: sans-serif;
    }

    /* 本は画面中央に配置 */
    .book-wrapper {
        margin-left: 0;
        height: 85vh;
        width: calc(85vh * (1192 / 1684));
        max-width: 90vw;
        max-height: calc(90vw * (1684 / 1192));
    }

    .book-container {
        width: 100%;
        height: 100%;
        overflow: visible;
    }

    .spread {
        width: 100%;
        height: 100%;
        overflow: visible;
    }

    .page {
        display: none;
        width: 100% !important;
        height: 100% !important;
        left: 0 !important;
        transform: none !important;
        flex: none;
    }

    .page.mobile-active {
        display: block;
    }

    #prevBtn {
        left: 1px;
    }

    #nextBtn {
        right: 1px;
    }
}
