3Dページめくり

CSS perspective と rotateY で本のページがめくれる演出。ボタンで前後にめくれ、自動ループにも対応。ページの裏表と影で立体感を出します。電子書籍やポートフォリオの導入演出に向きます。

#3d#css#perspective#flip#book

ライブデモ

使用例(お題: カフェ MOON BREW)

この技法を「カフェ MOON BREW」というテーマのダミーサイトで実際に使った例です。

HTML
<!-- MOON BREW:めくれるメニューブック -->
<section class="mb-menu" aria-label="MOON BREW メニューブック">
  <header class="mb-menu__head">
    <span class="mb-menu__logo">◐ MOON BREW</span>
    <span class="mb-menu__sub">DRINK & FOOD MENU</span>
  </header>

  <div class="mb-book" aria-label="ページめくりメニュー">
    <div class="mb-book__base">
      <div class="mb-book__spine" aria-hidden="true"></div>
      <!-- 左ページ(背表紙側の固定面) -->
      <div class="mb-book__left">
        <span class="mb-book__leftnum" id="mbLeft">表紙</span>
      </div>
      <!-- めくれるページ群はJSが右側に積層生成 -->
      <div class="mb-book__pages" id="mbPages"></div>
    </div>
  </div>

  <div class="mb-book__nav">
    <button class="mb-book__btn" id="mbPrev" type="button" aria-label="前のページ">‹ 前</button>
    <span class="mb-book__status" id="mbStatus" aria-live="polite">1 / 5</span>
    <button class="mb-book__btn" id="mbNext" type="button" aria-label="次のページ">次 ›</button>
  </div>
</section>
CSS
/* MOON BREW:めくれるメニューブック */
:root {
  --cream: #f5ede1;
  --brown: #2b1d12;
  --amber: #c98a3b;
  --page: #fffaf1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Hiragino Mincho ProN", "Georgia", "Segoe UI", serif;
  background: radial-gradient(circle at 50% 0%, #3a2817 0%, var(--brown) 80%);
  color: var(--cream);
  overflow: hidden;
}

.mb-menu__head { text-align: center; padding: 14px 0 6px; }
.mb-menu__logo { font-size: 15px; font-weight: 800; letter-spacing: 0.06em; display: block; }
.mb-menu__sub { font-size: 10px; letter-spacing: 0.24em; color: var(--amber); }

/* 本体:perspective が立体の肝 */
.mb-book {
  perspective: 1400px;
  perspective-origin: 50% 40%;
}
.mb-book__base {
  position: relative;
  width: 360px;
  height: 220px;
  display: flex;
}
.mb-book__spine {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 4px; transform: translateX(-2px);
  background: linear-gradient(to right, rgba(0,0,0,.3), rgba(0,0,0,.05));
  z-index: 50;
}

/* 左の固定ページ */
.mb-book__left {
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, var(--page), #f3e7d2);
  border-radius: 8px 0 0 8px;
  box-shadow: inset -8px 0 16px rgba(43,29,18,.12);
  display: grid;
  place-items: center;
  color: #8a6a3e;
}
.mb-book__leftnum { font-size: 13px; letter-spacing: 0.1em; }

/* めくれるページ群 */
.mb-book__pages {
  position: relative;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
}
.mb-page {
  position: absolute;
  inset: 0;
  transform-origin: left center;  /* 背表紙側を軸に回転 */
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(.3,.1,.2,1);
}
.mb-page.is-flipped { transform: rotateY(-180deg); }

.mb-page__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 0 8px 8px 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--page), #f5ead6);
  box-shadow: inset 8px 0 16px rgba(43,29,18,.1);
  color: var(--brown);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mb-page__face--back {
  transform: rotateY(180deg);
  border-radius: 8px 0 0 8px;
  box-shadow: inset -8px 0 16px rgba(43,29,18,.1);
}

