/*
//
// As seen here https://motion.dev/docs
//
*/

@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&family=IBM+Plex+Mono&family=Press+Start+2P&display=swap");

/* Original idea and inspiration for the Book Cover Effect by https://codepen.io/realvjy */

:root {
  /* Light mode variables */
  --bg-color: #ffffff;
  --text-color: #333333;
  --title-color: #000000;
  --overlay-text-color: rgba(0, 0, 0, 0.05);
  --shelf-bg: linear-gradient(to bottom, #f0f0f0, #e0e0e0);
  --shelf-edge-top: rgba(255, 255, 255, 0.01);
  --shelf-edge-bottom: rgba(0, 0, 0, 0.1);
  --book-back-cover: #111111;
  --book-page: #ffffff;
  --book-page-border: rgba(0, 0, 0, 0.2);
  --book-shadow: rgba(0, 0, 0, 0.15);
  --book-shadow-strong: rgba(0, 0, 0, 0.35);
  --side-book-bg: linear-gradient(to right, #181818 0%, #4e5e61 50%, #686372 100%);
  --side-book-text: #f0f0f0;
  --side-book-decoration: rgba(255, 255, 255, 0.3);
  --toggle-dot: #333333;
  
  /* Original header variables */
  --color--background: rgb(21, 21, 21);
  --color--foreground: rgb(232, 227, 213);
  --font-primary: "Inter", sans-serif;
  --font-secondary: "IBM Plex Mono", monospace;
  --margin: 64px;
  --gutter: 16px;
}

.dark-mode {
  /* Dark mode variables */
  --bg-color: #121212;
  --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); /* Lighter in dark mode */
  --shelf-edge-bottom: rgba(0, 0, 0, 0.3);
  --book-back-cover: #ffffff; /* Changed to white in dark mode */
  --book-page: #ffffff; /* Changed to white in dark mode */
  --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, #181818 0%, #4e5e61 50%, #686372 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");
}

*,
*::after,
*::before {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: "Cabinet Grotesk", sans-serif;
  letter-spacing: -0.02em;
  color: var(--text-color);
  transition: background-color 0.5s ease, color 0.5s ease;
}

/* Header styles (keeping original navigation) */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 96px;
  z-index: 10;
}

/* Halftone effect container */
.halftone {
  position: absolute;
  inset: 0;
  background-color: transparent;
  background-image: radial-gradient(transparent 1px, var(--bg-color) 1px);
  background-size: 4px 4px;
  backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgb(0, 0, 0) 60%,
    transparent 100%
  );
  mask-image: linear-gradient(to bottom, rgb(0, 0, 0) 60%, transparent 100%);
  transition: background-image 0.5s ease;
}

nav {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--margin);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  width: 48px;
  height: 48px;
  border: 1px solid var(--text-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  text-decoration: none;
  font-weight: bold;
  font-family: var(--font-secondary);
  transition: border-color 0.5s ease, color 0.5s ease;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-items {
  display: flex;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-items a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 16px;
  position: relative;
  padding-bottom: 2px;
  transition: color 0.5s ease;
}

.nav-items a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: currentColor;
  transition: width 0.3s ease;
}

.nav-items a:hover::after {
  width: 100%;
}

.search-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.3s ease, color 0.5s ease;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.dark-mode .search-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.search-btn svg {
  width: 20px;
  height: 20px;
}

/* Theme toggle button */
.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.3s ease, color 0.5s ease;
  color: var(--text-color);
  margin-left: 25px;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.dark-mode .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* 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", sans-serif;
  font-weight: 800;
  font-size: 20rem;
  color: var(--overlay-text-color);
  text-transform: uppercase;
  text-align: center;
  line-height: 1;
  max-width: 90vw;
  transition: color 0.5s ease;
}

/* Shelf container to manage stacking context */
.shelf-container {
  position: relative;
  width: 100%;
  height: 500px; /* Increased height to accommodate descriptions */
  margin: 0 auto;
  display: flex;
  justify-content: center;
  z-index: 1;
  /* Above the text overlay */
}

.shelf {
  display: block;
  position: absolute;
  bottom: 270px; /* Adjusted to make room for descriptions */
  width: 100%;
  max-width: 800px;
  height: 15px;
  background: var(--shelf-bg);
  border-radius: 1px;
  z-index: 20;
  box-shadow:
        /* Subtle top highlight */ 0px -1px 1px rgba(255, 255, 255, 0.15),
    /* Close shadow */ 0px 2px 3px rgba(0, 0, 0, 0.12),
    /* Medium shadow */ 0px 5px 10px rgba(0, 0, 0, 0.08),
    /* Larger shadow */ 0px 15px 20px rgba(0, 0, 0, 0.06),
    /* Very large diffused shadow */ 0px 25px 30px rgba(0, 0, 0, 0.04),
    /* Extra large ambient shadow */ 0px 40px 60px rgba(0, 0, 0, 0.2),
    /* Massive soft shadow for dramatic effect */ 0px 60px 80px
      rgba(0, 0, 0, 0.12);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* 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; /* Adjusted to match new shelf position */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2rem;
  z-index: 10;
  /* Below the shelf */
}

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

