body {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #333;
  box-sizing: border-box;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  scrollbar-color: #012169;
}

.one {
  columns: 2;
}

::-webkit-scrollbar-thumb {
  background-color: #012169;
}

::-webkit-scrollbar {
  width: 1em;
}

main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

nav {
  overflow: hidden;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 60%;
  text-align: center;
  padding-top: 0%;
  padding-bottom: 0;
  border-top: 2px solid #012169;
  border-bottom: 2px solid #012169;
  border-left: 2px solid #012169;
  border-right: 2px solid #012169;
}

nav a {
  background-color: #fff;
  padding: 10px 15px;
  font-size: clamp(14px, 1.5dvw, 24px);
  text-align: center;
  text-decoration: none;
  color: #000;
  transition: all 0.3s ease;
}

nav a:hover {
  background-color: #c8102e;
  color: white;
  border-top: 2.5px solid #000;
  border-bottom: 2.5px solid #000;
}

nav a.active {
  border-top: 2.5px solid #000;
  border-bottom: 2.5px solid #000;
  background-color: #c8102e;
  color: white;
  text-decoration: underline;
}

header {
  width: 100vw !important;
  margin-left: calc(-50vw + 50%) !important;
  margin-right: calc(-50vw + 50%) !important;
  margin-bottom: 0 !important;
  background-color: white;
  position: relative;
}

/* Container for the flipbook */
#flipbook-container {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  margin: 0 auto;
  position: relative;
  background-color: #333;
  transition: background-color 0.3s ease;
}

#flipbook-container.light-mode {
  background-color: #f4f4f0;
}

#flipbook-container.dark-mode {
  background-color: #1a1a1a;
}

#flipbook {
  width: 1188px; /* A4 double width: 594 * 2 */
  height: 841px; /* A4 height */
  position: relative;
}

.page {
  background-color: white;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-sizing: border-box;
}

/* Navigation buttons */
.controls {
  margin-top: 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  z-index: 100;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

/* Theme toggle button */
.theme-toggle {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background-color: #012169;
  color: white;
  border: none;
  border-radius: 4px;
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle:hover {
  background-color: #c8102e;
}

.theme-icon {
  font-size: 18px;
}

button {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background-color: white;
  border: none;
  border-radius: 4px;
}

button:hover {
  background-color: #f0f0f0;
}

/* Contents page */
.contents-page {
  position: relative;
}

.toc-link {
  position: absolute;
  display: block;
  cursor: pointer;
  background-color: transparent;
  border: none;
  padding: 0;
  z-index: 10;
  width: 500px;
  height: 45px;
  left: 50px;
}

.toc-link:hover {
  background-color: rgba(0, 123, 255, 0);
  outline: 2px solid rgba(0, 123, 255, 0);
}

/* Position each TOC link */
.toc-link[data-page="3"] {
  top: 425px;
}

.toc-link[data-page="6"] {
  top: 470px;
}

.toc-link[data-page="9"] {
  top: 515px;
}

.toc-link[data-page="13"] {
  top: 555px;
}

.toc-link[data-page="20"] {
  top: 600px;
}

.toc-link[data-page="24"] {
  top: 645px;
}

.toc-link[data-page="27"] {
  top: 690px;
}

.toc-link[data-page="31"] {
  top: 730px;
}

/* ========================================
   RESPONSIVE DESIGN - ALL SCREEN SIZES
   ======================================== */

/* Large desktops and wide screens */
@media (min-width: 1401px) {
  #flipbook-container {
    padding: 40px 20px;
    max-width: 1600px;
  }
}

/* Standard desktops */
@media (min-width: 1201px) and (max-width: 1400px) {
  #flipbook-container {
    padding: 30px 20px;
    max-width: 1400px;
  }
}

/* Medium screens - tablets landscape and small laptops */
@media (min-width: 769px) and (max-width: 1200px) {
  #flipbook-container {
    padding: 25px 15px;
    max-width: 100%;
  }

  nav {
    max-width: 70%;
  }

  nav a {
    padding: 8px 12px;
    font-size: clamp(12px, 1.8dvw, 20px);
  }

  button {
    padding: 9px 18px;
    font-size: 15px;
  }
}

/* Tablets in portrait and large phones - FULL WIDTH */
@media (max-width: 768px) {
  body {
    padding: 0;
    overflow-x: hidden;
    width: 100vw;
  }

  #flipbook-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100vw !important;
    width: 100vw !important;
    height: auto;
    min-height: 80vh;
    overflow: visible;
    background-color: #333;
    display: block;
    position: relative;
  }

  /* Switch to single page view on mobile - FULL WIDTH */
  #flipbook {
    width: 594px !important;
    height: 841px !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
  }

  /* Override any Turn.js centering */
  #flipbook * {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  nav {
    max-width: 90%;
    flex-wrap: wrap;
  }

  nav a {
    padding: 8px 10px;
    font-size: clamp(11px, 2.5dvw, 16px);
  }

  .controls {
    margin-top: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1000;
    gap: 8px;
  }

  button {
    padding: 8px 15px;
    font-size: 14px;
  }

  .theme-toggle {
    padding: 8px 15px;
    font-size: 14px;
  }

  /* Adjust TOC links for single page view */
  .toc-link {
    width: 80%;
    left: 10%;
    height: 40px;
  }

  /* Scale TOC link positions proportionally */
  .toc-link[data-page="3"] {
    top: 51%;
  }

  .toc-link[data-page="6"] {
    top: 56%;
  }

  .toc-link[data-page="9"] {
    top: 61%;
  }

  .toc-link[data-page="13"] {
    top: 66%;
  }

  .toc-link[data-page="20"] {
    top: 71%;
  }

  .toc-link[data-page="24"] {
    top: 76%;
  }

  .toc-link[data-page="27"] {
    top: 82%;
  }

  .toc-link[data-page="31"] {
    top: 87%;
  }
}

/* Small phones - iPhone SE, etc */
@media (max-width: 480px) {
  #flipbook-container {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 85vh;
    overflow: visible;
  }

  nav {
    max-width: 95%;
  }

  nav a {
    padding: 6px 8px;
    font-size: clamp(10px, 3dvw, 14px);
  }

  .controls {
    gap: 5px;
  }

  button {
    padding: 6px 12px;
    font-size: 12px;
  }

  .toc-link {
    width: 85%;
    left: 7.5%;
    height: 35px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  nav {
    max-width: 98%;
  }

  nav a {
    padding: 5px 6px;
    font-size: clamp(9px, 3.5dvw, 12px);
  }

  button {
    padding: 5px 10px;
    font-size: 11px;
  }

  .toc-link {
    width: 90%;
    left: 5%;
    height: 30px;
  }

  .controls {
    gap: 3px;
  }
}

/* Landscape orientation for mobile devices */
@media (max-width: 768px) and (orientation: landscape) {
  #flipbook-container {
    min-height: 70vh;
  }

  .controls {
    margin-top: 5px;
    margin-bottom: 5px;
  }
}

/* Footer pinned to bottom */
footer {
  font-size: clamp(12px, 2dvw, 24px);
  padding: 1rem 0;
  margin-top: auto;
  width: 60vw;
  position: relative;
  margin-left: auto;
  margin-right: auto;
  background-color: #012169;
  color: white;
}

.footertop a {
  color: white;
}

.footertop {
  color: white;
}

footer a {
  color: white;
  text-decoration: none;
}

footer a:hover {
  background-color: #c8102e;
  text-decoration: underline;
  color: white;
}

.page {
  background-color: white;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-sizing: border-box;
  position: relative; /* Add this */
  z-index: 1; /* Add this */
}