.mb-page__cat {
  font-size: 12px; letter-spacing: 0.2em; color: var(--amber);
  font-weight: 700; border-bottom: 1px solid rgba(201,138,59,.4);
  padding-bottom: 6px; margin-bottom: 8px;
}
.mb-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; margin: 5px 0; gap: 8px;
}
.mb-row b { font-weight: 600; }
.mb-row .mb-dots {
  flex: 1; border-bottom: 1px dotted rgba(43,29,18,.3); margin: 0 4px 3px;
}
.mb-row .mb-price { color: #a8651f; font-weight: 700; white-space: nowrap; }
.mb-page__note { margin-top: auto; font-size: 10px; color: #9a8569; }

.mb-page__thumb {
  width: 100%; height: 64px; object-fit: cover; border-radius: 6px;
  margin-bottom: 8px; filter: sepia(.2) saturate(1.1);
}

/* ナビ */
.mb-book__nav {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 10px;
}
.mb-book__btn {
  font: inherit; font-size: 12px; font-weight: 700;
  color: var(--brown);
  background: linear-gradient(135deg, #e0a85a, var(--amber));
  border: none; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 14px rgba(201,138,59,.35);
  transition: transform 0.2s ease;
}
.mb-book__btn:hover:not(:disabled) { transform: translateY(-2px); }
.mb-book__btn:disabled { opacity: .4; cursor: default; }
.mb-book__status { font-size: 12px; letter-spacing: 0.1em; color: var(--cream); }

@media (prefers-reduced-motion: reduce) {
  .mb-page { transition-duration: .01ms; }
}
JavaScript
// MOON BREW メニューブック:perspective + rotateY でページをめくる(ボタン+自動ループ)
(() => {
  const pagesEl = document.getElementById("mbPages");
  const prev = document.getElementById("mbPrev");
  const next = document.getElementById("mbNext");
  const status = document.getElementById("mbStatus");
  const leftEl = document.getElementById("mbLeft");
  if (!pagesEl || !prev || !next) return; // null安全

  // メニュー内容(表=カテゴリ見出し+写真、裏=品目リスト)
  const sheets = [
    {
      cat: "COFFEE", seed: 71,
      items: [["本日のドリップ", "¥520"], ["カフェラテ", "¥580"], ["月夜のカフェモカ", "¥640"]],
    },
    {
      cat: "ESPRESSO", seed: 72,
      items: [["エスプレッソ", "¥420"], ["カプチーノ", "¥560"], ["マキアート", "¥480"]],
    },
    {
      cat: "SWEETS", seed: 73,
      items: [["ガトーショコラ", "¥560"], ["チーズケーキ", "¥540"], ["焼き菓子セット", "¥620"]],
    },
    {
      cat: "FOOD", seed: 74,
      items: [["厚切りトースト", "¥480"], ["キッシュプレート", "¥880"], ["本日のスープ", "¥420"]],
    },
    {
      cat: "SEASONAL", seed: 75,
      items: [["桜ラテ(春限定)", "¥620"], ["和栗モンブラン", "¥680"], ["柚子はちみつ", "¥540"]],
    },
  ];
  const total = sheets.length;

  // 品目リストのHTMLを組み立て
  const rowsHtml = (items) =>
    items.map(([n, p]) =>
      `<div class="mb-row"><b>${n}</b><span class="mb-dots"></span><span class="mb-price">${p}</span></div>`
    ).join("");

  // 1枚のページDOMを生成(表=写真+見出し、裏=品目)
  sheets.forEach((s, i) => {
    const page = document.createElement("div");
    page.className = "mb-page";
    page.style.zIndex = String(total - i);

    const front = document.createElement("div");
    front.className = "mb-page__face mb-page__face--front";
    front.innerHTML =
      `<div class="mb-page__cat">${s.cat}</div>` +
      `<img class="mb-page__thumb" alt="" src="https://picsum.photos/seed/moonbrew${s.seed}/240/130">` +
      `<div class="mb-page__note">${i + 1} / ${total} 月夜のひととき</div>`;

    const back = document.createElement("div");
    back.className = "mb-page__face mb-page__face--back";
    back.innerHTML =
      `<div class="mb-page__cat">${s.cat} 一覧</div>` +
      rowsHtml(s.items) +
      `<div class="mb-page__note">表示は税込価格です</div>`;

    page.appendChild(front);
    page.appendChild(back);
    pagesEl.appendChild(page);
  });

  const pageEls = Array.from(pagesEl.querySelectorAll(".mb-page"));
  let index = 0; // めくった枚数 0..total

  // 表示更新:index枚目までめくり、重なり順を整える
  const render = () => {
    pageEls.forEach((el, i) => {
      const flipped = i < index;
      el.classList.toggle("is-flipped", flipped);
      el.style.zIndex = String(flipped ? i + 1 : total - i);
    });
    prev.disabled = index <= 0;
    next.disabled = index >= total;
    if (status) status.textContent = `${Math.min(index + 1, total)} / ${total}`;
    if (leftEl) leftEl.textContent = index === 0 ? "表紙" : `${sheets[Math.min(index, total) - 1].cat}`;
  };

  const go = (dir) => {
    index = Math.max(0, Math.min(total, index + dir));
    render();
  };

  prev.addEventListener("click", () => go(-1));
  next.addEventListener("click", () => go(1));
  render();

  // 自動めくりループ(操作・reduced-motion時は停止)
  const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  let timer = null;
  const tick = () => {
    if (index >= total) index = 0; // 末尾まで来たら閉じてループ
    else index += 1;
    render();
  };
  const start = () => { if (!reduce && !timer) timer = setInterval(tick, 2400); };
  const stop = () => { if (timer) { clearInterval(timer); timer = null; } };
  [prev, next].forEach((b) => b.addEventListener("click", stop));
  start();
})();

コード

HTML
<div class="book" aria-label="3Dページめくりのデモ">
  <div class="book__scene">
    <!-- 本体: 左に表紙/中身、右に重なるページをJSが配置 -->
    <div class="book__base">
      <div class="book__spine" aria-hidden="true"></div>
      <div class="book__left">
        <span class="book__num" id="curLeft">1</span>
      </div>
      <!-- ページ群はJSが生成して右側に積層 -->
      <div class="book__pages" id="pages"></div>
    </div>
  </div>
  <div class="book__nav">
    <button class="book__btn" id="prev" type="button" aria-label="前のページ">‹ 前</button>
    <span class="book__status" id="status" aria-live="polite">1 / 6</span>
    <button class="book__btn" id="next" type="button" aria-label="次のページ">次 ›</button>
  </div>
</div>
CSS
/* ===== 3Dページめくり ===== */
* { box-sizing: border-box; }

:root {
  --page-w: 150px;      /* ページ1枚の幅 */
  --page-h: 200px;      /* ページの高さ */
  --paper: #f7f3ea;     /* 紙色 */
  --paper-edge: #e2d9c4;/* 紙の小口 */
  --ink: #4a4034;       /* 文字色 */
  --flip: .85s;         /* めくり時間 */
}

body {
  margin: 0;
  min-height: 360px;
  display: grid;
  place-items: center;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(120% 120% at 50% 0%, #2b2f45 0%, #14161f 60%, #090a10 100%);
  overflow: hidden;
}

.book { display: grid; place-items: center; gap: 18px; }

/* 奥行きを与えるシーン */
.book__scene {
  perspective: 1600px;
  perspective-origin: 50% 40%;
}

/* 見開きの土台(左右ページ分の幅) */
.book__base {
  position: relative;
  width: calc(var(--page-w) * 2);
  height: var(--page-h);
  transform: rotateX(6deg); /* やや見下ろす立体感 */
  transform-style: preserve-3d;
  /* 本の床影 */
  filter: drop-shadow(0 22px 26px rgba(0,0,0,.55));
}

/* 中央の綴じ目 */
.book__spine {
  position: absolute;
  left: 50%; top: 0;
  width: 8px; height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,.05), rgba(0,0,0,.35));
  z-index: 5;
}

/* 左ページ(めくり済みが見える側) */
.book__left {
  position: absolute;
  left: 0; top: 0;
  width: var(--page-w); height: 100%;
  background: var(--paper);
  border-radius: 6px 2px 2px 6px;
  box-shadow: inset -14px 0 22px rgba(0,0,0,.14);
  display: grid; place-items: center;
}

/* 右側ページの積層エリア */
.book__pages {
  position: absolute;
  right: 0; top: 0;
  width: var(--page-w); height: 100%;
  transform-style: preserve-3d;
}

/* 1枚のページ(綴じ目=左端を軸に回転) */
.page {
  position: absolute;
  inset: 0;
  transform-origin: left center;     /* 綴じ側を軸に */
  transform-style: preserve-3d;
  transition: transform var(--flip) cubic-bezier(.3,.05,.2,1);
  transform: rotateY(0deg);
}
.page.is-flipped { transform: rotateY(-180deg); } /* めくられた状態 */

/* ページの表/裏 */
.page__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 2px 6px 6px 2px;
  background: var(--paper);
  color: var(--ink);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* 小口(右端)の質感 + 綴じ側の陰影 */
  box-shadow:
    inset -4px 0 0 var(--paper-edge),
    inset 16px 0 24px rgba(0,0,0,.12);
}
.page__face--back {
  transform: rotateY(180deg); /* 裏面 */
  border-radius: 6px 2px 2px 6px;
  box-shadow:
    inset 4px 0 0 var(--paper-edge),
    inset -16px 0 24px rgba(0,0,0,.12);
}

.page__title { font-size: 13px; font-weight: 800; letter-spacing: .08em; }
.page__num   { font-size: 28px; font-weight: 800; color: var(--ink); opacity: .85; }
.page__thumb {
  width: 100%; height: 76px;
  object-fit: cover;
  border-radius: 4px;
  filter: sepia(.18) saturate(.9);
}
.page__line {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--paper-edge), transparent);
}

