/* ========================================
   School Books EKPA — Main Stylesheet
   Colors: Navy #1B3A5C, Gold #C5A55A
   ======================================== */

/* --- Base & Typography --- */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Serif:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  --navy: #1B3A5C;
  --navy-dark: #122944;
  --navy-light: #2A5280;
  --gold: #C5A55A;
  --gold-light: #D4BA7A;
  --gold-dark: #A68B42;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F5;
  --gray-200: #E9ECEF;
  --gray-300: #DEE2E6;
  --gray-400: #CED4DA;
  --gray-500: #ADB5BD;
  --gray-600: #6C757D;
  --gray-700: #495057;
  --gray-800: #343A40;
  --gray-900: #212529;
  --white: #FFFFFF;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-serif: 'Noto Serif', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--gray-800);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  background: var(--white);
}

/* --- Header / Navigation --- */

.site-header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.site-header a {
  color: var(--white);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-header a:hover {
  color: var(--gold);
}

.nav-link {
  position: relative;
  padding-bottom: 2px;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gold);
  transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* Mobile menu */
.mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.mobile-menu.open {
  max-height: 200px;
}

/* --- Hero Section --- */

.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 50%, #0F1F33 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23C5A55A' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.hero-title {
  font-family: var(--font-serif);
  letter-spacing: -0.02em;
}

.gold-accent {
  color: var(--gold);
}

.gold-line {
  width: 80px;
  height: 3px;
  background: var(--gold);
  border: none;
}

/* --- Filter Bar --- */

.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 64px;
  z-index: 90;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.filter-btn {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--gray-300);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
}

.filter-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.filter-btn-type {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--gray-300);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-btn-type:hover {
  border-color: var(--gold-dark);
  color: var(--gold-dark);
}

.filter-btn-type.active {
  background: var(--gold);
  color: var(--navy-dark);
  border-color: var(--gold);
  font-weight: 600;
}

/* --- Book Cards --- */

.book-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .book-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.book-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(27, 58, 92, 0.12);
}

.book-card-cover {
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
  position: relative;
  overflow: hidden;
}

.book-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.book-card:hover .book-card-cover img {
  transform: scale(1.03);
}

.book-card-cover .placeholder-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--gray-400);
}

.book-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-card-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.book-card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-grade {
  background: rgba(27, 58, 92, 0.1);
  color: var(--navy);
}

.badge-book {
  background: rgba(197, 165, 90, 0.15);
  color: var(--gold-dark);
}

.badge-workbook {
  background: rgba(27, 58, 92, 0.08);
  color: var(--navy-light);
}

.badge-primary {
  background: #E8F4E8;
  color: #2D5A2D;
}

.badge-secondary {
  background: #E8EEF4;
  color: #2A4A6B;
}

/* --- Selling Points Section --- */

.selling-points {
  background: var(--gray-50);
}

.selling-point-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.selling-point-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(197, 165, 90, 0.15);
}

.selling-point-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(27, 58, 92, 0.08);
  color: var(--navy);
}

.selling-point-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.selling-point-desc {
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.6;
}

/* --- Empty State --- */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-400);
}

.empty-state-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  color: var(--gray-500);
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 auto;
}

/* --- Footer --- */

.site-footer {
  background: var(--navy-dark);
  color: rgba(255, 255, 255, 0.7);
}

.site-footer a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-footer a:hover {
  color: var(--gold);
}

.footer-heading {
  color: var(--white);
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Book Detail Page --- */

.book-detail-cover {
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--gray-100), var(--gray-200));
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.book-detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.expandable-section {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.expandable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--gray-50);
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
  transition: background-color 0.2s ease;
  user-select: none;
}

.expandable-header:hover {
  background: var(--gray-100);
}

.expandable-header svg {
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.expandable-header.open svg {
  transform: rotate(180deg);
}

.expandable-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.expandable-body.open {
  max-height: 2000px;
}

.expandable-content {
  padding: 1.25rem;
  color: var(--gray-700);
  line-height: 1.7;
}

.pdf-viewer-area {
  background: var(--gray-100);
  border: 2px dashed var(--gray-300);
  border-radius: 12px;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--gray-500);
}

.digital-format-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

.digital-format-badge.available {
  background: rgba(27, 58, 92, 0.08);
  color: var(--navy);
  border-color: rgba(27, 58, 92, 0.2);
}

/* Related books horizontal scroll */
.related-books {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.related-books::-webkit-scrollbar {
  height: 4px;
}

.related-books::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 2px;
}

.related-book-card {
  flex: 0 0 180px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.related-book-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --- About Page --- */

.about-section {
  border-left: 3px solid var(--gold);
  padding-left: 1.5rem;
  margin-bottom: 2rem;
}

.about-heading {
  font-family: var(--font-serif);
  color: var(--navy);
}

/* --- Utilities --- */

.text-navy { color: var(--navy); }
.text-gold { color: var(--gold); }
.bg-navy { background-color: var(--navy); }
.bg-gold { background-color: var(--gold); }
.bg-gray-50 { background-color: var(--gray-50); }

/* --- Page transitions --- */

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

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

.fade-in-up {
  animation: fadeInUp 0.5s ease-out forwards;
  opacity: 0;
}

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

/* Stagger children */
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }

/* Loading spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Responsive adjustments --- */

@media (max-width: 639px) {
  .hero-title {
    font-size: 1.5rem;
  }
}

/* Print styles */
@media print {
  .site-header,
  .site-footer,
  .filter-bar {
    display: none;
  }
}
