/* 試し読みビューア（ebook5 の代替）。右開き・見開き／単ページ自動切り替え
   色・書体は幸福の科学出版サイト（irhpress.co.jp）に合わせる */
:root {
  --green: #7ec42f;      /* サイトのヘッダー */
  --green-dk: #57bf37;   /* サイトの見出し */
  --gold: #c29560;       /* サイトのボタン */
  --text: #333;
  --bg: #f3f5ee;
  --bar: #fff;
  --bar-fg: #444;
  --accent: var(--green);
  --head-h: 52px;
  --bar-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ヘッダー（サイトと同じ緑の帯） */
#head {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--head-h);
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 5;
}
#head .logo { flex: none; display: block; line-height: 0; }
#head .logo img { width: 160px; height: auto; }
#book-title {
  flex: 1; min-width: 0; margin: 0;
  padding-top: 6px;  /* ロゴ画像の文字（画像内でやや下寄り）と高さを揃える */
  font-size: 15px; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.buy {
  flex: none;
  display: inline-flex; align-items: center;
  height: 36px; padding: 0 22px;
  border-radius: 999px;
  background: var(--gold); color: #fff;
  font-size: 14px; font-weight: 700; text-decoration: none; letter-spacing: .06em;
  transition: opacity .15s;
}
.buy:hover { opacity: .85; }
@media (max-width: 560px) {
  #head { gap: 10px; padding: 0 12px; }
  #head .logo img { width: 124px; }
  #book-title { visibility: hidden; }  /* 狭い画面では誌名を省き、ロゴと購入ボタンだけにする */
  .buy { height: 32px; padding: 0 14px; font-size: 13px; }
}

/* 誌面 */
#stage {
  position: fixed;
  inset: var(--head-h) 0 calc(var(--bar-h) + env(safe-area-inset-bottom)) 0;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.spread {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row-reverse;   /* 右開き: 先のページが右 */
  justify-content: center;
  align-items: center;
}
.spread.solo-left  { justify-content: flex-end;   padding-left:  calc(50% - var(--pw)); }
.page {
  position: relative;
  width: var(--pw);
  height: var(--ph);
  background: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .16);
}
.page img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
/* のど（見開き中央）の影 */
.spread.pair .page:first-child::after,
.spread.pair .page:last-child::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; width: 6%;
  pointer-events: none;
}
.spread.pair .page:first-child::after { left: 0;  background: linear-gradient(to right, rgba(0,0,0,.14), transparent); }
.spread.pair .page:last-child::after  { right: 0; background: linear-gradient(to left,  rgba(0,0,0,.14), transparent); }

/* ページ送りでめくる紙 */
.turn { position: absolute; inset: 0; pointer-events: none; }
.curl { position: absolute; }
.curl-layer, .curl-front, .curl-flapwrap { position: absolute; inset: 0; }
.curl-flap { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0; background: #fff; }
.curl .page { width: 100%; height: 100%; box-shadow: none; }
.curl-flapwrap { filter: drop-shadow(0 0 6px rgba(0,0,0,.28)); }
.curl-strip { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.curl-strip.under { background: linear-gradient(to right, rgba(0,0,0,.38), rgba(0,0,0,.12) 40%, rgba(0,0,0,0)); }
.curl-strip.flap {
  background: linear-gradient(to right,
    rgba(0,0,0,.20) 0, rgba(255,255,255,.28) 10%, rgba(255,255,255,.08) 35%,
    rgba(0,0,0,0) 65%, rgba(0,0,0,.10) 100%);
}
/* 単ページの紙の裏: 表の誌面が白く透けて見える */
.curl-flap.wash img { transform: scaleX(-1); }
.curl-flap.wash::before { content: ""; position: absolute; inset: 0; background: rgba(250,250,248,.86); z-index: 1; }
/* のどの影（見開きの .page と同じ） */
.face .page::after { content: ""; position: absolute; top: 0; bottom: 0; width: 6%; pointer-events: none; }
.face.l .page::after { right: 0; background: linear-gradient(to left,  rgba(0,0,0,.14), transparent); }
.face.r .page::after { left: 0;  background: linear-gradient(to right, rgba(0,0,0,.14), transparent); }

/* 購入リンク */
.hot {
  position: absolute;
  display: block;
  border-radius: 2px;
  transition: background-color .15s;
}
.hot:hover, .hot:focus-visible { background: rgba(126, 196, 47, .12); outline: 2px solid rgba(126, 196, 47, .7); }

/* 操作バー */
#bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bar-h) + env(safe-area-inset-bottom));
  padding: 0 8px env(safe-area-inset-bottom);
  background: var(--bar);
  color: var(--bar-fg);
  border-top: 1px solid #e3e6dc;
  display: flex;
  align-items: center;
  gap: 4px;
}
#bar button {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 6px;
  flex: none;
}
#bar button:hover { background: #eef6e4; color: var(--green-dk); }
#bar button:disabled { opacity: .3; cursor: default; background: none; }
#bar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#btn-list svg { fill: currentColor; stroke: none; }
#slider-wrap { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 6px; }
#slider { flex: 1; min-width: 0; accent-color: var(--accent); }
#counter { flex: none; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: center; }

/* ページ一覧 */
#panel {
  position: fixed;
  top: var(--head-h); bottom: calc(var(--bar-h) + env(safe-area-inset-bottom)); left: 0;
  width: min(360px, 100%);
  background: #fff;
  box-shadow: 4px 0 20px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
#panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid #e5e5e5; }
.panel-head h1 { flex: 1; margin: 0; font-size: 14px; font-weight: 700; line-height: 1.4; color: var(--green-dk); }
.panel-head button { width: 36px; height: 36px; font-size: 22px; border-radius: 6px; }
.panel-head button:hover { background: #f0f0f0; }
#thumbs { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
#thumbs button {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 6px; border-radius: 6px; text-align: left;
}
#thumbs button:hover { background: #f3f3f3; }
#thumbs button[aria-current="true"] { background: #eef6e4; box-shadow: inset 3px 0 0 var(--green); }
#thumbs img { width: 56px; height: auto; flex: none; box-shadow: 0 1px 4px rgba(0,0,0,.2); background: #fff; }
#thumbs .no { font-size: 12px; color: #777; font-variant-numeric: tabular-nums; }
#thumbs .ttl { font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* 拡大 */
#zoom { position: fixed; inset: 0; background: var(--bg); z-index: 20; }
#zoom[hidden] { display: none; }
#zoom-scroll { position: absolute; inset: 0; overflow: auto; cursor: grab; }
#zoom-scroll.dragging { cursor: grabbing; }
#zoom-inner { display: flex; flex-direction: row-reverse; justify-content: center; margin: auto; padding: 24px; width: max-content; min-width: 100%; }
#zoom-inner img { display: block; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.22); }
.zoom-tools { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.zoom-tools button {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--gold); color: #fff; font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