.book__num {
  font-size: 26px; font-weight: 800; color: var(--ink); opacity: .8;
}

/* 操作 */
.book__nav { display: flex; align-items: center; gap: 14px; }
.book__btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.07);
  color: #fff;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s, opacity .2s;
}
.book__btn:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.book__btn:active:not(:disabled) { transform: scale(.94); }
.book__btn:disabled { opacity: .35; cursor: default; }
.book__btn:focus-visible { outline: 2px solid #9ad; outline-offset: 2px; }
.book__status {
  color: #cfd3e6; font-size: 13px; letter-spacing: .06em;
  min-width: 52px; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .page { transition: none; }
}
JavaScript
// 3Dページめくり: perspective + rotateY で本のページをめくる(ボタン+自動ループ)
(() => {
  const pagesEl = document.getElementById('pages');
  const prev = document.getElementById('prev');
  const next = document.getElementById('next');
  const status = document.getElementById('status');
  const curLeft = document.getElementById('curLeft');
  if (!pagesEl || !prev || !next) return; // null安全

  // ページ内容(表=奇数, 裏=偶数 として連番を振る)
  const sheets = [
    { title: 'PROLOGUE', seed: 11 },
    { title: 'CHAPTER 1', seed: 24 },
    { title: 'CHAPTER 2', seed: 37 },
    { title: 'CHAPTER 3', seed: 52 },
    { title: 'EPILOGUE', seed: 68 },
    { title: 'THE END', seed: 80 },
  ];
  const total = sheets.length;

  // 1枚のページDOMを生成(表/裏の2面)
  const makeFace = (mod, title, num) => {
    const face = document.createElement('div');
    face.className = 'page__face page__face--' + mod;
    const img = mod === 'front'
      ? `<img class="page__thumb" alt="" src="https://picsum.photos/seed/book${num}/240/160">`
      : `<div class="page__line"></div><div class="page__line" style="width:70%"></div>`;
    face.innerHTML =
      `<div class="page__title">${title}</div>` +
      img +
      `<div class="page__num">${num}</div>`;
    return face;
  };

  // ページを積層生成(後ろのページほど下に重なるよう z-index 調整)
  sheets.forEach((s, i) => {
    const page = document.createElement('div');
    page.className = 'page';
    page.style.zIndex = String(total - i); // 上に来る順
    page.dataset.index = String(i);
    page.appendChild(makeFace('front', s.title, i * 2 + 1)); // 表ページ番号
    page.appendChild(makeFace('back', '', i * 2 + 2));        // 裏ページ番号
    pagesEl.appendChild(page);
  });

  const pageEls = Array.from(pagesEl.querySelectorAll('.page'));
  let index = 0; // 0..total(めくった枚数)

  // 表示更新: index枚目までめくり、z-indexで重なりを整える
  const render = () => {
    pageEls.forEach((el, i) => {
      const flipped = i < index;
      el.classList.toggle('is-flipped', flipped);
      // めくった側は左へ積み上げ、残りは右に重ねる
      el.style.zIndex = String(flipped ? i + 1 : total - i);
    });
    prev.disabled = index <= 0;
    next.disabled = index >= total;
    if (status) status.textContent = `${Math.min(index + 1, total)} / ${total}`;
    if (curLeft) curLeft.textContent = String(index === 0 ? 1 : index * 2);
  };

  const go = (dir) => {
    index = Math.max(0, Math.min(total, index + dir));
    render();
  };

  prev.addEventListener('click', () => go(-1));
  next.addEventListener('click', () => go(1));

  render();

  // 自動めくりループ(操作・reduced-motion時は停止)
  const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  let timer = null;
  const tick = () => {
    if (index >= total) index = 0; // 末尾まで来たら閉じてループ
    else index += 1;
    render();
  };
  const start = () => {
    if (reduce || timer) return;
    timer = setInterval(tick, 2200);
  };
  const stop = () => { if (timer) { clearInterval(timer); timer = null; } };

  [prev, next].forEach((b) => b.addEventListener('click', stop));
  start();
})();

🤖 AIエージェント用プロンプト

このままコピーしてAIに貼り付け「追加する場所」だけ書き換えればOK
あなたは熟練のフロントエンドエンジニアです。私のWebサイトに「3Dページめくり」の効果を追加してください。

# 追加してほしい効果
3Dページめくり(3D & パースペクティブ)
CSS perspective と rotateY で本のページがめくれる演出。ボタンで前後にめくれ、自動ループにも対応。ページの裏表と影で立体感を出します。電子書籍やポートフォリオの導入演出に向きます。

# 追加する場所
👉【ここに対象箇所を記入:例「トップのヒーローセクション」「お問い合わせボタン」「記事カードの一覧」など】

# 参考実装(この見た目・挙動を再現してください)
【HTML】
<div class="book" aria-label="3Dページめくりのデモ">
  <div class="book__scene">
    <!-- 本体: 左に表紙/中身、右に重なるページをJSが配置 -->
    <div class="book__base">
      <div class="book__spine" aria-hidden="true"></div>
      <div class="book__left">
        <span class="book__num" id="curLeft">1</span>
      </div>
      <!-- ページ群はJSが生成して右側に積層 -->
      <div class="book__pages" id="pages"></div>
    </div>
  </div>
  <div class="book__nav">
    <button class="book__btn" id="prev" type="button" aria-label="前のページ">‹ 前</button>
    <span class="book__status" id="status" aria-live="polite">1 / 6</span>
    <button class="book__btn" id="next" type="button" aria-label="次のページ">次 ›</button>
  </div>
</div>

【CSS】
/* ===== 3Dページめくり ===== */
* { box-sizing: border-box; }

:root {
  --page-w: 150px;      /* ページ1枚の幅 */
  --page-h: 200px;      /* ページの高さ */
  --paper: #f7f3ea;     /* 紙色 */
  --paper-edge: #e2d9c4;/* 紙の小口 */
  --ink: #4a4034;       /* 文字色 */
  --flip: .85s;         /* めくり時間 */
}

body {
  margin: 0;
  min-height: 360px;
  display: grid;
  place-items: center;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(120% 120% at 50% 0%, #2b2f45 0%, #14161f 60%, #090a10 100%);
  overflow: hidden;
}

.book { display: grid; place-items: center; gap: 18px; }

/* 奥行きを与えるシーン */
.book__scene {
  perspective: 1600px;
  perspective-origin: 50% 40%;
}

/* 見開きの土台(左右ページ分の幅) */
.book__base {
  position: relative;
  width: calc(var(--page-w) * 2);
  height: var(--page-h);
  transform: rotateX(6deg); /* やや見下ろす立体感 */
  transform-style: preserve-3d;
  /* 本の床影 */
  filter: drop-shadow(0 22px 26px rgba(0,0,0,.55));
}

/* 中央の綴じ目 */
.book__spine {
  position: absolute;
  left: 50%; top: 0;
  width: 8px; height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(0,0,0,.05), rgba(0,0,0,.35));
  z-index: 5;
}

/* 左ページ(めくり済みが見える側) */
.book__left {
  position: absolute;
  left: 0; top: 0;
  width: var(--page-w); height: 100%;
  background: var(--paper);
  border-radius: 6px 2px 2px 6px;
  box-shadow: inset -14px 0 22px rgba(0,0,0,.14);
  display: grid; place-items: center;
}

/* 右側ページの積層エリア */
.book__pages {
  position: absolute;
  right: 0; top: 0;
  width: var(--page-w); height: 100%;
  transform-style: preserve-3d;
}

/* 1枚のページ(綴じ目=左端を軸に回転) */
.page {
  position: absolute;
  inset: 0;
  transform-origin: left center;     /* 綴じ側を軸に */
  transform-style: preserve-3d;
  transition: transform var(--flip) cubic-bezier(.3,.05,.2,1);
  transform: rotateY(0deg);
}
.page.is-flipped { transform: rotateY(-180deg); } /* めくられた状態 */

/* ページの表/裏 */
.page__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 2px 6px 6px 2px;
  background: var(--paper);
  color: var(--ink);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* 小口(右端)の質感 + 綴じ側の陰影 */
  box-shadow:
    inset -4px 0 0 var(--paper-edge),
    inset 16px 0 24px rgba(0,0,0,.12);
}
.page__face--back {
  transform: rotateY(180deg); /* 裏面 */
  border-radius: 6px 2px 2px 6px;
  box-shadow:
    inset 4px 0 0 var(--paper-edge),
    inset -16px 0 24px rgba(0,0,0,.12);
}

