/* ==========================================
   BOOKS MAGIC CLUB — LIBRARY STYLES
   ========================================== */

/* ==========================================
   1. LIBRARY PAGE
   ========================================== */

.library-page {
  min-height: 100vh;
  padding-bottom: 90px;
  background: #f8f4ee;
  color: #48363c;
}

/* ==========================================
     2. LIBRARY HEADER
     ========================================== */

.library-header {
  padding: 65px 20px 55px;
  background: #f2e9e1;
  text-align: center;
}

.library-header a {
  display: inline-block;
  margin-bottom: 35px;
  color: #642b3d;
  font-size: 14px;
  text-decoration: none;
}

.library-header a:hover {
  text-decoration: underline;
}

.library-header > p:first-of-type {
  color: #986a72;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.library-header h1 {
  margin: 18px 0;
  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(36px, 5vw, 58px);
}

.library-header > p:last-of-type {
  max-width: 550px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.8;
}

/* ==========================================
     3. LIBRARY COLLECTION
     ========================================== */

.library-section {
  max-width: 1100px;
  margin: 65px auto;
  padding: 0 24px;
}

.library-section h2 {
  margin-bottom: 35px;
  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 32px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}

/* ==========================================
     4. BOOK CARDS
     ========================================== */

.library-card {
  padding: 24px;
  background: #fffdf9;
  border: 1px solid #eaded8;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 6px 25px rgba(60, 30, 40, 0.05);
  transition: transform 0.3s ease;
}

.library-card:hover {
  transform: translateY(-5px);
}

.library-card img {
  display: block;
  width: 155px;
  height: 225px;
  margin: 0 auto 20px;
  object-fit: contain;
}

.library-card h3 {
  margin-bottom: 8px;
  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 21px;
}

.library-card p {
  margin-bottom: 20px;
  color: #7a6970;
  font-size: 14px;
}

/* ==========================================
     5. BUTTONS
     ========================================== */

.library-btn {
  display: inline-block;
  padding: 12px 20px;
  background: #642b3d;
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s ease;
}

.library-btn:hover {
  background: #85435a;
  color: #ffffff;
}

.library-btn:focus-visible {
  outline: 2px solid #986a72;
  outline-offset: 3px;
}

/* ==========================================
     6. BOOK DETAILS
     ========================================== */

.book-details {
  max-width: 900px;
  margin: 60px auto;
  padding: 35px;
  background: #fffdf9;
  border: 1px solid #eaded8;
  border-radius: 16px;
}

.book-details h2 {
  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
}

.library-review-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin: 35px 0 25px;
}

.library-review-heading h3 {
  margin: 0;
  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 24px;
}

/* ==========================================
     7. COMMUNITY REVIEWS
     ========================================== */

.review-card {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #eaded8;
}

.review-card h3 {
  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
}

.review-author {
  margin-bottom: 20px;
  color: #986a72;
  font-size: 14px;
}

.review-text {
  font-size: 16px;
  line-height: 1.9;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.no-reviews {
  color: #7a6970;
  font-style: italic;
}

/* ==========================================
     8. REVIEW POP-UP OVERLAY
     ========================================== */

#review-form-container[hidden] {
  display: none !important;
}

#review-form-container:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  flex-direction: column;

  width: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 35px max(20px, calc((100vw - 560px) / 2));

  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;

  background: rgba(30, 18, 25, 0.72);
  border: none;
  border-radius: 0;
}

/* ==========================================
     9. POP-UP CONTENT
     ========================================== */

#review-form-container > h3,
#review-form-container > form,
#review-form-container > #review-form-message {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  background: #fffdf9;
}

#review-form-container > h3 {
  margin-top: auto;
  margin-bottom: 0;
  padding: 30px 30px 15px;
  border-radius: 16px 16px 0 0;

  color: #552a3a;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 25px;
}

#review-form-container > form {
  padding: 0 30px 30px;
  border-radius: 0 0 16px 16px;
}

#review-form-container > #review-form-message {
  margin-top: 0;
  margin-bottom: auto;
  padding: 0 30px 20px;
  color: #642b3d;
  font-size: 14px;
  line-height: 1.6;
}

#review-form-container > #review-form-message:empty {
  display: none;
}

/* ==========================================
     10. FORM FIELDS
     ========================================== */

#review-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#review-form label {
  display: block;
  margin-top: 12px;

  color: #552a3a;
  font-size: 14px;
  font-weight: 600;
}

#review-form input,
#review-form select,
#review-form textarea {
  display: block;
  width: 100%;
  padding: 13px 15px;
  box-sizing: border-box;

  background: #fffdf9;
  border: 1px solid #d9c9c5;
  border-radius: 7px;

  color: #48363c;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
}

#review-form textarea {
  min-height: 180px;
  resize: vertical;
}

#review-form input:focus,
#review-form select:focus,
#review-form textarea:focus {
  outline: 2px solid #986a72;
  outline-offset: 2px;
  border-color: #986a72;
}

/* ==========================================
     11. FORM SUBMISSION
     ========================================== */

.review-form-note {
  margin: 15px 0 5px;
  color: #7a6970;
  font-size: 13px;
  line-height: 1.6;
}

#review-form button[type="submit"] {
  align-self: flex-start;
  margin-top: 10px;
  padding: 13px 26px;
}

#review-form-message {
  color: #642b3d;
}

/* ==========================================
     12. POP-UP CLOSE BUTTON
     ========================================== */

#review-form-container .review-modal-close {
  position: fixed;
  top: 48px;
  left: calc(50% + 240px);
  z-index: 10001;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;
  padding: 0;

  background: #f2e9e1;
  border: none;
  border-radius: 50%;

  color: #642b3d;
  font-family: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;

  transition: background 0.2s ease;
}

#review-form-container .review-modal-close:hover {
  background: #e8d8dc;
}

#review-form-container .review-modal-close:focus-visible {
  outline: 2px solid #642b3d;
  outline-offset: 3px;
}

/* ==========================================
     13. TABLET RESPONSIVENESS
     ========================================== */

@media (max-width: 800px) {
  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================
     14. MOBILE RESPONSIVENESS
     ========================================== */

@media (max-width: 600px) {
  .library-grid {
    grid-template-columns: 1fr;
  }

  .library-header {
    padding: 45px 18px;
  }

  .library-section {
    margin: 40px auto;
  }

  .book-details {
    margin: 30px 16px;
    padding: 22px;
  }

  .library-review-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  #review-form-container:not([hidden]) {
    padding: 15px;
  }

  #review-form-container > h3 {
    padding: 24px 20px 15px;
    font-size: 23px;
  }

  #review-form-container > form {
    padding: 0 20px 25px;
  }

  #review-form-container > #review-form-message {
    padding: 0 20px 20px;
  }

  #review-form-container .review-modal-close {
    top: 25px;
    left: auto;
    right: 25px;
  }

  #review-form textarea {
    min-height: 150px;
  }
}
