/* 3D Book Collection Styles - Adapted from GSAP animated book collection */

:root {
  /* Dark mode variables (matching the site's dark theme) */
  --bg-color: #0a0a0a;
  --text-color: #e0e0e0;
  --title-color: #ffffff;
  --overlay-text-color: rgba(255, 255, 255, 0.05);
  --shelf-bg: linear-gradient(to bottom, #2a2a2a, #1a1a1a);
  --shelf-edge-top: rgba(255, 255, 255, 0.03);
  --shelf-edge-bottom: rgba(0, 0, 0, 0.3);
  --book-back-cover: #ffffff;
  --book-page: #ffffff;
  --book-page-border: rgba(0, 0, 0, 0.2);
  --book-shadow: rgba(0, 0, 0, 0.3);
  --book-shadow-strong: rgba(0, 0, 0, 0.5);
  --side-book-bg: linear-gradient(to right, #222 0%, #444 50%, #222 100%);
  --side-book-text: #ffffff;
  --side-book-decoration: rgba(255, 255, 255, 0.2);
  --toggle-dot: #ffffff;
}

@font-face {
  font-family: "Cabinet Grotesk";
  font-style: normal;
  font-weight: 800;
  src: local("Cabinet Grotesk"),
    url("https://fonts.cdnfonts.com/s/85514/CabinetGrotesk-Extrabold.woff")
      format("woff");
}

@font-face {
  font-family: "Cabinet Grotesk";
  font-style: normal;
  font-weight: 400;
  src: local("Cabinet Grotesk"),
    url("https://fonts.cdnfonts.com/s/85514/CabinetGrotesk-Medium.woff")
      format("woff");
}

/* Ambient light animation */
@keyframes pulseLight {
  0% {
    opacity: 0.7;
    filter: blur(15px);
  }
  100% {
    opacity: 0.9;
    filter: blur(20px);
  }
}

/* Glass shelf glow animation */
@keyframes shelfGlow {
  0% {
    box-shadow: 
      0 20px 50px rgba(0, 0, 0, 0.6),
      inset 0 -10px 30px rgba(255, 255, 255, 0.5),
      inset 0 5px 35px rgba(255, 255, 255, 0.6),
      0 0 20px rgba(255, 255, 255, 0.6),
      0 5px 15px rgba(47, 128, 237, 0.4);
  }
  100% {
    box-shadow: 
      0 20px 50px rgba(0, 0, 0, 0.6),
      inset 0 -10px 30px rgba(255, 255, 255, 0.5),
      inset 0 5px 35px rgba(255, 255, 255, 0.6),
      0 0 30px rgba(255, 255, 255, 0.8),
      0 5px 25px rgba(47, 128, 237, 0.6);
  }
}

/* Theme toggle dot */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--toggle-dot);
  cursor: pointer;
  z-index: 100;
  transition: background-color 0.3s ease;
}

/* Big centered text that appears on hover */
.book-title-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: -1;
  opacity: 1; /* Visible by default */
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.book-title-text {
  font-family: "Cabinet Grotesk", "Helvetica Neue", sans-serif;
  font-weight: 800;
  font-size: 18rem; /* Slightly smaller text */
  color: var(--overlay-text-color);
  text-transform: uppercase;
  text-align: center;
  line-height: 1;
  max-width: 90vw;
  transition: color 0.5s ease;
  /* Add edge fade effect - comprehensive fade in all directions */
  mask-image: radial-gradient(
    ellipse at center,
    black 30%,
    rgba(0, 0, 0, 0.9) 60%,
    rgba(0, 0, 0, 0.6) 80%,
    transparent 100%
  );
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    black 30%,
    rgba(0, 0, 0, 0.9) 60%,
    rgba(0, 0, 0, 0.6) 80%,
    transparent 100%
  );
}

/* Shelf container to manage stacking context */
.shelf-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20px; /* Small padding to maintain animation integrity */
  margin-top: -100px; /* Move shelf up by 80px while maintaining animations */
  z-index: 1;
}

/* Subtle ambient light effect underneath shelf */
.shelf-ambient-light {
  display: block;
  position: absolute;
  bottom: 255px;
  width: 100%;
  max-width: 900px;
  height: 80px;
  background: radial-gradient(
    ellipse at center,
    rgba(100, 150, 220, 0.6) 0%,
    rgba(100, 150, 220, 0.3) 40%,
    rgba(100, 150, 220, 0.1) 70%,
    rgba(100, 150, 220, 0) 85%
  );
  filter: blur(30px);
  border-radius: 50%;
  z-index: 19;
  animation: pulseLight 5s infinite alternate;
  opacity: 0.7;
}

