/* ============================================
 * WebBook Viewer — flipbook-vue 版スタイルシート
 * ============================================ */

/* --- リセット・ベース --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-dark: #1a1a1a;
  --accent: #4a7c59;
  --accent-light: #6ba37a;
  --text-light: #e8e4dc;
  --text-muted: #8a8580;
  --safe-top: 0px;
  --safe-bottom: 0px;
  --safe-left: 0px;
  --safe-right: 0px;
}

@supports (padding: env(safe-area-inset-top, 0px)) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
  }
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

@supports (height: 100dvh) {
  body { height: 100dvh; }
}

/* --- Flipbook コンテナ --- */
.viewer-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

@supports (height: 100dvh) {
  .viewer-container { height: 100dvh; }
}

.flipbook-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 80vh;
  max-width: 100vw;
}

@supports (height: 80dvh) {
  .flipbook-area { height: 80dvh; }
}

.flipbook-wrapper {
  position: relative;
  width: 90vw;
  height: 100%;
  max-width: 1300px;
}

.flipbook {
  width: 100%;
  height: 100%;
}

/* --- リンクオーバーレイ --- */
.link-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 10;
}

.link-overlay__area {
  position: absolute;
  display: block;
  pointer-events: auto;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.link-overlay__area:hover {
  background: rgba(74, 124, 89, 0.2);
  border-color: rgba(74, 124, 89, 0.5);
  box-shadow: 0 0 8px rgba(74, 124, 89, 0.3);
}

/* --- ヘッダー --- */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) calc(24px + var(--safe-right)) 12px calc(24px + var(--safe-left));
  background: linear-gradient(180deg, rgba(26,26,26,0.95) 0%, rgba(26,26,26,0.7) 70%, transparent 100%);
  pointer-events: none;
}

.header > * { pointer-events: auto; }

.header-title {
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.header-title span {
  color: var(--accent-light);
  font-weight: 500;
}

.page-indicator {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 1px;
}

/* --- フルスクリーンボタン --- */
.fullscreen-btn {
  position: fixed;
  top: calc(12px + var(--safe-top)); right: calc(16px + var(--safe-right));
  z-index: 101;
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(26,26,26,0.5);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.fullscreen-btn:hover {
  background: rgba(74, 124, 89, 0.3);
  border-color: var(--accent-light);
}

.fullscreen-btn svg {
  width: 16px; height: 16px;
  fill: none; stroke: var(--text-light);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* --- ナビゲーションボタン（左右） --- */
.nav-btn {
  z-index: 90;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(26,26,26,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-btn:hover {
  opacity: 1 !important;
  background: rgba(74, 124, 89, 0.4);
  border-color: var(--accent-light);
  transform: scale(1.1);
}

.nav-btn svg {
  width: 20px; height: 20px;
  fill: none; stroke: var(--text-light);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.nav-btn:disabled {
  opacity: 0.15 !important;
  pointer-events: none;
}

.viewer-container:hover .nav-btn:not(:disabled) {
  opacity: 0.7;
}

/* --- コントロールバー（下部） --- */
.controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px calc(24px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(24px + var(--safe-left));
  background: linear-gradient(0deg, rgba(26,26,26,0.95) 0%, rgba(26,26,26,0.7) 70%, transparent 100%);
  gap: 12px;
  pointer-events: none;
}

.controls > * { pointer-events: auto; }

/* --- ズームボタン --- */
.ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(26,26,26,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-light);
  font-size: 18px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.ctrl-btn:hover {
  background: rgba(74, 124, 89, 0.4);
  border-color: var(--accent-light);
  transform: scale(1.1);
}

.ctrl-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* --- サムネイルバー --- */
.thumb-strip {
  display: flex;
  flex-direction: row-reverse;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 70vw;
  scrollbar-width: none;
}

.thumb-strip::-webkit-scrollbar { display: none; }

.thumb {
  width: 42px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0.5;
  flex-shrink: 0;
}

.thumb:hover {
  opacity: 0.8;
  transform: translateY(-4px);
}

.thumb.active {
  border-color: var(--accent-light);
  opacity: 1;
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- ローディング --- */
.loading {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: opacity 0.5s ease;
}

.loading.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
 * レスポンシブ
 * ============================================ */

/* タブレット */
@media (max-width: 768px) {
  .flipbook-area { gap: 6px; }
  .flipbook-wrapper {
    width: 85vw;
    max-width: none;
  }
  .nav-btn { width: 36px; height: 36px; }
  .thumb { width: 32px; height: 42px; }
  .header-title { font-size: 12px; }
  .ctrl-btn { width: 32px; height: 32px; font-size: 16px; }
}

/* スマホ */
@media (max-width: 480px) {
  .header {
    padding: calc(8px + var(--safe-top)) calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  }
  .header-title { font-size: 11px; letter-spacing: 1px; }
  .page-indicator { font-size: 11px; }
  .flipbook-wrapper {
    width: 100vw;
    height: 75vh;
  }
  .nav-btn { display: none; }
  .flipbook-area { gap: 0; }
  .thumb { width: 28px; height: 36px; border-width: 1.5px; }
  .thumb-strip { gap: 5px; max-width: 60vw; }
  .controls {
    padding: 8px calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(12px + var(--safe-left));
  }
  .fullscreen-btn { width: 32px; height: 32px; }
  .fullscreen-btn svg { width: 14px; height: 14px; }
}

/* 小型スマホ（SE等） */
@media (max-width: 375px) {
  .flipbook-wrapper { height: 70vh; }
  .thumb { width: 24px; height: 32px; }
  .thumb-strip { gap: 4px; }
}

/* 横向きスマホ */
@media (max-height: 500px) and (orientation: landscape) {
  .header { padding-top: 4px; padding-bottom: 4px; }
  .header-title { font-size: 11px; }
  .flipbook-area { height: 90vh; gap: 8px; }
  .flipbook-wrapper {
    width: 65vw;
    height: 100%;
  }
  .controls { padding-top: 4px; padding-bottom: calc(4px + var(--safe-bottom)); }
  .thumb { width: 24px; height: 32px; }
  .fullscreen-btn { top: 4px; }
}

/* PC — 大画面 */
@media (min-width: 1024px) {
  .flipbook-area { gap: 20px; }
  .flipbook-wrapper {
    width: calc(90vw - 128px);
    max-width: 1000px;
  }
}
