:root {
  --bg: #f7f3ec;
  --bg-soft: #fffdf9;
  --card: #ffffff;
  --ink: #2b2620;
  --ink-soft: #6b6358;
  --line: #e7ded0;
  --gold: #b8862f;
  --gold-soft: #f3e6cc;
  --green: #2e8b57;
  --green-soft: #e3f3ea;
  --shadow: 0 14px 40px rgba(60, 45, 20, 0.10);
  --radius: 18px;
  --font: 'Cairo', 'Tajawal', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.container { width: min(1180px, 92vw); margin: 0 auto; }

/* ===== Hero ===== */
.hero {
  position: relative;
  text-align: center;
  padding: 72px 0 56px;
  background:
    radial-gradient(1200px 400px at 50% -10%, var(--gold-soft), transparent 60%),
    linear-gradient(180deg, #fffdf9, var(--bg));
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(184,134,47,0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.hero-badge {
  display: inline-block;
  font-size: 13px; font-weight: 700;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 6px 16px; border-radius: 999px;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(120deg, #2b2620, var(--gold));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  color: var(--ink-soft);
  font-size: clamp(15px, 2.2vw, 19px);
  margin: 12px 0 28px;
}
.search-box {
  display: flex; align-items: center; gap: 10px;
  max-width: 560px; margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  color: var(--ink-soft);
}
.search-box input {
  border: none; outline: none;
  width: 100%; font-family: var(--font);
  font-size: 16px; background: transparent; color: var(--ink);
}
.filters {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 24px; flex-wrap: wrap;
}
.filter {
  font-family: var(--font);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  padding: 9px 22px; border-radius: 999px;
  cursor: pointer; font-weight: 600; font-size: 14px;
  transition: all .2s ease;
}
.filter:hover { border-color: var(--gold); color: var(--gold); }
.filter.active {
  background: var(--ink); color: #fff; border-color: var(--ink);
}

/* ===== Grid ===== */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 26px;
  padding: 54px 0 70px;
}
.book-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  display: flex; flex-direction: column;
}
.book-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow);
}
.cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #efe7d7, #e3d6bd);
  overflow: hidden;
}
.cover-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; transition: transform .4s ease;
}
.book-card:hover .cover-wrap img { transform: scale(1.05); }
.badges {
  position: absolute; top: 10px; inset-inline-start: 10px;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.badge {
  font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.badge.free { background: var(--green); color: #fff; }
.badge.paid { background: var(--gold); color: #fff; }
.badge.featured { background: var(--ink); color: var(--gold-soft); }
.book-info { padding: 14px 14px 18px; }
.book-info h3 {
  font-size: 16px; font-weight: 700; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-info .author {
  color: var(--ink-soft); font-size: 13px; margin-top: 5px;
}
.empty { text-align: center; color: var(--ink-soft); padding: 60px 0; font-size: 17px; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 34px 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
}
.social { display: flex; gap: 14px; justify-content: center; margin-top: 12px; }
.social a {
  color: var(--ink); text-decoration: none; font-weight: 600;
  background: var(--gold-soft); padding: 6px 14px; border-radius: 999px;
  transition: .2s;
}
.social a:hover { background: var(--gold); color: #fff; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(30,22,10,0.55); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  background: var(--card);
  border-radius: 22px;
  width: min(820px, 100%);
  max-height: 90vh; overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; inset-inline-end: 14px;
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: var(--bg); color: var(--ink);
  font-size: 24px; cursor: pointer; line-height: 1; z-index: 2;
}
.modal-close:hover { background: var(--line); }
.modal-body { display: grid; grid-template-columns: 260px 1fr; gap: 26px; padding: 30px; }
.modal-body img.cover {
  width: 100%; border-radius: 14px; box-shadow: var(--shadow);
  aspect-ratio: 2/3; object-fit: cover; background: #efe7d7;
}
.modal-body h2 { font-size: 24px; font-weight: 800; }
.modal-body .m-author { color: var(--gold); font-weight: 700; margin: 4px 0 14px; }
.modal-body .m-desc { color: var(--ink-soft); font-size: 15px; }
.modal-body .m-cat {
  display: inline-block; font-size: 12px; font-weight: 700;
  background: var(--gold-soft); color: var(--gold);
  padding: 4px 12px; border-radius: 999px; margin-bottom: 14px;
}
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.btn {
  font-family: var(--font); font-weight: 700; font-size: 15px;
  text-decoration: none; cursor: pointer;
  padding: 12px 22px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px;
  transition: .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.store { background: var(--ink); color: #fff; border-color: var(--ink); }
.price-tag { font-size: 22px; font-weight: 800; color: var(--gold); margin-bottom: 6px; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; padding: 36px 0 50px; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-body img.cover { max-width: 200px; margin: 0 auto; }
  .hero { padding: 52px 0 40px; }
}
