/* =========================================
   Global Book Pages Styles (TTS, Elements)
   ========================================= */

/* Remove mobile tap highlight (blue box) */
*, *::before, *::after { -webkit-tap-highlight-color: transparent !important; }

/* ---------- Book Title in Wheel Nav ---------- */
.wheel-book-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.72rem;
  color: rgba(212, 168, 83, 0.75);
  text-align: center;
  padding: 0.4rem 0.5rem 0.2rem;
  letter-spacing: 0.08em;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- Content Book Title ---------- */
.content-book-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.15rem;
  color: #d4a853;
  margin-bottom: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.9;
  text-align: center;
}

/* ---------- Back to Hero Button ---------- */
.wheel-back-hero {
  display: block;
  width: 80%;
  margin: 0.3rem auto 0.5rem;
  padding: 0.3rem 0.5rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: rgba(255,255,255,0.45);
  font-size: 0.7rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 0.05em;
}
.wheel-back-hero:hover {
  border-color: rgba(212,168,83,0.4);
  color: #d4a853;
  background: rgba(212,168,83,0.06);
}

/* ---------- Mobile Book Title ---------- */
.mobile-book-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.72rem;
  color: rgba(212, 168, 83, 0.7);
  text-align: center;
  padding: 0.2rem 0.5rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Mobile Back to Hero ---------- */
.mobile-back-hero {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.5);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s;
  z-index: 10;
}
.mobile-back-hero:active {
  background: rgba(212,168,83,0.1);
  border-color: rgba(212,168,83,0.3);
  color: #d4a853;
}

@media (min-width: 769px) {
  .mobile-book-title { display: none; }
  .mobile-back-hero { display: none; }
}
@media (max-width: 768px) {
  .wheel-book-title { display: none; }
  .wheel-back-hero { display: none; }
}

/* ---------- Hero Logo (Splash Screen) ---------- */
.hero-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin-bottom: 1.5rem;
  object-fit: contain;
  animation: heroLogoIn 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s both;
  filter: drop-shadow(0 0 30px rgba(212, 168, 83, 0.3));
}

@keyframes heroLogoIn {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 768px) {
  .hero-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin-bottom: 1rem;
  }
}

/* ---------- Hero Slogan (Poster-style) ---------- */
.hero-slogan {
  font-family: 'Noto Serif SC', serif;
  font-weight: 900;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  color: #d4a853;
  letter-spacing: 0.15em;
  line-height: 1.6;
  text-shadow: 0 0 40px rgba(212, 168, 83, 0.3), 0 2px 8px rgba(0,0,0,0.8);
  margin-bottom: 1.5rem;
  animation: sloganIn 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.3s both;
}

@keyframes sloganIn {
  from { opacity: 0; transform: translateY(25px); letter-spacing: 0.3em; }
  to   { opacity: 1; transform: translateY(0); letter-spacing: 0.15em; }
}

@media (max-width: 768px) {
  .hero-slogan {
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
  }
}

.tts-btn {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-sec);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  margin-right: 0.8rem;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.tts-btn:hover {
  background: var(--c-surface-hover);
  color: var(--c-text-primary);
}

.tts-btn.playing {
  color: #ff3b30;
  border-color: #ff3b30;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

@media (max-width: 600px) {
  .tts-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }
}

/* =========================================
   Mobile Prev/Next Navigation Buttons
   ========================================= */
.mobile-nav-btns {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav-btns {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.5rem;
    padding-bottom: 1rem;
  }

  .mnb {
    flex: 1;
    padding: 0.9rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.6);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s;
  }

  .mnb:active {
    transform: scale(0.97);
    background: rgba(212,168,83,0.1);
    border-color: rgba(212,168,83,0.3);
    color: #d4a853;
  }

  .mnb-prev { text-align: left; }
  .mnb-next { text-align: right; }
}

/* =========================================
   Chapter TOC Popup
   ========================================= */

