/* ── 리셋 & 기본 ──────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #1a1a1a;
  display: flex;
  flex-direction: column;
}

/* ── 책 컨테이너 ──────────────────────────────────────── */
#book-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 10px 20px 85px; /* 하단: 컨트롤바(1행) 여유 */
  width: 100%;
}

/* ── 책 래퍼 ──────────────────────────────────────────── */
.flip-wrapper {
  display: block;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 10px 50px rgba(0,0,0,0.35);
  transition: transform 0.08s ease-out;
}

/* 양면 모드: 중앙 접힘선 */
@media (min-width: 1200px) {
  .flip-wrapper::before {
    content: '';
    position: absolute;
    left: 50%; top: 0; bottom: 0;
    width: 20px;
    transform: translateX(-50%);
    background: linear-gradient(to right,
      rgba(0,0,0,0) 0%, rgba(0,0,0,0.05) 20%,
      rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.05) 80%, rgba(0,0,0,0) 100%);
    z-index: 10;
    pointer-events: none;
  }
  .flip-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right,
      rgba(0,0,0,0.03) 0%, rgba(255,255,255,0.05) 2%, rgba(0,0,0,0) 10%,
      rgba(0,0,0,0) 45%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0) 55%,
      rgba(0,0,0,0) 98%, rgba(255,255,255,0.05) 99%, rgba(0,0,0,0.03) 100%);
    z-index: 5;
    pointer-events: none;
    mix-blend-mode: multiply;
  }
}

/* ── 페이지 & 이미지 ──────────────────────────────────── */
.page { background: white; width: 100%; height: 100%; overflow: hidden; }
.page img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; display: block; }

/* ── 컨트롤바 (공통) ─────────────────────────────────── */
#page-control {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: row;          /* 데스크탑: 1행 */
  align-items: center;
  gap: 6px;
  background: rgba(18, 18, 18, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  padding: 8px 16px;
  box-shadow: 0 4px 28px rgba(0,0,0,0.5);
  white-space: nowrap;
  /* 화면보다 넓을 경우 넘치지 않도록 */
  max-width: calc(100vw - 20px);
}

/* ── 컨트롤 그룹 ──────────────────────────────────────── */
.ctrl-nav,
.ctrl-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* 데스크탑: 그룹 사이 구분선 */
.ctrl-actions {
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 10px;
  margin-left: 4px;
}

/* ── 공통 버튼 ────────────────────────────────────────── */
.page-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.15);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.page-btn i { font-size: 16px; line-height: 1; }

.page-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.38);
  transform: scale(1.07);
}
.page-btn:active:not(:disabled) {
  transform: scale(0.93);
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(102,126,234,0.5);
}
.page-btn:disabled { opacity: 0.28; cursor: not-allowed; }

/* ── 페이지 표시 ──────────────────────────────────────── */
#page-display {
  background: rgba(255,255,255,0.11);
  color: #fff;
  padding: 9px 16px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  min-width: 90px;
  text-align: center;
  border: 1.5px solid rgba(255,255,255,0.18);
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
  letter-spacing: 0.02em;
}
#page-display:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(74,144,226,0.7);
}
#page-display.hidden { display: none; }

/* ── 페이지 입력 ──────────────────────────────────────── */
#pageInput {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1.5px solid #4a90e2;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 25px;
  width: 90px;
  text-align: center;
  outline: none;
  box-shadow: 0 0 10px rgba(74,144,226,0.25);
}
#pageInput:focus { border-color: #63a8f0; box-shadow: 0 0 16px rgba(74,144,226,0.45); }
#pageInput.hidden { display: none; }

/* ── 줌 표시 ──────────────────────────────────────────── */
#zoom-display {
  background: rgba(255,255,255,0.11);
  color: #fff;
  padding: 9px 14px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  min-width: 64px;
  text-align: center;
  border: 1.5px solid rgba(255,255,255,0.18);
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
  letter-spacing: 0.03em;
}
#zoom-display:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.45);
}

/* ── 모바일 레이아웃 (≤ 640px) ───────────────────────── */
@media (max-width: 640px) {
  /* 컨트롤바: 2행으로 전환 + 전체 30% 축소 */
  #page-control {
    flex-direction: column;
    border-radius: 16px;
    padding: 7px 10px;
    gap: 5px;
    bottom: 6px;
  }

  /* 그룹 구분선: 좌측→상단 */
  .ctrl-nav,
  .ctrl-actions {
    gap: 4px;
  }
  .ctrl-actions {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 6px;
  }

  /* 책 컨테이너: 2행 컨트롤 높이 확보 */
  #book-container {
    padding-bottom: 110px;
  }

  /* 버튼 30% 축소: 40px → 28px */
  .page-btn { width: 28px; height: 28px; }
  .page-btn i { font-size: 11px; }

  #page-display {
    padding: 5px 9px;
    font-size: 11px;
    min-width: 64px;
    border-radius: 18px;
  }
  #pageInput {
    padding: 5px 8px;
    font-size: 11px;
    width: 64px;
    border-radius: 18px;
  }
  #zoom-display {
    padding: 5px 9px;
    font-size: 11px;
    min-width: 46px;
    border-radius: 18px;
  }
}

/* ── 소형 모바일 (≤ 380px) ───────────────────────────── */
@media (max-width: 380px) {
  .page-btn { width: 26px; height: 26px; }
  .page-btn i { font-size: 10px; }
  #page-display, #pageInput { min-width: 58px; font-size: 10px; }
  #zoom-display { min-width: 42px; font-size: 10px; }
}