.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;
}

.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: 60px;
  /* Thin width for side view */
  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-family: "Press Start 2P", monospace;
  font-size: 12px;
  padding: 5px 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 0.5s ease;
}

.side-book__title img {
  writing-mode: horizontal-tb;
  transform: rotate(90deg);
  height: 10%;
  width: auto;
  object-fit: contain;
}

.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; /* Adjusted to match new shelf position */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2rem;
  z-index: 15;
  /* Between books and shelf */
}

.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: 55px;
}

/* 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: "Cabinet Grotesk", sans-serif;
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--text-color);
  transition: opacity 0.3s ease, visibility 0.3s ease, color 0.5s ease;
}

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

.book-description h3 {
  font-weight: 800;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--title-color);
  transition: color 0.5s ease;
}

.book-description .author {
  font-style: italic;
  opacity: 0.8;
  margin-bottom: 1rem;
}

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

.book-description a {
  color: #888888;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.book-description a:hover {
  color: #666666;
}

/* 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
  ); /* Changed from 100% to make text visible by default */
  opacity: 1; /* Changed from 0 to make text visible by default */
}

/* Tap and drag arrow */
.arrow {
  font-family: 'Gloria Hallelujah', cursive;
  font-size: 0.875rem;
  position: absolute;
  opacity: 0.6;
  pointer-events: none;
  z-index: 100;
}

.arrow span {
  white-space: nowrap;
  display: inline-block;
  position: relative;
  left: 20px;
  top: 10px;
}

.arrow--main {
  top: -60px;
  right: -50px;
  rotate: -30deg;
  transition: opacity 0.26s ease-out;
}

.arrow--main svg {
  rotate: 10deg;
  width: 24px;
  top: 150%;
  left: 50%;
  position: absolute;
  scale: 1 1;
}

/* Ensure mail and theme toggle icons always stay visible */
.search-btn,
.theme-toggle {
  flex-shrink: 0 !important;
  min-width: 40px !important;
  min-height: 40px !important;
}

.nav-right {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  /* Ensure body doesn't overflow on mobile */
  body {
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  
  /* Move nav items to bottom of page on mobile */
  .nav-items {
    position: fixed;
    bottom: 10vh; /* 5% higher than the previous 5vh */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    background: var(--bg-color);
    padding: 10px 16px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .nav-items a {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 15px;
    transition: background-color 0.3s ease;
  }
  
  .nav-items a:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }
  
  .dark-mode .nav-items {
    background: var(--bg-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }
  
  .dark-mode .nav-items a:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .book-title-text {
    font-size: 6rem;
    transform: translateY(-20vh); /* Move background text 20% higher */
  }
  
  /* Scale down the entire shelf container more aggressively */
  .shelf-container {
    transform: scale(0.4);
    transform-origin: center center;
    height: 250px;
    margin-top: -50px;
  }
  
  /* Make shelf bar wider on mobile */
  .shelf {
    max-width: 1000px; /* Wider than desktop's 800px */
  }
  
  /* Make text larger and more readable on mobile */
  .book-descriptions {
    max-width: 95%;
    font-size: 1.5rem;
    bottom: 13vh; /* Adjusted to match the higher nav position */
    height: 150px;
    transform: scale(1.5); /* Scale up text to counteract the container scaling */
    transform-origin: center center;
    left: 50%;
    transform: translateX(-50%) scale(1.5); /* Center the block horizontally */
  }
  
  .book-description h3 {
    font-size: 3rem; /* Increased from 2.5rem to 3rem */
  }
  
  .book-description {
    font-size: 1.5rem; /* Increased from 1.2rem to 1.5rem */
  }
  
  .book-description .author {
    font-size: 1.6rem; /* Increased from 1.3rem to 1.6rem */
  }
  
  /* Mobile: Position coming soon arrow at top left of last book */
  .arrow--main {
    top: -170px; /* 50px higher than -120px */
    left: -60px; /* 30px more to the left than -30px */
    right: auto;
    rotate: 30deg; /* Flip the arrow direction */
    font-size: 2.3625rem; /* 20% smaller than 2.953125rem */
  }
  
  .arrow--main span {
    /* Text is not mirrored - reads normally */
  }
  
  .arrow--main svg {
    rotate: -10deg; /* Adjust arrow rotation */
    width: 64.8px; /* 20% smaller than 81px */
    height: 64.8px;
    transform: scaleX(-1); /* Mirror only the arrow horizontally */
    position: relative;
    top: -5px; /* 5px lower than -10px */
    left: -5px; /* 5px more to the left */
  }
}

/* Additional media queries for intermediate screen sizes */
@media (max-width: 900px) {
  .nav-items {
    gap: 16px;
  }
  
  .nav-items a {
    font-size: 14px;
  }
}

@media (max-width: 400px) {
  .nav-right {
    gap: 5px;
  }
  
  .search-btn,
  .theme-toggle {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  
  .search-btn svg,
  .theme-toggle svg {
    width: 18px;
    height: 18px;
  }
}