/* Liquid glass oval shelf - dramatic glass with intense reflections */
.shelf {
  display: block;
  position: absolute;
  bottom: 270px;
  width: 100%;
  max-width: 800px;
  height: 40px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 150px / 40px; /* Creates oval shape */
  z-index: 20;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.6),
    inset 0 -10px 30px rgba(255, 255, 255, 0.5),
    inset 0 5px 35px rgba(255, 255, 255, 0.6),
    0 0 20px rgba(255, 255, 255, 0.6),
    0 5px 15px rgba(47, 128, 237, 0.4);
  position: relative;
  overflow: hidden;
  
  /* Dramatic light reflections on glass */
  background-image: 
    linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.2) 30%, transparent 60%),
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.3) 40%, transparent 70%);
  
  /* More dramatic 3D feel */  
  transform-style: preserve-3d;
  perspective: 800px;
  animation: shelfGlow 4s infinite alternate;

  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* Shelf reflection/highlight for liquid glass effect */
.shelf::before {
  content: '';
  position: absolute;
  top: 0;
  left: 5%;
  width: 90%;
  height: 50%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.1) 100%
  );
  border-radius: 100px / 15px;
}

/* Add a subtle edge to the shelf */
.shelf:after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: var(--shelf-edge-bottom);
  transition: background-color 0.5s ease;
}

.shelf:before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--shelf-edge-top);
  transition: background-color 0.5s ease;
}

/* Books wrapper */
.books-wrapper {
  position: absolute;
  bottom: 287px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2rem;
  z-index: 10;
}

/* Books wrapper to align books on shelf */
.books-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2rem;
  position: absolute;
  bottom: 285px; /* Position books perfectly on the glass shelf */
  width: 100%;
  max-width: 800px;
  z-index: 21;
}

/* Book Item Styles */
.books__item {
  text-align: center;
  cursor: default;
  height: 220px;
}

/* Base alignment for all books */
.books-wrapper > div {
  transform: translateY(-25px);
}

/* Move Art of War and How to Win Friends up by additional 20px */
.books-wrapper > div:first-child,
.books-wrapper > div:last-child {
  transform: translateY(-38px);
}

.books__container {
  position: relative;
  width: 160px;
  margin: 0 auto;
  height: 100%;
}

.books__cover {
  position: relative;
  will-change: transform;
  height: 100%;
}

.books__hitbox {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 10;
  cursor: pointer;
}

/* Back Cover: 96% with 2% margin */
.books__back-cover {
  position: absolute;
  width: 96%;
  height: 96%;
  top: 2%;
  left: 2%;
  background: var(--book-back-cover);
  border-radius: 0 6px 6px 0;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.25);
  z-index: -10;
  transition: background 0.5s ease;
}

/* Paper Container: 90% with equal top/bottom margin */
.books__inside {
  position: absolute;
  width: 90%;
  height: 94%;
  top: 3%;
  left: 5%;
  z-index: 0;
}

/* Paper Pages: height is 100% */
.books__page {
  position: absolute;
  top: 0;
  right: 0;
  width: 98%;
  height: 100%;
  background: var(--book-page);
  border: 1px solid var(--book-page-border);
  border-radius: 0 6px 6px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transform-origin: right center;
  z-index: -5;
  transition: background 0.5s ease, border-color 0.5s ease;
}

/* Front Cover Image */
.books__image {
  line-height: 0;
  position: relative;
  border-radius: 2px 6px 6px 2px;
  height: 100%;
  box-shadow: var(--book-shadow) 10px -5px 20px,
    var(--book-shadow) 20px 0px 30px;
  transform-origin: left center;
  cursor: pointer;
  will-change: transform, box-shadow;
  z-index: 10;
  transition: box-shadow 0.5s ease;
}

.books__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px 6px 6px 2px;
}

/* Specific zoom for certain books */
.books__image img[src="images/books/ArtOfWar.png"] {
  object-fit: cover;
  object-position: center;
  transform: scale(1.15);
}

/* Still using PsychoCybernetics.png as the filename but it's actually How to Win Friends */
.books__image img[src="images/books/PsychoCybernetics.png"] {
  object-fit: cover;
  object-position: center;
  transform: scale(1.2);
}

.books__effect {
  position: absolute;
  width: 24px;
  height: 100%;
  margin-left: 12px;
  top: 0;
  border-left: 2px solid rgba(0, 0, 0, 0.08);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.25) 0%,
    rgba(255, 255, 255, 0) 100%
  );
  transform-origin: left center;
  z-index: 5;
  pointer-events: none;
  will-change: margin-left;
}

.books__light {
  width: 100%;
  height: 100%;
  position: absolute;
  border-radius: 2px 6px 6px 2px;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.5) 100%
  );
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.15;
  transform-origin: left center;
  z-index: 4;
  pointer-events: none;
  mix-blend-mode: overlay;
  will-change: opacity;
}

