/* Stylesheet for the main HTML (book.html), defining book functionality */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height when available */
  background: #ffffff;
  overflow: hidden; /* Prevent body scrolling */
  display: flex;
  flex-direction: column;
}

/* Main content area */
#reader {
  position: relative;
  flex: 1;
  overflow: hidden; /* Important: only let iframe scroll */
}

iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  overflow-y: auto; /* Only let iframe content scroll */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Footer with page navigation */
.footer {
  background: #ffffff;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
  z-index: 10;
  flex: 0 0 auto;
}

.footer a {
  flex: 0 0 auto;
  cursor: pointer;
  text-decoration: none;
  color: #333;
  padding: 0.5rem;
}

.footer span {
  flex: 1;
  text-align: center;
  pointer-events: none;
}

/* Navigation swipe areas */
.nav-button {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20%;
  z-index: 5;
}

#prevBtn { left: 0; }
#nextBtn { right: 0; }

@media (hover: hover) and (pointer: fine) {
  /* Disable clickability of invisible left/right buttons on desktop */
  .nav-button {
	pointer-events: none;
  }
}

/* Floating hamburger menu button */
#tocBtn {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  color: #333;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  font-size: 1.25rem;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background 0.2s ease;
}

#tocBtn:hover, #tocBtn:active {
  background: rgba(255, 255, 255, 0.9);
}

/* Table of Contents Menu */
#toc {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: white;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  padding: 0;
  display: none;
  z-index: 25;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  min-width: 200px;
}

#toc .menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f5f5f5;
  border-bottom: 1px solid #eee;
}

#toc .menu-title {
  font-weight: bold;
  font-size: 1rem;
}

#toc .menu-close {
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
}

#toc .menu-item {
  display: block;
  text-decoration: none;
  color: #333;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

#toc .menu-item:last-child {
  border-bottom: none;
}

#toc .menu-item:hover, 
#toc .menu-item:active {
  background: #f8f8f8;
}

/* Language Selector */
#langSelector {
  position: absolute;
  top: 0;
  left: 0;
  background: white;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  padding: 0;
  display: none;
  z-index: 30;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  min-width: 150px;
}
