/* ============================================
   電子書籍リーダー スタイル
   ============================================ */

:root {
  --color-bg: #faf9f7;
  --color-text: #333;
  --color-text-light: #666;
  --color-primary: #2c5545;
  --color-primary-light: #3d7a5f;
  --color-border: #e0ddd8;
  --color-page-bg: #fff;
  --font-serif: 'Noto Serif JP', serif;
  --font-sans: 'Noto Sans JP', sans-serif;
  --max-width: 800px;
  --page-padding: 1rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.8;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================
   目次ページ（index.html）
   ============================================ */

.book-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem var(--page-padding);
}

.book-header {
  text-align: center;
  margin-bottom: 2rem;
}

.book-title {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.book-author {
  color: var(--color-text-light);
  font-size: 1rem;
}

.cover-image {
  text-align: center;
  margin-bottom: 2rem;
}

.cover-image img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.book-description {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--color-page-bg);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.book-description h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: var(--color-primary);
}

.book-description p {
  color: var(--color-text-light);
}

.table-of-contents {
  margin-bottom: 2rem;
}

.table-of-contents h2 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

.toc-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.toc-list li a {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--color-page-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
  text-align: center;
  transition: all 0.2s ease;
}

.toc-list li a:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.start-reading {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 2rem;
  padding: 1rem 2rem;
  background: var(--color-primary);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  border-radius: 50px;
  transition: background 0.2s ease;
}

.start-reading:hover {
  background: var(--color-primary-light);
}

.book-footer {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-light);
  font-size: 0.875rem;
}

/* ============================================
   ページ表示（page-XX.html）
   ============================================ */

.reader-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
.reader-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem var(--page-padding);
  background: var(--color-page-bg);
  border-bottom: 1px solid var(--color-border);
}

.reader-header .home-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.reader-header .home-link:hover {
  text-decoration: underline;
}

.reader-header .page-indicator {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

/* メインコンテンツ */
.reader-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--page-padding);
  touch-action: pan-y pinch-zoom;
}

.page-content {
  width: 100%;
  max-width: 700px;
  background: var(--color-page-bg);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.page-content img {
  display: block;
  width: 100%;
  height: auto;
}

/* SEO用 非表示テキスト */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ナビゲーション */
.reader-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem var(--page-padding);
  background: var(--color-page-bg);
  border-top: 1px solid var(--color-border);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  min-width: 100px;
  justify-content: center;
}

.nav-btn:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.nav-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.nav-btn.prev {
  padding-left: 1rem;
}

.nav-btn.next {
  padding-right: 1rem;
}

/* スワイプフィードバック */
.reader-main.swiping-left {
  transform: translateX(-20px);
  opacity: 0.8;
}

.reader-main.swiping-right {
  transform: translateX(20px);
  opacity: 0.8;
}

.reader-main {
  transition: transform 0.15s ease, opacity 0.15s ease;
}

/* スワイプヒント */
.swipe-hint {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.swipe-hint.show {
  opacity: 1;
}

/* フッター */
.reader-footer {
  text-align: center;
  padding: 1rem var(--page-padding);
  color: var(--color-text-light);
  font-size: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* PC: 画面タップでもページ移動 */
@media (min-width: 768px) {
  .reader-main {
    cursor: pointer;
  }
  
  .tap-zone {
    position: fixed;
    top: 60px;
    bottom: 80px;
    width: 20%;
    z-index: 10;
    cursor: pointer;
  }
  
  .tap-zone.left {
    left: 0;
  }
  
  .tap-zone.right {
    right: 0;
  }
  
  .tap-zone:hover::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
  }
  
  .tap-zone.left:hover::after {
    left: 20px;
  }
  
  .tap-zone.right:hover::after {
    right: 20px;
  }
}