.page__title { font-size: 13px; font-weight: 800; letter-spacing: .08em; }
.page__num   { font-size: 28px; font-weight: 800; color: var(--ink); opacity: .85; }
.page__thumb {
  width: 100%; height: 76px;
  object-fit: cover;
  border-radius: 4px;
  filter: sepia(.18) saturate(.9);
}
.page__line {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--paper-edge), transparent);
}

.book__num {
  font-size: 26px; font-weight: 800; color: var(--ink); opacity: .8;
}

/* 操作 */
.book__nav { display: flex; align-items: center; gap: 14px; }
.book__btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.07);
  color: #fff;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s, opacity .2s;
}
.book__btn:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.book__btn:active:not(:disabled) { transform: scale(.94); }
.book__btn:disabled { opacity: .35; cursor: default; }
.book__btn:focus-visible { outline: 2px solid #9ad; outline-offset: 2px; }
.book__status {
  color: #cfd3e6; font-size: 13px; letter-spacing: .06em;
  min-width: 52px; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .page { transition: none; }
}

【JavaScript】
// 3Dページめくり: perspective + rotateY で本のページをめくる(ボタン+自動ループ)
(() => {
  const pagesEl = document.getElementById('pages');
  const prev = document.getElementById('prev');
  const next = document.getElementById('next');
  const status = document.getElementById('status');
  const curLeft = document.getElementById('curLeft');
  if (!pagesEl || !prev || !next) return; // null安全

  // ページ内容(表=奇数, 裏=偶数 として連番を振る)
  const sheets = [
    { title: 'PROLOGUE', seed: 11 },
    { title: 'CHAPTER 1', seed: 24 },
    { title: 'CHAPTER 2', seed: 37 },
    { title: 'CHAPTER 3', seed: 52 },
    { title: 'EPILOGUE', seed: 68 },
    { title: 'THE END', seed: 80 },
  ];
  const total = sheets.length;

  // 1枚のページDOMを生成(表/裏の2面)
  const makeFace = (mod, title, num) => {
    const face = document.createElement('div');
    face.className = 'page__face page__face--' + mod;
    const img = mod === 'front'
      ? `<img class="page__thumb" alt="" src="https://picsum.photos/seed/book${num}/240/160">`
      : `<div class="page__line"></div><div class="page__line" style="width:70%"></div>`;
    face.innerHTML =
      `<div class="page__title">${title}</div>` +
      img +
      `<div class="page__num">${num}</div>`;
    return face;
  };

  // ページを積層生成(後ろのページほど下に重なるよう z-index 調整)
  sheets.forEach((s, i) => {
    const page = document.createElement('div');
    page.className = 'page';
    page.style.zIndex = String(total - i); // 上に来る順
    page.dataset.index = String(i);
    page.appendChild(makeFace('front', s.title, i * 2 + 1)); // 表ページ番号
    page.appendChild(makeFace('back', '', i * 2 + 2));        // 裏ページ番号
    pagesEl.appendChild(page);
  });

  const pageEls = Array.from(pagesEl.querySelectorAll('.page'));
  let index = 0; // 0..total(めくった枚数)

  // 表示更新: index枚目までめくり、z-indexで重なりを整える
  const render = () => {
    pageEls.forEach((el, i) => {
      const flipped = i < index;
      el.classList.toggle('is-flipped', flipped);
      // めくった側は左へ積み上げ、残りは右に重ねる
      el.style.zIndex = String(flipped ? i + 1 : total - i);
    });
    prev.disabled = index <= 0;
    next.disabled = index >= total;
    if (status) status.textContent = `${Math.min(index + 1, total)} / ${total}`;
    if (curLeft) curLeft.textContent = String(index === 0 ? 1 : index * 2);
  };

  const go = (dir) => {
    index = Math.max(0, Math.min(total, index + dir));
    render();
  };

  prev.addEventListener('click', () => go(-1));
  next.addEventListener('click', () => go(1));

  render();

  // 自動めくりループ(操作・reduced-motion時は停止)
  const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  let timer = null;
  const tick = () => {
    if (index >= total) index = 0; // 末尾まで来たら閉じてループ
    else index += 1;
    render();
  };
  const start = () => {
    if (reduce || timer) return;
    timer = setInterval(tick, 2200);
  };
  const stop = () => { if (timer) { clearInterval(timer); timer = null; } };

  [prev, next].forEach((b) => b.addEventListener('click', stop));
  start();
})();

# 外部ライブラリ
なし(追加ライブラリ不要)

# 守ってほしいこと
- 既存のHTML構造・レイアウト・デザインを壊さないこと。必要に応じてクラス名・色・サイズを私のサイトに合わせて調整してよい。
- クラス名やidが既存と衝突しないよう、必要なら接頭辞で名前空間を分けること。
- レスポンシブ対応と prefers-reduced-motion への配慮を入れること。
- 私のサイトのフレームワーク(React / Vue / 素のHTML など)に合わせて実装すること。不明な場合は素のHTML/CSS/JSで提示し、組み込み手順も説明すること。
- 変更後の確認手順も簡潔に教えてください。