/* Side view book styles */
.side-book {
  height: 220px;
  width: 30px;
  position: relative;
  cursor: pointer;
  background: var(--side-book-bg);
  border-radius: 2px;
  box-shadow: var(--book-shadow) 5px -3px 10px, var(--book-shadow) 10px 0px 15px;
  transform-origin: bottom center;
  will-change: transform, box-shadow;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.side-book__title {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  color: var(--side-book-text);
  font-size: 12px;
  padding: 5px 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 0.5s ease;
}

.side-book__decoration {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 1px;
  background-color: var(--side-book-decoration);
  transition: background-color 0.5s ease;
}

.side-book__decoration:nth-child(2) {
  top: auto;
  bottom: 20px;
}

/* Contact shadow where book meets shelf */
.book-shadow {
  position: absolute;
  bottom: 285px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2rem;
  z-index: 15;
}

.book-shadow__item {
  width: 120px;
  height: 2px;
  background: radial-gradient(
    ellipse at center,
    var(--book-shadow) 0%,
    rgba(0, 0, 0, 0) 70%
  );
  border-radius: 50%;
  will-change: width, opacity;
  transition: background 0.5s ease;
}

.book-shadow__item.side {
  width: 25px;
}

/* Book descriptions */
.book-descriptions {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  z-index: 5;
  height: 200px; /* Fixed height for descriptions */
}

.book-description {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  font-family: "Helvetica Neue", sans-serif;
  font-weight: 300;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--text-color);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.book-description.active {
  opacity: 1;
  visibility: visible;
}

.book-description h3 {
  font-weight: 400;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
  color: var(--title-color);
}

.book-description .author {
  font-style: italic;
  font-weight: 300;
  opacity: 0.8;
  margin-bottom: 1rem;
  letter-spacing: 0.2px;
}

.book-description p {
  margin-bottom: 0.75rem;
}

/* Split Type styles */
.lines-animation {
  overflow: hidden;
}

/* Critical fix: Ensure each line has overflow hidden */
.line {
  overflow: hidden !important;
  display: block;
}

/* Ensure the line inner content has proper transform properties */
.line .line-inner {
  display: block;
  transform: translateY(0);
  opacity: 1;
}

/* Responsive styles matching main site breakpoints */
@media (max-width: 768px) {
  .book-title-text {
    font-size: 10rem;
  }
  
  .shelf-container {
    height: 450px;
  }
  
  .shelf {
    bottom: 230px;
    max-width: 700px;
  }
  
  .book-shadow {
    bottom: 245px;
  }
  
  .books-wrapper {
    gap: 1.5rem;
    max-width: 700px;
  }
  
  .books__container {
    width: 120px;
  }
  
  .books__image, .books__cover {
    height: 180px;
  }
  
  .side-book {
    width: 25px;
    height: 180px;
  }
  
  .book-description h3 {
    font-size: 1.5rem;
  }
  
  .book-description {
    font-size: 1rem;
  }
  
  .book-descriptions {
    max-width: 600px;
  }
}

/* Mobile devices */
@media (max-width: 480px) {
  .book-title-text {
    font-size: 5rem;
  }
  
  .shelf-container {
    height: 550px;
  }
  
  .books-wrapper {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 300px;
  }
  
  .books__container {
    width: 90px;
  }
  
  .books__item {
    height: 140px;
  }
  
  .books__image, .books__cover {
    height: 130px;
  }
  
  .side-book {
    width: 20px;
    height: 130px;
    margin-right: 10px;
  }
  
  .shelf {
    max-width: 320px;
    bottom: 300px;
  }
  
  .book-shadow {
    bottom: 315px;
  }
  
  .book-descriptions {
    bottom: 50px;
    max-width: 90%;
  }
  
  .book-description h3 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
  }
  
  .book-description .author {
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
  }
  
  .book-description {
    font-size: 0.9rem;
  }
}

/* Extra small devices */
@media (max-width: 320px) {
  .book-title-text {
    font-size: 4rem;
  }
  
  .shelf-container {
    height: 500px;
  }
  
  .shelf {
    bottom: 280px;
    max-width: 280px;
  }
  
  .book-shadow {
    bottom: 295px;
  }
  
  .books-wrapper {
    max-width: 280px;
  }
  
  .books__container {
    width: 80px;
  }
  
  .books__image, .books__cover {
    height: 120px;
  }
  
  .side-book {
    height: 120px;
    width: 18px;
  }
  
  .book-description h3 {
    font-size: 1.1rem;
  }
  
  .book-description {
    font-size: 0.85rem;
  }
}
