/* ---------- Base styles ---------- */
body {
  font-family: "Noto Sans Devanagari", "Inter", sans-serif;
  margin: 0;
  color: #333;
  min-height: 100vh;
  background: url('background.jpg') no-repeat center center fixed;
  background-size: cover;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
header {
  background: rgba(42, 93, 159, 0.9);
  color: white;
  text-align: center;
  padding: 1rem;
  font-size: 1.6rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ---------- Books Grid Page ---------- */
main.grid {
  flex: 1;
  padding: 3rem 5%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2rem;
  justify-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 12px;
  width: 100%;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.card img {
  width: 100%;
  height: 260px;              /* ✅ Uniform height */
  object-fit: cover;          /* Crop edges neatly */
  border-radius: 12px 12px 0 0;
  background: #f5f5f5;
  display: block;
}

.card h2 {
  margin: 0.5rem 0 0.3rem;
  font-size: 1.1rem;
  color: #2a5d9f;
}

.card h3 {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #555;
}

/* ---------- Book Details Page ---------- */
.book-detail-container {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.book-card {
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 16px;
  max-width: 550px;
  width: 100%;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(5px);
}

.book-card img {
  width: 220px;               /* ✅ Uniform size */
  height: 320px;
  object-fit: cover;
  border-radius: 10px;
  margin: 0 auto 1rem auto;
  display: block;
  background: #f5f5f5;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.book-card h2 {
  margin: 0.4rem 0;
  font-size: 1.5rem;
  color: #2a5d9f;
}

.book-card h3 {
  margin: 0.2rem 0 1rem;
  font-size: 1.1rem;
  color: #444;
}

.book-card p {
  margin: 0.4rem 0;
  font-size: 1rem;
  color: #333;
  line-height: 1.5;
}

.book-card a {
  color: #2a5d9f;
  text-decoration: none;
}

.book-card a:hover {
  text-decoration: underline;
}

.book-card button {
  margin-top: 1.2rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  background-color: #2a5d9f;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.book-card button:hover {
  background-color: #1f467f;
}

/* ---------- Home Button (Books Page) ---------- */
.nav-btn-container {
  text-align: center;
  margin: 1.2rem 0 0.5rem 0;
}

.home-btn {
  background: linear-gradient(135deg, #2a5d9f, #4e8ad3);
  color: #fff;
  border: none;
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.25s ease;
}

.home-btn:hover {
  background: linear-gradient(135deg, #1f467f, #366fb8);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

/* ---------- Banner with Background Image + Parallax ---------- */
header {
  position: relative;
  width: 100%;
  height: 220px; /* adjust height */
  background: url('https://cjagroxccgawxxehdode.supabase.co/storage/v1/object/public/Book%20Cover%20Images/background%20image.png') no-repeat center center;
  background-size: cover;
  background-attachment: fixed; /* parallax effect */
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 2rem;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  overflow: hidden; /* prevents horizontal scrollbar */
  margin: 0;
  padding: 0;
}

/* Overlay for dim effect and fade-in */
header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55); /* dim overlay */
  opacity: 0;
  animation: fadeIn 1.8s ease forwards;
  pointer-events: none;
}

/* Header text */
header > * {
  position: relative; /* above overlay */
  z-index: 1;
  opacity: 0;
  animation: fadeInText 1.8s ease forwards;
}

header > *:first-child { animation-delay: 0.3s; }
header > *:last-child { animation-delay: 0.6s; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInText {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile adjustments for index header */
@media (max-width: 600px) {
  header {
    height: 160px;
    font-size: 1.5rem;
    background-attachment: scroll; /* disable parallax on mobile for performance */
  }
}

/* ---------- Books Page Header as top banner ---------- */
.books-header {
  position: sticky;
  top: 0;
  width: 100%;
  height: 20vh; /* initial height ~20% of viewport */
  background: linear-gradient(rgba(42,93,159,0.85), rgba(42,93,159,0.95));
  color: white;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  z-index: 10;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

/* Shrink header on scroll */
.books-header.shrink {
  height: 8vh; /* shrinked height */
  font-size: 1.2rem; /* smaller text */
}

.books-header h1 {
  margin: 0;
}

/* Grid spacing so content doesn't overlap header */
#books-container {
  padding-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin: 0 auto;
  max-width: 1000px;
}

/* ---------- Mobile Fixes for Books Page ---------- */
@media (max-width: 600px) {
  .books-header {
    height: 10vh;
    font-size: 1.3rem;
    padding: 0 1rem;
  }

  .books-header.shrink {
    height: 6vh;
    font-size: 1rem;
  }

  #books-container {
    grid-template-columns: 1fr; /* single column */
    gap: 1rem;
    padding: 0.5rem 1rem 1rem 1rem;
    max-width: 100%;
    margin: 0 auto;
  }

  .card {
    width: 100%;
    max-width: 100%;
  }

  .card img {
    width: 100%;
    height: 220px;
  }

  .card h2 {
    font-size: 1rem;
  }

  .card h3 {
    font-size: 0.85rem;
  }

  .nav-btn-container {
    margin: 0.8rem 0;
    padding: 0 1rem;
  }
}
