.hidden {
  visibility: hidden;
}

.home-page {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 50px 0 150px 0;
}

.book-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 40px;
}

.book-nav-group {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 80px;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.book-nav-group:hover {
  opacity: 0.8;
}

.book-nav-prev-group {
  justify-content: flex-end;
}

.book-nav-next-group {
  justify-content: flex-start;
}

.nav-year {
  font-size: 1.5rem;
  font-family: 'Lora', serif;
  font-weight: 500;
  color: #333;
  transition: all 0.3s ease;
  min-width: 50px;
  text-align: center;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
}

.nav-year-prev {
  text-align: right;
}

.nav-year-next {
  text-align: left;
}

.book-nav {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.book-nav:hover {
  opacity: 1;
  transform: scale(1.1);
}

.book-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.book-nav img {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

input[type=checkbox] {
  display: none;
}

h1 {
  margin: 0;
}

.book {
  position: relative;
  width: 400px;
  height: 450px;
  margin-left: 400px;
  -webkit-perspective: 1000px;
  -moz-perspective: 1000px;
  perspective: 1000px;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.book .pages,
.book .pages > div {
  position: absolute;
  top: 0;
  left: 0;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.book .pages {
  width: 100%;
  height: 98%;
  top: 1%;
  left: 3%;
  z-index: 10;
}

.book .pages > div {
  /*width: 100%;
  height: 100%;*/
  -webkit-transform-origin: left center;
  -moz-transform-origin: left center;
  transform-origin: left center;
  /* Transitions temporarily disabled for testing */
  /*-webkit-transition-property: transform;
  -moz-transition-property: transform;
  transition-property: transform;
  -webkit-transition-timing-function: ease;
  -moz-transition-timing-function: ease;
  transition-timing-function: ease;*/
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: inset 0px -1px 2px rgba(50, 50, 50, 0.1), inset -1px 0px 1px rgba(150, 150, 150, 0.2);
  border-radius: 0px 5px 5px 0px;
  -webkit-transition-duration: 1s;
  
  /* Default background */
  background-color: #808080;
}

/* Dynamic page sizing - dimensions calculated by JavaScript based on book container size */
.book .pages > div.loaded:not(.flipped), .book .pages > div.flipped, .book .pages > div:not(.flipped) {
  background-position: center center;
}
.book .pages > div.flipped {
  /* Width set dynamically by JavaScript to match progressive scaling */
}

/* Optimized image loading */
.book .pages > div[data-src-medium], .book .pages > div[data-src-large] {
  background-image: none;
  /* Optimize rendering */
  will-change: background-image;
  transform: translateZ(0); /* Force hardware acceleration */
}

.book .pages > div.loaded {
  background-image: var(--bg-image);
  /* Let JavaScript-generated width rules take precedence */
  box-sizing: border-box;
  /* Ensure loaded pages don't expand beyond their intended width */
  max-width: inherit;
  /* Optimize background image rendering */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Remove hardware acceleration trigger once loaded */
  will-change: auto;
}

.book .pages > div.active .page-year-display {
  background-color: rgba(0, 0, 0, 0.4);
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  font-family: 'Lora', serif;
  color: #fff;
}

.book .pages > div.flipped {
  background-image: none;
  background-color: black;
}

.book .pages > div:hover {
  box-shadow: inset 1px 0px 2px rgba(50, 50, 50, 0.1), inset -3px 1px 1px rgba(150, 150, 150, 0.2);
  filter: brightness(0.8);
  transition: filter 0.3s ease;
}

.book .pages > div label {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  text-align: center;
  vertical-align: middle;
}


/* Responsive book sizing */
/* Common mobile styles (applies to all mobile breakpoints) */
@media (max-width: 768px) {
  .book-container {
    flex-direction: column;
    padding-bottom: 100px;
  }

  .book-nav-group {
    width: 50%;
    position: absolute;
    bottom: 0;
  }

  .book-nav-prev-group {
    order: 2;
    left: 40px;
    justify-content: start;
  }

  .book-nav-next-group {
    order: 3;
    right: 0;
    justify-content: end;
  }

  .book .pages > div.active .page-year-display {
    font-size: 2rem;
  }
}

/* Navigation arrows behind book for tablet and smaller screens */
@media (max-width: 992px) {
  .book-container {
    position: relative;
  }
  
  .book-nav-group {
    position: absolute;
    top: 100%;
    bottom: -100px;
  }
  
  .book-nav-prev-group {
    left: 10px;
  }
  
  .book-nav-next-group {
    right: 10px;
  }
  
  .book {
    z-index: 10; /* Ensure book is in front of navigation */
  }
}

/* Responsive book sizes using viewport-based calculations */
@media (max-width: 400px) {
  .book {
    width: 50vw;
    height: calc(50vw * 1.125);
    margin-left: calc(50vw * 0.75);
    order: 1;
  }
}

@media (min-width: 401px) and (max-width: 575px) {
  .book {
    width: 45vw;
    height: calc(45vw * 1.125);
    margin-left: calc(45vw * 0.775);
    order: 1;
  }
}

@media (min-width: 576px) and (max-width: 768px) {
  .book {
    width: 40vw;
    height: calc(40vw * 1.125);
    margin-left: 40vw;
    order: 1;
  }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .book {
    width: 35vw;
    height: calc(35vw * 1.125);
    margin-left: 35vw;
  }
}

@media (min-width: 1024px) and (max-width: 1439px) {
  .book {
    width: 320px;
    height: 360px;
    margin-left: 320px;
  }
}

@media (min-width: 1440px) {
  .book {
    width: 384px;
    height: 432px;
    margin-left: 340px;
  }
}
