/* ============= RESET ============= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #ffffff;
  color: #111;
}

/* ============= PAGE HEADER (TITLE + SUBTITLE) ============= */

.page-header {
  text-align: center;
  padding: 24px 16px 12px;
}

.site-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 1px;
}

.site-subtitle {
  font-size: 14px;
  color: #777;
  margin-top: 4px;
}

/* ============= MAIN AREA ============= */

.main-area {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 16px 40px;
}

/* Wrapper that holds Telegram/Sold + shelf */
.shelf-wrapper {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Telegram + Sold text sitting on the top of the shelf */
.shelf-top-info {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  padding: 0 8px;
}

.shelf-link {
  font-size: 18px;
  text-decoration: none;
  color: #111;
}

.shelf-link:hover {
  text-decoration: underline;
}

.shelf-sold {
  font-size: 18px;
  color: #111;
}

/* ============= BOOKSHELF ============= */

/*
  Shelf uses a rich wood background and repeating planks.
  It extends to the bottom of the page (no internal scroll;
  the PAGE scrolls instead).
*/

.bookshelf {
  width: 100%;
  min-height: 60vh;
  background-color: #2a1306;
  background-image:
    /* subtle diagonal sheen */
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.06),
      rgba(0, 0, 0, 0.55)
    ),
    /* repeating horizontal planks for realism */
    repeating-linear-gradient(
      to bottom,
      rgba(91, 43, 11, 0.95) 0,
      rgba(91, 43, 11, 0.95) 16px,
      rgba(26, 11, 4, 0.97) 16px,
      rgba(26, 11, 4, 0.97) 180px
    );
  background-blend-mode: soft-light, normal;
  border: 18px solid #5b2b0b;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  padding: 36px 30px 32px;
  display: flex;
  flex-direction: column;
  gap: 80px; /* vertical spacing between shelf rows */
}

/* Each logical shelf row (books positioned here). 
   Only change: we shift the whole row down so books sit on the plank. */
.shelf-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  min-height: 210px;
  position: relative;

  /* shift the row downward so books rest on the visible plank */
  transform: translateY(32px);
}

/* ============= BOOKS ON SHELF ============= */

.book {
  width: 120px;
  height: 200px;
  background: #050505;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.9);
  transition: transform 0.16s ease, box-shadow 0.16s ease;

  /* push the book up so it sits in the column, not on the plank */
  margin-bottom: 40px;
}

/* hover */
.book:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 1);
}

/* pick-up animation (on click) */
.book.pickup {
  animation: bookPickup 0.25s ease forwards;
}

@keyframes bookPickup {
  0% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(-28px) scale(1.08);
  }
}

/* Book title: HORIZONTAL to the book (not vertical text) */
.book-title {
  color: #f6a623;
  font-family: "Georgia", serif;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-align: center;
  line-height: 1.2;
}

/* ============= SUMMARY POPUP (YELLOW CARD) ============= */

.summary-popup {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  background: #f9dc63;
  color: #222;
  padding: 18px 20px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  max-width: 520px;
  z-index: 100;
}

.summary-popup.hidden {
  display: none;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
}

.summary-note {
  margin-top: 8px;
  font-size: 13px;
  color: #6b5d2e;
}

.summary-close-btn {
  position: absolute;
  right: 8px;
  top: 6px;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #444;
}

/* ============= OPEN BOOK MODAL ============= */

.book-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
}

.book-modal.hidden {
  display: none;
}

.book-modal-content {
  background: transparent;
  max-width: 960px;
  width: 96%;
  position: relative;
  animation: bookOpen 0.35s ease forwards;
}

/* book opening animation */
@keyframes bookOpen {
  0% {
    transform: scale(0.3) rotateY(-40deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotateY(0deg);
    opacity: 1;
  }
}

/* Close button */
.close-btn {
  position: absolute;
  right: -8px;
  top: -34px;
  background: transparent;
  border: none;
  font-size: 26px;
  color: #f5f5f5;
  cursor: pointer;
}

/* Actual book shape */
.book-inner {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: #fdf1d5; /* cream pages */
  border-radius: 8px;
  border: 4px solid #000000;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
}

/* subtle spine lines on left side */
.book-inner::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 10px;
  background-image: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.3) 1px,
    transparent 1px
  );
  background-size: 4px 100%;
  opacity: 0.65;
}

/* pages */
.book-page {
  padding: 24px 26px;
  position: relative;
}

.book-left {
  border-right: 2px solid #dcc194;
}

/* page edges on right side */
.book-right::after {
  content: "";
  position: absolute;
  top: 0;
  right: 6px;
  width: 16px;
  height: 100%;
  background-image: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.25) 2px,
    transparent 2px
  );
  background-size: 6px 100%;
  opacity: 0.6;
}

/* photos scroller */
.image-scroller {
  height: 100%;
  overflow-y: auto;
  padding-right: 8px;
}

.book-photo {
  width: 100%;
  border-radius: 4px;
  margin-bottom: 12px;
  display: block;
  object-fit: cover;
  border: 1px solid #ccc;
}

/* right-page content */
#detail-title {
  font-family: "Georgia", serif;
  font-size: 22px;
  margin-bottom: 4px;
}

.detail-price {
  font-weight: 600;
  margin-bottom: 8px;
}

.detail-condition {
  font-size: 14px;
  margin-bottom: 8px;
  color: #5a4a2b;
}

.detail-summary {
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Buy button */
.buy-btn {
  display: inline-block;
  padding: 10px 20px;
  background: #7a3510;
  color: #fdf1d5;
  text-decoration: none;
  border-radius: 999px;
  font-size: 15px;
  margin-bottom: 10px;
}

.buy-btn:hover {
  background: #9a4715;
}

.book-note {
  font-size: 12px;
  color: #6b5a3a;
}

/* ============= MOBILE ============= */

@media (max-width: 768px) {
  .page-header {
    padding: 18px 10px 8px;
  }

  .site-title {
    font-size: 26px;
  }

  .site-subtitle {
    font-size: 13px;
  }

  .main-area {
    padding: 8px 8px 24px;
  }

  .shelf-wrapper {
    max-width: 100%;
  }

  .shelf-top-info {
    padding: 0 2px;
    font-size: 16px;
  }

  .bookshelf {
    padding: 20px 10px 24px;
    border-width: 14px;
    min-height: 60vh;
    gap: 50px;
  }

  .shelf-row {
    min-height: 200px;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
  }

  /* 2 books per row on mobile (Design requirement #4) */
  .book {
    flex: 0 0 calc(50% - 16px);
    height: 190px;
  }

  .book-inner {
    grid-template-columns: 1fr;
  }

  .close-btn {
    right: 6px;
    top: 6px;
    color: #222;
  }
}