/* Desktop trigger: bottom of wheel-nav */
.toc-trigger-desktop {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0.05em;
}
.toc-trigger-desktop:hover {
  border-color: #d4a853;
  color: #d4a853;
  background: rgba(212,168,83,0.08);
}

/* Mobile trigger: floating button */
.toc-trigger-mobile {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,10,15,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: all 0.3s;
}
.toc-trigger-mobile:active {
  transform: scale(0.92);
  border-color: #d4a853;
}
@media (max-width: 768px) {
  .toc-trigger-mobile { display: flex; }
  .toc-trigger-desktop { display: none; }
}

/* Overlay */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.toc-overlay.toc-open {
  opacity: 1;
  visibility: visible;
}

/* Panel */
.toc-panel {
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  background: rgba(18,18,26,0.97);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.toc-open .toc-panel {
  transform: translateY(0) scale(1);
}

/* Header */
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.toc-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 1rem;
  color: #fff;
  font-weight: 700;
}
.toc-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.toc-close:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* Search */
.toc-search {
  margin: 0.6rem 1rem;
  padding: 0.6rem 1rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: #e8e6e1;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
}
.toc-search::placeholder { color: rgba(255,255,255,0.3); }
.toc-search:focus { border-color: rgba(212,168,83,0.4); }

/* List */
.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0.6rem;
  -webkit-overflow-scrolling: touch;
}
.toc-list::-webkit-scrollbar { width: 3px; }
.toc-list::-webkit-scrollbar-thumb { background: rgba(212,168,83,0.2); border-radius: 10px; }

/* Items */
.toc-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.toc-item:hover {
  background: rgba(255,255,255,0.05);
}
.toc-item-active {
  background: rgba(212,168,83,0.1) !important;
  border: 1px solid rgba(212,168,83,0.25);
}
.toc-item-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.4);
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}
.toc-item-active .toc-item-num {
  background: linear-gradient(135deg, #d4a853, #c49a42);
  color: #0a0a0f;
}
.toc-item-label {
  flex: 1;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.4;
}
.toc-item-active .toc-item-label {
  color: #d4a853;
  font-weight: 600;
}
.toc-item-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: rgba(212,168,83,0.15);
  color: #d4a853;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Footer */
.toc-footer {
  text-align: center;
  padding: 0.6rem;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.25);
  border-top: 1px solid rgba(255,255,255,0.06);
  letter-spacing: 0.1em;
}

.toc-empty {
  text-align: center;
  padding: 2rem;
  color: rgba(255,255,255,0.25);
  font-size: 0.88rem;
}

/* Pager */
.toc-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.6rem 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
}
.toc-page-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  font-family: inherit;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.toc-page-btn:hover:not(.disabled) {
  border-color: rgba(212,168,83,0.4);
  color: #d4a853;
  background: rgba(212,168,83,0.06);
}
.toc-page-btn.active {
  background: linear-gradient(135deg, #d4a853, #c49a42);
  color: #0a0a0f;
  border-color: transparent;
  font-weight: 700;
}
.toc-page-btn.disabled {
  opacity: 0.2;
  cursor: default;
}

/* =========================================
   PWA Update Toast
   ========================================= */
.update-toast {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  padding: 0.8rem;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.update-toast.update-toast-show {
  transform: translateY(0);
}
.update-toast-content {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  background: rgba(18,18,26,0.97);
  border: 1px solid rgba(212,168,83,0.25);
  border-radius: 14px;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.4), 0 0 20px rgba(212,168,83,0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.update-toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.update-toast-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.update-toast-text strong {
  font-size: 0.88rem;
  color: #fff;
}
.update-toast-text span {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
}
.update-toast-btn {
  background: linear-gradient(135deg, #d4a853, #c49a42);
  color: #0a0a0f;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.update-toast-btn:active {
  transform: scale(0.95);
}
.update-toast-dismiss {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.3rem;
  line-height: 1;
  transition: color 0.2s;
}
.update-toast-dismiss:hover {
  color: rgba(255,255,255,0.7);
}
